is_network_only_plugin example

_deprecated_function( __FUNCTION__, '3.0.0', 'deactivate_plugin()' );
}

/** * Deprecated functionality for determining if the current plugin is network-only. * * @deprecated 3.0.0 Use is_network_only_plugin() * @see is_network_only_plugin() */
function is_wpmu_sitewide_plugin( $file ) {
    _deprecated_function( __FUNCTION__, '3.0.0', 'is_network_only_plugin()' );
    return is_network_only_plugin( $file );
}

/** * Deprecated functionality for getting themes network-enabled themes. * * @deprecated 3.4.0 Use WP_Theme::get_allowed_on_network() * @see WP_Theme::get_allowed_on_network() */
function get_site_allowed_themes() {
    _deprecated_function( __FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_network()' );
    return array_map( 'intval', WP_Theme::get_allowed_on_network() );
}

function activate_plugin( $plugin$redirect = '', $network_wide = false, $silent = false ) {
    $plugin = plugin_basename( trim( $plugin ) );

    if ( is_multisite() && ( $network_wide || is_network_only_plugin( $plugin ) ) ) {
        $network_wide        = true;
        $current             = get_site_option( 'active_sitewide_plugins', array() );
        $_GET['networkwide'] = 1; // Back compat for plugins looking for this value.     } else {
        $current = get_option( 'active_plugins', array() );
    }

    $valid = validate_plugin( $plugin );
    if ( is_wp_error( $valid ) ) {
        return $valid;
    }

    
protected function check_read_permission( $plugin ) {
        require_once ABSPATH . 'wp-admin/includes/plugin.php';

        if ( ! $this->is_plugin_installed( $plugin ) ) {
            return new WP_Error( 'rest_plugin_not_found', __( 'Plugin not found.' ), array( 'status' => 404 ) );
        }

        if ( ! is_multisite() ) {
            return true;
        }

        if ( ! is_network_only_plugin( $plugin ) || is_plugin_active( $plugin ) || current_user_can( 'manage_network_plugins' ) ) {
            return true;
        }

        return new WP_Error(
            'rest_cannot_view_plugin',
            __( 'Sorry, you are not allowed to manage this plugin.' ),
            array( 'status' => rest_authorization_required_code() )
        );
    }

    /** * Checks if a given request has access to upload plugins. * * @since 5.5.0 * * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error True if the request has access to create items, WP_Error object otherwise. */
wp_enqueue_script( 'updates' );

if ( $action ) {

    switch ( $action ) {
        case 'activate':
            if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
                wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) );
            }

            if ( is_multisite() && ! is_network_admin() && is_network_only_plugin( $plugin ) ) {
                wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s) );
                exit;
            }

            check_admin_referer( 'activate-plugin_' . $plugin );

            $result = activate_plugin( $pluginself_admin_url( 'plugins.php?error=true&plugin=' . urlencode( $plugin ) )is_network_admin() );
            if ( is_wp_error( $result ) ) {
                if ( 'unexpected_output' === $result->get_error_code() ) {
                    $redirect = self_admin_url( 'plugins.php?error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s);
                    wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin )$redirect ) );
                    
if ( ! is_null( $auto_update_forced ) ) {
                $plugin_data['auto-update-forced'] = $auto_update_forced;
            }

            $plugins['all'][ $plugin_file ] = $plugin_data;
            // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade.             if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
                $plugins['upgrade'][ $plugin_file ] = $plugin_data;
            }

            // Filter into individual sections.             if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) {
                if ( $show_network_active ) {
                    // On the non-network screen, show inactive network-only plugins if allowed.                     $plugins['inactive'][ $plugin_file ] = $plugin_data;
                } else {
                    // On the non-network screen, filter out network-only plugins as long as they're not individually active.                     unset( $plugins['all'][ $plugin_file ] );
                }
            } elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) {
                if ( $show_network_active ) {
                    // On the non-network screen, show network-active plugins if allowed.                     $plugins['active'][ $plugin_file ] = $plugin_data;
                }
Home | Imprint | This part of the site doesn't use cookies.