WordPress.org

Plugin Directory

Changeset 633839


Ignore:
Timestamp:
12/04/12 05:30:05 (17 months ago)
Author:
trepmal
Message:

1.6 update

Location:
active-plugins-on-multisite
Files:
2 added
2 edited
4 copied

Legend:

Unmodified
Added
Removed
  • active-plugins-on-multisite/tags/1.6/active-plugins.php

    r633837 r633839  
    55Description: Get number of users for each active plugin (minus network-activated). Then break down by site. 
    66Author: Kailey Lampert 
    7 Version: 1.5 
     7Version: 1.6 
    88Author URI: http://kaileylampert.com/ 
    99Network: true 
    10 */ 
    11 /* 
    12     Copyright (C) 2011  Kailey Lampert 
    1310 
    14     This program is free software: you can redistribute it and/or modify 
    15     it under the terms of the GNU General Public License as published by 
    16     the Free Software Foundation, either version 3 of the License, or 
    17     (at your option) any later version. 
     11Copyright (C) 2011-12 Kailey Lampert 
    1812 
    19     This program is distributed in the hope that it will be useful, 
    20     but WITHOUT ANY WARRANTY; without even the implied warranty of 
    21     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    22     GNU General Public License for more details. 
     13This program is free software: you can redistribute it and/or modify 
     14it under the terms of the GNU General Public License as published by 
     15the Free Software Foundation, either version 3 of the License, or 
     16(at your option) any later version. 
    2317 
    24     You should have received a copy of the GNU General Public License 
    25     along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     18This program is distributed in the hope that it will be useful, 
     19but WITHOUT ANY WARRANTY; without even the implied warranty of 
     20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     21GNU General Public License for more details. 
     22 
     23You should have received a copy of the GNU General Public License 
     24along with this program.  If not, see <http://www.gnu.org/licenses/>. 
    2625*/ 
    2726 
     
    2928 
    3029    function __construct() { 
    31         add_action('init', array( &$this, 'setup' ) ); 
     30        add_action( 'init', array( &$this, 'init' ) ); 
    3231    } 
    3332 
    34     function setup() { 
     33    function init() { 
    3534        if ( ! is_multisite() ) 
    36             add_action('admin_notices', array( &$this, 'notice' ) ); 
     35            add_action( 'admin_notices', array( &$this, 'admin_notices' ) ); 
    3736        else 
    38             add_action('network_admin_menu', array( &$this, 'menu' ) ); 
     37            add_action( 'network_admin_menu', array( &$this, 'network_admin_menu' ) ); 
    3938    } 
    4039 
    41     function notice() { 
     40    function admin_notices() { 
    4241        echo '<div class="error fade"><p>'; 
    4342        _e( 'Acitve Plugins is for multisite use only.', 'active-plugins' ); 
     
    4544    } 
    4645 
    47     function menu() { 
    48         add_submenu_page( 'settings.php', 'Active Plugins', 'Active Plugins', 'unfiltered_html', __FILE__, array( &$this, 'page' ) ); 
     46    function network_admin_menu() { 
     47        add_submenu_page( 'settings.php', __( 'Active Plugins', 'active-plugins' ), __( 'Active Plugins', 'active-plugins' ), 'unfiltered_html', __FILE__, array( &$this, 'page' ) ); 
    4948    } 
    5049 
     
    5251 
    5352        echo '<div class="wrap">'; 
    54         echo '<h2>'; _e( 'Active Plugins', 'active-plugins' ); echo '</h2>'; 
    55         echo '<p>'; _e( 'Network-Activated plugins not listed.', 'active-plugins' ); echo '</p>'; 
     53        echo '<h2>'. __( 'Active Plugins', 'active-plugins' ) .'</h2>'; 
     54        echo '<p>'. __( 'Network-Activated plugins not listed.', 'active-plugins' ) .'</p>'; 
    5655 
    5756        global $wpdb; 
    58         $query =  "SELECT * FROM {$wpdb->blogs}, {$wpdb->registration_log} 
     57        $query = "SELECT * FROM {$wpdb->blogs}, {$wpdb->registration_log} 
    5958                            WHERE site_id = '{$wpdb->siteid}' 
    6059                            AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id"; 
     
    6362        $all_plugins = get_plugins(); 
    6463        $plugins_list = array_keys( get_plugins() ); 
    65         //echo '<pre>'. print_r( get_plugins(), true) .'</pre>'; 
     64 
    6665        $pi = array(); 
    6766 
     
    8382        } 
    8483 
    85         echo "<pre style='background:#cfc'>Totals (each active plugin and how many users): \n"; 
     84        echo '<div style="background:#f3f3f3;padding:5px;">'; 
     85        _e( 'Totals (each active plugin and how many users)', 'active-plugins' ); 
     86 
    8687            $totals = $tags = array_count_values( $pi_count ); 
    8788            ksort( $totals ); 
     89            echo '<ul class="ul-disc">'; 
    8890            foreach( $totals as $name => $tot) { 
    8991 
     
    9698 
    9799                if ( in_array( $name, $plugins_list ) ) { 
    98                     $plugins_list = array_flip( $plugins_list ); 
    99                     unset( $plugins_list[ $name ] ); 
    100                     $plugins_list = array_flip( $plugins_list ); 
     100                    $plugins_list = array_flip( $plugins_list ); 
     101                    unset( $plugins_list[ $name ] ); 
     102                    $plugins_list = array_flip( $plugins_list ); 
    101103                } 
    102104 
    103                 $realname = $all_plugins[$name]['Name'] . ' v' . $all_plugins[$name]['Version']; 
    104                 //$realname = $all_plugins[$name]['Name']; 
    105                 echo "\t<strong>" . $realname . (!is_numeric($tags[ $name ]) ? ' (tagged: '.$tags[ $name ].')' : '') . '</strong> is used by <strong>' . $tot . ' site' . (($tot == '1') ? '' : 's') . "</strong>\n"; 
     105                $version = isset( $all_plugins[$name]['Version'] ) ? $all_plugins[$name]['Version'] : ''; 
     106                $version = sprintf( __( 'v%s', 'active-plugins' ), $version ); 
     107                if ( isset( $all_plugins[ $name ] ) ) { 
     108                    $label = sprintf( __( '%1$s %2$s', 'active-plugins' ), $all_plugins[$name]['Name'], $version ); 
     109                } else { 
     110                    $label = sprintf( __( '%s (Uninstalled)', 'active-plugins' ), $name ); 
     111                } 
     112 
     113                $label .= is_numeric( $tags[ $name ] ) ? '' : sprintf( __( ' (tagged: %s)', 'active-plugins' ), $tags[ $name ] ); 
     114 
     115                $fulllabel = sprintf( _n( '<strong>%s</strong> is used by %d site', '<strong>%s</strong> is used by %d sites', $tot, 'active-plugins' ), $label, $tot ); 
     116                echo "<li>$fulllabel</li>"; 
    106117 
    107118            } 
     119            echo '</ul>'; 
    108120 
    109121            //find which are network-activated 
     
    113125 
    114126            //show which not-network-activated plugins have 0 users 
    115             echo "\nInactive (plugins with zero (0) users): \n"; 
     127            _e( 'Plugins with zero (0) users:', 'active-plugins' ); 
     128            echo '<ul class="ul-disc">'; 
    116129            foreach( $remove_network as $k => $inactive ) { 
    117                 $realname = $all_plugins[$inactive]['Name'] . ' v' . $all_plugins[$inactive]['Version']; 
    118                 echo "\t{$realname}\n"; 
     130                // $realname = $all_plugins[$inactive]['Name'] . ' v' . $all_plugins[ $inactive ]['Version']; 
     131                $version = isset( $all_plugins[$name]['Version'] ) ? $all_plugins[$name]['Version'] : ''; 
     132                $version = sprintf( __( 'v%s', 'active-plugins' ), $version ); 
     133                $realname = sprintf( __( '%1$s %2$s', 'active-plugins' ), $all_plugins[ $inactive ]['Name'], $version ); 
     134                $unused[] = "<li>{$realname}</li>"; 
    119135            } 
     136            echo empty( $unused ) ? '<li><em>'. __( 'none', 'active-plugins' ) .'</em></li>' : implode( $unused ); 
     137            echo '</ul>'; 
    120138 
    121         echo '</pre>'; 
     139        echo '</div>'; 
    122140 
    123         echo '<br />'; 
    124         echo "<pre style='background:#ccf'>\n"; 
     141        echo '<div style="background:#dfdfdf;padding:5px;margin-top:30px;">'; 
    125142            foreach( $pi as $siteid => $list ) { 
    126                 $details = get_blog_details( $siteid ); 
    127143 
    128                 $plugins = "$details->siteurl/wp-admin/plugins.php"; 
    129                 $dash = "$details->siteurl/wp-admin/"; 
    130                 $view = "$details->siteurl"; 
     144                switch_to_blog( $siteid ); 
     145 
    131146                $edit = network_admin_url( "site-info.php?id=$siteid" ); 
     147                $view = home_url(); 
     148                $dash = admin_url(); 
     149                $plugins = admin_url('/plugins.php'); 
    132150 
    133                 echo "$details->blogname <a href='$edit'>($siteid) Edit</a> [<a href='$view'>View</a>] [<a href='$dash'>Dashboard</a>] [<a href='$plugins'>Plugins page</a>] \n"; 
     151                $blogname = get_bloginfo('name'); 
     152                $edit_label = __( 'Edit', 'active-plugins' ); 
     153                $view_label = __( 'View', 'active-plugins' ); 
     154                $dashboard_label = __( 'Dashboard', 'active-plugins' ); 
     155                $plugins_label = __( 'Plugins', 'active-plugins' ); 
    134156 
     157                echo "<h3>$blogname ($siteid) [<a href='$edit'>$edit_label</a>] [<a href='$view'>$view_label</a>] [<a href='$dash'>$dashboard_label</a>] [<a href='$plugins'>$plugins_label</a>]</h3>"; 
     158                echo '<ul class="ul-disc">'; 
    135159                $tagged = array(); 
    136                 $nottagged = ''; 
     160                $nottagged = array(); 
    137161                foreach( $list as $name ) { 
    138                     //$realname = $all_plugins[$name]['Name'] . ' v' . $all_plugins[$name]['Version']; 
    139                     $realname = $all_plugins[$name]['Name']; 
     162                    $realname = isset( $all_plugins[ $name ] ) ? $all_plugins[ $name ]['Name'] : $name; 
    140163                    if ( is_numeric( $tags[ $name ] ) ) 
    141                         $nottagged .= "\t{$realname}\n"; 
     164                        $nottagged[] .= "<li>{$realname}</li>"; 
    142165                    else 
    143                         $tagged["\t({$tags[ $name ]}) $realname\n"] = $tags[ $name ]; 
     166                        $tagged["<li>({$tags[ $name ]}) $realname</li>"] = $tags[ $name ]; 
    144167                } 
    145168                asort( $tagged ); 
    146169                $tagged = array_keys( $tagged ); 
    147                 echo implode( $tagged ) . $nottagged . "\n"; 
     170                echo implode( $tagged ); 
    148171 
    149                 unset( $tagged ); 
    150                 unset( $nottagged ); 
     172                sort( $nottagged ); 
     173                echo implode( $nottagged ); 
     174                echo '</ul><hr />'; 
     175 
     176                restore_current_blog(); 
    151177            } 
    152178 
    153         echo '</pre>'; 
     179        echo '</div>'; 
    154180 
    155181        echo '</div>'; 
  • active-plugins-on-multisite/tags/1.6/readme.txt

    r633837 r633839  
    44Tags: mutlisite, plugins, utility 
    55Requires at least: 3.2.1 
    6 Tested up to: 3.3-beta3 
    7 Stable tag: trunk 
     6Tested up to: 3.5 
     7Stable tag: 1.6 
    88 
    99Generates a list of plugins that are currently in use 
     
    4545 
    4646= 1.5 = 
     47Not pretty, but not as ugly either. Code cleanup. 
     48 
     49= 1.5 = 
    4750A little prettier. 
    4851 
     
    5154 
    5255== Changelog == 
     56 
     57= 1.6 = 
     58* Verified agains 3.5 
     59* More code clean up 
     60* Slight de-uglification. 
    5361 
    5462= 1.5 = 
  • active-plugins-on-multisite/trunk/active-plugins.php

    r461634 r633839  
    55Description: Get number of users for each active plugin (minus network-activated). Then break down by site. 
    66Author: Kailey Lampert 
    7 Version: 1.5 
     7Version: 1.6 
    88Author URI: http://kaileylampert.com/ 
    99Network: true 
    10 */ 
    11 /* 
    12     Copyright (C) 2011  Kailey Lampert 
    1310 
    14     This program is free software: you can redistribute it and/or modify 
    15     it under the terms of the GNU General Public License as published by 
    16     the Free Software Foundation, either version 3 of the License, or 
    17     (at your option) any later version. 
     11Copyright (C) 2011-12 Kailey Lampert 
    1812 
    19     This program is distributed in the hope that it will be useful, 
    20     but WITHOUT ANY WARRANTY; without even the implied warranty of 
    21     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    22     GNU General Public License for more details. 
     13This program is free software: you can redistribute it and/or modify 
     14it under the terms of the GNU General Public License as published by 
     15the Free Software Foundation, either version 3 of the License, or 
     16(at your option) any later version. 
    2317 
    24     You should have received a copy of the GNU General Public License 
    25     along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     18This program is distributed in the hope that it will be useful, 
     19but WITHOUT ANY WARRANTY; without even the implied warranty of 
     20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     21GNU General Public License for more details. 
     22 
     23You should have received a copy of the GNU General Public License 
     24along with this program.  If not, see <http://www.gnu.org/licenses/>. 
    2625*/ 
    2726 
     
    2928 
    3029    function __construct() { 
    31         add_action('init', array( &$this, 'setup' ) ); 
     30        add_action( 'init', array( &$this, 'init' ) ); 
    3231    } 
    3332 
    34     function setup() { 
     33    function init() { 
    3534        if ( ! is_multisite() ) 
    36             add_action('admin_notices', array( &$this, 'notice' ) ); 
     35            add_action( 'admin_notices', array( &$this, 'admin_notices' ) ); 
    3736        else 
    38             add_action('network_admin_menu', array( &$this, 'menu' ) ); 
     37            add_action( 'network_admin_menu', array( &$this, 'network_admin_menu' ) ); 
    3938    } 
    4039 
    41     function notice() { 
     40    function admin_notices() { 
    4241        echo '<div class="error fade"><p>'; 
    4342        _e( 'Acitve Plugins is for multisite use only.', 'active-plugins' ); 
     
    4544    } 
    4645 
    47     function menu() { 
    48         add_submenu_page( 'settings.php', 'Active Plugins', 'Active Plugins', 'unfiltered_html', __FILE__, array( &$this, 'page' ) ); 
     46    function network_admin_menu() { 
     47        add_submenu_page( 'settings.php', __( 'Active Plugins', 'active-plugins' ), __( 'Active Plugins', 'active-plugins' ), 'unfiltered_html', __FILE__, array( &$this, 'page' ) ); 
    4948    } 
    5049 
     
    5251 
    5352        echo '<div class="wrap">'; 
    54         echo '<h2>'; _e( 'Active Plugins', 'active-plugins' ); echo '</h2>'; 
    55         echo '<p>'; _e( 'Network-Activated plugins not listed.', 'active-plugins' ); echo '</p>'; 
     53        echo '<h2>'. __( 'Active Plugins', 'active-plugins' ) .'</h2>'; 
     54        echo '<p>'. __( 'Network-Activated plugins not listed.', 'active-plugins' ) .'</p>'; 
    5655 
    5756        global $wpdb; 
    58         $query =  "SELECT * FROM {$wpdb->blogs}, {$wpdb->registration_log} 
     57        $query = "SELECT * FROM {$wpdb->blogs}, {$wpdb->registration_log} 
    5958                            WHERE site_id = '{$wpdb->siteid}' 
    6059                            AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id"; 
     
    6362        $all_plugins = get_plugins(); 
    6463        $plugins_list = array_keys( get_plugins() ); 
    65         //echo '<pre>'. print_r( get_plugins(), true) .'</pre>'; 
     64 
    6665        $pi = array(); 
    6766 
     
    8382        } 
    8483 
    85         echo "<pre style='background:#cfc'>Totals (each active plugin and how many users): \n"; 
     84        echo '<div style="background:#f3f3f3;padding:5px;">'; 
     85        _e( 'Totals (each active plugin and how many users)', 'active-plugins' ); 
     86 
    8687            $totals = $tags = array_count_values( $pi_count ); 
    8788            ksort( $totals ); 
     89            echo '<ul class="ul-disc">'; 
    8890            foreach( $totals as $name => $tot) { 
    8991 
     
    9698 
    9799                if ( in_array( $name, $plugins_list ) ) { 
    98                     $plugins_list = array_flip( $plugins_list ); 
    99                     unset( $plugins_list[ $name ] ); 
    100                     $plugins_list = array_flip( $plugins_list ); 
     100                    $plugins_list = array_flip( $plugins_list ); 
     101                    unset( $plugins_list[ $name ] ); 
     102                    $plugins_list = array_flip( $plugins_list ); 
    101103                } 
    102104 
    103                 $realname = $all_plugins[$name]['Name'] . ' v' . $all_plugins[$name]['Version']; 
    104                 //$realname = $all_plugins[$name]['Name']; 
    105                 echo "\t<strong>" . $realname . (!is_numeric($tags[ $name ]) ? ' (tagged: '.$tags[ $name ].')' : '') . '</strong> is used by <strong>' . $tot . ' site' . (($tot == '1') ? '' : 's') . "</strong>\n"; 
     105                $version = isset( $all_plugins[$name]['Version'] ) ? $all_plugins[$name]['Version'] : ''; 
     106                $version = sprintf( __( 'v%s', 'active-plugins' ), $version ); 
     107                if ( isset( $all_plugins[ $name ] ) ) { 
     108                    $label = sprintf( __( '%1$s %2$s', 'active-plugins' ), $all_plugins[$name]['Name'], $version ); 
     109                } else { 
     110                    $label = sprintf( __( '%s (Uninstalled)', 'active-plugins' ), $name ); 
     111                } 
     112 
     113                $label .= is_numeric( $tags[ $name ] ) ? '' : sprintf( __( ' (tagged: %s)', 'active-plugins' ), $tags[ $name ] ); 
     114 
     115                $fulllabel = sprintf( _n( '<strong>%s</strong> is used by %d site', '<strong>%s</strong> is used by %d sites', $tot, 'active-plugins' ), $label, $tot ); 
     116                echo "<li>$fulllabel</li>"; 
    106117 
    107118            } 
     119            echo '</ul>'; 
    108120 
    109121            //find which are network-activated 
     
    113125 
    114126            //show which not-network-activated plugins have 0 users 
    115             echo "\nInactive (plugins with zero (0) users): \n"; 
     127            _e( 'Plugins with zero (0) users:', 'active-plugins' ); 
     128            echo '<ul class="ul-disc">'; 
    116129            foreach( $remove_network as $k => $inactive ) { 
    117                 $realname = $all_plugins[$inactive]['Name'] . ' v' . $all_plugins[$inactive]['Version']; 
    118                 echo "\t{$realname}\n"; 
     130                // $realname = $all_plugins[$inactive]['Name'] . ' v' . $all_plugins[ $inactive ]['Version']; 
     131                $version = isset( $all_plugins[$name]['Version'] ) ? $all_plugins[$name]['Version'] : ''; 
     132                $version = sprintf( __( 'v%s', 'active-plugins' ), $version ); 
     133                $realname = sprintf( __( '%1$s %2$s', 'active-plugins' ), $all_plugins[ $inactive ]['Name'], $version ); 
     134                $unused[] = "<li>{$realname}</li>"; 
    119135            } 
     136            echo empty( $unused ) ? '<li><em>'. __( 'none', 'active-plugins' ) .'</em></li>' : implode( $unused ); 
     137            echo '</ul>'; 
    120138 
    121         echo '</pre>'; 
     139        echo '</div>'; 
    122140 
    123         echo '<br />'; 
    124         echo "<pre style='background:#ccf'>\n"; 
     141        echo '<div style="background:#dfdfdf;padding:5px;margin-top:30px;">'; 
    125142            foreach( $pi as $siteid => $list ) { 
    126                 $details = get_blog_details( $siteid ); 
    127143 
    128                 $plugins = "$details->siteurl/wp-admin/plugins.php"; 
    129                 $dash = "$details->siteurl/wp-admin/"; 
    130                 $view = "$details->siteurl"; 
     144                switch_to_blog( $siteid ); 
     145 
    131146                $edit = network_admin_url( "site-info.php?id=$siteid" ); 
     147                $view = home_url(); 
     148                $dash = admin_url(); 
     149                $plugins = admin_url('/plugins.php'); 
    132150 
    133                 echo "$details->blogname <a href='$edit'>($siteid) Edit</a> [<a href='$view'>View</a>] [<a href='$dash'>Dashboard</a>] [<a href='$plugins'>Plugins page</a>] \n"; 
     151                $blogname = get_bloginfo('name'); 
     152                $edit_label = __( 'Edit', 'active-plugins' ); 
     153                $view_label = __( 'View', 'active-plugins' ); 
     154                $dashboard_label = __( 'Dashboard', 'active-plugins' ); 
     155                $plugins_label = __( 'Plugins', 'active-plugins' ); 
    134156 
     157                echo "<h3>$blogname ($siteid) [<a href='$edit'>$edit_label</a>] [<a href='$view'>$view_label</a>] [<a href='$dash'>$dashboard_label</a>] [<a href='$plugins'>$plugins_label</a>]</h3>"; 
     158                echo '<ul class="ul-disc">'; 
    135159                $tagged = array(); 
    136                 $nottagged = ''; 
     160                $nottagged = array(); 
    137161                foreach( $list as $name ) { 
    138                     //$realname = $all_plugins[$name]['Name'] . ' v' . $all_plugins[$name]['Version']; 
    139                     $realname = $all_plugins[$name]['Name']; 
     162                    $realname = isset( $all_plugins[ $name ] ) ? $all_plugins[ $name ]['Name'] : $name; 
    140163                    if ( is_numeric( $tags[ $name ] ) ) 
    141                         $nottagged .= "\t{$realname}\n"; 
     164                        $nottagged[] .= "<li>{$realname}</li>"; 
    142165                    else 
    143                         $tagged["\t({$tags[ $name ]}) $realname\n"] = $tags[ $name ]; 
     166                        $tagged["<li>({$tags[ $name ]}) $realname</li>"] = $tags[ $name ]; 
    144167                } 
    145168                asort( $tagged ); 
    146169                $tagged = array_keys( $tagged ); 
    147                 echo implode( $tagged ) . $nottagged . "\n"; 
     170                echo implode( $tagged ); 
    148171 
    149                 unset( $tagged ); 
    150                 unset( $nottagged ); 
     172                sort( $nottagged ); 
     173                echo implode( $nottagged ); 
     174                echo '</ul><hr />'; 
     175 
     176                restore_current_blog(); 
    151177            } 
    152178 
    153         echo '</pre>'; 
     179        echo '</div>'; 
    154180 
    155181        echo '</div>'; 
  • active-plugins-on-multisite/trunk/readme.txt

    r461634 r633839  
    44Tags: mutlisite, plugins, utility 
    55Requires at least: 3.2.1 
    6 Tested up to: 3.3-beta3 
    7 Stable tag: trunk 
     6Tested up to: 3.5 
     7Stable tag: 1.6 
    88 
    99Generates a list of plugins that are currently in use 
     
    4545 
    4646= 1.5 = 
     47Not pretty, but not as ugly either. Code cleanup. 
     48 
     49= 1.5 = 
    4750A little prettier. 
    4851 
     
    5154 
    5255== Changelog == 
     56 
     57= 1.6 = 
     58* Verified agains 3.5 
     59* More code clean up 
     60* Slight de-uglification. 
    5361 
    5462= 1.5 = 
Note: See TracChangeset for help on using the changeset viewer.