Everyone knows that when editing a theme in the wordpress background, we can only edit files with css and php suffixes. People like me who love JavaScript always need to change js in the running space, this is really troublesome, so I thought of adding a recognized file type for the topic editing. Next I will introduce how to make js files appear in the wordpress topic editing list. in wp-admintheme
Everyone knows that when editing a theme in the wordpress background, we can only edit files with css and php suffixes. People like me who love JavaScript always need to change js in the running space, this is really troublesome, so I thought of adding a recognized file type for the topic editing. Next I will introduce how to make js files appear in the wordpress topic editing list. in wp-admin/theme
Everyone knows that when editing a theme in the wordpress background, we can only edit files with css and php suffixes. People like me who love JavaScript always need to change js in the running space, this is really troublesome, so I thought of adding a recognized file type for the topic editing. Next I will introduce how to make js files appear in the wordpress topic editing list.
In wp-admin/theme-editor.php, find the following code:
$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;
In a simple explanation, the Code aims to limit the file types allowed in theme-editor (subject editing). This makes it easy to handle,
Take adding js as an example and change the above Code to the following:
$allowed_files = $theme->get_files( 'php', 1 );$has_templates = ! empty( $allowed_files );$js_files = $theme->get_files( 'js' );$style_files = $theme->get_files( 'css' );$allowed_files['style.css'] = $style_files['style.css'];$allowed_files += $style_files;$allowed_files += $js_files;
On:
Note that only files in the root directory are displayed.
Original article address: added the file type that is visible when the wordpress background is edited. Thank you for sharing it with the original author.