WordPress.org

Ready to get started?Download WordPress

Forums

Social Sharing Toolkit
Adding support for qTranslate / Polylang / WPML (1 post)

  1. leoloso
    Member
    Posted 9 months ago #

    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!

    http://wordpress.org/extend/plugins/social-sharing-toolkit/

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.