Ticket #35788: 35788.patch
File 35788.patch, 2.5 KB (added by , 9 years ago) |
---|
-
plugin-editor.php
14 14 exit(); 15 15 } 16 16 17 if ( ! current_user_can('edit_plugins') )17 if ( ! current_user_can('edit_plugins') ) { 18 18 wp_die( __('You do not have sufficient permissions to edit plugins for this site.') ); 19 } 19 20 20 $title = __( "Edit Plugins");21 $title = __('Edit Plugins'); 21 22 $parent_file = 'plugins.php'; 22 23 23 24 wp_reset_vars( array( 'action', 'error', 'file', 'plugin' ) ); … … 36 37 exit; 37 38 } 38 39 40 $current_plugin = $plugin ? $plugin : null; 41 39 42 if ( $file ) { 40 43 $plugin = $file; 41 44 } elseif ( empty( $plugin ) ) { … … 45 48 46 49 $plugin_files = get_plugin_files($plugin); 47 50 48 if ( empty( $file) )51 if ( empty( $file ) ) { 49 52 $file = $plugin_files[0]; 53 } 50 54 51 55 $file = validate_file_to_edit($file, $plugin_files); 52 56 $real_file = WP_PLUGIN_DIR . '/' . $file; … … 92 96 check_admin_referer('edit-plugin-test_' . $file); 93 97 94 98 $error = validate_plugin($file); 95 if ( is_wp_error( $error) )99 if ( is_wp_error( $error ) ) { 96 100 wp_die( $error ); 101 } 97 102 98 103 if ( ( ! empty( $_GET['networkwide'] ) && ! is_plugin_active_for_network($file) ) || ! is_plugin_active($file) ) 99 104 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 … … 121 126 if ( preg_match('/\.([^.]+)$/', $real_file, $matches) ) { 122 127 $ext = strtolower($matches[1]); 123 128 // If extension is not in the acceptable list, skip it 124 if ( ! in_array( $ext, $editable_extensions) )129 if ( ! in_array( $ext, $editable_extensions ) ) { 125 130 wp_die(sprintf('<p>%s</p>', __('Files of this type are not editable.'))); 126 131 } 127 132 } 133 } 128 134 129 135 get_current_screen()->add_help_tab( array( 130 136 'id' => 'overview', … … 212 218 <strong><label for="plugin"><?php _e('Select plugin to edit:'); ?> </label></strong> 213 219 <select name="plugin" id="plugin"> 214 220 <?php 221 $errors = array(); 215 222 foreach ( $plugins as $plugin_key => $a_plugin ) { 216 223 $plugin_name = $a_plugin['Name']; 217 if ( $plugin_key == $plugin ) 218 $selected = " selected='selected'"; 219 else 220 $selected = ''; 224 225 $selected = ( $plugin_key == $plugin || $plugin_key == $current_plugin ) ? ' selected="selected"' : ''; 226 221 227 $plugin_name = esc_attr($plugin_name); 222 228 $plugin_key = esc_attr($plugin_key); 223 229 echo "\n\t<option value=\"$plugin_key\" $selected>$plugin_name</option>";