ID) ? $post->ID : -1;
if (is_home || is_single || !is_page) {
$content = dom_swipebox($content, $id);
//$content = dom_swipebox_2($content, $id);
}
}
return $content;
}
/* automatically insert rel="lightbox[nameofpost]" to every image with no manual work.
if there are already rel="lightbox[something]" attributes, they are not clobbered.
Michael Tyson, you are a regular expressions god! - http://atastypixel.com
function jqlb_do_regexp($content, $id){
$id = esc_attr($id);
$pattern = "/(]*?rel=['\"]lightbox.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)(\?\S{0,}){0,1}['\"][^\>]*)>/i";
$replacement = '$1 rel="lightbox['.$id.']">';
return preg_replace($pattern, $replacement, $content);
}
*/
/*** ***/
function dom_swipebox_2($content, $id) {
$id = esc_attr($id);
// Nom du script JS de lightbox
$lightbox = 'swipebox';
$content = mb_convert_encoding($content, 'HTML-ENTITIES', "UTF-8");
$html = new DOMDocument();
$html->loadHTML($content);
$root = $html->documentElement; // get the first child node (the root)
$elms = $root->getElementsByTagName("*"); // gets all elements ("*") in root
$nr_elms = $elms->length; // gets the number of elements
// loop through all elements stored in $elms
for($i = 0; $i<$nr_elms; $i++) {
$node = $elms->item($i); // gets the current node
// on recherche les liens
if($node->nodeName=='a') {
$old_node = $node;
// on teste si le lien n'appartient pas à une gallery
$parent = $node->parentNode;
if ($parent->nodeName != 'dt') {
$enfants = $node->childNodes;
foreach($enfants as $enfant) {
//uniquement les liens images
//et pas les liens textex bla-bla
if ($enfant->nodeName == 'img') {
//On récupère l'attribut 'class' et on ajoute swipebox à sa valeur
$oldClass = $node->getAttribute('class');
if (strstr($oldClass, $lightbox) != false) $newClass = $oldClass;
else $newClass = $oldClass . ' ' . $lightbox;
$node->setAttribute('class', $newClass);
//Chaque article à sa gallery
$newRel = 'gallery-' . $id;
$node->setAttribute('rel', $newRel);
//
}
}
}
/*
else {
echo $old_node->nodeValue;
}
*/
}
}
// save the new xml content in the same file and output its structure
$newHtml = preg_replace('/^/', '', str_replace( array('', '', '
T'approches pas de mon nid !!
*/ $img = substr($atts['image'], 0, strlen($atts['image']) - 4); if ($atts['caption'] != "") { $zenphoto_img = '
';
$zenphoto_img .= '
';
$zenphoto_img .= '';
if ($atts['caption'] != "") {
$zenphoto_img .= '' . $atts['caption'] . '
';
$zenphoto_img .= '
';
$zenphoto_img .= '';
if ($atts['caption'] != "") {
$zenphoto_img .= '' . $atts['caption'] . '
Title
Meta description
post->ID,'_parametres_seo_description',true) ) { echo ''; } } add_action( 'wp_head', 'modify_description_from_metabox' ); function modify_title_from_metabox($title) { global $wp_query; if ( get_post_meta($wp_query->post->ID,'_parametres_seo_title',true) ) { return get_post_meta($wp_query->post->ID,'_parametres_seo_title',true); } else { return $title; } } add_filter( 'wp_title', 'modify_title_from_metabox' ); /*** /SEO ***/ /*** Fil d'arianne ***/ //Récupérer les catégories parentes function myget_category_parents($id, $link = false,$separator ='/',$nicename = false,$visited = array()) { $chain = '';$parent = &get_category($id); if (is_wp_error($parent))return $parent; if ($nicename)$name = $parent->name; else $name = $parent->cat_name; if ($parent->parent && ($parent->parent != $parent->term_id ) &&!in_array($parent->parent, $visited)) { $visited[] = $parent->parent;$chain .= myget_category_parents($parent->parent, $link, $separator, $nicename, $visited );} if ($link) $chain .= ''.$name.'' . $separator; else $chain .= $name.$separator; return $chain; } //Le rendu function mybread() { // variables gloables global $wp_query;$ped=get_query_var('paged');$rendu = '', '' ); ?>
' . '
', 'url' => '' . '
', ); $required_text = sprintf( ' ' . __('Required fields are marked %s'), '*' ); $defaults = array( 'fields' => apply_filters( 'comment_form_default_fields', $fields ), 'comment_field' => '', 'must_log_in' => '
' . sprintf( __( 'You must be logged in to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
', 'logged_in_as' => '' . sprintf( __( 'Logged in as %2$s. Log out?' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
', 'comment_notes_before' => '' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '
', 'comment_notes_after' => '', 'id_form' => 'commentform', 'id_submit' => 'submit', 'title_reply' => __( 'Leave a Reply' ), 'title_reply_to' => __( 'Leave a Reply to %s' ), 'cancel_reply_link' => __( 'Cancel reply' ), 'label_submit' => __( 'Post Comment' ), 'format' => 'xhtml', ); $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); ?>' . '
', 'url' => '' . '
', ); $required_text = sprintf( ' ' . __('Required fields are marked %s'), '*' ); $defaults = array( 'fields' => apply_filters( 'comment_form_default_fields', $fields ), 'comment_field' => '', 'must_log_in' => '
' . sprintf( __( 'You must be logged in to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
', 'logged_in_as' => '' . sprintf( __( 'Logged in as %2$s. Log out?' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
', 'comment_notes_before' => '' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '
', 'comment_notes_after' => '', 'id_form' => 'commentform', 'id_submit' => 'submit', 'title_reply' => __( ' → Leave a Reply' ), 'title_reply_to' => __( 'Leave a Reply to %s' ), 'cancel_reply_link' => __( 'Cancel reply' ), 'label_submit' => __( 'Post Comment' ), 'format' => 'xhtml', ); $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); ?> Afficher '; ?>