PluginProbe
Gutenberg / 23.9.0
Gutenberg v23.9.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.9.0, at lib/experimental/experiments/load.php

210 lines 8.5 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-global-styles-inheritance-ui',
34 'label' => __( 'Global Styles inheritance in the block inspector', 'gutenberg' ),
35 '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' ),
36 ),
37 array(
38 'id' => 'gutenberg-grid-interactivity',
39 'label' => __( 'Grid interactivity', 'gutenberg' ),
40 'description' => __( 'Enables enhancements to the Grid block that let you move and resize items in the editor canvas.', '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' => __( 'Replaces the core Edit Media screen with a dedicated route-based media editor 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' => 'real-time-collaboration',
89 'label' => _x( 'Real-Time Collaboration', 'experiments group name', 'gutenberg' ),
90 'items' => array(
91 array(
92 'id' => 'gutenberg-real-time-collaboration',
93 'label' => __( 'Enable real-time collaboration', 'gutenberg' ),
94 'description' => __( 'Allows multiple people to edit the same post at the same time.', 'gutenberg' ),
95 ),
96 ),
97 ),
98 array(
99 'slug' => 'templates',
100 'label' => _x( 'Templates', 'experiments group name', 'gutenberg' ),
101 'items' => array(
102 array(
103 'id' => 'active_templates',
104 'label' => __( 'Template Activation', 'gutenberg' ),
105 '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' ),
106 'separateOption' => true,
107 ),
108 ),
109 ),
110 array(
111 'slug' => 'other',
112 'label' => _x( 'Other', 'experiments group name', 'gutenberg' ),
113 'items' => array(
114 array(
115 'id' => 'gutenberg-color-randomizer',
116 'label' => __( 'Color randomizer', 'gutenberg' ),
117 'description' => __( 'Enables the Global Styles color randomizer in the Site Editor; a utility that lets you mix the current color palette pseudo-randomly.', 'gutenberg' ),
118 ),
119 array(
120 'id' => 'gutenberg-workflow-palette',
121 'label' => __( 'Workflow Palette', 'gutenberg' ),
122 'description' => __( 'Enables the Workflow Palette for running workflows composed of abilities, from a unified interface.', 'gutenberg' ),
123 ),
124 array(
125 'id' => 'gutenberg-extensible-site-editor',
126 'label' => __( 'Extensible Site Editor', 'gutenberg' ),
127 'description' => __( 'Redirects the default site editor (Appearance > Design) to use the extensible site editor page.', 'gutenberg' ),
128 ),
129 array(
130 'id' => 'gutenberg-guidelines',
131 'label' => __( 'Guidelines', 'gutenberg' ),
132 'description' => __( 'Enables the Guidelines page under Settings and the experimental knowledge storage (wp_knowledge).', 'gutenberg' ),
133 ),
134 array(
135 'id' => 'gutenberg-dashboard-widgets',
136 'label' => __( 'New Dashboard experience', 'gutenberg' ),
137 'description' => __( 'Enables a new dashboard experience with resizable, reorderable widgets that plugins can register and users can personalize.', 'gutenberg' ),
138 ),
139 array(
140 'id' => 'gutenberg-react-19',
141 'label' => __( 'React 19', 'gutenberg' ),
142 'description' => __( 'Registers React 19 as the bundled React version, replacing the default React 18 scripts.', 'gutenberg' ),
143 ),
144 ),
145 ),
146 );
147
148 $properties = array();
149
150 foreach ( $groups as $group ) {
151 foreach ( $group['items'] as $experiment ) {
152 $property = array(
153 'type' => 'boolean',
154 'title' => $experiment['label'],
155 'description' => $experiment['description'],
156 'group' => $group['slug'],
157 'group_label' => $group['label'],
158 );
159
160 // Metadata-only entry: values for separateOption experiments live in
161 // their own option (e.g. `active_templates`). Surfaced here so the UI
162 // can render them from the settings schema.
163 if ( ! empty( $experiment['separateOption'] ) ) {
164 $property['separate_option'] = true;
165 $property['option_name'] = $experiment['id'];
166 }
167
168 $properties[ $experiment['id'] ] = $property;
169 }
170 }
171
172 register_setting(
173 'gutenberg-experiments',
174 'gutenberg-experiments',
175 array(
176 'label' => __( 'Gutenberg Experiments', 'gutenberg' ),
177 'show_in_rest' => array(
178 'schema' => array(
179 'type' => 'object',
180 'properties' => $properties,
181 ),
182 ),
183 'default' => array(),
184 )
185 );
186 }
187
188 add_action( 'rest_api_init', 'gutenberg_initialize_experiments_settings' );
189
190 /**
191 * Allows the legacy `gutenberg-experiments` route. Without this, accessing
192 * `?page=gutenberg-experiments` results in an HTTP 403 error.
193 *
194 * Allowing the route is done by adding a wp-admin submenu page that won't be rendered.
195 */
196 function gutenberg_experiments_legacy_menu() {
197 add_submenu_page( '', '', '', 'manage_options', 'gutenberg-experiments', '__return_empty_string' );
198 }
199 add_action( 'admin_menu', 'gutenberg_experiments_legacy_menu', 9 );
200
201 /**
202 * Redirects the legacy `?page=gutenberg-experiments` URL to the new
203 * `?page=experiments-wp-admin` URL.
204 */
205 function gutenberg_redirect_legacy_experiments_page() {
206 wp_safe_redirect( admin_url( 'options-general.php?page=experiments-wp-admin' ) );
207 exit;
208 }
209 add_action( 'load-admin_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );
210