PluginProbe
Gutenberg / 24.0.0
Gutenberg v24.0.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / lib / experimental / experiments / load.php

load.php in Gutenberg 24.0.0, at lib/experimental/experiments/load.php

175 lines 6.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Bootstraps the Gutenberg experiments page in wp-admin.
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * Set up the experiments settings.
10 *
11 * Registering an experiment here only exposes it on the Experiments screen.
12 * To actually enable a new experiment in the editor, add a matching bridge
13 * (e.g. a `window.__experimental*` global) in `gutenberg_enable_experiments()`
14 * in `lib/experimental/editor-settings.php`.
15 */
16 function gutenberg_initialize_experiments_settings() {
17 $groups = array(
18 array(
19 'slug' => 'blocks',
20 'label' => _x( 'Blocks', 'experiments group name', 'gutenberg' ),
21 'items' => array(
22 array(
23 'id' => 'gutenberg-block-experiments',
24 'label' => __( 'Experimental blocks', 'gutenberg' ),
25 'description' => __( 'Enables experimental blocks on a rolling basis as they are developed. (Warning: these blocks may have significant changes during development that cause validation errors and display issues.)', 'gutenberg' ),
26 ),
27 array(
28 'id' => 'gutenberg-global-styles-inheritance-ui',
29 'label' => __( 'Global Styles inheritance in the block inspector', 'gutenberg' ),
30 'description' => __( 'Shows the value a block inherits from Global Styles in the block inspector when nothing is set on the block itself, and adds a control to clear a value you set back to the inherited one.', 'gutenberg' ),
31 ),
32 array(
33 'id' => 'gutenberg-grid-interactivity',
34 'label' => __( 'Grid interactivity', 'gutenberg' ),
35 'description' => __( 'Enables enhancements to the Grid block that let you move and resize items in the editor canvas.', 'gutenberg' ),
36 ),
37 ),
38 ),
39 array(
40 'slug' => 'media',
41 'label' => _x( 'Media', 'experiments group name', 'gutenberg' ),
42 'items' => array(
43 array(
44 'id' => 'gutenberg-media-editor',
45 'label' => __( 'Media Editor (Route)', 'gutenberg' ),
46 'description' => __( 'Replaces the core Edit Media screen with a dedicated route-based media editor for editing media items (metadata and content).', 'gutenberg' ),
47 ),
48 array(
49 'id' => 'gutenberg-dataviews-media-modal',
50 'label' => __( 'Media Upload Modal', 'gutenberg' ),
51 'description' => __( 'Replaces the existing WordPress media modal with a new modal powered by Data Views, supporting browsing, selecting, and uploading media.', 'gutenberg' ),
52 ),
53 ),
54 ),
55 array(
56 'slug' => 'data-views',
57 'label' => _x( 'Data Views', 'experiments group name', 'gutenberg' ),
58 'items' => array(
59 array(
60 'id' => 'gutenberg-dataform-inspector',
61 'label' => __( 'Editor Inspector: Use DataForm', 'gutenberg' ),
62 'description' => __( 'Replaces the bespoke editor inspector panels with a unified DataForm-based implementation for Pages and Posts, matching the QuickEdit experience.', 'gutenberg' ),
63 ),
64 ),
65 ),
66 array(
67 'slug' => 'interactivity',
68 'label' => _x( 'Interactivity', 'experiments group name', 'gutenberg' ),
69 'items' => array(
70 array(
71 'id' => 'gutenberg-full-page-client-side-navigation',
72 'label' => __( 'Full-page client-side navigation', 'gutenberg' ),
73 'description' => __( 'Enables full-page client-side navigation, powered by the Interactivity API.', 'gutenberg' ),
74 ),
75 ),
76 ),
77 array(
78 'slug' => 'real-time-collaboration',
79 'label' => _x( 'Real-Time Collaboration', 'experiments group name', 'gutenberg' ),
80 'items' => array(
81 array(
82 'id' => 'gutenberg-real-time-collaboration',
83 'label' => __( 'Enable real-time collaboration', 'gutenberg' ),
84 'description' => __( 'Allows multiple people to edit the same post at the same time.', 'gutenberg' ),
85 ),
86 ),
87 ),
88 array(
89 'slug' => 'other',
90 'label' => _x( 'Other', 'experiments group name', 'gutenberg' ),
91 'items' => array(
92 array(
93 'id' => 'gutenberg-workflow-palette',
94 'label' => __( 'Workflow Palette', 'gutenberg' ),
95 'description' => __( 'Enables the Workflow Palette for running workflows composed of abilities, from a unified interface.', 'gutenberg' ),
96 ),
97 array(
98 'id' => 'gutenberg-extensible-site-editor',
99 'label' => __( 'Extensible Site Editor', 'gutenberg' ),
100 'description' => __( 'Redirects the default site editor (Appearance > Design) to use the extensible site editor page.', 'gutenberg' ),
101 ),
102 array(
103 'id' => 'gutenberg-guidelines',
104 'label' => __( 'Guidelines', 'gutenberg' ),
105 'description' => __( 'Enables the Guidelines page under Settings and the experimental knowledge storage (wp_knowledge).', 'gutenberg' ),
106 ),
107 array(
108 'id' => 'gutenberg-dashboard-widgets',
109 'label' => __( 'New Dashboard experience', 'gutenberg' ),
110 'description' => __( 'Enables a new dashboard experience with resizable, reorderable widgets that plugins can register and users can personalize.', 'gutenberg' ),
111 ),
112 array(
113 'id' => 'gutenberg-react-19',
114 'label' => __( 'React 19', 'gutenberg' ),
115 'description' => __( 'Registers React 19 as the bundled React version, replacing the default React 18 scripts.', 'gutenberg' ),
116 ),
117 ),
118 ),
119 );
120
121 $properties = array();
122
123 foreach ( $groups as $group ) {
124 foreach ( $group['items'] as $experiment ) {
125 $property = array(
126 'type' => 'boolean',
127 'title' => $experiment['label'],
128 'description' => $experiment['description'],
129 'group' => $group['slug'],
130 'group_label' => $group['label'],
131 );
132
133 $properties[ $experiment['id'] ] = $property;
134 }
135 }
136
137 register_setting(
138 'gutenberg-experiments',
139 'gutenberg-experiments',
140 array(
141 'label' => __( 'Gutenberg Experiments', 'gutenberg' ),
142 'show_in_rest' => array(
143 'schema' => array(
144 'type' => 'object',
145 'properties' => $properties,
146 ),
147 ),
148 'default' => array(),
149 )
150 );
151 }
152
153 add_action( 'rest_api_init', 'gutenberg_initialize_experiments_settings' );
154
155 /**
156 * Allows the legacy `gutenberg-experiments` route. Without this, accessing
157 * `?page=gutenberg-experiments` results in an HTTP 403 error.
158 *
159 * Allowing the route is done by adding a wp-admin submenu page that won't be rendered.
160 */
161 function gutenberg_experiments_legacy_menu() {
162 add_submenu_page( '', '', '', 'manage_options', 'gutenberg-experiments', '__return_empty_string' );
163 }
164 add_action( 'admin_menu', 'gutenberg_experiments_legacy_menu', 9 );
165
166 /**
167 * Redirects the legacy `?page=gutenberg-experiments` URL to the new
168 * `?page=experiments-wp-admin` URL.
169 */
170 function gutenberg_redirect_legacy_experiments_page() {
171 wp_safe_redirect( admin_url( 'options-general.php?page=experiments-wp-admin' ) );
172 exit;
173 }
174 add_action( 'load-admin_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );
175