• cozbaldwin

    (@cozbaldwin)


    I previously had a tutorial on a now-closed thread and it doesn’t take into account some of the new changes Facebook and WordPress have made. So here’s an updated one.

    1. Go to Plugins > Editor
    2. Choose “Jetpack by WordPress” from the drop-down menu on the right-hand side of the screen.
    3. Find and click to edit the following file in the list that appears:
      “jetpack/modules/sharedaddy/sharing-sources.php
      (NOTE: You may first have to click on “jetpack/modules/sharedaddy.php” to bring up a new list of files that will include “sharing-sources.php”). If you can’t find it, just put this after your wordpress url: /wp-admin/plugin-editor.php?file=jetpack%2Fmodules%2Fsharedaddy%2Fsharing-sources.php&plugin=jetpack%2Fmodules%2Fsharedaddy.php
    4. Search to locate the following “<div class=”like_button”>” — you should find it a little more than halfway down the page.
    5. Replace the following block of code:
      return '<div class="like_button"><iframe src="'.$url.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.( $inner_w + 6 ).'px; height:21px;" allowTransparency="true"></iframe></div>';

      with this block of code:

      return '<div class="fb-like" data-href="" data-width="120" data-layout="button_count" data-action="like" data-show-faces="false" data-share="true"></div>';
      (Other ways to display the button can be found here: https://developers.facebook.com/docs/plugins/like-button/)

    You’re also going to need this in your header (after body tag):

    <div id="fb-root"></div>
    <script>(function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=******************";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

    PLEASE NOTE: The use of the HTML5 version requires you to have an APP id which would replace the asterisks above. For more about this, visit: https://developers.facebook.com/docs/plugins/like-button/

    You may or may not need to make CSS adjustments after this. Probably not, though.

    And yes, you will have to re-do this every time they update Jetpack.
    (I’m sure there’s some way to avoid having to re-add the code but I’m not skilled enough to know how. Please add instructions if you do.)

    https://www.ads-software.com/plugins/jetpack/

Viewing 15 replies - 1 through 15 (of 41 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Instead of editing plugin files, I would suggest using Jetpack’s built-in custom sharing function. Try following these steps:

    1. Go to Settings > Sharing in your dashboard
    2. Sroll down until the “Button Style” option.
    3. Choose “Official Buttons”.

    The Facebook Share button has now changed into a Facebook Like Button. Save your changes, and let’s now add a Facebook Share button next to the Like button.

    To do so, click on “Add a new service” next to the list of available services in Settings > Sharing.

    Then, enter the following information:

    • In “Service Name“, type in “Facebook”
    • In “Sharing URL“, enter https://www.facebook.com/sharer/sharer.php?u=%post_full_url%
    • In “Icon URL“, enter https://YOUR_SITE_URL/wp-content/plugins/jetpack/modules/sharedaddy/images/facebook.png

    Save your changes, and drag the new Share button next to your Like button.

    Done! ??
    https://i.wpne.ws/Sfgb

    Thread Starter cozbaldwin

    (@cozbaldwin)

    Thanks, Jeremy.
    Surely that is a much easier way to change and maintain the addition of a FB sharing button.

    However, for me, personally, it doesn’t fit the aesthetic I’m going for, which is the current official buttons and their inherent functions.

    You did however remind me that I left out an important part of my tutorial, which is:

    ADDENDUM TO MY ORIGINAL POST:
    The Sharing settings must already be set to have the Facebook Like button set in the Enabled Functions and set the button style to Official Buttons.

    cbridges

    (@cbridges)

    @jeremy,
    I tried doing your steps above to have both the sharing and like button but I do not get a facebook image. Could it be because I have installed the Remove Original Jetpack sharing buttons plugin to be able to use the sharing shortcode?
    Also, wordpress is actually installed in a subfolder in my site but when pointing to the icon in Icon URL field I included the subfolders
    e.g, https://mysite/testing/wordpress/wp-content/plugins/jetpack/modules/sharedaddy/images/facebook.png

    Any ideas?
    Thanks

    Thread Starter cozbaldwin

    (@cozbaldwin)

    @cbridges, if I may…
    When you replace your url within: https://YOUR_SITE_URL/wp-content/plugins/jetpack/modules/sharedaddy/images/facebook.png
    It should be the full url to where your wordpress is installed. So if your wordpress is installed on https://www.cbridges.com/testing/wordpress/ — then you want to put that whole string into where it says “YOUR_SITE_URL” above.

    However, I don’t know anything about the plugin you mentioned, the Remove Original Jetpack plugin… but it sounds like it might totally break the jetpack stuff, so therefore trying to link to the facebook icon may not work.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    @cbridges @cozbaldwin’s recommendation should help you get the Facebook icon to be displayed properly.

    If you still experience issues, do not hesitate to post your site URL here, and I’m sure we’ll both be happy to take a closer look!
    If you want your site URL to remain private, you can also contact me via this contact form:
    https://jetpack.me/contact-support/

    cbridges

    (@cbridges)

    @cozbaldwin & Jeremy,
    That did work, that you both much!
    Chris

    Did you guys figure out how to add the code to the settings like Jeremy did but using the original Facebook icon, not the fake one? I’ve added to this my site and it works great, but I hate the thought of having to re-edit the plugin files each update!

    Thanks!

    Charles

    https://underground.net is my site.

    Thread Starter cozbaldwin

    (@cozbaldwin)

    At this time, I believe your options are what I have above and Jeremy’s long-term method.

    It would be very nice if JetPack ShareDaddy added this in as the default, but, for now… this is it (unless there’s a way to code up a Function, which is beyond my capabilities).

    @cozbaldwin, Jeremy, & Barry Carlyon who did the Jetpack Extras plug in, you are wp heroes. Thank you so much for sharing your knowledge. I got my fb share button added, which had been a mystery to me, plus put share both above and below on posts/pages where I wanted. Thanks again.

    @cozbaldwin

    may I know if there is a way to move the separated facebook like and share above the twitter and google+ buttons and align it with the twitter button?

    thanks in advance for your help

    https://theasiandude.com/2014/04/15/making-a-photobook/#more-359

    Thread Starter cozbaldwin

    (@cozbaldwin)

    @theasiandude,

    I took a look at your blog entry linked above. I’m not positive if this will fix it, but it appears you’re not using the “official” buttons. See addendum in my 2nd post in this thread:

    ADDENDUM TO MY ORIGINAL POST:
    The Sharing settings must already be set to have the Facebook Like button set in the Enabled Functions and set the button style to Official Buttons.

    Try that and let me know.

    @cozbaldwin

    hey sir, I did followed the instruction above and tried the hack sharedaddy method.

    https://theasiandude.com/2014/04/15/making-a-photobook/

    this is what I am getting. The like and share will work alright but the count has been reset. I am thinking if the the counts for sharedaddy is different from the counts for official facebook like and share?

    my only worry is that things will get a reset again when jetpack releases new update. is it safer to say separate out the facebook like and share and use the one officially released by facebook.

    thanks again for your help and kind advice!

    ————————–

    opps, I have just checked my website, it seems the like and share counts for sharedaddy has synchronized with the counts by facebook official. again, thanks for your help

    now that I have fixed the facebook problem, theres a huge gap in between twitter button and google+, is there anyway I can fix that?

    Also it seems the counts for the homepage and the subpage is different, I dont know why either.

    https://theasiandude.com/2014/04/15/making-a-photobook/
    https://theasiandude.com/

    Thread Starter cozbaldwin

    (@cozbaldwin)

    OK, I’m glad your original issue has been fixed.

    If the counts are different (they aren’t right now) it’s because the number is reflecting the times that specific page has been shared/liked. That goes for all the other buttons, too. It’s not counting across all pages, just each page at a time.

    As far as the gap between Twitter and Google+, that is a width that’s being set by twitter themselves… in the code for their button.

    If you are that concerned with it, you can add this into your Custom CSS (via the jetpack plugin):

    .twitter_button iframe {width: 85px!important}

    @jeremy Herve

    I added the function to also share not only like the post on the settings.
    How can i make it to open in a new window like twitter does?

Viewing 15 replies - 1 through 15 (of 41 total)
  • The topic ‘Tutorial: Get Facebook Like&Share buttons in Jetpack Sharing’ is closed to new replies.