Changeset 35180
- Timestamp:
- 10/15/2015 02:19:45 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/theme-editor.php
r35134 r35180 62 62 } 63 63 64 $allowed_files = $ theme->get_files( 'php', 1);65 $has_templates = ! empty( $allowed_files );66 $ style_files = $theme->get_files('css' );67 $allowed_files['style.css'] = $style_files['style.css']; 64 $allowed_files = $style_files = array(); 65 $has_templates = false; 66 $default_types = array( 'php', 'css' ); 67 68 68 /** 69 * Filter the allowed files.69 * Filter the list of file types allowed for editing in the Theme editor. 70 70 * 71 71 * @since 4.4.0 72 72 * 73 * @param array $style_files List of style files.74 * @param object $themeThe current Theme object.73 * @param array $default_types List of file types. Default types include 'php' and 'css'. 74 * @param WP_Theme $theme The current Theme object. 75 75 */ 76 $allowed_files += apply_filters( 'wp_theme_editor_filetypes', $style_files, $theme ); 76 $file_types = apply_filters( 'wp_theme_editor_filetypes', $default_types, $theme ); 77 78 // Ensure that default types are still there. 79 $file_types = array_unique( array_merge( $file_types, $default_types ) ); 80 81 foreach ( $file_types as $type ) { 82 switch ( $type ) { 83 case 'php': 84 $allowed_files += $theme->get_files( 'php', 1 ); 85 $has_templates = ! empty( $allowed_files ); 86 break; 87 case 'css': 88 $style_files = $theme->get_files( 'css' ); 89 $allowed_files['style.css'] = $style_files['style.css']; 90 $allowed_files += $style_files; 91 break; 92 default: 93 $allowed_files += $theme->get_files( $type ); 94 break; 95 } 96 } 77 97 78 98 if ( empty( $file ) ) { … … 175 195 <?php 176 196 if ( $allowed_files ) : 177 if ( $has_templates || $theme->parent() ) : 178 ?> 179 <h2><?php _e( 'Templates' ); ?></h2> 180 <?php if ( $theme->parent() ) : ?> 181 <p class="howto"><?php printf( __( 'This child theme inherits templates from a parent theme, %s.' ), '<a href="' . self_admin_url('theme-editor.php?theme=' . urlencode( $theme->get_template() ) ) . '">' . $theme->parent()->display('Name') . '</a>' ); ?></p> 182 <?php endif; ?> 183 <ul> 184 <?php 185 endif; 197 $previous_file_type = ''; 186 198 187 199 foreach ( $allowed_files as $filename => $absolute_filename ) : 188 if ( 'style.css' == $filename ) 189 echo "\t</ul>\n\t<h2>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h2>\n\t<ul>\n"; 190 200 $file_type = substr( $filename, strrpos( $filename, '.' ) ); 201 202 if ( $file_type !== $previous_file_type ) { 203 if ( '' !== $previous_file_type ) { 204 echo "\t</ul>\n"; 205 } 206 207 switch ( $file_type ) { 208 case '.php': 209 if ( $has_templates || $theme->parent() ) : 210 echo "\t<h2>" . __( 'Templates' ) . "</h2>\n"; 211 if ( $theme->parent() ) { 212 echo '<p class="howto">' . sprintf( __( 'This child theme inherits templates from a parent theme, %s.' ), 213 sprintf( '<a href="%s">%s</a>', 214 self_admin_url( 'theme-editor.php?theme=' . urlencode( $theme->get_template() ) ), 215 $theme->parent()->display( 'Name' ) 216 ) 217 ) . "</p>\n"; 218 } 219 endif; 220 break; 221 case '.css': 222 echo "\t<h2>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h2>\n"; 223 break; 224 default: 225 /* translators: %s: file extension */ 226 echo "\t<h2>" . sprintf( __( '%s files' ), $file_type ) . "</h2>\n"; 227 break; 228 } 229 230 echo "\t<ul>\n"; 231 } 232 191 233 $file_description = get_file_description( $filename ); 192 234 if ( $filename !== basename( $absolute_filename ) || $file_description !== $filename ) { … … 197 239 $file_description = '<span class="highlight">' . $file_description . '</span>'; 198 240 } 241 242 $previous_file_type = $file_type; 199 243 ?> 200 244 <li><a href="theme-editor.php?file=<?php echo urlencode( $filename ) ?>&theme=<?php echo urlencode( $stylesheet ) ?>"><?php echo $file_description; ?></a></li>
Note: See TracChangeset
for help on using the changeset viewer.