wp/wp-admin/menu.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
   200 }
   200 }
   201 
   201 
   202 	/* translators: %s: Number of available theme updates. */
   202 	/* translators: %s: Number of available theme updates. */
   203 	$submenu['themes.php'][5] = array( sprintf( __( 'Themes %s' ), $count ), $appearance_cap, 'themes.php' );
   203 	$submenu['themes.php'][5] = array( sprintf( __( 'Themes %s' ), $count ), $appearance_cap, 'themes.php' );
   204 
   204 
   205 	$customize_url            = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' );
   205 if ( wp_is_block_theme() ) {
   206 	$submenu['themes.php'][6] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' );
   206 	$submenu['themes.php'][6] = array(
       
   207 		sprintf(
       
   208 			/* translators: %s: "beta" label */
       
   209 			__( 'Editor %s' ),
       
   210 			'<span class="awaiting-mod">' . __( 'beta' ) . '</span>'
       
   211 		),
       
   212 		'edit_theme_options',
       
   213 		'site-editor.php',
       
   214 	);
       
   215 }
       
   216 
       
   217 $customize_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' );
       
   218 
       
   219 // Hide Customize link on block themes unless a plugin or theme
       
   220 // is using 'customize_register' to add a setting.
       
   221 if ( ! wp_is_block_theme() || has_action( 'customize_register' ) ) {
       
   222 	$position = wp_is_block_theme() ? 7 : 6;
       
   223 
       
   224 	$submenu['themes.php'][ $position ] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' );
       
   225 }
   207 
   226 
   208 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) {
   227 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) {
   209 	$submenu['themes.php'][10] = array( __( 'Menus' ), 'edit_theme_options', 'nav-menus.php' );
   228 	$submenu['themes.php'][10] = array( __( 'Menus' ), 'edit_theme_options', 'nav-menus.php' );
   210 }
   229 }
   211 
   230 
   217 if ( current_theme_supports( 'custom-background' ) && current_user_can( 'customize' ) ) {
   236 if ( current_theme_supports( 'custom-background' ) && current_user_can( 'customize' ) ) {
   218 	$customize_background_url  = add_query_arg( array( 'autofocus' => array( 'control' => 'background_image' ) ), $customize_url );
   237 	$customize_background_url  = add_query_arg( array( 'autofocus' => array( 'control' => 'background_image' ) ), $customize_url );
   219 	$submenu['themes.php'][20] = array( __( 'Background' ), $appearance_cap, esc_url( $customize_background_url ), '', 'hide-if-no-customize' );
   238 	$submenu['themes.php'][20] = array( __( 'Background' ), $appearance_cap, esc_url( $customize_background_url ), '', 'hide-if-no-customize' );
   220 }
   239 }
   221 
   240 
   222 	unset( $customize_url );
   241 unset( $customize_url );
   223 
   242 
   224 unset( $appearance_cap );
   243 unset( $appearance_cap );
   225 
   244 
   226 // Add 'Theme Editor' to the bottom of the Appearance menu.
   245 // Add 'Theme File Editor' to the bottom of the Appearance (non-block themes) or Tools (block themes) menu.
   227 if ( ! is_multisite() ) {
   246 if ( ! is_multisite() ) {
       
   247 	// Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook.
   228 	add_action( 'admin_menu', '_add_themes_utility_last', 101 );
   248 	add_action( 'admin_menu', '_add_themes_utility_last', 101 );
   229 }
   249 }
   230 /**
   250 /**
   231  * Adds the 'Theme Editor' link to the bottom of the Appearance menu.
   251  * Adds the 'Theme File Editor' menu item to the bottom of the Appearance (non-block themes)
       
   252  * or Tools (block themes) menu.
   232  *
   253  *
   233  * @access private
   254  * @access private
   234  * @since 3.0.0
   255  * @since 3.0.0
       
   256  * @since 5.9.0 Renamed 'Theme Editor' to 'Theme File Editor'.
       
   257  *              Relocates to Tools for block themes.
   235  */
   258  */
   236 function _add_themes_utility_last() {
   259 function _add_themes_utility_last() {
   237 	// Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook.
   260 	add_submenu_page(
   238 	add_submenu_page( 'themes.php', __( 'Theme Editor' ), __( 'Theme Editor' ), 'edit_themes', 'theme-editor.php' );
   261 		wp_is_block_theme() ? 'tools.php' : 'themes.php',
       
   262 		__( 'Theme File Editor' ),
       
   263 		__( 'Theme File Editor' ),
       
   264 		'edit_themes',
       
   265 		'theme-editor.php'
       
   266 	);
       
   267 }
       
   268 
       
   269 /**
       
   270  * Adds the 'Plugin File Editor' menu item after the 'Themes File Editor' in Tools
       
   271  * for block themes.
       
   272  *
       
   273  * @access private
       
   274  * @since 5.9.0
       
   275  */
       
   276 function _add_plugin_file_editor_to_tools() {
       
   277 	if ( ! wp_is_block_theme() ) {
       
   278 		return;
       
   279 	}
       
   280 	add_submenu_page(
       
   281 		'tools.php',
       
   282 		__( 'Plugin File Editor' ),
       
   283 		__( 'Plugin File Editor' ),
       
   284 		'edit_plugins',
       
   285 		'plugin-editor.php'
       
   286 	);
   239 }
   287 }
   240 
   288 
   241 $count = '';
   289 $count = '';
   242 if ( ! is_multisite() && current_user_can( 'update_plugins' ) ) {
   290 if ( ! is_multisite() && current_user_can( 'update_plugins' ) ) {
   243 	if ( ! isset( $update_data ) ) {
   291 	if ( ! isset( $update_data ) ) {
   256 $submenu['plugins.php'][5] = array( __( 'Installed Plugins' ), 'activate_plugins', 'plugins.php' );
   304 $submenu['plugins.php'][5] = array( __( 'Installed Plugins' ), 'activate_plugins', 'plugins.php' );
   257 
   305 
   258 if ( ! is_multisite() ) {
   306 if ( ! is_multisite() ) {
   259 	/* translators: Add new plugin. */
   307 	/* translators: Add new plugin. */
   260 	$submenu['plugins.php'][10] = array( _x( 'Add New', 'plugin' ), 'install_plugins', 'plugin-install.php' );
   308 	$submenu['plugins.php'][10] = array( _x( 'Add New', 'plugin' ), 'install_plugins', 'plugin-install.php' );
   261 	$submenu['plugins.php'][15] = array( __( 'Plugin Editor' ), 'edit_plugins', 'plugin-editor.php' );
   309 	if ( wp_is_block_theme() ) {
       
   310 		// Place the menu item below the Theme File Editor menu item.
       
   311 		add_action( 'admin_menu', '_add_plugin_file_editor_to_tools', 101 );
       
   312 	} else {
       
   313 		$submenu['plugins.php'][15] = array( __( 'Plugin File Editor' ), 'edit_plugins', 'plugin-editor.php' );
       
   314 	}
   262 }
   315 }
   263 
   316 
   264 unset( $update_data );
   317 unset( $update_data );
   265 
   318 
   266 if ( current_user_can( 'list_users' ) ) {
   319 if ( current_user_can( 'list_users' ) ) {