Don't loose social counts when change permalinks?
-
Hi!
very neat graphics, and veryy nice plug-in, indeed.My issue is that I’ve changed permalinks and now social plugin do not recognize the old counts. So it turned out that there’s a couple of ways to solve this, depending on the social plugin. But it basically depends on what kind of link management the plugin and the APIs actually.
First, I’ve tried to customize your plugin which seems very “open” (great! ?? ). Unfortunatelly I’m not so skilled. I’ve tried with the features in the frontend panel but it’s not ruling for specific files. So I’ve decided to take a look at the code and try to hook the code with strategies like that. But I’m not an expert so I was trying.
Now the plugin is restored.. But maybe you can easily fix this.The pseudocode to do that in other (less open, and less beautiful) plugin is something like that:
– social plugin by means of variables, arrays AND/OR databases try to figure out not only the setting like “it’s a post” o “it’s a page” / or “already counted etc…
They primarly ask the page what is the url name and or the id. Now, I guess the id is the same all the time, while I’m sure that the url could change dynamically in many ways (curated or not).
One way to workaound this issue is to have a feature that before communicating with the various APIs tells them that this page was created a certain day, and that the name is another (the old current permalink). This cover all the old post that has been followed by many people, by leaving you with a current better permalink for SEO etc.. and of course reduce a pain for people like me that despite enjoy learning new stuff, would prefer blog rather than fix issues on his blog.I think it’s a very big issue that turned out from many people and you know for sure how much it’s important to keep your “social presence quantification” while moving……
Here two links with the https://encosia.com/preserving-social-sharing-counters-through-a-url-change/ and
https://lutfitorla.com/keeping-sharethis-digg-digg-social-counts-after-a-wordpress-permalink-change/ people who have kinda fix it fo some other plugins.My trial, (my code in the middle)
function ajax_get_counts() { if( !wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-get-counts" ) ) { die( json_encode( array() ) ); } $url = $_REQUEST['url'];
$url = get_permalink();
$url_change_date = strtotime(“7/06/2013”);
$post_date = strtotime(get_the_date());
if ($post_date < $url_change_date) {
// Build the /yyyy/mm/dd prefix to insert.
$url_date_prefix = “/” . date(“Y”, $post_date) .
“/” . date(“m”, $post_date) .
“/” . date(“d”, $post_date);// Update $url by replacing the beginning of the URL with
// the beginning prefixed by the date prefix string I just built.
$url = str_replace(“://semanto.me”,
“://semanto.me” . $url_date_prefix,
$url);$post_id = $_REQUEST['post_id']; $counts = array(); $buttons = $this->Button->get(); foreach( $buttons as $button ) { $counts[$button['type']] = $this->Button->get_count( $button['type'], $url ); } // Update stored count value update_post_meta( $post_id, "_{$this->namespace}_counts", $counts ); do_action( "{$this->namespace}_get_counts", $url, $post_id, $counts ); die( json_encode( $counts ) ); }
and I’m also trying something like overwriting the final output $count, but I cannot get the permission and It turned in a fatal error. Hopes you could help, this feature will attract a lot of people for sure.
Thanks a lot,Best
–Eugenio
- The topic ‘Don't loose social counts when change permalinks?’ is closed to new replies.