diff --git src/wp-admin/includes/plugin.php src/wp-admin/includes/plugin.php
index 7d804e1c66..910a78049c 100644
|
|
|
function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen |
| 557 | 557 | ob_start(); |
| 558 | 558 | wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); |
| 559 | 559 | $_wp_plugin_file = $plugin; |
| | 560 | |
| | 561 | if ( ! defined( 'WP_ADMIN' ) ) { |
| | 562 | define( 'WP_ADMIN', true ); |
| | 563 | } |
| | 564 | |
| | 565 | $tested_actions = array( |
| | 566 | 'plugins_loaded' => array(), |
| | 567 | 'setup_theme' => array(), |
| | 568 | 'after_setup_theme' => array(), |
| | 569 | 'init' => array(), |
| | 570 | 'wp_loaded' => array(), |
| | 571 | 'admin_init' => array(), |
| | 572 | ); |
| | 573 | array_map( 'remove_all_actions', array_keys( $tested_actions ) ); |
| | 574 | |
| 560 | 575 | include_once( WP_PLUGIN_DIR . '/' . $plugin ); |
| | 576 | |
| | 577 | // Trigger key actions that are done on the plugin editor to cause the relevant plugin hooks to fire and potentially cause errors. |
| | 578 | foreach ( $tested_actions as $action => $args ) { |
| | 579 | do_action_ref_array( $action, $args ); |
| | 580 | } |
| | 581 | |
| 561 | 582 | $plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin. |
| 562 | 583 | |
| 563 | 584 | if ( ! $silent ) { |
diff --git src/wp-admin/plugin-editor.php src/wp-admin/plugin-editor.php
index 14d2b65039..53947fff11 100644
|
|
|
if ( isset( $_REQUEST['plugin'] ) ) { |
| 46 | 46 | |
| 47 | 47 | if ( empty( $plugin ) ) { |
| 48 | 48 | if ( $file ) { |
| 49 | | $plugin = $file; |
| | 49 | |
| | 50 | // Locate the plugin for a given plugin file being edited. |
| | 51 | $file_dirname = dirname( $file ); |
| | 52 | foreach ( array_keys( $plugins ) as $plugin_candidate ) { |
| | 53 | if ( $plugin_candidate === $file || ( '.' !== $file_dirname && dirname( $plugin_candidate ) === $file_dirname ) ) { |
| | 54 | $plugin = $plugin_candidate; |
| | 55 | break; |
| | 56 | } |
| | 57 | } |
| | 58 | |
| | 59 | // Fallback to the file as the plugins. |
| | 60 | if ( empty( $plugin ) ) { |
| | 61 | $plugin = $file; |
| | 62 | } |
| 50 | 63 | } else { |
| 51 | 64 | $plugin = array_keys( $plugins ); |
| 52 | 65 | $plugin = $plugin[0]; |
| … |
… |
if ( isset( $_REQUEST['action'] ) && 'update' === $_REQUEST['action'] ) { |
| 72 | 85 | fwrite($f, $newcontent); |
| 73 | 86 | fclose($f); |
| 74 | 87 | |
| | 88 | if ( function_exists( 'opcache_invalidate' ) ) { |
| | 89 | opcache_invalidate( $real_file, true ); |
| | 90 | } |
| | 91 | |
| 75 | 92 | $network_wide = is_plugin_active_for_network( $file ); |
| 76 | 93 | |
| 77 | 94 | // Deactivate so we can test it. |
| … |
… |
if ( isset( $_REQUEST['action'] ) && 'update' === $_REQUEST['action'] ) { |
| 220 | 237 | <?php if (isset($_GET['a'])) : ?> |
| 221 | 238 | <div id="message" class="updated notice is-dismissible"><p><?php _e('File edited successfully.') ?></p></div> |
| 222 | 239 | <?php elseif (isset($_GET['phperror'])) : ?> |
| 223 | | <div id="message" class="updated"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p> |
| | 240 | <div id="message" class="notice notice-error"><p><?php _e( 'This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.' ); ?></p> |
| 224 | 241 | <?php |
| 225 | | if ( wp_verify_nonce( $_GET['_error_nonce'], 'plugin-activation-error_' . $file ) ) { |
| | 242 | if ( wp_verify_nonce( $_GET['_error_nonce'], 'plugin-activation-error_' . $plugin ) ) { |
| 226 | 243 | $iframe_url = add_query_arg( array( |
| 227 | 244 | 'action' => 'error_scrape', |
| 228 | | 'plugin' => urlencode( $file ), |
| | 245 | 'plugin' => urlencode( $plugin ), |
| 229 | 246 | '_wpnonce' => urlencode( $_GET['_error_nonce'] ), |
| 230 | 247 | ), admin_url( 'plugins.php' ) ); |
| 231 | 248 | ?> |