【问题标题】:Trouble with Wordpress Pretty Photo Pin It ButtonWordPress Pretty Photo Pin It 按钮的问题
【发布时间】:2014-02-14 16:00:39
【问题描述】:

如果您访问http://jbrazeal.com/galleries/bridals,您可以看到我的网站,其中包含 Wordpress 主题中的 PrettyPhoto 画廊。默认情况下,当您单击图片时,图片会展开并为您提供“Tweet”或“Like”图片下方按钮的选项。我安装了一个名为“prettyPhoto Media Pinterest”(https://github.com/Lawdawg/prettyphoto-media-pinterest)的插件,它为每张特定图片添加了一个“Pin It”按钮。

但是,该插件仅适用于某些页面而不适用于其他页面。它适用于上面链接的页面,但不适用于其他画廊页面。例如,它不适用于页面 /galleries/weddings 上的任何图片(我无法发布链接,因为我仅限于两个链接。

下面是PHP。我认为这是一个 PHP 问题,但如果您另有建议,我可以发布任何其他相关信息(该插件也有一个 javascript 文件)。此外,您可以看到我上面链接的实际网页以及插件页面。谢谢!

<?php
add_action('init', 'ppm_pinterest_init');

function ppm_pinterest_init() {
    define('PPM_PINTEREST_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
    define('PPM_PINTEREST_VERSION', '0.1' );

    if (!is_admin()) {
            wp_enqueue_style('ppm_pinterest', PPM_PINTEREST_URI . 'css/ppm-pinterest.css', false, PPM_PINTEREST_VERSION, 'screen');
            wp_enqueue_script('pinterest_plus', PPM_PINTEREST_URI . 'js/pinterest-plus.min.js', false, false, true);
            add_action('wp_footer', 'ppm_pinterest_footer_script', 101);
    }        
}

function ppm_pinterest_footer_script() {
    $out = '<script>' . "\n";
    $out .= 'jQuery(function($) {' . "\n";        
    $out .= '  $(document).bind(\'DOMNodeInserted\', function(event) {' . "\n";
    $out .= '    if (window.settings && !window.settings.changepicturecallbackupdated) {' . "\n";
    $out .= '      window.settings.changepicturecallback = add_pinterest_pin_it_button' . "\n";
    $out .= '      window.settings.changepicturecallbackupdated = true;' . "\n"; 
    $out .= '    }' . "\n";
    $out .= '  });' . "\n";
    $out .= '});' . "\n";
    $out .= "\n";
    $out .= 'function add_pinterest_pin_it_button() {' . "\n";
    $out .= '  var i = jQuery(\'.pp_gallery\').find(\'li\').index(jQuery(\'.selected\'));' . "\n";
    $out .= '  var m = pp_images[i];' . "\n";
    $out .= '  jQuery(\'.pp_social\').append(\'<div class="pinterest"><a href="http://pinterest.com/pin/create/button/?url=\' + encodeURI(location.href.replace(location.hash,"")) + \'&media=\' + encodeURI(m) + \'" class="pin-it-button" count-layout="none"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a></div>\');' . "\n";
    $out .= '}' . "\n";
    $out .= '</script>' . "\n";

    echo $out;
}

?>

【问题讨论】:

    标签: php jquery wordpress javascript-framework prettyphoto


    【解决方案1】:

    我想通了。你可以在这里查看我的插件分支,现在可以使用了!

    https://github.com/Lawdawg/prettyphoto-media-pinterest

    我将 jQuery 调用更改为:

        $out .= '  jQuery(\'.pp_social\').append(\'<div class="pinterest"><a target="_blank" href="http://pinterest.com/pin/create/button/?url=\' + encodeURI(location.href.replace(location.hash,"")) + \'&media=\' + encodeURI(m) + \'&description=\' + encodeURI(o) + \'" class="pin-it-button" count-layout="none"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a></div>\');' . "\n";
    $out .= '}' . "\n";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-07
      • 2013-03-27
      • 1970-01-01
      • 1970-01-01
      • 2014-01-27
      • 2023-04-08
      • 1970-01-01
      • 2012-10-11
      相关资源
      最近更新 更多