Viewing 6 posts - 1 through 6 (of 6 total)
    • Author
      Posts
    • afcondon
      Guest

      Hi Aakash, i want to make a mod to (my local copy of) the socializer code to support a domain name change that has reset all the counters to zero, and more importantly hides dZone comments and so on.

      So the basic idea is similar to that discussed here: http://encosia.com/preserving-social-sharing-counters-through-a-url-change/ except that i want to do it in WP Socializer…what i’m looking for is a suggestion of what variable i should hijack in your code to ensure it’s the cleanest and least invasive edit?

      any words of wisdom most appreciated! thanks for you good work!

      cheers, Andrew

      Use the latest WP Socializer version.

      You need to do the domain name change work in the “wp-socializer.php” file.

      The function “wpsr_get_post_details()” sends the post details to the share buttons.

      So inside that function in line 1174 (as of v2.4.5) add your post URL changing code block like this

      Code:

      /******* TO CHANGE THE POST URL (obtained from encosia.com ) ***/

      // Changed URL structure from /yyyy/mm/dd/slug to /slug on
      // 5/28/2011. This ensures older posts still present the old URLs
      // to sharing services so that share counts are maintained.
      $url_change_date = strtotime(“5/28/2011”);
      $post_date = strtotime(get_the_date());

      $post_url = get_permalink($post->ID);

      if ($post_date < $url_change_date) {
      $url_date_prefix = "/" . date("Y", $post_date) .
      "/" . date("m", $post_date) .
      "/" . date("d", $post_date);

      $permalink_inside_loop = str_replace("://encosia.com",
      "://encosia.com" . $url_date_prefix,
      $post_url);
      }

      /*********************** END *************************************************/

      The actual concept is to store the “$permalink_inside_loop” variable with tweaked URL thats all.

      Anonymous
      Guest

      Thanks a lot for the response, Aakash. I made the change and verified that $permalink_inside_loop was getting substituted correctly (logging to wp-content/debug.log). However, still not picking up the old comments, tweets and so forth…probably there’s something else i’ve overlooked,

      thanks again, A

      If the $permalink_inside_loop variable holds the required URL, then the buttons load the count for that URL.

      Its also a good yet worst idea to leave the old count and start from ground up 🙄

      Anonymous
      Guest

      Just FYI – it’s the $permalink_outside_loop variable that actually provides the URL for the social buttons that are displayed…

      …not quite sure what’s going on in that code btw – you seem to be computing the $permalink_inside_loop value 135 times

      thanks again, A

      Anonymous
      Guest

      Where would this appear in version 2.4.9? Need to amend plug-in to go from OldDomainName.com to NewDomainName.com.

    Viewing 6 posts - 1 through 6 (of 6 total)
    • The topic ‘Preserving social sharing button count after domain change’ is closed to new replies.

    Subscribe for updates

    Get updates on the WordPress plugins, tips and tricks to enhance your WordPress experience. No spam. View newsletter