• This plugin perfectly help me to implement SSL on my blog without mixed content!

    Only one question remains:
    With the transition to SSL all sociale media counts (Facebook shares) are lost and set to zero. The solution would be to add a meta tag like:
    <meta property=”og:url” content=”https://www.yourpagelink&#8221; />
    this way both the https:// and the https:// versions are recognised by Facebook.

    BUT: the plugin replaces the https:// with https:// (as it is intended to do).
    ??
    I wonder if there is a way to ‘hardcode’ a https:// og:url into the page so that both shares are counted?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    Interesting, does this work? I’ve been using this approach for this issue:
    https://searchenginewatch.com/sew/how-to/2172926/maintain-social-shares-site-migration

    If your method works, let me know!

    You can use a filter to replace back a specific string
    https://really-simple-ssl.com/knowledge-base/exclude-url-mixed-content-fixer/

    In this case you would not just replace the url to http, but you want to replace the whole string:
    ‘<meta property=”og:url” content=”https://www.yourpagelink” />’
    to
    ‘<meta property=”og:url” content=”https://www.yourpagelink” />’

    Thread Starter ambientblog

    (@ambientblog)

    Thanks for your reply.
    First option will not work for me since the share buttons are placed using a jetpack plugin function, not the standalone FB code.

    Will try the replace option tomorrow. Wonder if it will work, since in fact what I need to combine the share counts it 2 different og:url’s:
    ‘<meta property=”og:url” content=”https://www.yourpagelink” />’
    AND
    ‘<meta property=”og:url” content=”https://www.yourpagelink” />’

    The replace function will probably result in only one…. ??

    Will let you know asap!

    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    I guess you would need to combine the two strings then:
    So you replace:
    ‘<meta property=”og:url” content=”https://www.yourpagelink” /><meta property=”og:url” content=”https://www.yourpagelink” />’

    into
    ‘<meta property=”og:url” content=”https://www.yourpagelink” /><meta property=”og:url” content=”https://www.yourpagelink” />’

    Let me know if this solves your problem!

    Thread Starter ambientblog

    (@ambientblog)

    I feel we’re very close, but there’s one thing I don’t know how to solve…
    The link in the header is dynamic, so it calls get_permalink() instead of the full link.

    <meta property=”og:url” content=”<?php echo get_permalink();?>”/>

    I don’t know how to replace the https:// to https:// using this function.

    But I guess this is more about PHP programming syntax than about the SLL plugin so I shouldn’t really bother you with this at all ??

    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    The filter uses the output of that function, so it doesn’t really matter. Your website will output something like:
    <meta property=”og:url” content=”https://www.yourpagelink” />

    Then the filter can replace it.

    -edit-
    As your permalink may change from page to page, I guess the replace can’t be a generic string replace. So maybe it’s better to replace only the first occurrence using preg_replace. I haven’t tested it, but should be something like this:

    $html = preg_replace('<meta property=”og:url” content=”https://', '<meta property=”og:url” content=”https://', $html, 1);

    Thread Starter ambientblog

    (@ambientblog)

    True, but that would replace all occurences of the https:// (in og:url) to https:// ?
    And I understood I need both now . One og:url to https:// and another to https://

    But I will try and see if the above fix will bring back the original counts.
    I wonder why facebook hasn’t fixed this issue for their counter. Especially when lots of site will make the move to SSL in the near future

    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    The preg_replace function gives you the option to replace only the first occurrence, so that should work.

    https://php.net/manual/en/function.preg-replace.php

    Thread Starter ambientblog

    (@ambientblog)

    I’ve updated the replace function with you latest suggestions, but the og:url is still not changed. It remains https:// which is not replaced…

    I’m giving up for now, but thanks A LOT for your help!!!

    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    One last try ??
    If it doesn’t work, I think there is no match, so you need to carefully check the string.

    Check if the quotes are the right ones. In the above snippet they got converted to something else. Here’s the code you should have:

    function rsssl_exclude_http_url($html) {
      $html = preg_replace(
        '<meta property="og:url" content="https://', 
        '<meta property="og:url" content="https://', 
        $html, 1);
      return $html;
    }
    add_filter("rsssl_fixer_output","rsssl_exclude_http_url");
    Thread Starter ambientblog

    (@ambientblog)

    I don’t really see any difference with the first snippet? But when I place this function code in functions.php the page output remains completely blank.
    Will have a more detailed look tomorrow!

    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    I fortgot to add a delimiter, in this case I’ll use ~. This code is tested and works. It replaces one (the first) occurrence:

    function rsssl_exclude_http_url($html) {
      $html = preg_replace(
        '~<meta property="og:url" content="https://~', 
        '<meta property="og:url" content="https://', 
        $html, 1);
      return $html;
    }
    add_filter("rsssl_fixer_output","rsssl_exclude_http_url");
    Thread Starter ambientblog

    (@ambientblog)

    Well that nailed it!
    Works like a charm now!

    I’ll have to wait a while to see if this brings back the FB share count, but the code issue is tackled at last!

    Thanks again!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Perfect (but one question about og:url)’ is closed to new replies.