/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
lib/experimental/experiments/load.php
198 строк
8 KB
Nik Tsekouras
Remove content types experiment (#81340)
10 авг 2026, 10:09
Не верифицирован
10 авг 2026, 10:09
226f1e8
Код
Авторство
О чём код?
<?php /** * Bootstraps the Gutenberg experiments page in wp-admin. * * @package gutenberg */ /** * Set up the experiments settings. * * Registering an experiment here only exposes it on the Experiments screen. * To actually enable a new experiment in the editor, add a matching bridge * (e.g. a `window.__experimental*` global) in `gutenberg_enable_experiments()` * in `lib/experimental/editor-settings.php`. */ function gutenberg_initialize_experiments_settings() { $groups = array( array( 'slug' => 'blocks', 'label' => _x( 'Blocks', 'experiments group name', 'gutenberg' ), 'items' => array( array( 'id' => 'gutenberg-block-experiments', 'label' => __( 'Experimental blocks', 'gutenberg' ), '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' ), ), array( 'id' => 'gutenberg-form-blocks', 'label' => __( 'Form and input blocks', 'gutenberg' ), 'description' => __( 'Enables new blocks to allow building forms. You are likely to experience UX issues that are being addressed.', 'gutenberg' ), ), array( 'id' => 'gutenberg-global-styles-inheritance-ui', 'label' => __( 'Global Styles inheritance in the block inspector', 'gutenberg' ), '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' ), ), array( 'id' => 'gutenberg-grid-interactivity', 'label' => __( 'Grid interactivity', 'gutenberg' ), 'description' => __( 'Enables enhancements to the Grid block that let you move and resize items in the editor canvas.', 'gutenberg' ), ), ), ), array( 'slug' => 'media', 'label' => _x( 'Media', 'experiments group name', 'gutenberg' ), 'items' => array( array( 'id' => 'gutenberg-media-editor', 'label' => __( 'Media Editor (Route)', 'gutenberg' ), 'description' => __( 'Enables a dedicated route-based media editor screen for editing media items (metadata and content).', 'gutenberg' ), ), array( 'id' => 'gutenberg-dataviews-media-modal', 'label' => __( 'Media Upload Modal', 'gutenberg' ), 'description' => __( 'Replaces the existing WordPress media modal with a new modal powered by Data Views, supporting browsing, selecting, and uploading media.', 'gutenberg' ), ), ), ), array( 'slug' => 'data-views', 'label' => _x( 'Data Views', 'experiments group name', 'gutenberg' ), 'items' => array( array( 'id' => 'gutenberg-content-only-inspector-fields', 'label' => __( 'Block fields: Show dataform driven inspector fields on blocks that support them', 'gutenberg' ), 'description' => __( 'Enables editable block inspector fields that are generated using a dataform.', 'gutenberg' ), ), array( 'id' => 'gutenberg-dataform-inspector', 'label' => __( 'Editor Inspector: Use DataForm', 'gutenberg' ), 'description' => __( 'Replaces the bespoke editor inspector panels with a unified DataForm-based implementation for Pages and Posts, matching the QuickEdit experience.', 'gutenberg' ), ), ), ), array( 'slug' => 'interactivity', 'label' => _x( 'Interactivity', 'experiments group name', 'gutenberg' ), 'items' => array( array( 'id' => 'gutenberg-full-page-client-side-navigation', 'label' => __( 'Full-page client-side navigation', 'gutenberg' ), 'description' => __( 'Enables full-page client-side navigation, powered by the Interactivity API.', 'gutenberg' ), ), ), ), array( 'slug' => 'templates', 'label' => _x( 'Templates', 'experiments group name', 'gutenberg' ), 'items' => array( array( 'id' => 'active_templates', 'label' => __( 'Template Activation', 'gutenberg' ), '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' ), 'separateOption' => true, ), ), ), array( 'slug' => 'other', 'label' => _x( 'Other', 'experiments group name', 'gutenberg' ), 'items' => array( array( 'id' => 'gutenberg-color-randomizer', 'label' => __( 'Color randomizer', 'gutenberg' ), 'description' => __( 'Enables the Global Styles color randomizer in the Site Editor; a utility that lets you mix the current color palette pseudo-randomly.', 'gutenberg' ), ), array( 'id' => 'gutenberg-workflow-palette', 'label' => __( 'Workflow Palette', 'gutenberg' ), 'description' => __( 'Enables the Workflow Palette for running workflows composed of abilities, from a unified interface.', 'gutenberg' ), ), array( 'id' => 'gutenberg-extensible-site-editor', 'label' => __( 'Extensible Site Editor', 'gutenberg' ), 'description' => __( 'Redirects the default site editor (Appearance > Design) to use the extensible site editor page.', 'gutenberg' ), ), array( 'id' => 'gutenberg-guidelines', 'label' => __( 'Guidelines', 'gutenberg' ), 'description' => __( 'Enables the Guidelines page under Settings and the experimental knowledge storage (wp_knowledge).', 'gutenberg' ), ), array( 'id' => 'gutenberg-dashboard-widgets', 'label' => __( 'New Dashboard experience', 'gutenberg' ), 'description' => __( 'Enables a new dashboard experience with resizable, reorderable widgets that plugins can register and users can personalize.', 'gutenberg' ), ), array( 'id' => 'gutenberg-react-19', 'label' => __( 'React 19', 'gutenberg' ), 'description' => __( 'Registers React 19 as the bundled React version, replacing the default React 18 scripts.', 'gutenberg' ), ), ), ), ); $properties = array(); foreach ( $groups as $group ) { foreach ( $group['items'] as $experiment ) { $property = array( 'type' => 'boolean', 'title' => $experiment['label'], 'description' => $experiment['description'], 'group' => $group['slug'], 'group_label' => $group['label'], ); // Metadata-only entry: values for separateOption experiments live in // their own option (e.g. `active_templates`). Surfaced here so the UI // can render them from the settings schema. if ( ! empty( $experiment['separateOption'] ) ) { $property['separate_option'] = true; $property['option_name'] = $experiment['id']; } $properties[ $experiment['id'] ] = $property; } } register_setting( 'gutenberg-experiments', 'gutenberg-experiments', array( 'label' => __( 'Gutenberg Experiments', 'gutenberg' ), 'show_in_rest' => array( 'schema' => array( 'type' => 'object', 'properties' => $properties, ), ), 'default' => array(), ) ); } add_action( 'rest_api_init', 'gutenberg_initialize_experiments_settings' ); /** * Allows the legacy `gutenberg-experiments` route. Without this, accessing * `?page=gutenberg-experiments` results in an HTTP 403 error. * * Allowing the route is done by adding a wp-admin submenu page that won't be rendered. */ function gutenberg_experiments_legacy_menu() { add_submenu_page( '', '', '', 'manage_options', 'gutenberg-experiments', '__return_empty_string' ); } add_action( 'admin_menu', 'gutenberg_experiments_legacy_menu', 9 ); /** * Redirects the legacy `?page=gutenberg-experiments` URL to the new * `?page=experiments-wp-admin` URL. */ function gutenberg_redirect_legacy_experiments_page() { wp_safe_redirect( admin_url( 'options-general.php?page=experiments-wp-admin' ) ); exit; } add_action( 'load-admin_page_gutenberg-experiments', 'gutenberg_redirect_legacy_experiments_page' );