it-swarm-eu.dev

Galerie plugin nutí nad text

Používám plugin „gamma-gallery“. Trochu upravené, to je.

Galerie se nutí nad jakýkoli text, který byl v příspěvku. Nějaký nápad proč?

Zde je v případě potřeby kód zásuvných modulů:

<?php
/*
Plugin Name:Gamma Gallery
Plugin URI: http://wordpress.org/extend/plugins/gamma-gallery/
Description: A responsive wordpress gallery with montage image arrangement.
Author: ezhil
Version: 1.8
Author URI: http://profiles.wordpress.org/ezhil/
License: GPLv2 or later
*/


define( 'GG_PATH', content_url().'/plugins/gamma-gallery' );

 remove_shortcode('gallery', 'gallery_shortcode'); // removes the original shortcode
   add_shortcode('gallery', 'gamma_gallery'); // add your own shortcode

   // loads jquery
function jq_gg_load()
{
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts','jq_gg_load');
    function gamma_gallery($attr) {
    $post = get_post();
//    echo $post;
//        examine($post);

    static $instance = 0;
    $instance++;

    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;

    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    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,
        'include'    => '',
        'exclude'    => ''
    ), $attr));

    $id = intval($id);
    if ( 'Rand' == $order )
        $orderby = 'none';

//    the_content();
//  echo $text;

?>
<link rel="stylesheet" type="text/css" href="<?php echo GG_PATH;?>/css/style.css"/>
        <script src="<?php echo GG_PATH;?>/js/modernizr.custom.70736.js"></script>
        <noscript><link rel="stylesheet" type="text/css" href="<?php echo GG_PATH;?>/css/noJS.css"/></noscript>
        <!--[if lte IE 7]><style>.main{display:none;} .support-note .note-ie{display:block;}</style><![endif]-->                
                <div class="gamma-container gamma-loading" id="gamma-container">
                    <ul class="gamma-gallery">
                    <?php

        $photos = lc_grab_ids_from_gallery($post);      

    if ($photos) {$ct=0;
        foreach ($photos as $photo) {$ct++;
            $imgdata = get_post($photo);
//            examine($imgdata);
    // data-attachment_url="<?php //echo $imgdata; >"
            $url = get_attachment_link( $imgdata->ID );
?>
<li data-attachment_url="<?php echo $url; ?>">
    <?php //examine($photo); ?>
    <div data-alt="img<?php echo $ct;?>" data-description="<h3><?php 
    $imgdata = get_post($photo);
    if($imgdata->post_excerpt != '')
        echo $imgdata->post_excerpt;
    else
        echo $imgdata->post_title;
?> </h3>" data-max-width="3000" data-max-height="2200">
                                <div data-src="<?php $image_attributes = wp_get_attachment_image_src( $photo, 'xxlarge');echo $image_attributes[0]; ?>" data-min-width="2000"></div>
                                <div data-src="<?php $image_attributes = wp_get_attachment_image_src( $photo, 'xlarge');echo $image_attributes[0]; ?>" data-min-width="1300"></div>
                                <div data-src="<?php $image_attributes = wp_get_attachment_image_src( $photo, 'xlarge');echo $image_attributes[0]; ?>" data-min-width="1000"></div>
                                <div data-src="<?php $image_attributes = wp_get_attachment_image_src( $photo, 'large');echo $image_attributes[0]; ?>" data-min-width="700"></div>
                                <div data-src="<?php $image_attributes = wp_get_attachment_image_src( $photo, 'large');echo $image_attributes[0]; ?>" data-min-width="300"></div>
                                <div data-src="<?php $image_attributes = wp_get_attachment_image_src( $photo, 'medium');echo $image_attributes[0]; ?>" data-min-width="200"></div>
                                <div data-src="<?php $image_attributes = wp_get_attachment_image_src( $photo, 'medium');echo $image_attributes[0]; ?>" data-min-width="140"></div>
                                <div data-src="<?php $image_attributes = wp_get_attachment_image_src( $photo, 'medium');echo $image_attributes[0]; ?>"></div>
                                <noscript>
                                    <img src="<?php $image_attributes = wp_get_attachment_image_src( $photo, 'medium');echo $image_attributes[0]; ?>" alt="img<?php echo $ct;?>"/>
                                </noscript>
                            </div>
</li>
<?php 
        }   
    } ?>
</ul>
<div class="gamma-overlay"></div>
</div>
<?php 
    gg_load_scripts();
}
?>
1
foaly

Vaše zpětné volání funkce shortcode musí vrátit výstup, jako je tento:

function gamma_gallery( $attr ) {
    $html = '';

    // your stuff, where all the output is assigned to the $html variable

    return $html;
}

nebo můžete vyzkoušet vyrovnávací paměť výstupu:

function gamma_gallery( $attr ) {
    $html = '';

    ob_start();

    // your stuff

    $html = ob_get_contents();    
    ob_end_clean();

    return $html;
}
2
birgire