Skip to content

Commit 238c573

Browse files
Command Palette: Enqueue assets globally (#71264)
* Command Palette: Enqueue assets globally * Move function to compat directory * Add backport changelog * initializeCommandPalette: Remove IS_GUTENBERG_PLUGIN check Co-authored-by: t-hamano <[email protected]> Co-authored-by: youknowriad <[email protected]>
1 parent 390880a commit 238c573

File tree

11 files changed

+24
-69
lines changed

11 files changed

+24
-69
lines changed

backport-changelog/6.9/9542.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
https://github.com/WordPress/wordpress-develop/pull/9542
2+
3+
* https://github.com/WordPress/gutenberg/pull/71264
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Enqueues the assets required for the Command Palette.
4+
*/
5+
function gutenberg_enqueue_command_palette_assets() {
6+
if ( ! is_admin() ) {
7+
return;
8+
}
9+
10+
wp_enqueue_script( 'wp-commands' );
11+
wp_enqueue_style( 'wp-commands' );
12+
wp_enqueue_script( 'wp-core-commands' );
13+
wp_add_inline_script( 'wp-core-commands', 'wp.coreCommands.initializeCommandPalette();' );
14+
}
15+
16+
if ( has_filter( 'admin_enqueue_scripts', 'wp_enqueue_command_palette_assets' ) ) {
17+
remove_filter( 'admin_enqueue_scripts', 'wp_enqueue_command_palette_assets', 9 );
18+
}
19+
add_filter( 'admin_enqueue_scripts', 'gutenberg_enqueue_command_palette_assets', 9 );

lib/experimental/commands.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

lib/experiments-page.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,6 @@ function gutenberg_initialize_experiments_settings() {
9191
)
9292
);
9393

94-
add_settings_field(
95-
'gutenberg-command-palette-everywhere',
96-
__( 'Command Palette: enable everywhere', 'gutenberg' ),
97-
'gutenberg_display_experiment_field',
98-
'gutenberg-experiments',
99-
'gutenberg_experiments_section',
100-
array(
101-
'label' => __( 'Enables the Command Palette everywhere in the admin dashboard.', 'gutenberg' ),
102-
'id' => 'gutenberg-command-palette-everywhere',
103-
)
104-
);
105-
10694
add_settings_field(
10795
'gutenberg-media-processing',
10896
__( 'Client-side media processing', 'gutenberg' ),

lib/load.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ function gutenberg_is_experiment_enabled( $name ) {
8181

8282
// WordPress 6.9 compat.
8383
require __DIR__ . '/compat/wordpress-6.9/customizer-preview-custom-css.php';
84+
require __DIR__ . '/compat/wordpress-6.9/command-palette.php';
8485

8586
// Experimental features.
8687
require __DIR__ . '/experimental/block-editor-settings-mobile.php';
@@ -91,7 +92,6 @@ function gutenberg_is_experiment_enabled( $name ) {
9192
require __DIR__ . '/experimental/synchronization.php';
9293
require __DIR__ . '/experimental/script-modules.php';
9394
require __DIR__ . '/experimental/posts/load.php';
94-
require __DIR__ . '/experimental/commands.php';
9595

9696
if ( gutenberg_is_experiment_enabled( 'gutenberg-no-tinymce' ) ) {
9797
require __DIR__ . '/experimental/disable-tinymce.php';

package-lock.json

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core-commands/src/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ function CommandPalette() {
3030
* Initializes the Command Palette.
3131
*/
3232
export function initializeCommandPalette() {
33-
if ( ! globalThis.IS_GUTENBERG_PLUGIN ) {
34-
return;
35-
}
3633
const root = document.createElement( 'div' );
3734
document.body.appendChild( root );
3835
createRoot( root ).render(

packages/edit-post/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"@wordpress/commands": "file:../commands",
3838
"@wordpress/components": "file:../components",
3939
"@wordpress/compose": "file:../compose",
40-
"@wordpress/core-commands": "file:../core-commands",
4140
"@wordpress/core-data": "file:../core-data",
4241
"@wordpress/data": "file:../data",
4342
"@wordpress/deprecated": "file:../deprecated",

packages/edit-post/src/components/layout/index.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ import {
3434
import { chevronDown, chevronUp } from '@wordpress/icons';
3535
import { store as noticesStore } from '@wordpress/notices';
3636
import { store as preferencesStore } from '@wordpress/preferences';
37-
import {
38-
CommandMenu,
39-
privateApis as commandsPrivateApis,
40-
} from '@wordpress/commands';
41-
import { privateApis as coreCommandsPrivateApis } from '@wordpress/core-commands';
37+
import { privateApis as commandsPrivateApis } from '@wordpress/commands';
4238
import { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';
4339
import { addQueryArgs } from '@wordpress/url';
4440
import { decodeEntities } from '@wordpress/html-entities';
@@ -77,7 +73,6 @@ import useNavigateToEntityRecord from '../../hooks/use-navigate-to-entity-record
7773
import { useMetaBoxInitialization } from '../meta-boxes/use-meta-box-initialization';
7874

7975
const { getLayoutStyles } = unlock( blockEditorPrivateApis );
80-
const { useCommands } = unlock( coreCommandsPrivateApis );
8176
const { useCommandContext } = unlock( commandsPrivateApis );
8277
const { Editor, FullscreenMode, NavigableRegion } = unlock( editorPrivateApis );
8378
const { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );
@@ -373,7 +368,6 @@ function Layout( {
373368
settings,
374369
initialEdits,
375370
} ) {
376-
useCommands();
377371
useEditPostCommands();
378372
const shouldIframe = useShouldIframe();
379373
const { createErrorNotice } = useDispatch( noticesStore );
@@ -583,7 +577,6 @@ function Layout( {
583577
return (
584578
<SlotFillProvider>
585579
<ErrorBoundary canCopyContent>
586-
<CommandMenu />
587580
<WelcomeGuide postType={ currentPostType } />
588581
<div
589582
className={ navigateRegionsProps.className }

packages/edit-site/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"@wordpress/commands": "file:../commands",
4040
"@wordpress/components": "file:../components",
4141
"@wordpress/compose": "file:../compose",
42-
"@wordpress/core-commands": "file:../core-commands",
4342
"@wordpress/core-data": "file:../core-data",
4443
"@wordpress/data": "file:../data",
4544
"@wordpress/dataviews": "file:../dataviews",

0 commit comments

Comments
 (0)