WordPress.org

Make WordPress Core

Ticket #15709: 15709.2.diff

File 15709.2.diff, 2.6 KB (added by PeteMall, 7 years ago)
  • wp-admin/includes/plugin.php

     
    455455}
    456456
    457457/**
     458 * Check whether the plugin is not network activated.
     459 *
     460 * Reverse of is_plugin_inactive_for_network(). Used as a callback.
     461 *
     462 * @since 3.1.0
     463 * @see is_plugin_inactive_for_network()
     464 *
     465 * @param string $plugin Base plugin path from plugins directory.
     466 * @return bool True if inactive. False if active.
     467 */
     468function is_plugin_inactive_for_network( $plugin ) {
     469        return ! is_plugin_active_for_network( $plugin );
     470}
     471
     472/**
    458473 * Checks for "Network: true" in the plugin header to see if this should
    459474 * be activated only as a network wide plugin. The plugin would also work
    460475 * when Multisite is not enabled.
     
    735750 * @return array invalid plugins, plugin as key, error as value
    736751 */
    737752function validate_active_plugins() {
    738         $plugins = get_option( 'active_plugins', array() );
    739         // validate vartype: array
    740         if ( ! is_array( $plugins ) ) {
    741                 update_option( 'active_plugins', array() );
    742                 $plugins = array();
     753        if ( !is_network_admin() ) {
     754                $plugins = get_option( 'active_plugins', array() );
     755                // validate vartype: array
     756                if ( ! is_array( $plugins ) ) {
     757                        update_option( 'active_plugins', array() );
     758                        $plugins = array();
     759                }
     760        } else {
     761                $plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
    743762        }
    744763
    745         if ( is_multisite() && is_super_admin() ) {
    746                 $network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
    747                 $plugins = array_merge( $plugins, array_keys( $network_plugins ) );
    748         }
    749 
    750764        if ( empty( $plugins ) )
    751765                return;
    752766
  • wp-admin/plugins.php

     
    195195
    196196                        //$_POST = from the plugin form; $_GET = from the FTP details screen.
    197197                        $plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
    198                         $plugins = array_filter($plugins, 'is_plugin_inactive'); // Do not allow to delete Activated plugins.
     198
     199                        if ( ! is_network_admin() )
     200                                $plugins = array_filter( $plugins, 'is_plugin_inactive' ); // Do not allow to delete Activated plugins.
     201                        else
     202                                $plugins = array_filter( $plugins, 'is_plugin_inactive_for_network' ); // Do not allow to delete Network Activated plugins.
     203
    199204                        if ( empty($plugins) ) {
    200205                                wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
    201206                                exit;