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

216 lines 8.6 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', 'gutenberg' ),
46 'description' => __( 'Adds an "Edit media" action on image blocks for editing the attached media item (metadata and content) in the editor.', 'gutenberg' ),
47 ),
48 array(
49 'id' => 'gutenberg-media-editor-modal',
50 'label' => __( 'Media Editor Modal', 'gutenberg' ),
51 'description' => __( 'Enables an in-place modal for image editing — cropping, adjustments, and metadata — opened from blocks like the image block without navigating away from the current post.', '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 under Settings. Custom post types will be explored soon.', '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 ),
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 * Registers the Experiments submenu page under the Gutenberg menu.
181 */
182 function gutenberg_experiments_menu() {
183 add_submenu_page(
184 'gutenberg',
185 __( 'Experiments Settings', 'gutenberg' ),
186 __( 'Experiments', 'gutenberg' ),
187 'manage_options',
188 'experiments-wp-admin',
189 'gutenberg_experiments_wp_admin_render_page'
190 );
191 }
192 add_action( 'admin_menu', 'gutenberg_experiments_menu' );
193
194 /**
195 * Allows the legacy `gutenberg-experiments` route. Without this, accessing
196 * `?page=gutenberg-experiments` results in an HTTP 403 error.
197 *
198 * Allowing the route is done by adding a wp-admin submenu page that won't be rendered.
199 */
200 function gutenberg_experiments_legacy_menu() {
201 add_submenu_page( '', '', '', 'manage_options', 'gutenberg-experiments', '__return_empty_string' );
202 }
203 add_action( 'admin_menu', 'gutenberg_experiments_legacy_menu', 9 );
204
205 /**
206 * Redirects the legacy `?page=gutenberg-experiments` URL to the new
207 * `?page=experiments-wp-admin` URL.
208 */
209 function gutenberg_redirect_legacy_experiments_page() {
210 wp_safe_redirect( admin_url( 'admin.php?page=experiments-wp-admin' ) );
211 exit;
212 }
213 add_action( 'load-admin_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );
214 add_action( 'load-toplevel_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );
215 add_action( 'load-gutenberg_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );
216