From 7c88e86bf6a43b0f0d3f045cb687b50f07fc6bdd Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 13 Oct 2015 14:14:24 +0000 Subject: [PATCH] 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 --- wp-admin/theme-editor.php | 21 ++++++++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php index 352deee2ca..ac77d57c8d 100644 --- a/wp-admin/theme-editor.php +++ b/wp-admin/theme-editor.php @@ -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'; diff --git a/wp-includes/version.php b/wp-includes/version.php index 36940a211b..07b4397573 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.