• Resolved Handoko

    (@handoko-zhang)


    Because of my curiosity how WP multisite works, I tried to install a multisite. It is a fresh install using subdomains for its sites. I’m glad it works. Then I installed WP SlimStat, and yes it works too.

    But I’m unable to make WP SlimStat Dashboard Widgets to work on the multisite installation. It’s even not showing up on the dashboard’s “Screen Options”. Is it anything I done wrong? I’ve tried to enable the dashboard widgets plugin both “network enabled” and “per site”.

    I’m using the latest version of WP and SlimStat.

    http://wordpress.org/extend/plugins/wp-slimstat/

Viewing 11 replies - 1 through 11 (of 11 total)
  • I’m having exactly the same problem. Please tell us what we can do to remedy this.

    I have the same problem too. In a Multisite environment, also in a subdomain and a sub directory structure. It is the same.

    No dashboard are visible, i activated the plugin in the multiste and on every site i have.

    The same error, no Dashboards are visible. No Errors in the Apache Log.

    Please advise.

    The problem is that the /wp-slimstat/wp-slimstat-dashboard.php file is only checking to see if WP SlimStat is active for a particular site, not side wide. So you could presumably work around this by deactivating it for the network and then activating per site, or if you want to update the code to have the dashboard widgets file check the site-wide plugins as well, change line 12 of the file to read:

    $multisite_plugin_active = (is_multisite() && array_key_exists('wp-slimstat/wp-slimstat.php', get_site_option('active_sitewide_plugins', array())) );
    if (!$multisite_plugin_active && !in_array('wp-slimstat/wp-slimstat.php', get_option('active_plugins', array()))) return;

    On second thought, a much better option than modifying the plugin code would be to use a filter on the get_option('active_plugins') to add the SlimStat plugin when it is active for multisite, so just add this to your functions.php:

    function activate_slimstat_dashboard_multisite($plugins){
    	// only run on multisite admin index screens ($pagenow isn't available, may need to mod if you are using subdirectories)
    	if (is_multisite() && $_SERVER['SCRIPT_NAME'] == "/wp-admin/index.php"){
    		$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' );

    EDIT: in the interest of not updating this post repeatedly, the latest working code is here – http://justin.ag/technology/activate-wp-slimstat-dashboard-widgets-in-wordpress-multisite/

    Which functions.php do you mean? I added in my theme functions.php but nothing is happened. I think it is normal because i need this for my admin index. But in which file i must added your code?

    wp-includes/functions.php don’t know add_filter
    And then i have more functions.php in my themes. But it doesn’t work for me.

    I get no dashboard widget in network admin dashboard and no one on site dashboard.

    You would add this in your /wp-content/themes/YOUR_THEME/functions.php. The widgets won’t show up on your network dash board (/wp-admin/network/) since it wouldn’t know what site to pull the stats for, but it will show up on the dashboards for your specific sites. I am using the code that I posted to my site (which should work for multisites using subfolders & subdomains) and it’s working for me.

    I added this to the right functions.php. But nothing is happened.

    First if i change the wp-slimstat-dashboard.php from your first post, i can see the dashboard widgets on my site dashboard.

    Do you have an idea why?

    Ahh, i think I know why – the plugins files are loading before functions.php, and the call in the slimstats plugin doesn’t use an action/filter hook so it executes immediately (which is why $pagenow isn’t available). With the filter being added in your theme, the call from the plugin happens before the filter is exists, so it doesn’t modify the results of get_option().

    The reason it works for me is that I actually wrote a plugin to use instead of the functions.php file for code that I want to keep around even if I change themes, and it is set up to run before any of the other plugins.

    If you want to do the same and use a filter instead of modifying the plugin, which I would recommend, you can set up your own custom functions.php plugin based on this code: http://justin.ag/technology/wordpress-plugins/wordpress-plugin-custom-functions-php/.

    Basically just create a custom-functions-php folder in your plugins directory, add the code from that link to a file called custom-functions.php and then include the filter from http://justin.ag/technology/activate-wp-slimstat-dashboard-widgets-in-wordpress-multisite/ in a file called functions.php in the custom-functions-php folder. Activate the new Custom functions.php plugin in your admin and you should be good to go – it should work as a site or network-wide plugin depending on how you want to distribute the custom functions. Nifty for other code too.

    Plugin Author Jason Crouse

    (@coolmann)

    Hi there,

    I’ve been busy with other stuff, but your idea is great, and I’m adding it to the next release of WP SlimStat. I’m also planning to add a series of hooks here and there (and document them, of course), so that it will be easier to customize the plugin’s behavior with a child plugin or something. Stay tuned!

    Plugin Author Jason Crouse

    (@coolmann)

    Thank you for your code, doublesharp, I added it to my plugin 🙂

    I am on WP 3.5.1 MS Network and I had unmoving widgets and it got fixed only by the Google Plugin for WP

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: WP SlimStat] Dashboard Widgets not working on Multisite’ is closed to new replies.