Changeset 61022
- Timestamp:
- 10/21/2025 12:32:08 PM (7 weeks ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
-
default-filters.php (modified) (1 diff)
-
script-loader.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/default-filters.php
r61008 r61022 593 593 add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 ); 594 594 add_action( 'admin_enqueue_scripts', 'wp_common_block_scripts_and_styles' ); 595 add_action( 'admin_enqueue_scripts', 'wp_enqueue_command_palette_assets' ); 595 596 add_action( 'enqueue_block_assets', 'wp_enqueue_classic_theme_styles' ); 596 597 add_action( 'enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles' ); -
trunk/src/wp-includes/script-loader.php
r61013 r61022 1745 1745 'block-directory' => array(), 1746 1746 'components' => array(), 1747 'commands' => array( ),1747 'commands' => array( 'wp-components' ), 1748 1748 'edit-post' => array( 1749 1749 'wp-components', … … 3421 3421 3422 3422 /** 3423 * Enqueues the assets required for the Command Palette. 3424 * 3425 * @since 6.9.0 3426 * 3427 * @global array $menu 3428 * @global array $submenu 3429 */ 3430 function wp_enqueue_command_palette_assets() { 3431 global $menu, $submenu; 3432 3433 $command_palette_settings = array(); 3434 3435 if ( $menu ) { 3436 $menu_commands = array(); 3437 foreach ( $menu as $menu_item ) { 3438 if ( empty( $menu_item[0] ) || ! empty( $menu_item[1] ) && ! current_user_can( $menu_item[1] ) ) { 3439 continue; 3440 } 3441 3442 // Remove all HTML tags and their contents. 3443 $menu_label = $menu_item[0]; 3444 while ( preg_match( '/<[^>]*>/', $menu_label ) ) { 3445 $menu_label = preg_replace( '/<[^>]*>.*?<\/[^>]*>|<[^>]*\/>|<[^>]*>/s', '', $menu_label ); 3446 } 3447 $menu_label = trim( $menu_label ); 3448 $menu_url = ''; 3449 $menu_slug = $menu_item[2]; 3450 3451 if ( preg_match( '/\.php($|\?)/', $menu_slug ) || wp_http_validate_url( $menu_slug ) ) { 3452 $menu_url = $menu_slug; 3453 } elseif ( ! empty( menu_page_url( $menu_slug, false ) ) ) { 3454 $menu_url = menu_page_url( $menu_slug, false ); 3455 } 3456 3457 if ( $menu_url ) { 3458 $menu_commands[] = array( 3459 'label' => $menu_label, 3460 'url' => $menu_url, 3461 'name' => $menu_slug, 3462 ); 3463 } 3464 3465 if ( array_key_exists( $menu_slug, $submenu ) ) { 3466 foreach ( $submenu[ $menu_slug ] as $submenu_item ) { 3467 if ( empty( $submenu_item[0] ) || ! empty( $submenu_item[1] ) && ! current_user_can( $submenu_item[1] ) ) { 3468 continue; 3469 } 3470 3471 // Remove all HTML tags and their contents. 3472 $submenu_label = $submenu_item[0]; 3473 while ( preg_match( '/<[^>]*>/', $submenu_label ) ) { 3474 $submenu_label = preg_replace( '/<[^>]*>.*?<\/[^>]*>|<[^>]*\/>|<[^>]*>/s', '', $submenu_label ); 3475 } 3476 $submenu_label = trim( $submenu_label ); 3477 $submenu_url = ''; 3478 $submenu_slug = $submenu_item[2]; 3479 3480 if ( preg_match( '/\.php($|\?)/', $submenu_slug ) || wp_http_validate_url( $submenu_slug ) ) { 3481 $submenu_url = $submenu_slug; 3482 } elseif ( ! empty( menu_page_url( $submenu_slug, false ) ) ) { 3483 $submenu_url = menu_page_url( $submenu_slug, false ); 3484 } 3485 3486 if ( $submenu_url ) { 3487 $menu_commands[] = array( 3488 'label' => sprintf( 3489 /* translators: 1: Menu label, 2: Submenu label. */ 3490 __( '%1$s > %2$s' ), 3491 $menu_label, 3492 $submenu_label 3493 ), 3494 'url' => $submenu_url, 3495 'name' => $menu_slug . '-' . $submenu_item[2], 3496 ); 3497 } 3498 } 3499 } 3500 } 3501 $command_palette_settings['menu_commands'] = $menu_commands; 3502 } 3503 3504 wp_enqueue_script( 'wp-commands' ); 3505 wp_enqueue_style( 'wp-commands' ); 3506 wp_enqueue_script( 'wp-core-commands' ); 3507 3508 wp_add_inline_script( 3509 'wp-core-commands', 3510 sprintf( 3511 'wp.coreCommands.initializeCommandPalette( %s );', 3512 wp_json_encode( $command_palette_settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 3513 ) 3514 ); 3515 } 3516 3517 /** 3423 3518 * Removes leading and trailing _empty_ script tags. 3424 3519 *
Note: See TracChangeset
for help on using the changeset viewer.