Changes in trunk/wp-admin/plugin-editor.php [4881:4495]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/plugin-editor.php
r4881 r4495 31 31 fwrite($f, $newcontent); 32 32 fclose($f); 33 34 // Deactivate so we can test it.35 $current = get_option('active_plugins');36 if ( in_array($file, $current) || isset($_POST['phperror']) ) {37 if ( in_array($file, $current) ) {38 array_splice($current, array_search( $file, $current), 1 ); // Array-fu!39 update_option('active_plugins', $current);40 }41 wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1"));42 exit();43 }44 33 wp_redirect("plugin-editor.php?file=$file&a=te"); 45 34 } else { … … 55 44 if ( !current_user_can('edit_plugins') ) 56 45 wp_die('<p>'.__('You do not have sufficient permissions to edit plugins for this blog.').'</p>'); 57 58 if ( $_GET['liveupdate'] ) {59 check_admin_referer('edit-plugin-test_' . $file);60 $current = get_option('active_plugins');61 $plugin = $file;62 if ( validate_file($plugin) )63 wp_die(__('Invalid plugin.'));64 if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )65 wp_die(__('Plugin file does not exist.'));66 if (!in_array($plugin, $current)) {67 wp_redirect("plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error68 @include(ABSPATH . PLUGINDIR . '/' . $plugin);69 $current[] = $plugin;70 sort($current);71 update_option('active_plugins', $current);72 }73 wp_redirect("plugin-editor.php?file=$file&a=te");74 }75 46 76 47 require_once('admin-header.php'); … … 90 61 <?php if (isset($_GET['a'])) : ?> 91 62 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div> 92 <?php elseif (isset($_GET['phperror'])) : ?>93 <div id="message" class="updated fade"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p></div>94 63 <?php endif; ?> 95 64 <div class="wrap"> 96 65 <?php 97 if ( in_array($file, (array) get_option('active_plugins')) ) { 98 if (is_writeable($real_file)) { 99 echo '<h2>' . sprintf(__('Editing <strong>%s</strong> (active)'), $file) . '</h2>'; 100 } else { 101 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong> (active)'), $file) . '</h2>'; 102 } 66 if (is_writeable($real_file)) { 67 echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>'; 103 68 } else { 104 if (is_writeable($real_file)) { 105 echo '<h2>' . sprintf(__('Editing <strong>%s</strong> (inactive)'), $file) . '</h2>'; 106 } else { 107 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong> (inactive)'), $file) . '</h2>'; 108 } 69 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), $file) . '</h2>'; 109 70 } 110 71 ?> … … 130 91 </div> 131 92 <?php if ( is_writeable($real_file) ) : ?> 132 <?php if ( in_array($file, (array) get_option('active_plugins')) ) { ?>133 <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>134 <?php } ?>135 93 <p class="submit"> 136 94 <?php 137 if ( isset($_GET['phperror']) ) 138 echo "<input type='hidden' name='phperror' value='1' /><input type='submit' name='submit' value='" . __('Update File and Attempt to Reactivate »') . "' tabindex='2' />"; 139 else 140 echo "<input type='submit' name='submit' value='" . __('Update File »') . "' tabindex='2' />"; 95 echo "<input type='submit' name='submit' value=' " . __('Update File »') . "' tabindex='2' />"; 141 96 ?> 142 97 </p>
Note: See TracChangeset
for help on using the changeset viewer.