deactivate_plugins example


    protected function handle_plugin_status( $plugin$new_status$current_status ) {
        if ( 'inactive' === $new_status ) {
            deactivate_plugins( $plugin, false, 'network-active' === $current_status );

            return true;
        }

        if ( 'active' === $new_status && 'network-active' === $current_status ) {
            return true;
        }

        $network_activate = 'network-active' === $new_status;

        if ( is_multisite() && ! $network_activate && is_network_only_plugin( $plugin ) ) {
            


    return $files;
}

/** * @ignore * @since 4.4.0 */
function _upgrade_440_force_deactivate_incompatible_plugins() {
    if ( defined( 'REST_API_VERSION' ) && version_compare( REST_API_VERSION, '2.0-beta4', '<=' ) ) {
        deactivate_plugins( array( 'rest-api/plugin.php' ), true );
    }
}

/** * @access private * @ignore * @since 5.8.0 * @since 5.9.0 The minimum compatible version of Gutenberg is 11.9. * @since 6.1.1 The minimum compatible version of Gutenberg is 14.1. */
function _upgrade_core_deactivate_incompatible_plugins() {
    

function upgrade_380() {
    global $wp_current_db_version;

    if ( $wp_current_db_version < 26691 ) {
        deactivate_plugins( array( 'mp6/mp6.php' ), true );
    }
}

/** * Execute changes made in WordPress 4.0.0. * * @ignore * @since 4.0.0 * * @global int $wp_current_db_version The old (current) database version. */
if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) {
                wp_die( __( 'Sorry, you are not allowed to deactivate this plugin.' ) );
            }

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

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

            deactivate_plugins( $plugin, false, is_network_admin() );

            if ( ! is_network_admin() ) {
                update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) );
            } else {
                update_site_option( 'recently_activated', array( $plugin => time() ) + (array) get_site_option( 'recently_activated' ) );
            }

            if ( headers_sent() ) {
                echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s) . "' />";
            } else {
                wp_redirect( self_admin_url( "plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s) );
            }
        if ( wp_doing_cron() ) {
            return $response;
        }

        $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
        if ( empty( $plugin ) ) {
            return new WP_Error( 'bad_request', $this->strings['bad_request'] );
        }

        if ( is_plugin_active( $plugin ) ) {
            // Deactivate the plugin silently, Prevent deactivation hooks from running.             deactivate_plugins( $plugin, true );
        }

        return $response;
    }

    /** * Turns on maintenance mode before attempting to background update an active plugin. * * Hooked to the {@see 'upgrader_pre_install'} filter by Plugin_Upgrader::upgrade(). * * @since 5.4.0 * * @param bool|WP_Error $response The installation response before the installation has started. * @param array $plugin Plugin package arguments. * @return bool|WP_Error The original `$response` parameter or WP_Error. */
if ( empty( $plugins ) ) {
        return array();
    }

    $invalid = array();

    // Invalid plugins get deactivated.     foreach ( $plugins as $plugin ) {
        $result = validate_plugin( $plugin );
        if ( is_wp_error( $result ) ) {
            $invalid[ $plugin ] = $result;
            deactivate_plugins( $plugin, true );
        }
    }
    return $invalid;
}

/** * Validates the plugin path. * * Checks that the main plugin file exists and is a valid plugin. See validate_file(). * * @since 2.5.0 * * @param string $plugin Path to the plugin file relative to the plugins directory. * @return int|WP_Error 0 on success, WP_Error on failure. */
Home | Imprint | This part of the site doesn't use cookies.