Adding support for qTranslate / Polylang / WPML
-
Hi, it would be nice to add a filter to get_permalink() so we can override which URL will be used for Facebook.
This is because I’m using qTranslate, I have the content in 2 different languages, but I want the FB likes to be unique, so both languages will point to the same URL.
So in social_sharing_toolkit.php, function share($content), I added a filter “sst_url”:
if ($this->options['mr_social_sharing_position'] == 'top') { $bookmarks = $this->create_bookmarks(apply_filters('sst_url', get_permalink()), the_title('','',false), '', $media, ''); $content = $bookmarks.$content; } if ($this->options['mr_social_sharing_position'] == 'bottom') { $bookmarks = $this->create_bookmarks(apply_filters('sst_url', get_permalink()), the_title('','',false), '', $media, ''); $content .= $bookmarks; } if ($this->options['mr_social_sharing_position'] == 'both') { $bookmarks = $this->create_bookmarks(apply_filters('sst_url', get_permalink()), the_title('','',false), '', $media, ''); $content = $bookmarks.$content.$bookmarks; }And then in my functions.php I can unify all these different qTranslate URLs into 1:
// Priority 100: execute after hook the_permalink in qTranslate, so it will always already have the language info add_filter("sst_url", "gd_sst_qtrans_default_url", 100); function gd_sst_qtrans_default_url($url) { global $q_config; if (qtrans_getLanguage() != $q_config['default_language']) { // Do not say if it's http or https $current = '://'.$_SERVER["SERVER_NAME"].'/'.qtrans_getLanguage().'/'; $default = '://'.$_SERVER["SERVER_NAME"].'/'.$q_config['default_language'].'/'; $url = str_replace($current, $default, $url); } return $url; }It would be nice if the author can include the filter in the plugin.
Thanks!
The topic ‘Adding support for qTranslate / Polylang / WPML’ is closed to new replies.