0

I'm working on developing a plugin for Wordpress to enable social share buttons inside blockquotes (to share the quoted text on social networks Twitter and Facebook). So that sites would look like this: enter image description here

Here's the current 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;
    });
});

But then I came across Facebook's Quote plugin: https://developers.facebook.com/docs/plugins/quote Which would be perfect, but I can't figure out how to attach the plugin script to an icon, rather than the way they enabled it which is by highlighting text. Could anyone help me out with how to attach the new "Quote" sharing function for Facebook to a button than would then share the text within the blockquote?

0

Kept on searching and found that I can just add a url parameter for the quote (source):

  • URL (of course) → u
  • custom image → picture
  • custom title → title
  • custom quote → quote
  • custom description → description

Example:

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.