Quantcast
Channel: WordPress.org Forums » [WordPress MU Domain Mapping] Support
Viewing all articles
Browse latest Browse all 3502

Fix for Social Posters which take permalink while in backend

$
0
0

Replies: 0

Like Social Network Auto Poster is using get_permalink and the_permalink function to get the url of a post (in the backend). Therefor all the time the wrong url is used.

following additional plugin could be integrated in your plugin, that will search wrong domain and replace it, that the backend is also using the correct url:

if (!class_exists('WUKCMUD')) {
	class WUKCMUD {
		function __construct() {
			if(SUNRISE == 'on') {
				add_filter('the_permalink', array(&$this, 'correctpermalink'), 9999);
				add_filter('post_link', array(&$this, 'correctpermalink'), 9999);
			}
		}

		function correctpermalink($permalink) {
			global $wpdb;
			$url = parse_url($permalink);
			if ($url != FALSE) {
				$blogid = get_current_blog_id();

				$query = $wpdb->prepare("SELECT domain FROM ".$wpdb->base_prefix."domain_mapping
 WHERE blog_id='%s' AND active='1' LIMIT 1;", $blogid );
				$correctdomain = $wpdb->get_var($query);
				if ($correctdomain != false AND $correctdomain != '') {
					$permalink = str_replace($url['host'],$correctdomain,$permalink);
				}
			}
			return $permalink;
		}
	}
	add_action('init', 'WUKCMUD1');
	function WUKCMUD1() {
		global $WUKCMUD;
		$WUKCMUD = new WUKCMUD();
	}
}

regards

  • This topic was modified 7 hours, 4 minutes ago by  Stefan M..

Viewing all articles
Browse latest Browse all 3502

Trending Articles