Recovering Facebook comments for all links after moving to HTTPS

Home Forums General issues Recovering Facebook comments for all links after moving to HTTPS

This topic contains 18 replies, has 3 voices, and was last updated by  Rogier Lankhorst 1 week, 4 days ago.

Viewing 19 posts - 1 through 19 (of 19 total)
  • Author
    Posts
  • #26345

    Michael

    Hey Rogier,

    After moving my entire site to HTTPS (and using the RSSSL mixed content option), my Facebook comments disappeared. I have Facebook comments appear on multiple pages.

    I’m using this code right now:

    function rsssl_exclude_http_url($html) {
    //replace the https url back to http
    $html = str_replace(‘data-href=”https://www.domain.com”‘, ‘data-href=”http://www.domain.com”‘, $html); return $html;
    }
    add_filter(“rsssl_fixer_output”,”rsssl_exclude_http_url”);

    And it’s working specifically for https://www.domain.com to http://www.domain.com.

    But I also need to do that for https://www.domain.com/xxyyzz to http://www.domain.com/xxyyzz.

    How can I adjust the code above so I can make that happen?

    Thanks!

    Mike

    #26346

    If you remove the closing quotes, like this:

    function rsssl_exclude_http_url($html) {
    //replace the https url back to http
    $html = str_replace(‘data-href=”https://www.domain.com‘, ‘data-href=”http://www.domain.com‘, $html); return $html;
    }
    add_filter(“rsssl_fixer_output”,”rsssl_exclude_http_url”);

    It should work. When the quotes are gone, it will replace back any string with that domain. In the former version it would replace all strings ending with a quote.

    #26375

    Michael

    Thank you so much! That worked.

    #33898

    Nils

    Hi,

    Thank you for a great plug-in! I’m experiencing the same problem (disappearing FB comments) and I’m exited that I found this solution here but… Where do I place this code? I would love a detailed explanation if possible as I’m not so skilled with code 🙂

    Many thanks

    nils

    #53585

    Sunday Ukafia

    @Nils

    Add the code to your theme’s function.php file (You can add it at the end)

    Navigate to appearance – editor – functions.php (located at the right hand side)

    Note that the code will be removed if you update your theme.

    It is recommended to create a child theme and add it to your child theme function.php

    Google how to create a WordPress Child theme for help. Its actually quite simple.

    Goodluck

    -Sukafia

    #64635

    igorber
    Participant

    I’ve tried the solution posted above (added the code to the functions.php). but I am getting the following error: Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /wp-content/themes/Fonovit/functions.php on line 1093. Any ideas why it does not work in my case? (https://vitafon.pl/bol-plecow.html)

    Thanks a lot for any advice!

    Igor

    #64657

    This might happen if there’s a PHP error on the line before. For example, if the last line before the function did not end with ;

    #64672

    igorber
    Participant

    Thank you for the reply. It have been the case, so I have added ; to the previous function(seems like it was missing there), but I still get an error Parse error: syntax error, unexpected ‘=’ in /wp-content/themes/Fonovit/functions.php on line 1095, if I place it in the front (just after <?php) of functions.php I also get: Parse error: syntax error, unexpected ‘=’ in /wp-content/themes/Fonovit/functions.php on line 5

    A bit lost here. No clue what is causing it.

    #64689

    What code is on line 5?

    #64696

    igorber
    Participant

    The same. I’ve tried to paste it to the beginning of the document and to the end (not at the same time), just to be sure it is not some strange character that got into functions.php accidentally. When I paste it to the document the website stops working. When I remove it all works fine

    #64697

    What I mean is, the error says there’s a fatal error on line 5. To say anything about it, I need to know what code you have on line 5.

    Possibly the quotes are changed by copying them. In that case you can try retyping the quotes in the code. If you post the line of code that is causing the error I might be able to help.

    #64705

    igorber
    Participant

    Seems like the quotes were the problem. At least the website is working fine.
    That the code I have now.

    function rsssl_exclude_http_url($html) {
    //replace the https url back to http
    $html = str_replace(‘data-href=”https://www.vitafon.pl’, ‘data-href=”http://www.vitafon.pl’, $html); return $html;
    }
    add_filter(“rsssl_fixer_output”,”rsssl_exclude_http_url”);

    But I still do not see the comments https://vitafon.pl/przepuklina-kregoslupa.html

    Could it be the way the facebook comments are implemented (as a code snippet inside of the theme)

    <div class=”facebook-comments”>
    <div class=”fb-comments” data-href=”<?php echo get_permalink( $post->ID ); ?>” data-width=”576″ data-numposts=”15″></div>
    </div>

    Thank you so much!

    #64717

    You can also try to change the og:url back to http:
    $html = str_replace(‘og:url=”https://’, ‘og:url=”http://’, $html);

    If that doesn’t help, you need to check how Facebook returns the shares. I have a very simple script to test this:
    https://really-simple-ssl.com/test-shares.php
    Where you can compare the shares that Facebook returns for the (recovered) share button, and the shares that are returned using the API. If you enter the http url, and the button does not show the correct number of shares, you can only recover the shares by using the API, and not using this replace script.

    You need to enter the url with http to see the correct results.

    #64800

    igorber
    Participant

    Thank you for your help. It seems that I need to use the API (still have to figure out how to do it :)) and the script does not work in my case. Thank you for your help!

    #64899

    In case you don’t want to do this yourself: the social add-on for Really Simple SSL has also built in share buttons, which use the API. You can customize the buttons using a template and css

    https://really-simple-ssl.com/downloads/really-simple-ssl-social/

    #64907

    igorber
    Participant

    Would that plugin recover comments that disappeared after moving to SSL? That is what I need the most.

    #64908

    No, I’m sorry, the API is used for shares only.

    #65408

    igorber
    Participant

    Tried different options (seemed quite straightforward) (also paid plugin http://www.heateor.com/facebook-comments-moderation/). Lost on what could be the problem. Do you provide premium support service or maybe you could recommend someone who could have a look at my website and see what the problem is?
    Regards,

    Igors

    #65554

    We’d have to investigate the plugin to see how it is retrieving the comments, and if there is a hook that can be used to override the URL. If you contact us https://really-simple-ssl.com/support and send us a zipped file of your comments plugin, we can take a look.

Viewing 19 posts - 1 through 19 (of 19 total)

You must be logged in to reply to this topic.