Administration: Add "File" to Theme/Plugin Editor menu names and relocate "Plugin File Editor" to Tools for block themes.

[52232] relocated the Theme Editor menu item from Appearance to Tools for block themes. This commit relocates the Plugin  Editor menu item from Plugins to Tools for block themes for a consistent workflow.

Both the Theme Editor and Plugin Editor menu items are renamed to "Theme File Editor" and "Plugin File Editor" respectively. Why? To better identify their purpose, i.e. to directly edit the code in the theme or plugin files. The rename is not limited to only block themes. 

Follow-up to [52232].

Props poena, annezazu, audrasjb, clorith, courane01, costdev, dryanpress, desrosj, hellofromTonya, ipstenu, jameskoster, joen, johnbillion, joyously, manfcarlo, marybaum, pbiron, SergeyBiryukov, walbo, youknowriad.
Fixes #54382.

git-svn-id: https://develop.svn.wordpress.org/trunk@52406 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork
2021-12-21 20:04:54 +00:00
parent 839a0bcf06
commit 6cba70d5e4
13 changed files with 59 additions and 32 deletions

View File

@@ -241,28 +241,50 @@ if ( current_theme_supports( 'custom-background' ) && current_user_can( 'customi
unset( $appearance_cap );
// Add 'Theme Editor' to the bottom of the Appearance menu.
// Add 'Theme File Editor' to the bottom of the Appearance (non-block themes) or Tools (block themes) menu.
if ( ! is_multisite() ) {
// Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook.
add_action( 'admin_menu', '_add_themes_utility_last', 101 );
}
/**
* Adds the 'Theme Editor' link to the bottom of the Appearance or Tools menu.
* Adds the 'Theme File Editor' menu item to the bottom of the Appearance (non-block themes)
* or Tools (block themes) menu.
*
* @access private
* @since 3.0.0
* @since 5.9.0 'Theme Editor' link has moved to the Tools menu when a block theme is active.
* @since 5.9.0 Renamed 'Theme Editor' to 'Theme File Editor'.
* Relocates to Tools for block themes.
*/
function _add_themes_utility_last() {
add_submenu_page(
wp_is_block_theme() ? 'tools.php' : 'themes.php',
__( 'Theme Editor' ),
__( 'Theme Editor' ),
__( 'Theme File Editor' ),
__( 'Theme File Editor' ),
'edit_themes',
'theme-editor.php'
);
}
/**
* Adds the 'Plugin File Editor' menu item after the 'Themes File Editor' in Tools
* for block themes.
*
* @access private
* @since 5.9.0
*/
function _add_plugin_file_editor_to_tools() {
if ( ! wp_is_block_theme() ) {
return;
}
add_submenu_page(
'tools.php',
__( 'Plugin File Editor' ),
__( 'Plugin File Editor' ),
'edit_plugins',
'plugin-editor.php'
);
}
$count = '';
if ( ! is_multisite() && current_user_can( 'update_plugins' ) ) {
if ( ! isset( $update_data ) ) {
@@ -283,7 +305,12 @@ $submenu['plugins.php'][5] = array( __( 'Installed Plugins' ), 'activate_plugins
if ( ! is_multisite() ) {
/* translators: Add new plugin. */
$submenu['plugins.php'][10] = array( _x( 'Add New', 'plugin' ), 'install_plugins', 'plugin-install.php' );
$submenu['plugins.php'][15] = array( __( 'Plugin Editor' ), 'edit_plugins', 'plugin-editor.php' );
if ( wp_is_block_theme() ) {
// Place the menu item below the Theme File Editor menu item.
add_action( 'admin_menu', '_add_plugin_file_editor_to_tools', 101 );
} else {
$submenu['plugins.php'][15] = array( __( 'Plugin File Editor' ), 'edit_plugins', 'plugin-editor.php' );
}
}
unset( $update_data );