Changeset 7525
- Timestamp:
- 03/26/2008 04:14:29 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/plugin-editor.php
r7456 r7525 15 15 $plugin_files = array_keys($plugins); 16 16 17 if (empty($file)) {17 if (empty($file)) 18 18 $file = $plugin_files[0]; 19 }20 19 21 20 $file = validate_file_to_edit($file, $plugin_files); … … 32 31 33 32 $newcontent = stripslashes($_POST['newcontent']); 34 if ( is_writeable($real_file)) {33 if ( is_writeable($real_file) ) { 35 34 $f = fopen($real_file, 'w+'); 36 35 fwrite($f, $newcontent); … … 38 37 39 38 // Deactivate so we can test it. 40 $current = get_option('active_plugins'); 41 if ( in_array($file, $current) || isset($_POST['phperror']) ) { 42 if ( in_array($file, $current) ) { 43 if ( ( $key = array_search( $plugin, $current) ) !== false ) 44 array_splice($current, $key, 1 ); // Fixed Array-fu! 45 update_option('active_plugins', $current); 46 } 39 if ( is_plugin_active($file) || isset($_POST['phperror']) ) { 40 if ( is_plugin_active($file) ) 41 deactivate_plugins($file, true); 47 42 wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1")); 48 exit ();43 exit; 49 44 } 50 45 wp_redirect("plugin-editor.php?file=$file&a=te"); … … 52 47 wp_redirect("plugin-editor.php?file=$file"); 53 48 } 54 55 exit(); 49 exit; 56 50 57 51 break; … … 62 56 wp_die('<p>'.__('You do not have sufficient permissions to edit plugins for this blog.').'</p>'); 63 57 64 if ( $_GET['liveupdate']) {58 if ( isset($_GET['liveupdate']) ) { 65 59 check_admin_referer('edit-plugin-test_' . $file); 66 $current = get_option('active_plugins'); 67 $plugin = $file; 68 if ( validate_file($plugin) ) 69 wp_die(__('Invalid plugin.')); 70 if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) 71 wp_die(__('Plugin file does not exist.')); 72 if (!in_array($plugin, $current)) { 73 wp_redirect("plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error 74 @include(ABSPATH . PLUGINDIR . '/' . $plugin); 75 $current[] = $plugin; 76 sort($current); 77 update_option('active_plugins', $current); 78 } 60 61 $error = validate_plugin($file); 62 if( is_wp_error($error) ) 63 wp_die( $error ); 64 65 if ( ! is_plugin_active($file) ) 66 activate_plugin($file, "plugin-editor.php?file=$file&phperror=1");// we'll override this later if the plugin can be included without fatal error 67 79 68 wp_redirect("plugin-editor.php?file=$file&a=te"); 69 exit; 80 70 } 81 71 … … 84 74 update_recently_edited(PLUGINDIR . "/$file"); 85 75 86 if ( !is_file($real_file))76 if ( ! is_file($real_file) ) 87 77 $error = 1; 88 78 89 if (!$error) { 90 $f = fopen($real_file, 'r'); 91 $content = fread($f, filesize($real_file)); 92 $content = htmlspecialchars($content); 93 } 79 if ( ! $error ) 80 $content = htmlspecialchars(file_get_contents($real_file)); 94 81 95 82 ?> … … 97 84 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div> 98 85 <?php elseif (isset($_GET['phperror'])) : ?> 99 <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> 86 <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> 87 <?php 88 if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $file) ) { ?> 89 <iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&plugin=<?php echo attribute_escape($file); ?>&_wpnonce=<?php echo attribute_escape($_GET['_error_nonce']); ?>"></iframe> 90 <?php } ?> 91 </div> 100 92 <?php endif; ?> 101 93 <div class="wrap"> … … 106 98 <div class="alignleft"> 107 99 <big><strong><?php 108 if ( i n_array($file, (array) get_option('active_plugins')) ) {109 if ( is_writeable($real_file)) {100 if ( is_plugin_active($file) ) { 101 if ( is_writeable($real_file) ) 110 102 echo sprintf(__('Editing <strong>%s</strong> (active)'), $file); 111 } else { 112 echo sprintf(__('Browsing <strong>%s</strong> (active)'), $file); 113 } 103 else 104 echo sprintf(__('Browsing <strong>%s</strong> (active)'), $file); 114 105 } else { 115 if ( is_writeable($real_file)) {106 if ( is_writeable($real_file) ) 116 107 echo sprintf(__('Editing <strong>%s</strong> (inactive)'), $file); 117 } else { 118 echo sprintf(__('Browsing <strong>%s</strong> (inactive)'), $file); 119 } 108 else 109 echo sprintf(__('Browsing <strong>%s</strong> (inactive)'), $file); 120 110 } 121 111 ?></strong></big> … … 125 115 <br class="clear" /> 126 116 <div id="templateside"> 127 <h3 id="bordertitle"><?php _e( "Plugin Files"); ?></h3>117 <h3 id="bordertitle"><?php _e('Plugin Files'); ?></h3> 128 118 129 119 <h4><?php _e('Plugins'); ?></h4> 130 120 <ul> 131 121 <?php foreach($plugin_files as $plugin_file) : ?> 132 <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>122 <li><a href="plugin-editor.php?file=<?php echo $plugin_file; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li> 133 123 <?php endforeach; ?> 134 124 </ul> 135 125 </div> 136 <?php if ( !$error) { ?>126 <?php if ( ! $error ) { ?> 137 127 <form name="template" id="template" action="plugin-editor.php" method="post"> 138 128 <?php wp_nonce_field('edit-plugin_' . $file) ?> … … 165 155 </div> 166 156 <?php 167 break;157 break; 168 158 } 169 159 include("admin-footer.php") ?>
Note: See TracChangeset
for help on using the changeset viewer.