Ticket #17552: 17552.patch
File 17552.patch, 7.4 KB (added by , 13 years ago) |
---|
-
wp-admin/plugin-editor.php
20 20 $title = __("Edit Plugins"); 21 21 $parent_file = 'plugins.php'; 22 22 23 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', ' a', 'file', 'plugin'));23 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'updated', 'file', 'plugin')); 24 24 25 25 wp_admin_css( 'theme-editor' ); 26 26 … … 29 29 if ( empty($plugins) ) 30 30 wp_die( __('There are no plugins installed on this site.') ); 31 31 32 if ( isset($_REQUEST['file']) )33 $plugin = stripslashes($_REQUEST['file']);34 35 32 if ( empty($plugin) ) { 36 $plugin = array_keys($plugins); 37 $plugin = $plugin[0]; 33 if ( ! empty($file) ) { 34 $plugin = $file; 35 } else { 36 $plugin = array_keys($plugins); 37 $plugin = $plugin[0]; 38 } 38 39 } 39 40 40 41 $plugin_files = get_plugin_files($plugin); … … 54 55 55 56 check_admin_referer('edit-plugin_' . $file); 56 57 57 $newcontent = stripslashes($_POST['newcontent']);58 58 if ( is_writeable($real_file) ) { 59 $f = fopen($real_file, 'w+'); 60 fwrite($f, $newcontent); 61 fclose($f); 59 $newcontent = stripslashes($_POST['newcontent']); 62 60 63 $network_wide = is_plugin_active_for_network( $file);61 file_put_contents($real_file, $newcontent); 64 62 63 $network_wide = is_plugin_active_for_network( $plugin ); 64 // @TODO: Network Wide activated plugins do not go through this lint check 65 65 // Deactivate so we can test it. 66 if ( is_plugin_active($ file) || isset($_POST['phperror']) ) {67 if ( is_plugin_active($ file) )68 deactivate_plugins($ file, true);66 if ( is_plugin_active($plugin) || isset($_POST['phperror']) ) { 67 if ( is_plugin_active($plugin) ) 68 deactivate_plugins($plugin, true); 69 69 70 update_option('recently_activated', array($ file=> time()) + (array)get_option('recently_activated'));70 update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated')); 71 71 72 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));72 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)); 73 73 exit; 74 74 } 75 wp_redirect( self_admin_url("plugin-editor.php?file=$file& a=te&scrollto=$scrollto") );75 wp_redirect( self_admin_url("plugin-editor.php?file=$file&plugin=$plugin&updated=1&scrollto=$scrollto") ); 76 76 } else { 77 wp_redirect( self_admin_url("plugin-editor.php?file=$file& scrollto=$scrollto") );77 wp_redirect( self_admin_url("plugin-editor.php?file=$file&plugin=$plugin&scrollto=$scrollto") ); 78 78 } 79 79 exit; 80 80 … … 85 85 if ( isset($_GET['liveupdate']) ) { 86 86 check_admin_referer('edit-plugin-test_' . $file); 87 87 88 $error = validate_plugin($ file);88 $error = validate_plugin($plugin); 89 89 if ( is_wp_error($error) ) 90 90 wp_die( $error ); 91 91 92 if ( ( ! empty( $_GET['networkwide'] ) && ! is_plugin_active_for_network($ file) ) || ! is_plugin_active($file) )93 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 error92 if ( ( ! empty( $_GET['networkwide'] ) && ! is_plugin_active_for_network($plugin) ) || ! is_plugin_active($plugin) ) 93 activate_plugin($plugin, "plugin-editor.php?file=$file&plugin=$plugin&phperror=1", ! empty( $_GET['networkwide'] ) ); // we'll override this later if the plugin can be included without fatal error 94 94 95 wp_redirect( self_admin_url("plugin-editor.php?file=$file& a=te&scrollto=$scrollto") );95 wp_redirect( self_admin_url("plugin-editor.php?file=$file&plugin=$plugin&updated=1&scrollto=$scrollto") ); 96 96 exit; 97 97 } 98 98 … … 101 101 $editable_extensions = (array) apply_filters('editable_extensions', $editable_extensions); 102 102 103 103 if ( ! is_file($real_file) ) { 104 wp_die( sprintf('<p>%s</p>', __('No such file exists! Double check the name and try again.')));104 wp_die( __('No such file exists! Double check the name and try again.') ); 105 105 } else { 106 106 // Get the extension of the file 107 107 if ( preg_match('/\.([^.]+)$/', $real_file, $matches) ) { 108 108 $ext = strtolower($matches[1]); 109 109 // If extension is not in the acceptable list, skip it 110 110 if ( !in_array( $ext, $editable_extensions) ) 111 wp_die( sprintf('<p>%s</p>', __('Files of this type are not editable.')));111 wp_die( __('Files of this type are not editable.') ); 112 112 } 113 113 } 114 114 … … 136 136 if ( !empty($functions) ) { 137 137 $docs_select = '<select name="docs-list" id="docs-list">'; 138 138 $docs_select .= '<option value="">' . __( 'Function Name…' ) . '</option>'; 139 foreach ( $functions as $function ) {139 foreach ( $functions as $function ) { 140 140 $docs_select .= '<option value="' . esc_attr( $function ) . '">' . esc_html( $function ) . '()</option>'; 141 141 } 142 142 $docs_select .= '</select>'; … … 145 145 146 146 $content = esc_textarea( $content ); 147 147 ?> 148 <?php if (isset($_GET[' a'])) : ?>148 <?php if (isset($_GET['updated'])) : ?> 149 149 <div id="message" class="updated"><p><?php _e('File edited successfully.') ?></p></div> 150 150 <?php elseif (isset($_GET['phperror'])) : ?> 151 151 <div id="message" class="updated"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p> 152 152 <?php 153 if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $file) ) { ?> 154 <iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&plugin=<?php echo esc_attr($file); ?>&_wpnonce=<?php echo esc_attr($_GET['_error_nonce']); ?>"></iframe> 153 if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?> 154 //@TODO: Is this Network Admin safe? (admin_url()) 155 <iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&plugin=' . urlencode($plugin) . '&_wpnonce=' . urlencode($_GET['_error_nonce']) ); ?>"></iframe> 155 156 <?php } ?> 156 157 </div> 157 158 <?php endif; ?> … … 162 163 <div class="fileedit-sub"> 163 164 <div class="alignleft"> 164 165 <big><?php 165 if ( is_plugin_active($plugin) ) {166 if ( is_plugin_active($plugin) || is_plugin_active_for_network($plugin) ) { 166 167 if ( is_writeable($real_file) ) 167 168 echo sprintf(__('Editing <strong>%s</strong> (active)'), $file); 168 169 else … … 231 232 <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( 'Lookup' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_locale() ) ?>&version=<?php echo urlencode( $wp_version ) ?>&redirect=true'); }" /></div> 232 233 <?php endif; ?> 233 234 <?php if ( is_writeable($real_file) ) : ?> 234 <?php if ( i n_array( $file, (array) get_option( 'active_plugins', array() )) ) { ?>235 <?php if ( is_plugin_active($plugin) || is_plugin_active_for_network($plugin) ) { ?> 235 236 <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> 236 237 <?php } ?> 237 238 <p class="submit">