Theme Editor: Ensure files listed recursively can be both viewed and edited.

Prevent edits to 2-level deep theme files from returning a `disallowed_theme_file` error when attempting to save an edit. Aligns logic for gathering `$allowed_files` in `theme-editor.php` for listing files with the validation logic in `wp_edit_theme_plugin_file()`.

Amends [41806].
See #6531.
Fixes #42425.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41941 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-11-02 23:05:48 +00:00
parent ef272167c4
commit 83c29a4d08
2 changed files with 4 additions and 4 deletions

View File

@ -432,15 +432,15 @@ function wp_edit_theme_plugin_file( $args ) {
foreach ( $editable_extensions as $type ) { foreach ( $editable_extensions as $type ) {
switch ( $type ) { switch ( $type ) {
case 'php': case 'php':
$allowed_files = array_merge( $allowed_files, $theme->get_files( 'php', 1 ) ); $allowed_files = array_merge( $allowed_files, $theme->get_files( 'php', -1 ) );
break; break;
case 'css': case 'css':
$style_files = $theme->get_files( 'css' ); $style_files = $theme->get_files( 'css', -1 );
$allowed_files['style.css'] = $style_files['style.css']; $allowed_files['style.css'] = $style_files['style.css'];
$allowed_files = array_merge( $allowed_files, $style_files ); $allowed_files = array_merge( $allowed_files, $style_files );
break; break;
default: default:
$allowed_files = array_merge( $allowed_files, $theme->get_files( $type ) ); $allowed_files = array_merge( $allowed_files, $theme->get_files( $type, -1 ) );
break; break;
} }
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9-RC1-42111'; $wp_version = '4.9-RC1-42112';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.