Make WordPress Core


Ignore:
Timestamp:
12/21/2021 08:04:54 PM (2 years ago)
Author:
hellofromTonya
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/menu.php

    r52330 r52406  
    242242unset( $appearance_cap );
    243243
    244 // Add 'Theme Editor' to the bottom of the Appearance menu.
     244// Add 'Theme File Editor' to the bottom of the Appearance (non-block themes) or Tools (block themes) menu.
    245245if ( ! is_multisite() ) {
    246246    // Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook.
     
    248248}
    249249/**
    250  * Adds the 'Theme Editor' link to the bottom of the Appearance or Tools menu.
     250 * Adds the 'Theme File Editor' menu item to the bottom of the Appearance (non-block themes)
     251 * or Tools (block themes) menu.
    251252 *
    252253 * @access private
    253254 * @since 3.0.0
    254  * @since 5.9.0 'Theme Editor' link has moved to the Tools menu when a block theme is active.
     255 * @since 5.9.0 Renamed 'Theme Editor' to 'Theme File Editor'.
     256 *              Relocates to Tools for block themes.
    255257 */
    256258function _add_themes_utility_last() {
    257259    add_submenu_page(
    258260        wp_is_block_theme() ? 'tools.php' : 'themes.php',
    259         __( 'Theme Editor' ),
    260         __( 'Theme Editor' ),
     261        __( 'Theme File Editor' ),
     262        __( 'Theme File Editor' ),
    261263        'edit_themes',
    262264        'theme-editor.php'
     265    );
     266}
     267
     268/**
     269 * Adds the 'Plugin File Editor' menu item after the 'Themes File Editor' in Tools
     270 * for block themes.
     271 *
     272 * @access private
     273 * @since 5.9.0
     274 */
     275function _add_plugin_file_editor_to_tools() {
     276    if ( ! wp_is_block_theme() ) {
     277        return;
     278    }
     279    add_submenu_page(
     280        'tools.php',
     281        __( 'Plugin File Editor' ),
     282        __( 'Plugin File Editor' ),
     283        'edit_plugins',
     284        'plugin-editor.php'
    263285    );
    264286}
     
    284306    /* translators: Add new plugin. */
    285307    $submenu['plugins.php'][10] = array( _x( 'Add New', 'plugin' ), 'install_plugins', 'plugin-install.php' );
    286     $submenu['plugins.php'][15] = array( __( 'Plugin Editor' ), 'edit_plugins', 'plugin-editor.php' );
     308    if ( wp_is_block_theme() ) {
     309        // Place the menu item below the Theme File Editor menu item.
     310        add_action( 'admin_menu', '_add_plugin_file_editor_to_tools', 101 );
     311    } else {
     312        $submenu['plugins.php'][15] = array( __( 'Plugin File Editor' ), 'edit_plugins', 'plugin-editor.php' );
     313    }
    287314}
    288315
Note: See TracChangeset for help on using the changeset viewer.