The MU forums have moved to WordPress.org

Enabling plugin to be available for particular blogs (2 posts)

  1. joreg
    Member
    Posted 16 years ago #

    Hi,

    I just created away to hide a plugin, only showning it to the blogs you really want.
    Yuu need to tweak plugins.php file under the wp-admin directory.
    First of all and before we change anything make a backup of this file!
    If there is any trouble you can always rollback!

    Also before start you must know the plugin name to hide.

    To do this copy this into plugins.php, after line 117:

    /* begin */

    foreach($plugins as $plugin_file => $plugin_data) {
    echo $plugin_file . ' | ' ;
    }

    /* end */

    Then refresh the plugin page, when your logged in and names will be displayed.
    copy the name of the plugin you want and remove this code.

    After this proceed with:

    Copy and paste the following code to this file rigth under
    $style = ''; - (line 117)

    //begin

    /* ******************************************** */
    /* To plug-in hider 2008 - Joreg */
    /* ******************************************** */
    /* PM for feedback */

    //declare $notshow as boolen

    $notshow = true;

    //here you select the plug-in to hide from all your blogs

    $plgin = 'feedwordpress/feedwordpress.php'; //in this case we want to hide "feedwordpres" plugin and make it available to blogs 1,33

    /* Array that will store the blogs id.
    works like $a = array(1,33) */

    $bl = array(1); //in this case the plugin will show up for blog with id 1
    //get the id of the current blog
    $blogid = $wpdb->blogid;

    //generate a loop, gets all plugin under your plugins folder
    foreach($plugins as $plugin_file => $plugin_data) {

    /*
    checks if the current plugin is the one we want to hide, in this case we want to
    hide "feedwordpress/feedwordpress.php"
    Remember: Replace with the name of the plug-in you want to hide.
    */
    if ($plugin_file == $plgin ) {

    //loops our created array for blogids
    foreach ($bl as $sh) {
    //checks if we want to show plugin to the current blog
    if ($sh == $blogid )
    $notshow = false; //Cool, we want to show this plug in to this blog
    }
    }

    }
    //if the current blog is not in the array then hide the current plugin.
    if ($notshow)
    unset($plugins[$plgin]);

    //end

    Tips:

    to get the blog id, you can go to the site Admin, when your logged in and see the ID of each blogs, goto blogs.
    I coded on version wordpress-mu-1.2.4 never tried on any other.
    If you can use this I can develop a multi-plugin hider.
    But first I need to see some feed-back!

    Regards,
    Joreg

  2. andrea_r
    Moderator
    Posted 16 years ago #

About this Topic