hacks Archives - Justin Silver https://www.justinsilver.com/tag/hacks/ Technology, Travel, and Pictures Mon, 30 Jun 2014 20:15:56 +0000 en-US hourly 1 https://wordpress.org/?v=6.0.1 https://www.justinsilver.com/wp-content/uploads/2013/06/cropped-apple-touch-icon-160x160.png hacks Archives - Justin Silver https://www.justinsilver.com/tag/hacks/ 32 32 Activate WP SlimStat Dashboard Widgets in WordPress Multisite https://www.justinsilver.com/technology/wordpress/activate-wp-slimstat-dashboard-widgets-in-wordpress-multisite/?utm_source=rss&utm_medium=rss&utm_campaign=activate-wp-slimstat-dashboard-widgets-in-wordpress-multisite https://www.justinsilver.com/technology/wordpress/activate-wp-slimstat-dashboard-widgets-in-wordpress-multisite/#comments Wed, 07 Nov 2012 00:24:26 +0000 http://justin.ag/?p=2807 If you have WordPress Multisite installed and the WP SlimStat plugin activated network wide, the optional WP SlimStat Dashboard widgets won’t be available to you. The problem is that the dashboard widgets file is...

The post Activate WP SlimStat Dashboard Widgets in WordPress Multisite appeared first on Justin Silver.

]]>
AmpedSense.OptimizeAdSpot('AP'); AmpedSense.OptimizeAdSpot('IL'); AmpedSense.OptimizeAdSpot('IR');

If you have WordPress Multisite installed and the WP SlimStat plugin activated network wide, the optional WP SlimStat Dashboard widgets won’t be available to you. The problem is that the dashboard widgets file is using get_option('active_plugins') to see if the plugin is active, and if it’s active network wide it won’t be in this array – it will be in get_site_options('active_sitewide_plugins'). Rather than modifying the WP SlimStat plugin files (which will be overwritten when you upgrade), I recommend adding the following filter to a custom functions plugin to add the value to the array before it is read by the dashboard widgets. Using functions.php in your theme is out because get_option() in the WP SlimStat plugin is called before it loads. You could also use a Must Use Plugin placed in /wp-content/mu-plugins.

There is some checking to make sure this only happens on the admin index page, but that’s just to be safe – it really shouldn’t have any adverse affects on your site except a few edge cases.

function activate_slimstat_dashboard_multisite($plugins){
	// only run on multisite admin index screens.
	// $pagenow isn't available, so we have to preg_match the SCRIPT_NAME (should work for subdirectories)
	if (is_multisite() && preg_match("~/wp-admin/index\.php$~", $_SERVER['SCRIPT_NAME'])){
		$slimstat_plugin = 'wp-slimstat/wp-slimstat.php';
		// check if plugin is active network wide and if so add to site plugins
		if (array_key_exists($slimstat_plugin, get_site_option('active_sitewide_plugins', array())))
			$plugins[] = $slimstat_plugin;
	}
	return $plugins;
}
add_filter( 'option_active_plugins', 'activate_slimstat_dashboard_multisite' );

The post Activate WP SlimStat Dashboard Widgets in WordPress Multisite appeared first on Justin Silver.

]]>
https://www.justinsilver.com/technology/wordpress/activate-wp-slimstat-dashboard-widgets-in-wordpress-multisite/feed/ 1