区块报价的Facebook报价插件?

时间:2017-03-16 作者:Nathan

我正在为Wordpress开发一个插件,以启用blockquotes中的社交共享按钮(在社交网络Twitter和Facebook上共享引用的文本)。因此,网站将如下所示:enter image description here

以下是当前的js:

jQuery(document).ready(function () {
    var blockquotes = jQuery(\'blockquote\');
    for (var i = 0; i < blockquotes.length; i++) {
        var blockQuoteText = jQuery(blockquotes[i]).text();
        var currentUrl = window.location;
        var textColor = jQuery(blockquotes[i]).css(\'color\');
        // add share buttons (change TwitterName to your Twitter handle for automatic mentions)
        // change paths to the icons to suit your installation (download link below)
        jQuery(blockquotes[i]).append(\'<div class="quote-share"><div class="wrapper">\' +
            \'<a class="quote-twitter pop-up" style="color:\' + textColor + \'"\' +
            \'href="http://twitter.com/intent/tweet?status=\' + blockQuoteText + \'+\' + currentUrl + \'+%40\' + data.twitter_id + \'">\' +
                \'<span class="icon-twitter"/></a>\' +
            \'<a class="quote-facebook pop-up" style="color:\' + textColor + \'"\' +
            \'href="https://www.facebook.com/sharer/sharer.php?u=\' + currentUrl + \'&amp;src=sdkpreparse&title=\' + blockQuoteText + \'">\' +
                \'<span class="icon-facebook"/>\' +
            \'</a></div></div>\');
    }

    // pop-up without being blocked by pop-up blockers
    jQuery(\'a.pop-up\').live(\'click\', function () {
        newwindow = window.open(jQuery(this).attr(\'href\'), \'\', \'height=640,width=600\');
        if (window.focus) {
            newwindow.focus()
        }
        return false;
    });
});
但后来我发现了Facebook的Quote插件:https://developers.facebook.com/docs/plugins/quote这将是完美的,但我不知道如何将插件脚本附加到图标,而不是他们通过突出显示文本来启用它的方式。有谁能帮我把Facebook新的“Quote”共享功能附加到一个按钮上,然后在blockquote中共享文本?

1 个回复
SO网友:Nathan

继续搜索,发现我可以为报价添加url参数(source):

URL(当然)→ u自定义图像→ 图片自定义标题→ 标题自定义报价→ 引用自定义描述→ 说明示例:

https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fstackoverflow.com%2Fq%2F20956229%2F1101509&picture=http%3A%2F%2Fwww.applezein.net%2Fwordpress%2Fwp-content%2Fuploads%2F2015%2F03%2Ffacebook-logo.jpg&title=A+nice+question+about+Facebook&quote=Does+anyone+know+if+there+have+been+recent+changes+which+could+have+suddenly+stopped+this+from+working%3F&description=Apparently%2C+the+accepted+answer+is+not+correct.

相关推荐

从我的Facebook帖子中删除文本

首先,我为我的英语感到抱歉,我会尽力做到最好,因为我是阿根廷人。我正在使用Publicate将我的wordpress帖子发送到我的Facebook粉丝页面。这就是Publication发送自动帖子的方式。我只需要删除描述就可以发送这样的帖子:我该怎么办?我正在努力解决这个问题,但我做不到。谢谢