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

221 lines 8.8 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 ),
139 ),
140 );
141
142 $properties = array();
143
144 foreach ( $groups as $group ) {
145 foreach ( $group['items'] as $experiment ) {
146 $property = array(
147 'type' => 'boolean',
148 'title' => $experiment['label'],
149 'description' => $experiment['description'],
150 'group' => $group['slug'],
151 'group_label' => $group['label'],
152 );
153
154 // Metadata-only entry: values for separateOption experiments live in
155 // their own option (e.g. `active_templates`). Surfaced here so the UI
156 // can render them from the settings schema.
157 if ( ! empty( $experiment['separateOption'] ) ) {
158 $property['separate_option'] = true;
159 $property['option_name'] = $experiment['id'];
160 }
161
162 $properties[ $experiment['id'] ] = $property;
163 }
164 }
165
166 register_setting(
167 'gutenberg-experiments',
168 'gutenberg-experiments',
169 array(
170 'label' => __( 'Gutenberg Experiments', 'gutenberg' ),
171 'show_in_rest' => array(
172 'schema' => array(
173 'type' => 'object',
174 'properties' => $properties,
175 ),
176 ),
177 'default' => array(),
178 )
179 );
180 }
181
182 add_action( 'rest_api_init', 'gutenberg_initialize_experiments_settings' );
183
184 /**
185 * Registers the Experiments submenu page under the Gutenberg menu.
186 */
187 function gutenberg_experiments_menu() {
188 add_submenu_page(
189 'gutenberg',
190 __( 'Experiments Settings', 'gutenberg' ),
191 __( 'Experiments', 'gutenberg' ),
192 'manage_options',
193 'experiments-wp-admin',
194 'gutenberg_experiments_wp_admin_render_page'
195 );
196 }
197 add_action( 'admin_menu', 'gutenberg_experiments_menu' );
198
199 /**
200 * Allows the legacy `gutenberg-experiments` route. Without this, accessing
201 * `?page=gutenberg-experiments` results in an HTTP 403 error.
202 *
203 * Allowing the route is done by adding a wp-admin submenu page that won't be rendered.
204 */
205 function gutenberg_experiments_legacy_menu() {
206 add_submenu_page( '', '', '', 'manage_options', 'gutenberg-experiments', '__return_empty_string' );
207 }
208 add_action( 'admin_menu', 'gutenberg_experiments_legacy_menu', 9 );
209
210 /**
211 * Redirects the legacy `?page=gutenberg-experiments` URL to the new
212 * `?page=experiments-wp-admin` URL.
213 */
214 function gutenberg_redirect_legacy_experiments_page() {
215 wp_safe_redirect( admin_url( 'admin.php?page=experiments-wp-admin' ) );
216 exit;
217 }
218 add_action( 'load-admin_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );
219 add_action( 'load-toplevel_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );
220 add_action( 'load-gutenberg_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );
221