Changeset 38745 for trunk/src/wp-admin/plugin-editor.php
- Timestamp:
- 10/07/2016 04:57:49 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/plugin-editor.php
r38722 r38745 20 20 $title = __("Edit Plugins"); 21 21 $parent_file = 'plugins.php'; 22 23 wp_reset_vars( array( 'action', 'error', 'file', 'plugin' ) );24 22 25 23 $plugins = get_plugins(); … … 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 … … 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); … … 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() ) { … … 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") );84 } else { 85 wp_redirect( self_admin_url( "plugin-editor.php?file=$file&scrollto=$scrollto") );92 wp_redirect( self_admin_url( "plugin-editor.php?file=$file&plugin=$plugin&a=te&scrollto=$scrollto" ) ); 93 } else { 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 ); 97 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 100 101 wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") ); 107 } 108 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 112 113 wp_redirect( self_admin_url("plugin-editor.php?file=$file&plugin=$plugin&a=te&scrollto=$scrollto") ); 102 114 exit; 103 115 } … … 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 } ?> … … 290 302 </script> 291 303 <?php 292 break; 293 } 304 } 305 294 306 include(ABSPATH . "wp-admin/admin-footer.php");
Note: See TracChangeset
for help on using the changeset viewer.