PluginProbe
Gutenberg / 23.6.0
Gutenberg v23.6.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.6.0, at lib/experimental/experiments/load.php

199 lines 7.9 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 ),
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' => __( 'Enables a dedicated route-based media editor screen 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-content-only-inspector-fields',
61 'label' => __( 'Block fields: Show dataform driven inspector fields on blocks that support them', 'gutenberg' ),
62 'description' => __( 'Enables editable block inspector fields that are generated using a dataform.', 'gutenberg' ),
63 ),
64 array(
65 'id' => 'gutenberg-dataform-inspector',
66 'label' => __( 'Editor Inspector: Use DataForm', 'gutenberg' ),
67 'description' => __( 'Replaces the bespoke editor inspector panels with a unified DataForm-based implementation for Pages and Posts, matching the QuickEdit experience.', 'gutenberg' ),
68 ),
69 ),
70 ),
71 array(
72 'slug' => 'interactivity',
73 'label' => _x( 'Interactivity', 'experiments group name', 'gutenberg' ),
74 'items' => array(
75 array(
76 'id' => 'gutenberg-full-page-client-side-navigation',
77 'label' => __( 'Full-page client-side navigation', 'gutenberg' ),
78 'description' => __( 'Enables full-page client-side navigation, powered by the Interactivity API.', 'gutenberg' ),
79 ),
80 ),
81 ),
82 array(
83 'slug' => 'templates',
84 'label' => _x( 'Templates', 'experiments group name', 'gutenberg' ),
85 'items' => array(
86 array(
87 'id' => 'active_templates',
88 'label' => __( 'Template Activation', 'gutenberg' ),
89 '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' ),
90 'separateOption' => true,
91 ),
92 ),
93 ),
94 array(
95 'slug' => 'other',
96 'label' => _x( 'Other', 'experiments group name', 'gutenberg' ),
97 'items' => array(
98 array(
99 'id' => 'gutenberg-color-randomizer',
100 'label' => __( 'Color randomizer', 'gutenberg' ),
101 'description' => __( 'Enables the Global Styles color randomizer in the Site Editor; a utility that lets you mix the current color palette pseudo-randomly.', 'gutenberg' ),
102 ),
103 array(
104 'id' => 'gutenberg-workflow-palette',
105 'label' => __( 'Workflow Palette', 'gutenberg' ),
106 'description' => __( 'Enables the Workflow Palette for running workflows composed of abilities, from a unified interface.', 'gutenberg' ),
107 ),
108 array(
109 'id' => 'gutenberg-extensible-site-editor',
110 'label' => __( 'Extensible Site Editor', 'gutenberg' ),
111 'description' => __( 'Redirects the default site editor (Appearance > Design) to use the extensible site editor page.', 'gutenberg' ),
112 ),
113 array(
114 'id' => 'gutenberg-guidelines',
115 'label' => __( 'Guidelines', 'gutenberg' ),
116 'description' => __( 'Enables the Guidelines page under Settings and the experimental knowledge storage (wp_knowledge).', 'gutenberg' ),
117 ),
118 array(
119 'id' => 'gutenberg-content-types',
120 'label' => __( 'Content types', 'gutenberg' ),
121 'description' => __( 'Enables a UI for creating and managing custom taxonomies and custom post types under Settings.', 'gutenberg' ),
122 ),
123 array(
124 'id' => 'gutenberg-dashboard-widgets',
125 'label' => __( 'New Dashboard experience', 'gutenberg' ),
126 'description' => __( 'Enables a new dashboard experience with resizable, reorderable widgets that plugins can register and users can personalize.', 'gutenberg' ),
127 ),
128 array(
129 'id' => 'gutenberg-react-19',
130 'label' => __( 'React 19', 'gutenberg' ),
131 'description' => __( 'Registers React 19 as the bundled React version, replacing the default React 18 scripts.', 'gutenberg' ),
132 ),
133 ),
134 ),
135 );
136
137 $properties = array();
138
139 foreach ( $groups as $group ) {
140 foreach ( $group['items'] as $experiment ) {
141 $property = array(
142 'type' => 'boolean',
143 'title' => $experiment['label'],
144 'description' => $experiment['description'],
145 'group' => $group['slug'],
146 'group_label' => $group['label'],
147 );
148
149 // Metadata-only entry: values for separateOption experiments live in
150 // their own option (e.g. `active_templates`). Surfaced here so the UI
151 // can render them from the settings schema.
152 if ( ! empty( $experiment['separateOption'] ) ) {
153 $property['separate_option'] = true;
154 $property['option_name'] = $experiment['id'];
155 }
156
157 $properties[ $experiment['id'] ] = $property;
158 }
159 }
160
161 register_setting(
162 'gutenberg-experiments',
163 'gutenberg-experiments',
164 array(
165 'label' => __( 'Gutenberg Experiments', 'gutenberg' ),
166 'show_in_rest' => array(
167 'schema' => array(
168 'type' => 'object',
169 'properties' => $properties,
170 ),
171 ),
172 'default' => array(),
173 )
174 );
175 }
176
177 add_action( 'rest_api_init', 'gutenberg_initialize_experiments_settings' );
178
179 /**
180 * Allows the legacy `gutenberg-experiments` route. Without this, accessing
181 * `?page=gutenberg-experiments` results in an HTTP 403 error.
182 *
183 * Allowing the route is done by adding a wp-admin submenu page that won't be rendered.
184 */
185 function gutenberg_experiments_legacy_menu() {
186 add_submenu_page( '', '', '', 'manage_options', 'gutenberg-experiments', '__return_empty_string' );
187 }
188 add_action( 'admin_menu', 'gutenberg_experiments_legacy_menu', 9 );
189
190 /**
191 * Redirects the legacy `?page=gutenberg-experiments` URL to the new
192 * `?page=experiments-wp-admin` URL.
193 */
194 function gutenberg_redirect_legacy_experiments_page() {
195 wp_safe_redirect( admin_url( 'options-general.php?page=experiments-wp-admin' ) );
196 exit;
197 }
198 add_action( 'load-admin_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );
199