Make WordPress Core

Changeset 35134


Ignore:
Timestamp:
10/13/2015 02:13:12 PM (9 years ago)
Author:
wonderboymusic
Message:

Theme Editor: add a filter, wp_theme_editor_filetypes, to allow more filetypes to be edited via the Theme Editor. Usage of the Theme Editor is strenuously discouraged, but we should allow you to add whatever filetypes (.less, .scss) you would like.

Props MikeHansenMe, pross.
Fixes #22924.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/theme-editor.php

    r34783 r35134  
    4646wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) );
    4747
    48 if ( $theme )
     48if ( $theme ) {
    4949    $stylesheet = $theme;
    50 else
     50} else {
    5151    $stylesheet = get_stylesheet();
     52}
    5253
    5354$theme = wp_get_theme( $stylesheet );
    5455
    55 if ( ! $theme->exists() )
     56if ( ! $theme->exists() ) {
    5657    wp_die( __( 'The requested theme does not exist.' ) );
    57 
    58 if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() )
     58}
     59
     60if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() ) {
    5961    wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() );
     62}
    6063
    6164$allowed_files = $theme->get_files( 'php', 1 );
     
    6366$style_files = $theme->get_files( 'css' );
    6467$allowed_files['style.css'] = $style_files['style.css'];
    65 $allowed_files += $style_files;
     68/**
     69 * Filter the allowed files.
     70 *
     71 * @since 4.4.0
     72 *
     73 * @param array  $style_files List of style files.
     74 * @param object $theme       The current Theme object.
     75 */
     76$allowed_files += apply_filters( 'wp_theme_editor_filetypes', $style_files, $theme );
    6677
    6778if ( empty( $file ) ) {
Note: See TracChangeset for help on using the changeset viewer.