validate_plugin example

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;
    }

    $requirements = validate_plugin_requirements( $plugin );
    if ( is_wp_error( $requirements ) ) {
        return $requirements;
    }

    if ( $network_wide && ! isset( $current[ $plugin ] )
        || ! $network_wide && ! in_array( $plugin$current, true )
    )
echo '</div>';
            require_once ABSPATH . 'wp-admin/admin-footer.php';
            exit;

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

            check_admin_referer( 'plugin-activation-error_' . $plugin );

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

            if ( ! WP_DEBUG ) {
                error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
            }

            ini_set( 'display_errors', true ); // Ensure that fatal errors are displayed.             // Go back to "sandbox" scope so we get the same errors as before.             plugin_sandbox_scrape( $plugin );
            
Home | Imprint | This part of the site doesn't use cookies.