Changeset 10879
- Timestamp:
- 04/06/2009 05:27:36 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/plugin-editor.php
r10734 r10879 19 19 $plugins = get_plugins(); 20 20 21 if ( isset($_REQUEST['plugin']) ) 22 $plugin = $_REQUEST['plugin']; 23 21 24 if ( empty($plugin) ) { 22 25 $plugin = array_keys($plugins); … … 26 29 $plugin_files = get_plugin_files($plugin); 27 30 28 if ( empty($file))31 if ( empty($file) ) 29 32 $file = $plugin_files[0]; 30 33 … … 32 35 $real_file = WP_PLUGIN_DIR . '/' . $file; 33 36 34 switch ($action) {37 switch ( $action ) { 35 38 36 39 case 'update': … … 71 74 72 75 $error = validate_plugin($file); 73 if ( is_wp_error($error) )76 if ( is_wp_error($error) ) 74 77 wp_die( $error ); 75 78 76 79 if ( ! is_plugin_active($file) ) 77 activate_plugin($file, "plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error80 activate_plugin($file, "plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error 78 81 79 82 wp_redirect("plugin-editor.php?file=$file&a=te"); … … 87 90 update_recently_edited(WP_PLUGIN_DIR . '/' . $file); 88 91 89 if ( ! is_file($real_file) ) 90 $error = 1; 92 // List of allowable extensions 93 $editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include'); 94 $extra_extensions = apply_filters('editable_extensions', null); 95 if ( is_array($extra_extensions) ) 96 $editable_extensions = array_merge($editable_extensions, $extra_extensions); 97 98 if ( ! is_file($real_file) ) { 99 $error = __('No such file exists! Double check the name and try again.'); 100 } else { 101 // Get the extension of the file 102 if ( preg_match('/\.([^.]+)$/', $real_file, $matches) ) { 103 $ext = strtolower($matches[1]); 104 // If extension is not in the acceptable list, skip it 105 if ( !in_array( $ext, $editable_extensions) ) 106 $error = __('Files of this type are not editable.'); 107 } 108 } 91 109 92 110 if ( ! $error ) { … … 99 117 $docs_select .= '<option value="">' . __( 'Function Name...' ) . '</option>'; 100 118 foreach ( $functions as $function) { 101 $docs_select .= '<option value="' . urlencode( $function ) . '">' . htmlspecialchars( $function ) . '()</option>';119 $docs_select .= '<option value="' . attribute_escape( $function ) . '">' . htmlspecialchars( $function ) . '()</option>'; 102 120 } 103 121 $docs_select .= '</select>'; … … 127 145 <select name="plugin" id="plugin"> 128 146 <?php 129 foreach ($plugins as $plugin_key => $a_plugin) { 130 $plugin_name = $a_plugin['Name']; 131 if ($plugin_key == $plugin) $selected = " selected='selected'"; 132 else $selected = ''; 133 $plugin_name = attribute_escape($plugin_name); 134 echo "\n\t<option value=\"$plugin_key\" $selected>$plugin_name</option>"; 135 } 147 foreach ( $plugins as $plugin_key => $a_plugin ) { 148 $plugin_name = $a_plugin['Name']; 149 if ( $plugin_key == $plugin ) 150 $selected = " selected='selected'"; 151 else 152 $selected = ''; 153 $plugin_name = attribute_escape($plugin_name); 154 $plugin_key = attribute_escape($plugin_key); 155 echo "\n\t<option value=\"$plugin_key\" $selected>$plugin_name</option>"; 156 } 136 157 ?> 137 158 </select> … … 162 183 163 184 <ul> 164 <?php foreach($plugin_files as $plugin_file) : ?> 185 <?php 186 foreach ( $plugin_files as $plugin_file ) : 187 // Get the extension of the file 188 if ( preg_match('/\.([^.]+)$/', $plugin_file, $matches) ) { 189 $ext = strtolower($matches[1]); 190 // If extension is not in the acceptable list, skip it 191 if ( !in_array( $ext, $editable_extensions ) ) 192 continue; 193 } else { 194 // No extension found 195 continue; 196 } 197 ?> 165 198 <li<?php echo $file == $plugin_file ? ' class="highlight"' : ''; ?>><a href="plugin-editor.php?file=<?php echo $plugin_file; ?>&plugin=<?php echo $plugin; ?>"><?php echo $plugin_file ?></a></li> 166 199 <?php endforeach; ?> … … 176 209 </div> 177 210 <?php if ( count( $functions ) ) : ?> 178 <div id="documentation"><label for="docs-list"> Documentation:</label> <?php echo $docs_select ?> <input type="button" class="button" value=" <?php _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>211 <div id="documentation"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value=" <?php echo attribute_escape(__( '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> 179 212 <?php endif; ?> 180 213 <?php if ( is_writeable($real_file) ) : ?> … … 196 229 <?php 197 230 } else { 198 echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.'). '</p></div>';231 echo '<div class="error"><p>' . $error . '</p></div>'; 199 232 } 200 233 ?>
Note: See TracChangeset
for help on using the changeset viewer.