Changeset 4881
- Timestamp:
- 02/14/2007 06:15:05 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/plugin-editor.php
r4495 r4881 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 } 33 44 wp_redirect("plugin-editor.php?file=$file&a=te"); 34 45 } else { … … 44 55 if ( !current_user_can('edit_plugins') ) 45 56 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 error 68 @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 } 46 75 47 76 require_once('admin-header.php'); … … 61 90 <?php if (isset($_GET['a'])) : ?> 62 91 <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> 63 94 <?php endif; ?> 64 95 <div class="wrap"> 65 96 <?php 66 if (is_writeable($real_file)) { 67 echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>'; 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 } 68 103 } else { 69 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), $file) . '</h2>'; 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 } 70 109 } 71 110 ?> … … 91 130 </div> 92 131 <?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 } ?> 93 135 <p class="submit"> 94 136 <?php 95 echo "<input type='submit' name='submit' value=' " . __('Update File »') . "' tabindex='2' />"; 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' />"; 96 141 ?> 97 142 </p>
Note: See TracChangeset
for help on using the changeset viewer.