Changes in trunk/wp-admin/theme-editor.php [15135:17471]
- File:
-
- 1 edited
-
trunk/wp-admin/theme-editor.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/theme-editor.php
r15135 r17471 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 12 17 if ( !current_user_can('edit_themes') ) 13 18 wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>'); … … 22 27 $help .= '<p>' . __('<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.') . '</p>'; 23 28 $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>'; 24 31 $help .= '<p><strong>' . __('For more information:') . '</strong></p>'; 25 32 $help .= '<p>' . __('<a href="http://codex.wordpress.org/Theme_Development" target="_blank">Documentation on Theme Development</a>') . '</p>'; … … 45 52 wp_die(__('The requested theme does not exist.')); 46 53 47 $allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']); 48 49 if (empty($file)) { 50 $file = $allowed_files[0]; 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]; 51 61 } else { 52 62 $file = stripslashes($file); … … 94 104 default: 95 105 96 require_once( './admin-header.php');106 require_once(ABSPATH . 'wp-admin/admin-header.php'); 97 107 98 108 update_recently_edited($file); … … 101 111 $error = 1; 102 112 113 $content = ''; 103 114 if ( !$error && filesize($file) > 0 ) { 104 115 $f = fopen($file, 'r'); … … 116 127 } 117 128 118 $content = htmlspecialchars( $content );129 $content = esc_textarea( $content ); 119 130 } 120 131 … … 125 136 126 137 $description = get_file_description($file); 127 $desc_header = ( $description != $file_show ) ? "<strong>$description</strong> (%s)" : "%s"; 138 $desc_header = ( $description != $file_show ) ? "$description <span>($file_show)</span>" : $file_show; 139 140 $is_child_theme = $themes[$theme]['Template'] != $themes[$theme]['Stylesheet']; 128 141 ?> 129 142 <div class="wrap"> … … 133 146 <div class="fileedit-sub"> 134 147 <div class="alignleft"> 135 < big><?php echo sprintf($desc_header, $file_show); ?></big>148 <h3><?php echo $themes[$theme]['Name'] . ': ' . $desc_header; ?></h3> 136 149 </div> 137 150 <div class="alignright"> … … 149 162 ?> 150 163 </select> 151 < input type="submit" name="Submit" value="<?php esc_attr_e('Select') ?>" class="button" />164 <?php submit_button( __( 'Select' ), 'button', 'Submit', false ); ?> 152 165 </form> 153 166 </div> … … 155 168 </div> 156 169 <div id="templateside"> 157 158 170 <?php 159 171 if ($allowed_files) : 160 172 ?> 161 173 <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; ?> 162 177 <ul> 163 178 <?php … … 165 180 $template_dir = $themes[$theme]['Template Dir']; 166 181 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 167 186 $description = trim( get_file_description($template_file) ); 168 187 $template_show = basename($template_file); 169 188 $filedesc = ( $description != $template_file ) ? "$description<br /><span class='nonessential'>($template_show)</span>" : "$description"; 170 189 $filedesc = ( $template_file == $file ) ? "<span class='highlight'>$description<br /><span class='nonessential'>($template_show)</span></span>" : $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 } 190 $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc ); 181 191 } 182 192 ksort( $template_mapping ); … … 192 202 $stylesheet_dir = $themes[$theme]['Stylesheet Dir']; 193 203 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 194 208 $description = trim( get_file_description($style_file) ); 195 209 $style_show = basename($style_file); … … 224 238 225 239 <div> 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 : ?> 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 : ?> 233 248 <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> 234 249 <?php endif; ?> … … 254 269 } 255 270 256 include( "./admin-footer.php");271 include(ABSPATH . "wp-admin/admin-footer.php");
Note: See TracChangeset
for help on using the changeset viewer.