PluginProbe
Gutenberg / 23.4.0
Gutenberg v23.4.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 7.4.0 All 402 releases
gutenberg / lib / experimental / experiments / load.php

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

226 lines 9.1 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-form-blocks',
29 'label' => __( 'Form and input blocks', 'gutenberg' ),
30 'description' => __( 'Enables new blocks to allow building forms. You are likely to experience UX issues that are being addressed.', '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 array(
38 'id' => 'gutenberg-classic-block-deprecation',
39 'label' => __( 'Classic block deprecation', 'gutenberg' ),
40 'description' => __( 'Enables UI changes aimed at deprecating the Classic block, including prompts on existing Classic blocks to migrate their content to blocks or to a Custom HTML block.', 'gutenberg' ),
41 ),
42 ),
43 ),
44 array(
45 'slug' => 'media',
46 'label' => _x( 'Media', 'experiments group name', 'gutenberg' ),
47 'items' => array(
48 array(
49 'id' => 'gutenberg-media-editor',
50 'label' => __( 'Media Editor (Route)', 'gutenberg' ),
51 'description' => __( 'Enables a dedicated route-based media editor screen for editing media items (metadata and content).', 'gutenberg' ),
52 ),
53 array(
54 'id' => 'gutenberg-dataviews-media-modal',
55 'label' => __( 'Media Upload Modal', 'gutenberg' ),
56 'description' => __( 'Replaces the existing WordPress media modal with a new modal powered by Data Views, supporting browsing, selecting, and uploading media.', 'gutenberg' ),
57 ),
58 ),
59 ),
60 array(
61 'slug' => 'data-views',
62 'label' => _x( 'Data Views', 'experiments group name', 'gutenberg' ),
63 'items' => array(
64 array(
65 'id' => 'gutenberg-content-only-inspector-fields',
66 'label' => __( 'Block fields: Show dataform driven inspector fields on blocks that support them', 'gutenberg' ),
67 'description' => __( 'Enables editable block inspector fields that are generated using a dataform.', 'gutenberg' ),
68 ),
69 array(
70 'id' => 'gutenberg-dataform-inspector',
71 'label' => __( 'Editor Inspector: Use DataForm', 'gutenberg' ),
72 'description' => __( 'Replaces the bespoke editor inspector panels with a unified DataForm-based implementation for Pages and Posts, matching the QuickEdit experience.', 'gutenberg' ),
73 ),
74 ),
75 ),
76 array(
77 'slug' => 'interactivity',
78 'label' => _x( 'Interactivity', 'experiments group name', 'gutenberg' ),
79 'items' => array(
80 array(
81 'id' => 'gutenberg-full-page-client-side-navigation',
82 'label' => __( 'Full-page client-side navigation', 'gutenberg' ),
83 'description' => __( 'Enables full-page client-side navigation, powered by the Interactivity API.', 'gutenberg' ),
84 ),
85 ),
86 ),
87 array(
88 'slug' => 'templates',
89 'label' => _x( 'Templates', 'experiments group name', 'gutenberg' ),
90 'items' => array(
91 array(
92 'id' => 'active_templates',
93 'label' => __( 'Template Activation', 'gutenberg' ),
94 'description' => __( 'Allows multiple templates of the same type to be created, of which one can be active at a time. (Warning: when you deactivate this experiment, it is best to delete all created templates except for the active ones.)', 'gutenberg' ),
95 'separateOption' => true,
96 ),
97 ),
98 ),
99 array(
100 'slug' => 'other',
101 'label' => _x( 'Other', 'experiments group name', 'gutenberg' ),
102 'items' => array(
103 array(
104 'id' => 'gutenberg-color-randomizer',
105 'label' => __( 'Color randomizer', 'gutenberg' ),
106 'description' => __( 'Enables the Global Styles color randomizer in the Site Editor; a utility that lets you mix the current color palette pseudo-randomly.', 'gutenberg' ),
107 ),
108 array(
109 'id' => 'gutenberg-workflow-palette',
110 'label' => __( 'Workflow Palette', 'gutenberg' ),
111 'description' => __( 'Enables the Workflow Palette for running workflows composed of abilities, from a unified interface.', 'gutenberg' ),
112 ),
113 array(
114 'id' => 'gutenberg-extensible-site-editor',
115 'label' => __( 'Extensible Site Editor', 'gutenberg' ),
116 'description' => __( 'Redirects the default site editor (Appearance > Design) to use the extensible site editor page.', 'gutenberg' ),
117 ),
118 array(
119 'id' => 'gutenberg-guidelines',
120 'label' => __( 'Guidelines', 'gutenberg' ),
121 'description' => __( 'Enables guidelines feature for managing editorial voice and tone guidelines under Settings.', 'gutenberg' ),
122 ),
123 array(
124 'id' => 'gutenberg-content-types',
125 'label' => __( 'Content types', 'gutenberg' ),
126 'description' => __( 'Enables a UI for creating and managing custom taxonomies and custom post types under Settings.', 'gutenberg' ),
127 ),
128 array(
129 'id' => 'gutenberg-dashboard-widgets',
130 'label' => __( 'New Dashboard experience', 'gutenberg' ),
131 'description' => __( 'Enables a new dashboard experience with resizable, reorderable widgets that plugins can register and users can personalize.', 'gutenberg' ),
132 ),
133 array(
134 'id' => 'gutenberg-admin-bar-in-editor',
135 'label' => __( 'Toolbar in editor', 'gutenberg' ),
136 'description' => __( 'Shows the Toolbar in the fullscreen Post and Site Editor.', 'gutenberg' ),
137 ),
138 array(
139 'id' => 'gutenberg-react-19',
140 'label' => __( 'React 19', 'gutenberg' ),
141 'description' => __( 'Registers React 19 as the bundled React version, replacing the default React 18 scripts.', 'gutenberg' ),
142 ),
143 ),
144 ),
145 );
146
147 $properties = array();
148
149 foreach ( $groups as $group ) {
150 foreach ( $group['items'] as $experiment ) {
151 $property = array(
152 'type' => 'boolean',
153 'title' => $experiment['label'],
154 'description' => $experiment['description'],
155 'group' => $group['slug'],
156 'group_label' => $group['label'],
157 );
158
159 // Metadata-only entry: values for separateOption experiments live in
160 // their own option (e.g. `active_templates`). Surfaced here so the UI
161 // can render them from the settings schema.
162 if ( ! empty( $experiment['separateOption'] ) ) {
163 $property['separate_option'] = true;
164 $property['option_name'] = $experiment['id'];
165 }
166
167 $properties[ $experiment['id'] ] = $property;
168 }
169 }
170
171 register_setting(
172 'gutenberg-experiments',
173 'gutenberg-experiments',
174 array(
175 'label' => __( 'Gutenberg Experiments', 'gutenberg' ),
176 'show_in_rest' => array(
177 'schema' => array(
178 'type' => 'object',
179 'properties' => $properties,
180 ),
181 ),
182 'default' => array(),
183 )
184 );
185 }
186
187 add_action( 'rest_api_init', 'gutenberg_initialize_experiments_settings' );
188
189 /**
190 * Registers the Experiments submenu page under the Gutenberg menu.
191 */
192 function gutenberg_experiments_menu() {
193 add_submenu_page(
194 'gutenberg',
195 __( 'Experiments Settings', 'gutenberg' ),
196 __( 'Experiments', 'gutenberg' ),
197 'manage_options',
198 'experiments-wp-admin',
199 'gutenberg_experiments_wp_admin_render_page'
200 );
201 }
202 add_action( 'admin_menu', 'gutenberg_experiments_menu' );
203
204 /**
205 * Allows the legacy `gutenberg-experiments` route. Without this, accessing
206 * `?page=gutenberg-experiments` results in an HTTP 403 error.
207 *
208 * Allowing the route is done by adding a wp-admin submenu page that won't be rendered.
209 */
210 function gutenberg_experiments_legacy_menu() {
211 add_submenu_page( '', '', '', 'manage_options', 'gutenberg-experiments', '__return_empty_string' );
212 }
213 add_action( 'admin_menu', 'gutenberg_experiments_legacy_menu', 9 );
214
215 /**
216 * Redirects the legacy `?page=gutenberg-experiments` URL to the new
217 * `?page=experiments-wp-admin` URL.
218 */
219 function gutenberg_redirect_legacy_experiments_page() {
220 wp_safe_redirect( admin_url( 'admin.php?page=experiments-wp-admin' ) );
221 exit;
222 }
223 add_action( 'load-admin_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );
224 add_action( 'load-toplevel_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );
225 add_action( 'load-gutenberg_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );
226