Greffon "Pubs WP" pour Wordpress (traduction du plugin WP-Ads)
Par Mathias le vendredi 11 juillet 2008, 21:31 - Lien permanent
Je vous propose une traduction du plugin WP-Ads de Nick Brady. Je l'ai appelé "Pubs WP".
Antoine Boucherie a rédigé récemment une présentation de ce plug-in.
Téléchargement
- format ZIP,
- format RAR,
- fichier pubswp.php,
- fichier pubswp-classe.php,
- fichier pubswp-options.php.
- Miroir de téléchargement
Rétro-compatibilité
Dans le code, j'ai fait en sorte que les anciens codes d'appel aux bannières (<?php wpads('nom_de_la_zone'); ?> dans les gabarits et <!--wpads#nom_de_la_zone--> dans les billets) continuent de fonctionner.
Ainsi, j'ai remplacé (dans pubswp.php) :
/**
* Print the html code for a random banner of the given zone
*/
function pubswp( $the_zone ) {
print get_wpads( $the_zone );
}
par:
/**
* Print the html code for a random banner of the given zone
*/
function pubswp( $the_zone ) {
print get_wpads( $the_zone );
}
/** old version (before translation : wpads) : */
function wpads( $the_zone ) {
print get_wpads( $the_zone );
}
/** END old version (before translation : wpads) : */
De même, j'ai remplacé (aussi dans pubswp.php) :
/**
* Content filter: replaces all ocurrences of
* <!-- wpads#zone_name -->
* in the post content for a random banner for that zone
*/
function wpads_content_filter( $data ) {
if( preg_match_all( "|<!--\s*wpads#(.*?)\s*-->|", $data, $matches ) ) {
for($i=0;$i<count($matches[0]);$i++) {
$banner = get_wpads( $matches[1][$i] );
$data = preg_replace( "|".$matches[0][$i]."|", $banner, $data );
}
}
return $data;
}
par :
/**
* Content filter: replaces all ocurrences of
* <!-- pubswp#zone_name -->
* in the post content for a random banner for that zone
*/
function wpads_content_filter( $data ) {
if( preg_match_all( "|<!--\s*pubswp#(.*?)\s*-->|", $data, $matches ) ) {
for($i=0;$i<count($matches[0]);$i++) {
$banner = get_wpads( $matches[1][$i] );
$data = preg_replace( "|".$matches[0][$i]."|", $banner, $data );
}
}
/* old version, before translation */
if( preg_match_all( "|<!--\s*wpads#(.*?)\s*-->|", $data, $matches ) ) {
for($i=0;$i<count($matches[0]);$i++) {
$banner = get_wpads( $matches[1][$i] );
$data = preg_replace( "|".$matches[0][$i]."|", $banner, $data );
}
}
/* END old version, before translation */
return $data;
}
Si vous ne souhaitez pas ces "bidouilles", vous pouvez les supprimer en éditant le fichier pubswp.php. Pour cela, allez dans l'onglet Extensions, sélectionnez la page Éditeur d’extension, puis choisissez le fichier Pubs WP.
Tests
Je l'ai testé sur mon blogue d'étudiant en DUT SRC (WP 2.5). J'ai désactivé le plugin WP-Ads, et activé Pubs WP. Je n'ai pas observé d'interférence avec l'autre plugin ou ses bases de données. A priori donc, tout fonctionne.


Commentaires