Make WordPress Core

Ticket #22924: 22924.2.diff

File 22924.2.diff, 1.7 KB (added by SergeyBiryukov, 9 years ago)
  • src/wp-admin/theme-editor.php

     
    6161        wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() );
    6262}
    6363
    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
    6867/**
    69  * Filter the allowed files.
     68 * Filter the list of file types allowed for editing in the Theme editor.
    7069 *
    7170 * @since 4.4.0
    7271 *
    73  * @param array  $style_files List of style files.
     72 * @param array  $style_files List of file types. Default types include 'php' and 'css'.
    7473 * @param object $theme       The current Theme object.
    7574 */
    76 $allowed_files += apply_filters( 'wp_theme_editor_filetypes', $style_files, $theme );
     75$file_types = apply_filters( 'wp_theme_editor_filetypes', array( 'php', 'css' ), $theme );
    7776
     77$file_types = array_merge( $file_types, array( 'php', 'css' ) );
     78
     79foreach ( $file_types as $type ) {
     80        switch ( $type ) {
     81                case 'php':
     82                        $allowed_files += $theme->get_files( 'php', 1 );
     83                        $has_templates = ! empty( $allowed_files );
     84                        break;
     85                case 'css':
     86                        $style_files = $theme->get_files( 'css' );
     87                        $allowed_files['style.css'] = $style_files['style.css'];
     88                        $allowed_files += $style_files;
     89                        break;
     90                default:
     91                        $allowed_files += $theme->get_files( $type );
     92                        break;
     93        }
     94}
     95
    7896if ( empty( $file ) ) {
    7997        $relative_file = 'style.css';
    8098        $file = $allowed_files['style.css'];