Changes in trunk/wp-admin/theme-editor.php [17471:15135]
- File:
-
- 1 edited
-
trunk/wp-admin/theme-editor.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/theme-editor.php
r17471 r15135 10 10 require_once('./admin.php'); 11 11 12 if ( is_multisite() && ! is_network_admin() ) {13 wp_redirect( network_admin_url( 'theme-editor.php' ) );14 exit();15 }16 17 12 if ( !current_user_can('edit_themes') ) 18 13 wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>'); … … 27 22 $help .= '<p>' . __('<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.') . '</p>'; 28 23 $help .= '<p>' . __('Upgrading to a newer version of the same theme will override changes made here. To avoid this, consider creating a <a href="http://codex.wordpress.org/Child_Themes" target="_blank">child theme</a> instead.') . '</p>'; 29 if ( is_network_admin() )30 $help .= '<p>' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '</p>';31 24 $help .= '<p><strong>' . __('For more information:') . '</strong></p>'; 32 25 $help .= '<p>' . __('<a href="http://codex.wordpress.org/Theme_Development" target="_blank">Documentation on Theme Development</a>') . '</p>'; … … 52 45 wp_die(__('The requested theme does not exist.')); 53 46 54 $allowed_files = array_merge( $themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files'] ); 55 56 if ( empty( $file ) ) { 57 if ( false !== array_search( $themes[$theme]['Stylesheet Dir'] . '/style.css', $allowed_files ) ) 58 $file = $themes[$theme]['Stylesheet Dir'] . '/style.css'; 59 else 60 $file = $allowed_files[0]; 47 $allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']); 48 49 if (empty($file)) { 50 $file = $allowed_files[0]; 61 51 } else { 62 52 $file = stripslashes($file); … … 104 94 default: 105 95 106 require_once( ABSPATH . 'wp-admin/admin-header.php');96 require_once('./admin-header.php'); 107 97 108 98 update_recently_edited($file); … … 111 101 $error = 1; 112 102 113 $content = '';114 103 if ( !$error && filesize($file) > 0 ) { 115 104 $f = fopen($file, 'r'); … … 127 116 } 128 117 129 $content = esc_textarea( $content );118 $content = htmlspecialchars( $content ); 130 119 } 131 120 … … 136 125 137 126 $description = get_file_description($file); 138 $desc_header = ( $description != $file_show ) ? "$description <span>($file_show)</span>" : $file_show; 139 140 $is_child_theme = $themes[$theme]['Template'] != $themes[$theme]['Stylesheet']; 127 $desc_header = ( $description != $file_show ) ? "<strong>$description</strong> (%s)" : "%s"; 141 128 ?> 142 129 <div class="wrap"> … … 146 133 <div class="fileedit-sub"> 147 134 <div class="alignleft"> 148 < h3><?php echo $themes[$theme]['Name'] . ': ' . $desc_header; ?></h3>135 <big><?php echo sprintf($desc_header, $file_show); ?></big> 149 136 </div> 150 137 <div class="alignright"> … … 162 149 ?> 163 150 </select> 164 < ?php submit_button( __( 'Select' ), 'button', 'Submit', false ); ?>151 <input type="submit" name="Submit" value="<?php esc_attr_e('Select') ?>" class="button" /> 165 152 </form> 166 153 </div> … … 168 155 </div> 169 156 <div id="templateside"> 157 170 158 <?php 171 159 if ($allowed_files) : 172 160 ?> 173 161 <h3><?php _e('Templates'); ?></h3> 174 <?php if ( $is_child_theme ) : ?>175 <p class="howto"><?php printf( __( 'This child theme inherits templates from a parent theme, %s.' ), $themes[$theme]['Parent Theme'] ); ?></p>176 <?php endif; ?>177 162 <ul> 178 163 <?php … … 180 165 $template_dir = $themes[$theme]['Template Dir']; 181 166 foreach ( $themes[$theme]['Template Files'] as $template_file ) { 182 // Don't show parent templates.183 if ( $is_child_theme && strpos( $template_file, trailingslashit( $template_dir ) ) === 0 )184 continue;185 186 167 $description = trim( get_file_description($template_file) ); 187 168 $template_show = basename($template_file); 188 169 $filedesc = ( $description != $template_file ) ? "$description<br /><span class='nonessential'>($template_show)</span>" : "$description"; 189 170 $filedesc = ( $template_file == $file ) ? "<span class='highlight'>$description<br /><span class='nonessential'>($template_show)</span></span>" : $filedesc; 190 $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc ); 171 172 // If we have two files of the same name prefer the one in the Template Directory 173 // This means that we display the correct files for child themes which overload Templates as well as Styles 174 if ( array_key_exists($description, $template_mapping ) ) { 175 if ( false !== strpos( $template_file, $template_dir ) ) { 176 $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc ); 177 } 178 } else { 179 $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc ); 180 } 191 181 } 192 182 ksort( $template_mapping ); … … 202 192 $stylesheet_dir = $themes[$theme]['Stylesheet Dir']; 203 193 foreach ( $themes[$theme]['Stylesheet Files'] as $style_file ) { 204 // Don't show parent styles.205 if ( $is_child_theme && strpos( $style_file, trailingslashit( $template_dir ) ) === 0 )206 continue;207 208 194 $description = trim( get_file_description($style_file) ); 209 195 $style_show = basename($style_file); … … 238 224 239 225 <div> 240 <?php if ( is_child_theme() && ! $is_child_theme && $themes[$theme]['Template'] == get_option('template') ) : ?> 241 <p><?php if ( is_writeable( $file ) ) { ?><strong><?php _e( 'Caution:' ); ?></strong><?php } ?> 242 <?php _e( 'This is a file in your current parent theme.' ); ?></p> 243 <?php endif; ?> 244 <?php 245 if ( is_writeable( $file ) ) : 246 submit_button( __( 'Update File' ), 'primary', 'submit', true, array( 'tabindex' => '2' ) ); 247 else : ?> 226 <?php if ( is_writeable($file) ) : ?> 227 <p class="submit"> 228 <?php 229 echo "<input type='submit' name='submit' class='button-primary' value='" . esc_attr__('Update File') . "' tabindex='2' />"; 230 ?> 231 </p> 232 <?php else : ?> 248 233 <p><em><?php _e('You need to make this file writable before you can save your changes. See <a href="http://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.'); ?></em></p> 249 234 <?php endif; ?> … … 269 254 } 270 255 271 include( ABSPATH . "wp-admin/admin-footer.php");256 include("./admin-footer.php");
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)