diff --git src/wp-admin/plugin-editor.php src/wp-admin/plugin-editor.php
index 9919005..b9caf51 100644
|
|
if ( !current_user_can('edit_plugins') ) |
20 | 20 | $title = __("Edit Plugins"); |
21 | 21 | $parent_file = 'plugins.php'; |
22 | 22 | |
23 | | wp_reset_vars( array( 'action', 'error', 'file', 'plugin' ) ); |
24 | | |
25 | 23 | $plugins = get_plugins(); |
26 | 24 | |
27 | 25 | if ( empty( $plugins ) ) { |
… |
… |
if ( empty( $plugins ) ) { |
36 | 34 | exit; |
37 | 35 | } |
38 | 36 | |
39 | | if ( $file ) { |
40 | | $plugin = $file; |
41 | | } elseif ( empty( $plugin ) ) { |
42 | | $plugin = array_keys($plugins); |
43 | | $plugin = $plugin[0]; |
| 37 | $file = ''; |
| 38 | $plugin = ''; |
| 39 | if ( isset( $_REQUEST['file'] ) ) { |
| 40 | $file = sanitize_text_field( $_REQUEST['file'] ); |
| 41 | } |
| 42 | |
| 43 | if ( isset( $_REQUEST['plugin'] ) ) { |
| 44 | $plugin = sanitize_text_field( $_REQUEST['plugin'] ); |
| 45 | } |
| 46 | |
| 47 | if ( empty( $plugin ) ) { |
| 48 | if ( $file ) { |
| 49 | $plugin = $file; |
| 50 | } else { |
| 51 | $plugin = array_keys( $plugins ); |
| 52 | $plugin = $plugin[0]; |
| 53 | } |
44 | 54 | } |
45 | 55 | |
46 | 56 | $plugin_files = get_plugin_files($plugin); |
… |
… |
$file = validate_file_to_edit($file, $plugin_files); |
52 | 62 | $real_file = WP_PLUGIN_DIR . '/' . $file; |
53 | 63 | $scrollto = isset($_REQUEST['scrollto']) ? (int) $_REQUEST['scrollto'] : 0; |
54 | 64 | |
55 | | switch ( $action ) { |
56 | | |
57 | | case 'update': |
| 65 | if ( isset( $_REQUEST['action'] ) && 'update' === $_REQUEST['action'] ) { |
58 | 66 | |
59 | 67 | check_admin_referer('edit-plugin_' . $file); |
60 | 68 | |
… |
… |
case 'update': |
67 | 75 | $network_wide = is_plugin_active_for_network( $file ); |
68 | 76 | |
69 | 77 | // Deactivate so we can test it. |
70 | | if ( is_plugin_active($file) || isset($_POST['phperror']) ) { |
71 | | if ( is_plugin_active($file) ) |
72 | | deactivate_plugins($file, true); |
| 78 | if ( is_plugin_active( $plugin ) || isset( $_POST['phperror'] ) ) { |
| 79 | if ( is_plugin_active( $plugin ) ) { |
| 80 | deactivate_plugins( $plugin, true ); |
| 81 | } |
73 | 82 | |
74 | 83 | if ( ! is_network_admin() ) { |
75 | 84 | update_option( 'recently_activated', array( $file => time() ) + (array) get_option( 'recently_activated' ) ); |
… |
… |
case 'update': |
77 | 86 | update_site_option( 'recently_activated', array( $file => time() ) + (array) get_site_option( 'recently_activated' ) ); |
78 | 87 | } |
79 | 88 | |
80 | | wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide)); |
| 89 | wp_redirect( add_query_arg( '_wpnonce', wp_create_nonce( 'edit-plugin-test_' . $file ), "plugin-editor.php?file=$file&plugin=$plugin&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide ) ); |
81 | 90 | exit; |
82 | 91 | } |
83 | | wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") ); |
| 92 | wp_redirect( self_admin_url( "plugin-editor.php?file=$file&plugin=$plugin&a=te&scrollto=$scrollto" ) ); |
84 | 93 | } else { |
85 | | wp_redirect( self_admin_url("plugin-editor.php?file=$file&scrollto=$scrollto") ); |
| 94 | wp_redirect( self_admin_url( "plugin-editor.php?file=$file&plugin=$plugin&scrollto=$scrollto" ) ); |
86 | 95 | } |
87 | 96 | exit; |
88 | 97 | |
89 | | default: |
| 98 | } else { |
90 | 99 | |
91 | 100 | if ( isset($_GET['liveupdate']) ) { |
92 | 101 | check_admin_referer('edit-plugin-test_' . $file); |
93 | 102 | |
94 | | $error = validate_plugin($file); |
95 | | if ( is_wp_error($error) ) |
| 103 | $error = validate_plugin( $plugin ); |
| 104 | |
| 105 | if ( is_wp_error( $error ) ) { |
96 | 106 | wp_die( $error ); |
| 107 | } |
97 | 108 | |
98 | | if ( ( ! empty( $_GET['networkwide'] ) && ! is_plugin_active_for_network($file) ) || ! is_plugin_active($file) ) |
99 | | activate_plugin($file, "plugin-editor.php?file=$file&phperror=1", ! empty( $_GET['networkwide'] ) ); // we'll override this later if the plugin can be included without fatal error |
| 109 | if ( ( ! empty( $_GET['networkwide'] ) && ! is_plugin_active_for_network( $file ) ) || ! is_plugin_active( $file ) ) { |
| 110 | activate_plugin( $plugin, "plugin-editor.php?file=$file&phperror=1", ! empty( $_GET['networkwide'] ) ); |
| 111 | } // we'll override this later if the plugin can be included without fatal error |
100 | 112 | |
101 | | wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") ); |
| 113 | wp_redirect( self_admin_url("plugin-editor.php?file=$file&plugin=$plugin&a=te&scrollto=$scrollto") ); |
102 | 114 | exit; |
103 | 115 | } |
104 | 116 | |
… |
… |
foreach ( $plugin_files as $plugin_file ) : |
263 | 275 | <div id="documentation" class="hide-if-no-js"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value="<?php esc_attr_e( 'Look Up' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'https://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_locale() ) ?>&version=<?php echo urlencode( get_bloginfo( 'version' ) ) ?>&redirect=true'); }" /></div> |
264 | 276 | <?php endif; ?> |
265 | 277 | <?php if ( is_writeable($real_file) ) : ?> |
266 | | <?php if ( in_array( $file, (array) get_option( 'active_plugins', array() ) ) ) { ?> |
| 278 | <?php if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) ) { ?> |
267 | 279 | <p><?php _e('<strong>Warning:</strong> Making changes to active plugins is not recommended. If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?></p> |
268 | 280 | <?php } ?> |
269 | 281 | <p class="submit"> |
… |
… |
jQuery(document).ready(function($){ |
289 | 301 | }); |
290 | 302 | </script> |
291 | 303 | <?php |
292 | | break; |
293 | 304 | } |
| 305 | |
294 | 306 | include(ABSPATH . "wp-admin/admin-footer.php"); |