WordPress的麻烦漂亮的照片PIN IT按钮



如果您访问http://jbrazeal.com/galleries/bridals,您可以在WordPress主题中看到我的网站,并在WordPress主题中看到我的网站。默认情况下,当您单击图片时,图片会展开并为您提供一个选项,以"鸣叫"或"喜欢"图片下方的按钮。我已经安装了一个名为" PrettyPhoto Media Pinterest"的插件(https://github.com/lawdawg/prettyphoto-media-pintest),在其中为每张特定图片添加了一个" pin it It"按钮。

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

下面是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;
}
?>

我弄清楚了。您可以在此处查看我的插件分支,现在可以使用!

https://github.com/lawdawg/prettyphoto-media-pintest

我将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";

最新更新