Benutzer-Werkzeuge

Webseiten-Werkzeuge

A PCRE internal error occured. This might be caused by a faulty plugin

patch:153:xtreme_gallery_shortcode

====== Xtreme Gallery Shortcode with ids ====== Leider funktionieren die globalen galleries die es seit WP 3.5 gibt, in der xtreme-one 1.5.3 noch nicht. Folgender patch löst das Problem.\\ Das schicke interface zur Bestimmenung der Bildgrößen für Anzeige(size) und target, also die Gallery settings bringt er nicht zurück. \\ Die bestehenden shortcode Attribute funktionieren trotzdem. Man kann also im Text Edit Modus die gewünschten Werte nach wie vor benutzen.\\ ''%%[gallery ids="8,15,24,33" columns="2" link="file" size="medium" target="large"]%%'' **related:** [[http://marketpress.de/support/topic/wo-ist-die-advanced-wordpress-gallery-hin/#post-3579|...einfache Galerie nicht mehr sichtbar]] ===== 1: Download patch file ===== Speichere dieses file als ''xtreme_gallery_shortcode_patch_153tc01.php'' und lege es in deinen ChildTheme Ordner.\\ Mit einem klick auf die erste Zeile im tab des codeblocks kannst Du das file direkt herunterladen. <file phpwp ChildTheme/xtreme_gallery_shortcode_patch_153tc01.php> <?php /* * patch for xtreme_gallery_shortcode (xtreme-one 1.5.3 with WP >= 3.5) to work with ids * see http://xfco.de/patch/153/xtreme_gallery_shortcode */ function xtreme_gallery_shortcode_patch_153tc01( $attr ) { $post = get_post(); global $xf_gallery_target_size; static $instance = 0; $instance++; // New in WP 3.5 if ( ! empty( $attr['ids'] ) ) { // 'ids' is explicitly ordered, unless you specify otherwise. if ( empty( $attr['orderby'] ) ) $attr['orderby'] = 'post__in'; $attr['include'] = $attr['ids']; } // Allow plugins/themes to override the default gallery template. $output = apply_filters ('post_gallery', '', $attr ); if ( $output != '' ) { return $output; } if ( isset( $attr['orderby'] ) ) { $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); if ( !$attr['orderby'] ) { unset( $attr['orderby'] ); } } extract( shortcode_atts( array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'target' => 'auto', 'include' => '', 'exclude' => '' ), $attr )); $id = intval( $id ); if ( 'RAND' == $order ) { $orderby = 'none'; } if ( !empty( $include ) ) { // $include = preg_replace( '/[^0-9,]+/', '', $include ); $_attachments = get_posts( array( 'include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); $attachments = array(); foreach ( $_attachments as $key => $val ) { $attachments[$val->ID] = $_attachments[$key]; } } elseif ( !empty($exclude) ) { // $exclude = preg_replace( '/[^0-9,]+/', '', $exclude ); $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); } else { $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); } if ( empty( $attachments ) ) { return ''; } if ( is_feed() ) { $output = "\n"; foreach ( $attachments as $att_id => $attachment ) { $output .= wp_get_attachment_link( $att_id, $size, true ) . "\n"; } return $output; } $html5 = xtreme_is_html5(); if ( $html5 ) { $el = 'ul'; $itemtag = 'li'; $icontag = 'figure'; $captiontag = 'figcaption'; } else { $el = 'div'; } $itemtag = tag_escape( $itemtag ); $captiontag = tag_escape( $captiontag ); $columns = intval( $columns ); $selector = "gallery-{$instance}"; $output = apply_filters( 'gallery_style', "<{$el} id='$selector' class='gallery galleryid-{$id}'>" ); $i = 0; foreach ( $attachments as $id => $attachment ) { $i++; $link = isset( $attr['link'] ) && 'file' == $attr['link'] ? xtreme_get_gallery_attachment_link( $id, $size, $target ) : wp_get_attachment_link( $id, $size, true, false ); $cls = ''; if ( $columns > 0 && $i % $columns == 0 ) { $cls = 'last'; } elseif ( $columns > 0 && $i % $columns == 1) { $cls = 'first'; } $output .= "<{$itemtag} class='gallery-item col-{$columns} {$cls}'>"; if ( $html5 ) { $output .= "<{$icontag} class='gallery-icon'>{$link}"; } else { $output .= "<{$icontag} class='gallery-icon'>{$link}</{$icontag}>"; } if ( $captiontag && trim( $attachment->post_excerpt ) ) { $output .= "<{$captiontag} class='gallery-caption'>"; $output .= wptexturize( $attachment->post_excerpt ) . "</{$captiontag}>"; } if ( $html5 ) { $output .= "</{$icontag}>"; } $output .= "</{$itemtag}>"; } $output .= "</{$el}>\n"; return $output; } </file> ===== 2: Setup function anpassen ===== Kopiere dir die folgenden 2 Zeilen in die ''_setup()((innerhalb der function blank_setup(), minimalist_setup(), indoor_setup(), tuscany_setup(), vintagefolio_setup() oder draft_setup() in deiner ''ChildTheme/functions.php'' )) function'' deines ChildThemes. <code phpwp> /* copy this into the blank_setup function in your ChildTheme/functions.php */ /* BEGIN _setup() patch xtreme_gallery_shortcode */ remove_shortcode( 'gallery', 'xtreme_gallery_shortcode' ); add_shortcode( 'gallery', 'xtreme_gallery_shortcode_patch_153tc01' ); /* END _setup() patch xtreme_gallery_shortcode */ </code> ===== 3: include patch file ===== Kopiere den include in deine ''ChildTheme/functions.php'' <code phpwp> /* copy this in your ChildTheme/functions.php */ /* BEGIN include patch xtreme_gallery_shortcode */ include('xtreme_gallery_shortcode_patch_153tc01.php'); /* END include patch xtreme_gallery_shortcode */ </code> ===== CSS Fix für col-1 galleries ===== Damit eine gallery mit nur einer column richtig angezeigt wird, braucht der .col-1 noch den richtigen style. Kommt in die ''ChildTheme/css/screen/theme.css'' <code css> .gallery .col-1 { width: 100%; } </code>

patch/153/xtreme_gallery_shortcode · Zuletzt geändert: 2019/04/25 14:03 (Externe Bearbeitung)
© 2013 <xfco.de> Impressum | Datenschutz

Seiten-Werkzeuge