WordPress.org

Make WordPress Core

Changeset 41819


Ignore:
Timestamp:
10/11/17 00:02:30 (4 months ago)
Author:
westonruter
Message:

Plugin Editor: Revert superseded changes to activate_plugin() and plugin_sandbox_scrape().

Partially revert [41671], [41561], [41560].
See #21622.
Fixes #39766.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/plugin.php

    r41806 r41819  
    564564            wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error 
    565565        ob_start(); 
    566  
    567         plugin_sandbox_scrape( $plugin ); 
     566        wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); 
     567        $_wp_plugin_file = $plugin; 
     568        include_once( WP_PLUGIN_DIR . '/' . $plugin ); 
     569        $plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin. 
    568570 
    569571        if ( ! $silent ) { 
     
    18971899 
    18981900/** 
    1899  * Simulate loading the WordPress admin with a given plugin active to attempt to generate errors. 
    1900  * 
    1901  * Actions are re-triggered in the WP bootstrap process for the WP Admin, and the WP_ADMIN constant is defined. 
     1901 * Load a given plugin attempt to generate errors. 
    19021902 * 
    19031903 * @since 3.0.0 
    19041904 * @since 4.4.0 Function was moved into the `wp-admin/includes/plugin.php` file. 
    1905  * @since 4.9.0 Add defining of WP_ADMIN and triggering admin WP bootstrap actions. 
    1906  * 
    1907  * @global array $wp_actions 
     1905 * 
    19081906 * @param string $plugin Plugin file to load. 
    19091907 */ 
    19101908function plugin_sandbox_scrape( $plugin ) { 
    1911     global $wp_actions; 
    19121909    wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); 
    1913  
    1914     if ( ! defined( 'WP_ADMIN' ) ) { 
    1915         define( 'WP_ADMIN', true ); 
    1916     } 
    1917  
    1918     $tested_actions = array( 
    1919         'setup_theme' => array(), 
    1920         'after_setup_theme' => array(), 
    1921         'init' => array(), 
    1922         'wp_loaded' => array(), 
    1923         'admin_init' => array(), 
    1924     ); 
    1925     $old_wp_actions = $wp_actions; 
    1926     array_map( 'remove_all_actions', array_keys( $tested_actions ) ); 
    1927  
    1928     include_once( WP_PLUGIN_DIR . '/' . $plugin ); 
    1929  
    1930     // Trigger key actions that are done on the plugin editor to cause the relevant plugin hooks to fire and potentially cause errors. 
    1931     foreach ( $tested_actions as $action => $args ) { 
    1932         do_action_ref_array( $action, $args ); 
    1933     } 
    1934  
    1935     $wp_actions = $old_wp_actions; // Restore actions. 
    1936 } 
     1910    include( WP_PLUGIN_DIR . '/' . $plugin ); 
     1911} 
Note: See TracChangeset for help on using the changeset viewer.