mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@35134 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b9e34ce4a2
commit
eb85b2c11b
@ -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';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user