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.

Built from https://develop.svn.wordpress.org/trunk@35134


git-svn-id: http://core.svn.wordpress.org/trunk@35099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-10-13 14:14:24 +00:00
parent 357b916211
commit 7c88e86bf6
2 changed files with 17 additions and 6 deletions

View File

@ -45,24 +45,35 @@ get_current_screen()->set_help_sidebar(
wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) );
if ( $theme )
if ( $theme ) {
$stylesheet = $theme;
else
} else {
$stylesheet = get_stylesheet();
}
$theme = wp_get_theme( $stylesheet );
if ( ! $theme->exists() )
if ( ! $theme->exists() ) {
wp_die( __( 'The requested theme does not exist.' ) );
}
if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() )
if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() ) {
wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() );
}
$allowed_files = $theme->get_files( 'php', 1 );
$has_templates = ! empty( $allowed_files );
$style_files = $theme->get_files( 'css' );
$allowed_files['style.css'] = $style_files['style.css'];
$allowed_files += $style_files;
/**
* Filter the allowed files.
*
* @since 4.4.0
*
* @param array $style_files List of style files.
* @param object $theme The current Theme object.
*/
$allowed_files += apply_filters( 'wp_theme_editor_filetypes', $style_files, $theme );
if ( empty( $file ) ) {
$relative_file = 'style.css';

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-35133';
$wp_version = '4.4-alpha-35134';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.