-
AuthorPosts
-
September 27, 2012 at 8:27 am #4710afcondonGuest
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:
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?http://encosia.com/preserving-social-sharing-counters-through-a-url-change/ any words of wisdom most appreciated! thanks for you good work!
cheers, Andrew
September 27, 2012 at 12:34 pm #6107Aakash ChakravarthyKeymasterUse 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 thisCode:/******* 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.
September 28, 2012 at 4:38 pm #6105AnonymousGuestThanks 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
October 4, 2012 at 1:37 pm #6104Aakash ChakravarthyKeymasterIf 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 🙄
October 12, 2012 at 12:51 pm #6106AnonymousGuestJust 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
August 17, 2013 at 6:41 pm #6108AnonymousGuestWhere would this appear in version 2.4.9? Need to amend plug-in to go from OldDomainName.com to NewDomainName.com.
-
AuthorPosts
- The topic ‘Preserving social sharing button count after domain change’ is closed to new replies.