diff --git a/gutenberg.php b/gutenberg.php
index b987d3259f482..dcb8b7a511da1 100644
--- a/gutenberg.php
+++ b/gutenberg.php
@@ -3,7 +3,7 @@
* Plugin Name: Gutenberg
* Plugin URI: https://github.com/WordPress/gutenberg
* Description: Printing since 1440. This is the development plugin for the new block editor in core.
- * Requires at least: 5.9
+ * Requires at least: 6.0
* Requires PHP: 5.6
* Version: 14.7.0
* Author: Gutenberg Team
diff --git a/lib/client-assets.php b/lib/client-assets.php
index 2bb1f95217742..b7a11724a5e09 100644
--- a/lib/client-assets.php
+++ b/lib/client-assets.php
@@ -539,6 +539,37 @@ function gutenberg_enqueue_stored_styles( $options = array() ) {
}
}
+/**
+ * Registers vendor JavaScript files to be used as dependencies of the editor
+ * and plugins.
+ *
+ * This function is called from a script during the plugin build process, so it
+ * should not call any WordPress PHP functions.
+ *
+ * @since 13.0
+ *
+ * @param WP_Scripts $scripts WP_Scripts instance.
+ */
+function gutenberg_register_vendor_scripts( $scripts ) {
+ $extension = SCRIPT_DEBUG ? '.js' : '.min.js';
+
+ gutenberg_override_script(
+ $scripts,
+ 'react',
+ gutenberg_url( 'build/vendors/react' . $extension ),
+ // See https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#externalising-react.
+ SCRIPT_DEBUG ? array( 'wp-react-refresh-entry', 'wp-polyfill' ) : array( 'wp-polyfill' )
+ );
+ gutenberg_override_script(
+ $scripts,
+ 'react-dom',
+ gutenberg_url( 'build/vendors/react-dom' . $extension ),
+ array( 'react' )
+ );
+}
+add_action( 'wp_default_scripts', 'gutenberg_register_vendor_scripts' );
+
+
/*
* Always remove the Core action hook while gutenberg_enqueue_stored_styles() exists to avoid styles being printed twice.
* This is also because gutenberg_enqueue_stored_styles uses the Style Engine's `gutenberg_*` functions and `_Gutenberg` classes,
diff --git a/lib/compat/wordpress-6.0/block-editor-settings.php b/lib/compat/wordpress-6.0/block-editor-settings.php
deleted file mode 100644
index 8aae673bff334..0000000000000
--- a/lib/compat/wordpress-6.0/block-editor-settings.php
+++ /dev/null
@@ -1,35 +0,0 @@
- .alignleft { float: left; margin-right: 2em; }';
- $root_styles .= '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }';
- $root_styles .= '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
-
- if (
- ( isset( $style['__unstableType'] ) && ( 'presets' === $style['__unstableType'] ) ) ||
- ( isset( $style['__unstableType'] ) && ( 'theme' === $style['__unstableType'] ) && str_contains( $style['css'], $root_styles ) )
- ) {
- return true;
- }
-
- return false;
-}
diff --git a/lib/compat/wordpress-6.0/block-gallery.php b/lib/compat/wordpress-6.0/block-gallery.php
deleted file mode 100644
index 53c3a0c2247fd..0000000000000
--- a/lib/compat/wordpress-6.0/block-gallery.php
+++ /dev/null
@@ -1,57 +0,0 @@
-= 6.0.
- *
- * @return void.
- */
-function gutenberg_check_gallery_block_v2_compatibility() {
- $use_balance_tags = (int) get_option( 'use_balanceTags' );
- $v2_gallery_enabled = boolval( 1 !== $use_balance_tags || is_wp_version_compatible( '6.0' ) ) ? 'true' : 'false';
-
- wp_add_inline_script(
- 'wp-dom-ready',
- 'wp.galleryBlockV2Enabled = ' . $v2_gallery_enabled . ';',
- 'after'
- );
-}
-add_action( 'init', 'gutenberg_check_gallery_block_v2_compatibility' );
-
-/**
- * Prevent use_balanceTags being enabled on WordPress 5.8 or earlier as it breaks
- * the layout of the new Gallery block.
- *
- * @since 12.1.0
- * @todo This should be removed when the minimum required WP version is >= 6.0.
- *
- * @param int $new_value The new value for use_balanceTags.
- */
-function gutenberg_use_balancetags_check( $new_value ) {
- global $wp_version;
-
- if ( 1 === (int) $new_value && version_compare( $wp_version, '6.0', '<' ) ) {
- /* translators: %s: Minimum required version */
- $message = sprintf( __( 'Gutenberg requires WordPress %s or later in order to enable the “Correct invalidly nested XHTML automatically” option. Please upgrade WordPress before enabling.', 'gutenberg' ), '6.0' );
- add_settings_error( 'gutenberg_use_balancetags_check', 'gutenberg_use_balancetags_check', $message, 'error' );
- if ( class_exists( 'WP_CLI' ) ) {
- WP_CLI::error( $message );
- }
- return 0;
- }
-
- return $new_value;
-}
-add_filter( 'pre_update_option_use_balanceTags', 'gutenberg_use_balancetags_check' );
diff --git a/lib/compat/wordpress-6.0/block-patterns-update.php b/lib/compat/wordpress-6.0/block-patterns-update.php
deleted file mode 100644
index c17a65be2ae22..0000000000000
--- a/lib/compat/wordpress-6.0/block-patterns-update.php
+++ /dev/null
@@ -1,217 +0,0 @@
-is_registered( 'query' ) ) {
- register_block_pattern_category( 'query', array( 'label' => __( 'Query', 'gutenberg' ) ) );
- }
-
- if ( ! $pattern_category_registry->is_registered( 'featured' ) ) {
- register_block_pattern_category( 'featured', array( 'label' => __( 'Featured', 'gutenberg' ) ) );
- }
-
- $patterns = array(
- 'query-standard-posts' => array(
- 'title' => _x( 'Standard', 'Block pattern title', 'gutenberg' ),
- 'blockTypes' => array( 'core/query' ),
- 'categories' => array( 'query' ),
- 'content' => '
-
-
-
-
-
-
-
-
-
-
-
- ',
- ),
- 'query-medium-posts' => array(
- 'title' => _x( 'Image at left', 'Block pattern title', 'gutenberg' ),
- 'blockTypes' => array( 'core/query' ),
- 'categories' => array( 'query' ),
- 'content' => '
-
- ',
- ),
- 'query-small-posts' => array(
- 'title' => _x( 'Small image and title', 'Block pattern title', 'gutenberg' ),
- 'blockTypes' => array( 'core/query' ),
- 'categories' => array( 'query' ),
- 'content' => '
-
- ',
- ),
- 'query-grid-posts' => array(
- 'title' => _x( 'Grid', 'Block pattern title', 'gutenberg' ),
- 'blockTypes' => array( 'core/query' ),
- 'categories' => array( 'query' ),
- 'content' => '
-
- ',
- ),
- 'query-large-title-posts' => array(
- 'title' => _x( 'Large title', 'Block pattern title', 'gutenberg' ),
- 'blockTypes' => array( 'core/query' ),
- 'categories' => array( 'query' ),
- 'content' => '
-
- ',
- ),
- 'query-offset-posts' => array(
- 'title' => _x( 'Offset', 'Block pattern title', 'gutenberg' ),
- 'blockTypes' => array( 'core/query' ),
- 'categories' => array( 'query' ),
- 'content' => '
-
- ',
- ),
- // Initial block pattern to be used with block transformations with patterns.
- 'social-links-shared-background-color' => array(
- 'title' => _x( 'Social links with a shared background color', 'Block pattern title', 'gutenberg' ),
- 'categories' => array( 'buttons' ),
- 'blockTypes' => array( 'core/social-links' ),
- 'viewportWidth' => 500,
- 'content' => '
-
- ',
- ),
- );
-
- foreach ( $patterns as $name => $pattern ) {
- $pattern_name = 'core/' . $name;
- if ( ! WP_Block_Patterns_Registry::get_instance()->is_registered( $pattern_name ) ) {
- register_block_pattern( $pattern_name, $pattern );
- }
- }
-}
-
-/**
- * Deactivate the legacy patterns bundled with WordPress.
- */
-function gutenberg_remove_core_patterns() {
- $core_block_patterns = array(
- 'text-two-columns',
- 'two-buttons',
- 'two-images',
- 'text-two-columns-with-images',
- 'text-three-columns-buttons',
- 'large-header',
- 'large-header-button',
- 'three-buttons',
- 'heading-paragraph',
- 'quote',
- 'query-standard-posts',
- 'query-medium-posts',
- 'query-small-posts',
- 'query-grid-posts',
- 'query-large-title-posts',
- 'query-offset-posts',
- 'social-links-shared-background-color',
- );
-
- foreach ( $core_block_patterns as $core_block_pattern ) {
- $name = 'core/' . $core_block_pattern;
- if ( WP_Block_Patterns_Registry::get_instance()->is_registered( $name ) ) {
- unregister_block_pattern( $name );
- }
- }
-}
-
-add_action(
- 'init',
- function() {
- if ( ! get_theme_support( 'core-block-patterns' ) || ! function_exists( 'unregister_block_pattern' ) ) {
- return;
- }
- gutenberg_remove_core_patterns();
- gutenberg_register_gutenberg_patterns();
- }
-);
diff --git a/lib/compat/wordpress-6.0/block-patterns.php b/lib/compat/wordpress-6.0/block-patterns.php
deleted file mode 100644
index c42ec73152219..0000000000000
--- a/lib/compat/wordpress-6.0/block-patterns.php
+++ /dev/null
@@ -1,44 +0,0 @@
-get_patterns();
- if ( empty( $pattern_settings ) ) {
- return;
- }
-
- $request = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
- $request['slug'] = $pattern_settings;
- $response = rest_do_request( $request );
- if ( $response->is_error() ) {
- return;
- }
- $patterns = $response->get_data();
- $patterns_registry = WP_Block_Patterns_Registry::get_instance();
- foreach ( $patterns as $pattern ) {
- $pattern_name = sanitize_title( $pattern['title'] );
- // Some patterns might be already registered as core patterns with the `core` prefix.
- $is_registered = $patterns_registry->is_registered( $pattern_name ) || $patterns_registry->is_registered( "core/$pattern_name" );
- if ( ! $is_registered ) {
- register_block_pattern( $pattern_name, (array) $pattern );
- }
- }
- }
-}
diff --git a/lib/compat/wordpress-6.0/block-template-utils.php b/lib/compat/wordpress-6.0/block-template-utils.php
deleted file mode 100644
index 1fcd3dae83e59..0000000000000
--- a/lib/compat/wordpress-6.0/block-template-utils.php
+++ /dev/null
@@ -1,132 +0,0 @@
-get( 'TextDomain' );
- $filename = get_temp_dir() . $theme_name . $obscura . '.zip';
-
- $zip = new ZipArchive();
- if ( true !== $zip->open( $filename, ZipArchive::CREATE | ZipArchive::OVERWRITE ) ) {
- return new WP_Error( 'unable_to_create_zip', __( 'Unable to open export file (archive) for writing.', 'gutenberg' ) );
- }
-
- $zip->addEmptyDir( 'templates' );
- $zip->addEmptyDir( 'parts' );
-
- // Get path of the theme.
- $theme_path = wp_normalize_path( get_stylesheet_directory() );
-
- // Create recursive directory iterator.
- $theme_files = new RecursiveIteratorIterator(
- new RecursiveDirectoryIterator( $theme_path ),
- RecursiveIteratorIterator::LEAVES_ONLY
- );
-
- // Make a copy of the current theme.
- foreach ( $theme_files as $file ) {
- // Skip directories as they are added automatically.
- if ( ! $file->isDir() ) {
- // Get real and relative path for current file.
- $file_path = wp_normalize_path( $file );
- $relative_path = substr( $file_path, strlen( $theme_path ) + 1 );
-
- if ( ! gutenberg_is_theme_directory_ignored( $relative_path ) ) {
- $zip->addFile( $file_path, $relative_path );
- }
- }
- }
-
- // Load templates into the zip file.
- $templates = gutenberg_get_block_templates();
- foreach ( $templates as $template ) {
- $template->content = _remove_theme_attribute_in_block_template_content( $template->content );
-
- $zip->addFromString(
- 'templates/' . $template->slug . '.html',
- $template->content
- );
- }
-
- // Load template parts into the zip file.
- $template_parts = gutenberg_get_block_templates( array(), 'wp_template_part' );
- foreach ( $template_parts as $template_part ) {
- $zip->addFromString(
- 'parts/' . $template_part->slug . '.html',
- $template_part->content
- );
- }
-
- // Load theme.json into the zip file.
- $tree = WP_Theme_JSON_Resolver_Gutenberg::get_theme_data( array(), array( 'with_supports' => false ) );
- // Merge with user data.
- $tree->merge( WP_Theme_JSON_Resolver_Gutenberg::get_user_data() );
-
- $theme_json_raw = $tree->get_data();
- // If a version is defined, add a schema.
- if ( $theme_json_raw['version'] ) {
- global $wp_version;
- $theme_json_version = 'wp/' . substr( $wp_version, 0, 3 );
- if ( defined( 'IS_GUTENBERG_PLUGIN' ) ) {
- $theme_json_version = 'trunk';
- }
- $schema = array( '$schema' => 'https://schemas.wp.org/' . $theme_json_version . '/theme.json' );
- $theme_json_raw = array_merge( $schema, $theme_json_raw );
- }
-
- // Convert to a string.
- $theme_json_encoded = wp_json_encode( $theme_json_raw, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
-
- // Replace 4 spaces with a tab.
- $theme_json_tabbed = preg_replace( '~(?:^|\G)\h{4}~m', "\t", $theme_json_encoded );
-
- // Add the theme.json file to the zip.
- $zip->addFromString(
- 'theme.json',
- $theme_json_tabbed
- );
-
- // Save changes to the zip file.
- $zip->close();
-
- return $filename;
-}
diff --git a/lib/compat/wordpress-6.0/blocks.php b/lib/compat/wordpress-6.0/blocks.php
deleted file mode 100644
index ed83f62f76d42..0000000000000
--- a/lib/compat/wordpress-6.0/blocks.php
+++ /dev/null
@@ -1,194 +0,0 @@
- 'comment_date_gmt',
- 'order' => 'ASC',
- 'status' => 'approve',
- 'no_found_rows' => false,
- );
-
- if ( is_user_logged_in() ) {
- $comment_args['include_unapproved'] = array( get_current_user_id() );
- } else {
- $unapproved_email = wp_get_unapproved_comment_author_email();
-
- if ( $unapproved_email ) {
- $comment_args['include_unapproved'] = array( $unapproved_email );
- }
- }
-
- if ( ! empty( $block->context['postId'] ) ) {
- $comment_args['post_id'] = (int) $block->context['postId'];
- }
-
- if ( get_option( 'thread_comments' ) ) {
- $comment_args['hierarchical'] = 'threaded';
- } else {
- $comment_args['hierarchical'] = false;
- }
-
- if ( get_option( 'page_comments' ) === '1' || get_option( 'page_comments' ) === true ) {
- $per_page = get_option( 'comments_per_page' );
- $default_page = get_option( 'default_comments_page' );
- if ( $per_page > 0 ) {
- $comment_args['number'] = $per_page;
-
- $page = (int) get_query_var( 'cpage' );
- if ( $page ) {
- $comment_args['paged'] = $page;
- } elseif ( 'oldest' === $default_page ) {
- $comment_args['paged'] = 1;
- } elseif ( 'newest' === $default_page ) {
- $max_num_pages = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pages;
- if ( 0 !== $max_num_pages ) {
- $comment_args['paged'] = $max_num_pages;
- }
- }
- // Set the `cpage` query var to ensure the previous and next pagination links are correct
- // when inheriting the Discussion Settings.
- if ( 0 === $page && isset( $comment_args['paged'] ) && $comment_args['paged'] > 0 ) {
- set_query_var( 'cpage', $comment_args['paged'] );
- }
- }
- }
-
- return $comment_args;
- }
-}
-
-if ( ! function_exists( 'get_comments_pagination_arrow' ) ) {
- /**
- * Helper function that returns the proper pagination arrow html for
- * `CommentsPaginationNext` and `CommentsPaginationPrevious` blocks based
- * on the provided `paginationArrow` from `CommentsPagination` context.
- *
- * It's used in CommentsPaginationNext and CommentsPaginationPrevious blocks.
- *
- * @since 6.0.0
- *
- * @param WP_Block $block Block instance.
- * @param string $pagination_type Type of the arrow we will be rendering. Default 'next'. Accepts 'next' or 'previous'.
- *
- * @return string|null Returns the constructed WP_Query arguments.
- */
- function get_comments_pagination_arrow( $block, $pagination_type = 'next' ) {
- $arrow_map = array(
- 'none' => '',
- 'arrow' => array(
- 'next' => '→',
- 'previous' => '←',
- ),
- 'chevron' => array(
- 'next' => '»',
- 'previous' => '«',
- ),
- );
- if ( ! empty( $block->context['comments/paginationArrow'] ) && ! empty( $arrow_map[ $block->context['comments/paginationArrow'] ][ $pagination_type ] ) ) {
- $arrow_attribute = $block->context['comments/paginationArrow'];
- $arrow = $arrow_map[ $block->context['comments/paginationArrow'] ][ $pagination_type ];
- $arrow_classes = "wp-block-comments-pagination-$pagination_type-arrow is-arrow-$arrow_attribute";
- return "$arrow";
- }
- return null;
- }
-}
-
-/**
- * Workaround for getting discussion settings as block editor settings
- * so any user can access to them without needing to be an admin.
- *
- * @param array $settings Default editor settings.
- *
- * @return array Filtered editor settings.
- */
-function gutenberg_extend_block_editor_settings_with_discussion_settings( $settings ) {
-
- $settings['__experimentalDiscussionSettings'] = array(
- 'commentOrder' => get_option( 'comment_order' ),
- 'commentsPerPage' => get_option( 'comments_per_page' ),
- 'defaultCommentsPage' => get_option( 'default_comments_page' ),
- 'pageComments' => get_option( 'page_comments' ),
- 'threadComments' => get_option( 'thread_comments' ),
- 'threadCommentsDepth' => get_option( 'thread_comments_depth' ),
- 'defaultCommentStatus' => get_option( 'default_comment_status' ),
- 'avatarURL' => get_avatar_url(
- '',
- array(
- 'size' => 96,
- 'force_default' => true,
- 'default' => get_option( 'avatar_default' ),
- )
- ),
- );
-
- return $settings;
-}
-add_filter( 'block_editor_settings_all', 'gutenberg_extend_block_editor_settings_with_discussion_settings' );
-
-/**
- * Mark the `children` attr of comments as embeddable so they can be included in
- * REST API responses without additional requests.
- *
- * @return void
- */
-function gutenberg_rest_comment_set_children_as_embeddable() {
- add_filter(
- 'rest_prepare_comment',
- function ( $response ) {
- $links = $response->get_links();
- if ( isset( $links['children'] ) ) {
- $href = $links['children'][0]['href'];
- $response->remove_link( 'children', $href );
- $response->add_link( 'children', $href, array( 'embeddable' => true ) );
- }
- return $response;
- }
- );
-}
-add_action( 'rest_api_init', 'gutenberg_rest_comment_set_children_as_embeddable' );
-
-/**
- * Registers the lock block attribute for block types.
- *
- * Once 6.0 is the minimum supported WordPress version for the Gutenberg
- * plugin, this shim can be removed
- *
- * Doesn't need to be backported into Core.
- *
- * @param array $args Array of arguments for registering a block type.
- * @return array $args
- */
-function gutenberg_register_lock_attribute( $args ) {
- // Setup attributes if needed.
- if ( ! isset( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) {
- $args['attributes'] = array();
- }
-
- if ( ! array_key_exists( 'lock', $args['attributes'] ) ) {
- $args['attributes']['lock'] = array(
- 'type' => 'object',
- );
- }
-
- return $args;
-}
-add_filter( 'register_block_type_args', 'gutenberg_register_lock_attribute' );
diff --git a/lib/compat/wordpress-6.0/class-gutenberg-rest-edit-site-export-controller.php b/lib/compat/wordpress-6.0/class-gutenberg-rest-edit-site-export-controller.php
deleted file mode 100644
index e4cffb2bff268..0000000000000
--- a/lib/compat/wordpress-6.0/class-gutenberg-rest-edit-site-export-controller.php
+++ /dev/null
@@ -1,89 +0,0 @@
-namespace = 'wp-block-editor/v1';
- $this->rest_base = 'export';
- }
-
- /**
- * Registers the necessary REST API routes.
- */
- public function register_routes() {
- register_rest_route(
- $this->namespace,
- '/' . $this->rest_base,
- array(
- array(
- 'methods' => WP_REST_Server::READABLE,
- 'callback' => array( $this, 'export' ),
- 'permission_callback' => array( $this, 'permissions_check' ),
- ),
- ),
- true // Override core route if already exists (WP 5.9).
- );
- }
-
- /**
- * Checks whether a given request has permission to export.
- *
- * @return WP_Error|bool True if the request has access, or WP_Error object.
- */
- public function permissions_check() {
- if ( current_user_can( 'edit_theme_options' ) ) {
- return true;
- }
-
- return new WP_Error(
- 'rest_cannot_export_templates',
- __( 'Sorry, you are not allowed to export templates and template parts.', 'gutenberg' ),
- array( 'status' => rest_authorization_required_code() )
- );
- }
-
- /**
- * Output a ZIP file with an export of the current templates
- * template parts, theme.json and index.php from the site editor,
- * and close the connection.
- *
- * @return WP_Error|void
- */
- public function export() {
- // Generate the export file.
- $filename = gutenberg_generate_block_templates_export_file();
-
- if ( is_wp_error( $filename ) ) {
- $filename->add_data( array( 'status' => 500 ) );
-
- return $filename;
- }
-
- $theme_name = basename( get_stylesheet() );
-
- header( 'Content-Type: application/zip' );
- header( 'Content-Disposition: attachment; filename=' . $theme_name . '.zip' );
- header( 'Content-Length: ' . filesize( $filename ) );
- flush();
- readfile( $filename );
- unlink( $filename );
- exit;
- }
-}
diff --git a/lib/compat/wordpress-6.0/class-gutenberg-rest-global-styles-controller.php b/lib/compat/wordpress-6.0/class-gutenberg-rest-global-styles-controller.php
deleted file mode 100644
index 5c5e7dbde73e7..0000000000000
--- a/lib/compat/wordpress-6.0/class-gutenberg-rest-global-styles-controller.php
+++ /dev/null
@@ -1,231 +0,0 @@
-namespace,
- '/' . $this->rest_base . '/themes/(?P[\/\s%\w\.\(\)\[\]\@_\-]+)/variations',
- array(
- array(
- 'methods' => WP_REST_Server::READABLE,
- 'callback' => array( $this, 'get_theme_items' ),
- 'permission_callback' => array( $this, 'get_theme_items_permissions_check' ),
- 'args' => array(
- 'stylesheet' => array(
- 'description' => __( 'The theme identifier', 'gutenberg' ),
- 'type' => 'string',
- ),
- ),
- ),
- )
- );
-
- parent::register_routes();
- }
-
- /**
- * Checks if a given request has access to read a single theme global styles config.
- *
- * @param WP_REST_Request $request Full details about the request.
- * @return true|WP_Error True if the request has read access for the item, WP_Error object otherwise.
- */
- public function get_theme_items_permissions_check( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
- // Verify if the current user has edit_theme_options capability.
- // This capability is required to edit/view/delete templates.
- if ( ! current_user_can( 'edit_theme_options' ) ) {
- return new WP_Error(
- 'rest_cannot_manage_global_styles',
- __( 'Sorry, you are not allowed to access the global styles on this site.', 'gutenberg' ),
- array(
- 'status' => rest_authorization_required_code(),
- )
- );
- }
-
- return true;
- }
-
- /**
- * Prepares a single global styles config for update.
- *
- * @since 5.9.0
- *
- * @param WP_REST_Request $request Request object.
- * @return stdClass Changes to pass to wp_update_post.
- */
- protected function prepare_item_for_database( $request ) {
- $changes = new stdClass();
- $changes->ID = $request['id'];
- $post = get_post( $request['id'] );
- $existing_config = array();
- if ( $post ) {
- $existing_config = json_decode( $post->post_content, true );
- $json_decoding_error = json_last_error();
- if ( JSON_ERROR_NONE !== $json_decoding_error || ! isset( $existing_config['isGlobalStylesUserThemeJSON'] ) ||
- ! $existing_config['isGlobalStylesUserThemeJSON'] ) {
- $existing_config = array();
- }
- }
- if ( isset( $request['styles'] ) || isset( $request['settings'] ) ) {
- $config = array();
- if ( isset( $request['styles'] ) ) {
- $config['styles'] = $request['styles'];
- } elseif ( isset( $existing_config['styles'] ) ) {
- $config['styles'] = $existing_config['styles'];
- }
- if ( isset( $request['settings'] ) ) {
- $config['settings'] = $request['settings'];
- } elseif ( isset( $existing_config['settings'] ) ) {
- $config['settings'] = $existing_config['settings'];
- }
- $config['isGlobalStylesUserThemeJSON'] = true;
- $config['version'] = WP_Theme_JSON_Gutenberg::LATEST_SCHEMA;
- $changes->post_content = wp_json_encode( $config );
- }
- // Post title.
- if ( isset( $request['title'] ) ) {
- if ( is_string( $request['title'] ) ) {
- $changes->post_title = $request['title'];
- } elseif ( ! empty( $request['title']['raw'] ) ) {
- $changes->post_title = $request['title']['raw'];
- }
- }
- return $changes;
- }
-
- /**
- * Prepare a global styles config output for response.
- *
- * @since 5.9.0
- *
- * @param WP_Post $post Global Styles post object.
- * @param WP_REST_Request $request Request object.
- * @return WP_REST_Response Response object.
- */
- public function prepare_item_for_response( $post, $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
- $raw_config = json_decode( $post->post_content, true );
- $is_global_styles_user_theme_json = isset( $raw_config['isGlobalStylesUserThemeJSON'] ) && true === $raw_config['isGlobalStylesUserThemeJSON'];
- $config = array();
- if ( $is_global_styles_user_theme_json ) {
- $config = ( new WP_Theme_JSON_Gutenberg( $raw_config, 'custom' ) )->get_raw_data();
- }
- // Base fields for every post.
- $data = array();
- $fields = $this->get_fields_for_response( $request );
- if ( rest_is_field_included( 'id', $fields ) ) {
- $data['id'] = $post->ID;
- }
- if ( rest_is_field_included( 'title', $fields ) ) {
- $data['title'] = array();
- }
- if ( rest_is_field_included( 'title.raw', $fields ) ) {
- $data['title']['raw'] = $post->post_title;
- }
- if ( rest_is_field_included( 'title.rendered', $fields ) ) {
- add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
- $data['title']['rendered'] = get_the_title( $post->ID );
- remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
- }
- if ( rest_is_field_included( 'settings', $fields ) ) {
- $data['settings'] = ! empty( $config['settings'] ) && $is_global_styles_user_theme_json ? $config['settings'] : new stdClass();
- }
- if ( rest_is_field_included( 'styles', $fields ) ) {
- $data['styles'] = ! empty( $config['styles'] ) && $is_global_styles_user_theme_json ? $config['styles'] : new stdClass();
- }
- $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
- $data = $this->add_additional_fields_to_object( $data, $request );
- $data = $this->filter_response_by_context( $data, $context );
- // Wrap the data in a response object.
- $response = rest_ensure_response( $data );
- $links = $this->prepare_links( $post->ID );
- $response->add_links( $links );
- if ( ! empty( $links['self']['href'] ) ) {
- $actions = $this->get_available_actions();
- $self = $links['self']['href'];
- foreach ( $actions as $rel ) {
- $response->add_link( $rel, $self );
- }
- }
- return $response;
- }
-
- /**
- * Returns the given theme global styles config.
- *
- * @since 5.9.0
- *
- * @param WP_REST_Request $request The request instance.
- * @return WP_REST_Response|WP_Error
- */
- public function get_theme_item( $request ) {
- if ( get_stylesheet() !== $request['stylesheet'] ) {
- // This endpoint only supports the active theme for now.
- return new WP_Error(
- 'rest_theme_not_found',
- __( 'Theme not found.', 'gutenberg' ),
- array( 'status' => 404 )
- );
- }
- $theme = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data( 'theme' );
- $data = array();
- $fields = $this->get_fields_for_response( $request );
- if ( rest_is_field_included( 'settings', $fields ) ) {
- $data['settings'] = $theme->get_settings();
- }
- if ( rest_is_field_included( 'styles', $fields ) ) {
- $raw_data = $theme->get_raw_data();
- $data['styles'] = isset( $raw_data['styles'] ) ? $raw_data['styles'] : array();
- }
- $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
- $data = $this->add_additional_fields_to_object( $data, $request );
- $data = $this->filter_response_by_context( $data, $context );
- $response = rest_ensure_response( $data );
- $links = array(
- 'self' => array(
- 'href' => rest_url( sprintf( '%s/%s/themes/%s', $this->namespace, $this->rest_base, $request['stylesheet'] ) ),
- ),
- );
- $response->add_links( $links );
- return $response;
- }
-
-
- /**
- * Returns the given theme global styles variations.
- *
- * @param WP_REST_Request $request The request instance.
- *
- * @return WP_REST_Response|WP_Error
- */
- public function get_theme_items( $request ) {
- if ( get_stylesheet() !== $request['stylesheet'] ) {
- // This endpoint only supports the active theme for now.
- return new WP_Error(
- 'rest_theme_not_found',
- __( 'Theme not found.', 'gutenberg' ),
- array( 'status' => 404 )
- );
- }
-
- $variations = WP_Theme_JSON_Resolver_Gutenberg::get_style_variations();
- $response = rest_ensure_response( $variations );
-
- return $response;
- }
-
-}
diff --git a/lib/compat/wordpress-6.0/class-gutenberg-rest-pattern-directory-controller-6-0.php b/lib/compat/wordpress-6.0/class-gutenberg-rest-pattern-directory-controller-6-0.php
deleted file mode 100644
index 331e6015edb0c..0000000000000
--- a/lib/compat/wordpress-6.0/class-gutenberg-rest-pattern-directory-controller-6-0.php
+++ /dev/null
@@ -1,48 +0,0 @@
-= 6.0.
- *
- * @param array $query_args Query arguments to generate a transient key from.
- * @return string Transient key.
- */
- protected function get_transient_key( $query_args ) {
- if ( method_exists( get_parent_class( $this ), __FUNCTION__ ) ) {
- return parent::get_transient_key( $query_args );
- }
-
- if ( isset( $query_args['slug'] ) ) {
- // This is an additional precaution because the "sort" function expects an array.
- $query_args['slug'] = wp_parse_list( $query_args['slug'] );
-
- // Empty arrays should not affect the transient key.
- if ( empty( $query_args['slug'] ) ) {
- unset( $query_args['slug'] );
- } else {
- // Sort the array so that the transient key doesn't depend on the order of slugs.
- sort( $query_args['slug'] );
- }
- }
-
- return 'wp_remote_block_patterns_' . md5( serialize( $query_args ) );
- }
-}
diff --git a/lib/compat/wordpress-6.0/class-wp-rest-block-pattern-categories-controller.php b/lib/compat/wordpress-6.0/class-wp-rest-block-pattern-categories-controller.php
deleted file mode 100644
index 0f60781dae106..0000000000000
--- a/lib/compat/wordpress-6.0/class-wp-rest-block-pattern-categories-controller.php
+++ /dev/null
@@ -1,152 +0,0 @@
-namespace = 'wp/v2';
- $this->rest_base = 'block-patterns/categories';
- }
-
- /**
- * Registers the routes for the objects of the controller.
- *
- * @see register_rest_route()
- *
- * @since 6.0.0
- */
- public function register_routes() {
- register_rest_route(
- $this->namespace,
- '/' . $this->rest_base,
- array(
- array(
- 'methods' => WP_REST_Server::READABLE,
- 'callback' => array( $this, 'get_items' ),
- 'permission_callback' => array( $this, 'get_items_permissions_check' ),
- ),
- 'schema' => array( $this, 'get_public_item_schema' ),
- )
- );
- }
-
- /**
- * Checks whether a given request has permission to read block patterns.
- *
- * @since 6.0.0
- *
- * @param WP_REST_Request $request Full details about the request.
- *
- * @return WP_Error|bool True if the request has read access, WP_Error object otherwise.
- */
- public function get_items_permissions_check( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
- if ( current_user_can( 'edit_posts' ) ) {
- return true;
- }
-
- foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) {
- if ( current_user_can( $post_type->cap->edit_posts ) ) {
- return true;
- }
- }
-
- return new WP_Error(
- 'rest_cannot_view',
- __( 'Sorry, you are not allowed to view the registered block pattern categories.', 'gutenberg' ),
- array( 'status' => rest_authorization_required_code() )
- );
- }
-
- /**
- * Retrieves all block pattern categories.
- *
- * @since 6.0.0
- *
- * @param WP_REST_Request $request Full details about the request.
- *
- * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
- */
- public function get_items( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
- $response = array();
- $categories = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered();
- foreach ( $categories as $category ) {
- $prepared_category = $this->prepare_item_for_response( $category, $request );
- $response[] = $this->prepare_response_for_collection( $prepared_category );
- }
- return rest_ensure_response( $response );
- }
-
- /**
- * Prepare a raw block pattern category before it gets output in a REST API response.
- *
- * @since 6.0.0
- *
- * @param object $item Raw category as registered, before any changes.
- * @param WP_REST_Request $request Request object.
- * @return WP_REST_Response
- */
- public function prepare_item_for_response( $item, $request ) {
- $fields = $this->get_fields_for_response( $request );
- $keys = array( 'name', 'label' );
- $data = array();
- foreach ( $keys as $key ) {
- if ( rest_is_field_included( $key, $fields ) ) {
- $data[ $key ] = $item[ $key ];
- }
- }
-
- $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
- $data = $this->add_additional_fields_to_object( $data, $request );
- $data = $this->filter_response_by_context( $data, $context );
- return rest_ensure_response( $data );
- }
-
- /**
- * Retrieves the block pattern category schema, conforming to JSON Schema.
- *
- * @since 6.0.0
- *
- * @return array Item schema data.
- */
- public function get_item_schema() {
- $schema = array(
- '$schema' => 'http://json-schema.org/draft-04/schema#',
- 'title' => 'block-pattern-category',
- 'type' => 'object',
- 'properties' => array(
- 'name' => array(
- 'description' => __( 'The category name.', 'gutenberg' ),
- 'type' => 'string',
- 'readonly' => true,
- 'context' => array( 'view', 'edit', 'embed' ),
- ),
- 'label' => array(
- 'description' => __( 'The category label, in human readable format.', 'gutenberg' ),
- 'type' => 'string',
- 'readonly' => true,
- 'context' => array( 'view', 'edit', 'embed' ),
- ),
- ),
- );
-
- return $this->add_additional_fields_schema( $schema );
- }
-}
diff --git a/lib/compat/wordpress-6.0/class-wp-theme-json-6-0.php b/lib/compat/wordpress-6.0/class-wp-theme-json-6-0.php
deleted file mode 100644
index 07820ccbd1dbe..0000000000000
--- a/lib/compat/wordpress-6.0/class-wp-theme-json-6-0.php
+++ /dev/null
@@ -1,680 +0,0 @@
- array( 'color', 'gradient' ),
- 'background-color' => array( 'color', 'background' ),
- 'border-radius' => array( 'border', 'radius' ),
- 'border-top-left-radius' => array( 'border', 'radius', 'topLeft' ),
- 'border-top-right-radius' => array( 'border', 'radius', 'topRight' ),
- 'border-bottom-left-radius' => array( 'border', 'radius', 'bottomLeft' ),
- 'border-bottom-right-radius' => array( 'border', 'radius', 'bottomRight' ),
- 'border-color' => array( 'border', 'color' ),
- 'border-width' => array( 'border', 'width' ),
- 'border-style' => array( 'border', 'style' ),
- 'border-top-color' => array( 'border', 'top', 'color' ),
- 'border-top-width' => array( 'border', 'top', 'width' ),
- 'border-top-style' => array( 'border', 'top', 'style' ),
- 'border-right-color' => array( 'border', 'right', 'color' ),
- 'border-right-width' => array( 'border', 'right', 'width' ),
- 'border-right-style' => array( 'border', 'right', 'style' ),
- 'border-bottom-color' => array( 'border', 'bottom', 'color' ),
- 'border-bottom-width' => array( 'border', 'bottom', 'width' ),
- 'border-bottom-style' => array( 'border', 'bottom', 'style' ),
- 'border-left-color' => array( 'border', 'left', 'color' ),
- 'border-left-width' => array( 'border', 'left', 'width' ),
- 'border-left-style' => array( 'border', 'left', 'style' ),
- 'color' => array( 'color', 'text' ),
- 'font-family' => array( 'typography', 'fontFamily' ),
- 'font-size' => array( 'typography', 'fontSize' ),
- 'font-style' => array( 'typography', 'fontStyle' ),
- 'font-weight' => array( 'typography', 'fontWeight' ),
- 'letter-spacing' => array( 'typography', 'letterSpacing' ),
- 'line-height' => array( 'typography', 'lineHeight' ),
- 'margin' => array( 'spacing', 'margin' ),
- 'margin-top' => array( 'spacing', 'margin', 'top' ),
- 'margin-right' => array( 'spacing', 'margin', 'right' ),
- 'margin-bottom' => array( 'spacing', 'margin', 'bottom' ),
- 'margin-left' => array( 'spacing', 'margin', 'left' ),
- 'padding' => array( 'spacing', 'padding' ),
- 'padding-top' => array( 'spacing', 'padding', 'top' ),
- 'padding-right' => array( 'spacing', 'padding', 'right' ),
- 'padding-bottom' => array( 'spacing', 'padding', 'bottom' ),
- 'padding-left' => array( 'spacing', 'padding', 'left' ),
- '--wp--style--block-gap' => array( 'spacing', 'blockGap' ),
- 'text-decoration' => array( 'typography', 'textDecoration' ),
- 'text-transform' => array( 'typography', 'textTransform' ),
- 'filter' => array( 'filter', 'duotone' ),
- );
-
- /**
- * Presets are a set of values that serve
- * to bootstrap some styles: colors, font sizes, etc.
- *
- * They are a unkeyed array of values such as:
- *
- * ```php
- * array(
- * array(
- * 'slug' => 'unique-name-within-the-set',
- * 'name' => 'Name for the UI',
- * => 'value'
- * ),
- * )
- * ```
- *
- * This contains the necessary metadata to process them:
- *
- * - path => Where to find the preset within the settings section.
- * - prevent_override => Disables override of default presets by theme presets.
- * The relationship between whether to override the defaults
- * and whether the defaults are enabled is inverse:
- * - If defaults are enabled => theme presets should not be overriden
- * - If defaults are disabled => theme presets should be overriden
- * For example, a theme sets defaultPalette to false,
- * making the default palette hidden from the user.
- * In that case, we want all the theme presets to be present,
- * so they should override the defaults by setting this false.
- * - use_default_names => whether to use the default names
- * - value_key => the key that represents the value
- * - value_func => optionally, instead of value_key, a function to generate
- * the value that takes a preset as an argument
- * (either value_key or value_func should be present)
- * - css_vars => template string to use in generating the CSS Custom Property.
- * Example output: "--wp--preset--duotone--blue: " will generate as many CSS Custom Properties as presets defined
- * substituting the $slug for the slug's value for each preset value.
- * - classes => array containing a structure with the classes to
- * generate for the presets, where for each array item
- * the key is the class name and the value the property name.
- * The "$slug" substring will be replaced by the slug of each preset.
- * For example:
- * 'classes' => array(
- * '.has-$slug-color' => 'color',
- * '.has-$slug-background-color' => 'background-color',
- * '.has-$slug-border-color' => 'border-color',
- * )
- * - properties => array of CSS properties to be used by kses to
- * validate the content of each preset
- * by means of the remove_insecure_properties method.
- */
- const PRESETS_METADATA = array(
- array(
- 'path' => array( 'color', 'palette' ),
- 'prevent_override' => array( 'color', 'defaultPalette' ),
- 'use_default_names' => false,
- 'value_key' => 'color',
- 'css_vars' => '--wp--preset--color--$slug',
- 'classes' => array(
- '.has-$slug-color' => 'color',
- '.has-$slug-background-color' => 'background-color',
- '.has-$slug-border-color' => 'border-color',
- ),
- 'properties' => array( 'color', 'background-color', 'border-color' ),
- ),
- array(
- 'path' => array( 'color', 'gradients' ),
- 'prevent_override' => array( 'color', 'defaultGradients' ),
- 'use_default_names' => false,
- 'value_key' => 'gradient',
- 'css_vars' => '--wp--preset--gradient--$slug',
- 'classes' => array( '.has-$slug-gradient-background' => 'background' ),
- 'properties' => array( 'background' ),
- ),
- array(
- 'path' => array( 'color', 'duotone' ),
- 'prevent_override' => array( 'color', 'defaultDuotone' ),
- 'use_default_names' => false,
- 'value_func' => 'gutenberg_get_duotone_filter_property',
- 'css_vars' => '--wp--preset--duotone--$slug',
- 'classes' => array(),
- 'properties' => array( 'filter' ),
- ),
- array(
- 'path' => array( 'typography', 'fontSizes' ),
- 'prevent_override' => false,
- 'use_default_names' => true,
- 'value_key' => 'size',
- 'css_vars' => '--wp--preset--font-size--$slug',
- 'classes' => array( '.has-$slug-font-size' => 'font-size' ),
- 'properties' => array( 'font-size' ),
- ),
- array(
- 'path' => array( 'typography', 'fontFamilies' ),
- 'prevent_override' => false,
- 'use_default_names' => false,
- 'value_key' => 'fontFamily',
- 'css_vars' => '--wp--preset--font-family--$slug',
- 'classes' => array( '.has-$slug-font-family' => 'font-family' ),
- 'properties' => array( 'font-family' ),
- ),
- );
-
- /**
- * The top-level keys a theme.json can have.
- *
- * @var string[]
- */
- const VALID_TOP_LEVEL_KEYS = array(
- 'customTemplates',
- 'patterns',
- 'settings',
- 'styles',
- 'templateParts',
- 'version',
- 'title',
- );
-
- const APPEARANCE_TOOLS_OPT_INS = array(
- array( 'border', 'color' ),
- array( 'border', 'radius' ),
- array( 'border', 'style' ),
- array( 'border', 'width' ),
- array( 'color', 'link' ),
- array( 'spacing', 'blockGap' ),
- array( 'spacing', 'margin' ),
- array( 'spacing', 'padding' ),
- array( 'typography', 'lineHeight' ),
- );
-
- /**
- * The valid properties under the settings key.
- *
- * @var array
- */
- const VALID_SETTINGS = array(
- 'appearanceTools' => null,
- 'border' => array(
- 'color' => null,
- 'radius' => null,
- 'style' => null,
- 'width' => null,
- ),
- 'color' => array(
- 'background' => null,
- 'custom' => null,
- 'customDuotone' => null,
- 'customGradient' => null,
- 'defaultDuotone' => null,
- 'defaultGradients' => null,
- 'defaultPalette' => null,
- 'duotone' => null,
- 'gradients' => null,
- 'link' => null,
- 'palette' => null,
- 'text' => null,
- ),
- 'custom' => null,
- 'layout' => array(
- 'contentSize' => null,
- 'wideSize' => null,
- ),
- 'spacing' => array(
- 'blockGap' => null,
- 'margin' => null,
- 'padding' => null,
- 'units' => null,
- ),
- 'typography' => array(
- 'customFontSize' => null,
- 'dropCap' => null,
- 'fontFamilies' => null,
- 'fontSizes' => null,
- 'fontStyle' => null,
- 'fontWeight' => null,
- 'letterSpacing' => null,
- 'lineHeight' => null,
- 'textDecoration' => null,
- 'textTransform' => null,
- ),
- );
-
- /**
- * The valid properties under the styles key.
- *
- * @var array
- */
- const VALID_STYLES = array(
- 'border' => array(
- 'color' => null,
- 'radius' => null,
- 'style' => null,
- 'width' => null,
- 'top' => null,
- 'right' => null,
- 'bottom' => null,
- 'left' => null,
- ),
- 'color' => array(
- 'background' => null,
- 'gradient' => null,
- 'text' => null,
- ),
- 'filter' => array(
- 'duotone' => null,
- ),
- 'spacing' => array(
- 'margin' => null,
- 'padding' => null,
- 'blockGap' => 'top',
- ),
- 'typography' => array(
- 'fontFamily' => null,
- 'fontSize' => null,
- 'fontStyle' => null,
- 'fontWeight' => null,
- 'letterSpacing' => null,
- 'lineHeight' => null,
- 'textDecoration' => null,
- 'textTransform' => null,
- ),
- );
-
- /**
- * Returns the current theme's wanted patterns(slugs) to be
- * registered from Pattern Directory.
- *
- * @return array
- */
- public function get_patterns() {
- if ( isset( $this->theme_json['patterns'] ) && is_array( $this->theme_json['patterns'] ) ) {
- return $this->theme_json['patterns'];
- }
- return array();
- }
-
- /**
- * Converts each style section into a list of rulesets
- * containing the block styles to be appended to the stylesheet.
- *
- * See glossary at https://developer.mozilla.org/en-US/docs/Web/CSS/Syntax
- *
- * For each section this creates a new ruleset such as:
- *
- * block-selector {
- * style-property-one: value;
- * }
- *
- * @param array $style_nodes Nodes with styles.
- * @return string The new stylesheet.
- */
- protected function get_block_classes( $style_nodes ) {
- $block_rules = '';
-
- foreach ( $style_nodes as $metadata ) {
- if ( null === $metadata['selector'] ) {
- continue;
- }
-
- $node = _wp_array_get( $this->theme_json, $metadata['path'], array() );
- $selector = $metadata['selector'];
- $settings = _wp_array_get( $this->theme_json, array( 'settings' ) );
- $declarations = static::compute_style_properties( $node, $settings );
-
- // 1. Separate the ones who use the general selector
- // and the ones who use the duotone selector.
- $declarations_duotone = array();
- foreach ( $declarations as $index => $declaration ) {
- if ( 'filter' === $declaration['name'] ) {
- unset( $declarations[ $index ] );
- $declarations_duotone[] = $declaration;
- }
- }
-
- /*
- * Reset default browser margin on the root body element.
- * This is set on the root selector **before** generating the ruleset
- * from the `theme.json`. This is to ensure that if the `theme.json` declares
- * `margin` in its `spacing` declaration for the `body` element then these
- * user-generated values take precedence in the CSS cascade.
- * @link https://github.com/WordPress/gutenberg/issues/36147.
- */
- if ( static::ROOT_BLOCK_SELECTOR === $selector ) {
- $block_rules .= 'body { margin: 0; }';
- }
-
- // 2. Generate the rules that use the general selector.
- $block_rules .= static::to_ruleset( $selector, $declarations );
-
- // 3. Generate the rules that use the duotone selector.
- if ( isset( $metadata['duotone'] ) && ! empty( $declarations_duotone ) ) {
- $selector_duotone = static::scope_selector( $metadata['selector'], $metadata['duotone'] );
- $block_rules .= static::to_ruleset( $selector_duotone, $declarations_duotone );
- }
-
- if ( static::ROOT_BLOCK_SELECTOR === $selector ) {
- $block_rules .= '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }';
- $block_rules .= '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }';
- $block_rules .= '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
-
- $has_block_gap_support = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'blockGap' ) ) !== null;
- if ( $has_block_gap_support ) {
- $block_rules .= '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }';
- $block_rules .= '.wp-site-blocks > * + * { margin-block-start: var( --wp--style--block-gap ); }';
- }
- }
- }
-
- return $block_rules;
- }
-
- /**
- * Merge new incoming data.
- *
- * @param WP_Theme_JSON $incoming Data to merge.
- */
- public function merge( $incoming ) {
- $incoming_data = $incoming->get_raw_data();
- $this->theme_json = array_replace_recursive( $this->theme_json, $incoming_data );
-
- /*
- * The array_replace_recursive algorithm merges at the leaf level,
- * but we don't want leaf arrays to be merged, so we overwrite it.
- *
- * For leaf values that are sequential arrays it will use the numeric indexes for replacement.
- * We rather replace the existing with the incoming value, if it exists.
- * This is the case of spacing.units.
- *
- * For leaf values that are associative arrays it will merge them as expected.
- * This is also not the behavior we want for the current associative arrays (presets).
- * We rather replace the existing with the incoming value, if it exists.
- * This happens, for example, when we merge data from theme.json upon existing
- * theme supports or when we merge anything coming from the same source twice.
- * This is the case of color.palette, color.gradients, color.duotone,
- * typography.fontSizes, or typography.fontFamilies.
- *
- * Additionally, for some preset types, we also want to make sure the
- * values they introduce don't conflict with default values. We do so
- * by checking the incoming slugs for theme presets and compare them
- * with the equivalent default presets: if a slug is present as a default
- * we remove it from the theme presets.
- */
- $nodes = static::get_setting_nodes( $incoming_data );
- $slugs_global = static::get_default_slugs( $this->theme_json, array( 'settings' ) );
- foreach ( $nodes as $node ) {
- $slugs_node = static::get_default_slugs( $this->theme_json, $node['path'] );
- $slugs = array_merge_recursive( $slugs_global, $slugs_node );
-
- // Replace the spacing.units.
- $path = array_merge( $node['path'], array( 'spacing', 'units' ) );
- $content = _wp_array_get( $incoming_data, $path, null );
- if ( isset( $content ) ) {
- _wp_array_set( $this->theme_json, $path, $content );
- }
-
- // Replace the presets.
- foreach ( static::PRESETS_METADATA as $preset ) {
- $override_preset = ! static::get_metadata_boolean( $this->theme_json['settings'], $preset['prevent_override'], true );
-
- foreach ( static::VALID_ORIGINS as $origin ) {
- $base_path = array_merge( $node['path'], $preset['path'] );
- $path = array_merge( $base_path, array( $origin ) );
- $content = _wp_array_get( $incoming_data, $path, null );
- if ( ! isset( $content ) ) {
- continue;
- }
-
- if ( 'theme' === $origin && $preset['use_default_names'] ) {
- foreach ( $content as &$item ) {
- if ( ! array_key_exists( 'name', $item ) ) {
- $name = static::get_name_from_defaults( $item['slug'], $base_path );
- if ( null !== $name ) {
- $item['name'] = $name;
- }
- }
- }
- }
-
- if (
- ( 'theme' !== $origin ) ||
- ( 'theme' === $origin && $override_preset )
- ) {
- _wp_array_set( $this->theme_json, $path, $content );
- } else {
- $slugs_for_preset = _wp_array_get( $slugs, $preset['path'], array() );
- $content = static::filter_slugs( $content, $slugs_for_preset );
- _wp_array_set( $this->theme_json, $path, $content );
- }
- }
- }
- }
- }
-
- /**
- * Converts all filter (duotone) presets into SVGs.
- *
- * @param array $origins List of origins to process.
- *
- * @return string SVG filters.
- */
- public function get_svg_filters( $origins ) {
- $blocks_metadata = static::get_blocks_metadata();
- $setting_nodes = static::get_setting_nodes( $this->theme_json, $blocks_metadata );
-
- $filters = '';
- foreach ( $setting_nodes as $metadata ) {
- $node = _wp_array_get( $this->theme_json, $metadata['path'], array() );
- if ( empty( $node['color']['duotone'] ) ) {
- continue;
- }
-
- $duotone_presets = $node['color']['duotone'];
-
- foreach ( $origins as $origin ) {
- if ( ! isset( $duotone_presets[ $origin ] ) ) {
- continue;
- }
- foreach ( $duotone_presets[ $origin ] as $duotone_preset ) {
- $filters .= gutenberg_get_duotone_filter_svg( $duotone_preset );
- }
- }
- }
-
- return $filters;
- }
-
- /**
- * For metadata values that can either be booleans or paths to booleans, gets the value.
- *
- * ```php
- * $data = array(
- * 'color' => array(
- * 'defaultPalette' => true
- * )
- * );
- *
- * static::get_metadata_boolean( $data, false );
- * // => false
- *
- * static::get_metadata_boolean( $data, array( 'color', 'defaultPalette' ) );
- * // => true
- * ```
- *
- * @param array $data The data to inspect.
- * @param bool|array $path Boolean or path to a boolean.
- * @param bool $default Default value if the referenced path is missing.
- * @return boolean
- */
- protected static function get_metadata_boolean( $data, $path, $default = false ) {
- if ( is_bool( $path ) ) {
- return $path;
- }
-
- if ( is_array( $path ) ) {
- $value = _wp_array_get( $data, $path );
- if ( null !== $value ) {
- return $value;
- }
- }
-
- return $default;
- }
-
- /**
- * Returns a valid theme.json as provided by a theme.
- *
- * Unlike get_raw_data() this returns the presets flattened, as provided by a theme.
- * This also uses appearanceTools instead of their opt-ins if all of them are true.
- *
- * @return string[]
- */
- public function get_data() {
- $output = $this->theme_json;
- $nodes = static::get_setting_nodes( $output );
-
- /**
- * Flatten the theme & custom origins into a single one.
- *
- * For example, the following:
- *
- * {
- * "settings": {
- * "color": {
- * "palette": {
- * "theme": [ {} ],
- * "custom": [ {} ]
- * }
- * }
- * }
- * }
- *
- * will be converted to:
- *
- * {
- * "settings": {
- * "color": {
- * "palette": [ {} ]
- * }
- * }
- * }
- */
- foreach ( $nodes as $node ) {
- foreach ( static::PRESETS_METADATA as $preset_metadata ) {
- $path = array_merge( $node['path'], $preset_metadata['path'] );
- $preset = _wp_array_get( $output, $path, null );
- if ( null === $preset ) {
- continue;
- }
-
- $items = array();
- if ( isset( $preset['theme'] ) ) {
- foreach ( $preset['theme'] as $item ) {
- $slug = $item['slug'];
- unset( $item['slug'] );
- $items[ $slug ] = $item;
- }
- }
- if ( isset( $preset['custom'] ) ) {
- foreach ( $preset['custom'] as $item ) {
- $slug = $item['slug'];
- unset( $item['slug'] );
- $items[ $slug ] = $item;
- }
- }
- $flattened_preset = array();
- foreach ( $items as $slug => $value ) {
- $flattened_preset[] = array_merge( array( 'slug' => (string) $slug ), $value );
- }
- _wp_array_set( $output, $path, $flattened_preset );
- }
- }
-
- // If all of the static::APPEARANCE_TOOLS_OPT_INS are true,
- // this code unsets them and sets 'appearanceTools' instead.
- foreach ( $nodes as $node ) {
- $all_opt_ins_are_set = true;
- foreach ( static::APPEARANCE_TOOLS_OPT_INS as $opt_in_path ) {
- $full_path = array_merge( $node['path'], $opt_in_path );
- // Use "unset prop" as a marker instead of "null" because
- // "null" can be a valid value for some props (e.g. blockGap).
- $opt_in_value = _wp_array_get( $output, $full_path, 'unset prop' );
- if ( 'unset prop' === $opt_in_value ) {
- $all_opt_ins_are_set = false;
- break;
- }
- }
-
- if ( $all_opt_ins_are_set ) {
- _wp_array_set( $output, array_merge( $node['path'], array( 'appearanceTools' ) ), true );
- foreach ( static::APPEARANCE_TOOLS_OPT_INS as $opt_in_path ) {
- $full_path = array_merge( $node['path'], $opt_in_path );
- // Use "unset prop" as a marker instead of "null" because
- // "null" can be a valid value for some props (e.g. blockGap).
- $opt_in_value = _wp_array_get( $output, $full_path, 'unset prop' );
- if ( true !== $opt_in_value ) {
- continue;
- }
-
- // The following could be improved to be path independent.
- // At the moment it relies on a couple of assumptions:
- //
- // - all opt-ins having a path of size 2.
- // - there's two sources of settings: the top-level and the block-level.
- if (
- ( 1 === count( $node['path'] ) ) &&
- ( 'settings' === $node['path'][0] )
- ) {
- // Top-level settings.
- unset( $output['settings'][ $opt_in_path[0] ][ $opt_in_path[1] ] );
- if ( empty( $output['settings'][ $opt_in_path[0] ] ) ) {
- unset( $output['settings'][ $opt_in_path[0] ] );
- }
- } elseif (
- ( 3 === count( $node['path'] ) ) &&
- ( 'settings' === $node['path'][0] ) &&
- ( 'blocks' === $node['path'][1] )
- ) {
- // Block-level settings.
- $block_name = $node['path'][2];
- unset( $output['settings']['blocks'][ $block_name ][ $opt_in_path[0] ][ $opt_in_path[1] ] );
- if ( empty( $output['settings']['blocks'][ $block_name ][ $opt_in_path[0] ] ) ) {
- unset( $output['settings']['blocks'][ $block_name ][ $opt_in_path[0] ] );
- }
- }
- }
- }
- }
-
- wp_recursive_ksort( $output );
-
- return $output;
- }
-
- /**
- * Enables some settings.
- *
- * @since 5.9.0
- *
- * @param array $context The context to which the settings belong.
- */
- protected static function do_opt_in_into_settings( &$context ) {
- foreach ( static::APPEARANCE_TOOLS_OPT_INS as $path ) {
- // Use "unset prop" as a marker instead of "null" because
- // "null" can be a valid value for some props (e.g. blockGap).
- if ( 'unset prop' === _wp_array_get( $context, $path, 'unset prop' ) ) {
- _wp_array_set( $context, $path, true );
- }
- }
-
- unset( $context['appearanceTools'] );
- }
-}
diff --git a/lib/compat/wordpress-6.0/class-wp-theme-json-resolver-6-0.php b/lib/compat/wordpress-6.0/class-wp-theme-json-resolver-6-0.php
deleted file mode 100644
index 832448ecf0044..0000000000000
--- a/lib/compat/wordpress-6.0/class-wp-theme-json-resolver-6-0.php
+++ /dev/null
@@ -1,223 +0,0 @@
- true ) );
- if ( null === static::$theme ) {
- $wp_theme = wp_get_theme();
- $theme_json_data = static::read_json_file( static::get_file_path_from_theme( 'theme.json' ) );
- $theme_json_data = static::translate( $theme_json_data, $wp_theme->get( 'TextDomain' ) );
- static::$theme = new WP_Theme_JSON_Gutenberg( $theme_json_data );
-
- if ( $wp_theme->parent() ) {
- // Get parent theme.json.
- $parent_theme_json_data = static::read_json_file( static::get_file_path_from_theme( 'theme.json', true ) );
- $parent_theme_json_data = static::translate( $parent_theme_json_data, $wp_theme->parent()->get( 'TextDomain' ) );
- $parent_theme = new WP_Theme_JSON_Gutenberg( $parent_theme_json_data );
-
- // Merge the child theme.json into the parent theme.json.
- // The child theme takes precedence over the parent.
- $parent_theme->merge( static::$theme );
- static::$theme = $parent_theme;
- }
- }
-
- if ( ! $options['with_supports'] ) {
- return static::$theme;
- }
-
- /*
- * We want the presets and settings declared in theme.json
- * to override the ones declared via theme supports.
- * So we take theme supports, transform it to theme.json shape
- * and merge the static::$theme upon that.
- */
- $theme_support_data = WP_Theme_JSON_Gutenberg::get_from_editor_settings( get_default_block_editor_settings() );
- if ( ! wp_theme_has_theme_json() ) {
- if ( ! isset( $theme_support_data['settings']['color'] ) ) {
- $theme_support_data['settings']['color'] = array();
- }
-
- $default_palette = false;
- if ( current_theme_supports( 'default-color-palette' ) ) {
- $default_palette = true;
- }
- if ( ! isset( $theme_support_data['settings']['color']['palette'] ) ) {
- // If the theme does not have any palette, we still want to show the core one.
- $default_palette = true;
- }
- $theme_support_data['settings']['color']['defaultPalette'] = $default_palette;
-
- $default_gradients = false;
- if ( current_theme_supports( 'default-gradient-presets' ) ) {
- $default_gradients = true;
- }
- if ( ! isset( $theme_support_data['settings']['color']['gradients'] ) ) {
- // If the theme does not have any gradients, we still want to show the core ones.
- $default_gradients = true;
- }
- $theme_support_data['settings']['color']['defaultGradients'] = $default_gradients;
-
- // Classic themes without a theme.json don't support global duotone.
- $theme_support_data['settings']['color']['defaultDuotone'] = false;
- }
- $with_theme_supports = new WP_Theme_JSON_Gutenberg( $theme_support_data );
- $with_theme_supports->merge( static::$theme );
-
- return $with_theme_supports;
- }
- /**
- * Returns the style variations defined by the theme.
- *
- * @return array
- */
- public static function get_style_variations() {
- $variations = array();
- $base_directory = get_stylesheet_directory() . '/styles';
- if ( is_dir( $base_directory ) ) {
- $nested_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory ) );
- $nested_html_files = iterator_to_array( new RegexIterator( $nested_files, '/^.+\.json$/i', RecursiveRegexIterator::GET_MATCH ) );
- ksort( $nested_html_files );
- foreach ( $nested_html_files as $path => $file ) {
- $decoded_file = wp_json_file_decode( $path, array( 'associative' => true ) );
- if ( is_array( $decoded_file ) ) {
- $translated = static::translate( $decoded_file, wp_get_theme()->get( 'TextDomain' ) );
- $variation = ( new WP_Theme_JSON_Gutenberg( $translated ) )->get_raw_data();
- if ( empty( $variation['title'] ) ) {
- $variation['title'] = basename( $path, '.json' );
- }
- $variations[] = $variation;
- }
- }
- }
- return $variations;
- }
-
- /**
- * Returns the user's origin config.
- *
- * @return WP_Theme_JSON_Gutenberg Entity that holds styles for user data.
- */
- public static function get_user_data() {
- if ( null !== static::$user ) {
- return static::$user;
- }
-
- $config = array();
- $user_cpt = static::get_user_data_from_wp_global_styles( wp_get_theme() );
-
- if ( array_key_exists( 'post_content', $user_cpt ) ) {
- $decoded_data = json_decode( $user_cpt['post_content'], true );
-
- $json_decoding_error = json_last_error();
- if ( JSON_ERROR_NONE !== $json_decoding_error ) {
- trigger_error( 'Error when decoding a theme.json schema for user data. ' . json_last_error_msg() );
- return new WP_Theme_JSON_Gutenberg( $config, 'custom' );
- }
-
- // Very important to verify if the flag isGlobalStylesUserThemeJSON is true.
- // If is not true the content was not escaped and is not safe.
- if (
- is_array( $decoded_data ) &&
- isset( $decoded_data['isGlobalStylesUserThemeJSON'] ) &&
- $decoded_data['isGlobalStylesUserThemeJSON']
- ) {
- unset( $decoded_data['isGlobalStylesUserThemeJSON'] );
- $config = $decoded_data;
- }
- }
- static::$user = new WP_Theme_JSON_Gutenberg( $config, 'custom' );
-
- return static::$user;
- }
-
- /**
- * There are three sources of data (origins) for a site:
- * default, theme, and custom. The custom's has higher priority
- * than the theme's, and the theme's higher than defaults's.
- *
- * Unlike the getters {@link get_core_data},
- * {@link get_theme_data}, and {@link get_user_data},
- * this method returns data after it has been merged
- * with the previous origins. This means that if the same piece of data
- * is declared in different origins (user, theme, and core),
- * the last origin overrides the previous.
- *
- * For example, if the user has set a background color
- * for the paragraph block, and the theme has done it as well,
- * the user preference wins.
- *
- * @param string $origin Optional. To what level should we merge data.
- * Valid values are 'theme' or 'custom'.
- * Default is 'custom'.
- * @return WP_Theme_JSON_Gutenberg
- */
- public static function get_merged_data( $origin = 'custom' ) {
- if ( is_array( $origin ) ) {
- _deprecated_argument( __FUNCTION__, '5.9' );
- }
-
- $result = new WP_Theme_JSON_Gutenberg();
- $result->merge( static::get_core_data() );
- $result->merge( static::get_theme_data() );
-
- if ( 'custom' === $origin ) {
- $result->merge( static::get_user_data() );
- }
-
- return $result;
- }
-}
diff --git a/lib/compat/wordpress-6.0/client-assets.php b/lib/compat/wordpress-6.0/client-assets.php
deleted file mode 100644
index f9affb31af4b5..0000000000000
--- a/lib/compat/wordpress-6.0/client-assets.php
+++ /dev/null
@@ -1,117 +0,0 @@
-get_all_registered() as $block_type ) {
- if ( ! empty( $block_type->style ) ) {
- $style_handles[] = $block_type->style;
- }
-
- if ( ! empty( $block_type->editor_style ) ) {
- $style_handles[] = $block_type->editor_style;
- }
-
- if ( ! empty( $block_type->script ) ) {
- $script_handles[] = $block_type->script;
- }
- }
-
- $style_handles = array_unique( $style_handles );
- $done = wp_styles()->done;
-
- ob_start();
-
- // We do not need reset styles for the iframed editor.
- wp_styles()->done = array( 'wp-reset-editor-styles' );
- wp_styles()->do_items( $style_handles );
- wp_styles()->done = $done;
-
- $styles = ob_get_clean();
-
- $script_handles = array_unique( $script_handles );
- $done = wp_scripts()->done;
-
- ob_start();
-
- wp_scripts()->done = array();
- wp_scripts()->do_items( $script_handles );
- wp_scripts()->done = $done;
-
- $scripts = ob_get_clean();
-
- return array(
- 'styles' => $styles,
- 'scripts' => $scripts,
- );
-}
-
-add_filter(
- 'block_editor_settings_all',
- function( $settings ) {
- // The `__unstableResolvedAssets` are generated by `_wp_get_iframed_editor_assets` for WP >= 6.0.
- if ( function_exists( '_wp_get_iframed_editor_assets' ) ) {
- return $settings;
- }
-
- // In the future we can allow WP Dependency handles to be passed.
- $settings['__unstableResolvedAssets'] = gutenberg_resolve_assets();
- return $settings;
- }
-);
diff --git a/lib/compat/wordpress-6.0/edit-form-blocks.php b/lib/compat/wordpress-6.0/edit-form-blocks.php
deleted file mode 100644
index b11851222b0ba..0000000000000
--- a/lib/compat/wordpress-6.0/edit-form-blocks.php
+++ /dev/null
@@ -1,66 +0,0 @@
- $user_path ) {
- if ( is_string( $user_path ) && str_starts_with( $user_path, '/wp/v2/users/me' ) ) {
- $preload_paths[ $user_index ] = '/wp/v2/users/me';
- break;
- }
- }
-
- return $preload_paths;
-}
-add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_optimize_preload_paths' );
-
-/**
- * Disables loading remote block patterns from REST while initializing the editor.
- * Nowadays these loads are done in the `block-patterns/patterns` REST endpoint, and
- * are undesired when initializing the block editor page, both in post and site editor.
- *
- * @param WP_Screen $current_screen WordPress current screen object.
- */
-function gutenberg_disable_load_remote_patterns( $current_screen ) {
- $is_site_editor = ( function_exists( 'gutenberg_is_edit_site_page' ) && gutenberg_is_edit_site_page( $current_screen->id ) );
- if ( $is_site_editor || $current_screen->is_block_editor() ) {
- add_filter( 'should_load_remote_block_patterns', '__return_false' );
- }
-}
-add_action( 'current_screen', 'gutenberg_disable_load_remote_patterns' );
diff --git a/lib/compat/wordpress-6.0/functions.php b/lib/compat/wordpress-6.0/functions.php
deleted file mode 100644
index 9368b211b0599..0000000000000
--- a/lib/compat/wordpress-6.0/functions.php
+++ /dev/null
@@ -1,27 +0,0 @@
-get_raw_data()['styles'];
- return _wp_array_get( $styles, $path, $styles );
-}
-
-/**
- * Returns a string containing the SVGs to be referenced as filters (duotone).
- *
- * @return string
- */
-function gutenberg_get_global_styles_svg_filters() {
- // Return cached value if it can be used and exists.
- // It's cached by theme to make sure that theme switching clears the cache.
- $transient_name = 'gutenberg_global_styles_svg_filters_' . get_stylesheet();
- $can_use_cached = (
- ! WP_DEBUG &&
- ! SCRIPT_DEBUG &&
- ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) &&
- ! is_admin()
- );
- if ( $can_use_cached ) {
- $cached = get_transient( $transient_name );
- if ( $cached ) {
- return $cached;
- }
- }
-
- $supports_theme_json = wp_theme_has_theme_json();
-
- $origins = array( 'default', 'theme', 'custom' );
- if ( ! $supports_theme_json ) {
- $origins = array( 'default' );
- }
-
- $tree = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data();
- $svgs = $tree->get_svg_filters( $origins );
-
- if ( $can_use_cached ) {
- // Cache for a minute, same as gutenberg_get_global_stylesheet.
- set_transient( $transient_name, $svgs, MINUTE_IN_SECONDS );
- }
-
- return $svgs;
-}
diff --git a/lib/compat/wordpress-6.0/post-lock.php b/lib/compat/wordpress-6.0/post-lock.php
deleted file mode 100644
index e36cdff3e7a22..0000000000000
--- a/lib/compat/wordpress-6.0/post-lock.php
+++ /dev/null
@@ -1,67 +0,0 @@
-display_name;
- }
- }
-
- return $response;
-}
-add_filter( 'heartbeat_received', 'gutenberg_refresh_post_lock', 20, 2 );
-
-/**
- * Updates post editor settings and adds avatar to the `postLock` user details.
- *
- * @param array $settings Default editor settings.
- * @param WP_Block_Editor_Context $block_editor_context The current block editor context.
- *
- * @return array Filtered editor settings.
- */
-function gutenberg_update_post_lock_details( $settings, $block_editor_context ) {
- if ( empty( $block_editor_context->post ) ) {
- return $settings;
- }
-
- if ( ! isset( $settings['postLock']['user'] ) ) {
- return $settings;
- }
-
- $user_id = wp_check_post_lock( $block_editor_context->post->ID );
- if ( $user_id ) {
- $settings['postLock']['user']['avatar'] = get_avatar_url( $user_id, array( 'size' => 128 ) );
- }
-
- return $settings;
-}
-add_filter( 'block_editor_settings_all', 'gutenberg_update_post_lock_details', 10, 2 );
diff --git a/lib/compat/wordpress-6.0/render-svg-filters.php b/lib/compat/wordpress-6.0/render-svg-filters.php
deleted file mode 100644
index f13502b867fe9..0000000000000
--- a/lib/compat/wordpress-6.0/render-svg-filters.php
+++ /dev/null
@@ -1,38 +0,0 @@
-is_block_editor()
- ) {
- return;
- }
-
- $filters = gutenberg_get_global_styles_svg_filters();
- if ( ! empty( $filters ) ) {
- echo $filters;
- }
-}
-
-// Override actions introduced in 5.9.1 if they exist.
-remove_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' );
-remove_action( 'in_admin_header', 'wp_global_styles_render_svg_filters' );
-add_action( 'wp_body_open', 'gutenberg_global_styles_render_svg_filters' );
-add_action( 'in_admin_header', 'gutenberg_global_styles_render_svg_filters' );
diff --git a/lib/compat/wordpress-6.0/rest-api.php b/lib/compat/wordpress-6.0/rest-api.php
deleted file mode 100644
index 0fa1852b18813..0000000000000
--- a/lib/compat/wordpress-6.0/rest-api.php
+++ /dev/null
@@ -1,65 +0,0 @@
-register_routes();
-}
-add_action( 'rest_api_init', 'gutenberg_register_global_styles_endpoints' );
-
-/**
- * Registers the Edit Site's Export REST API routes.
- *
- * @return void
- */
-function gutenberg_register_edit_site_export_endpoint() {
- $editor_settings = new Gutenberg_REST_Edit_Site_Export_Controller();
- $editor_settings->register_routes();
-}
-add_action( 'rest_api_init', 'gutenberg_register_edit_site_export_endpoint' );
-
-
-/**
- * Register a core site settings.
- *
- * Note: Needs to be backported into the `register_initial_settings` function.
- */
-function gutenberg_register_site_settings() {
- register_setting(
- 'reading',
- 'show_on_front',
- array(
- 'show_in_rest' => true,
- 'type' => 'string',
- 'description' => __( 'What to show on the front page', 'gutenberg' ),
- )
- );
-
- register_setting(
- 'reading',
- 'page_on_front',
- array(
- 'show_in_rest' => true,
- 'type' => 'number',
- 'description' => __( 'The ID of the page that should be displayed on the front page', 'gutenberg' ),
- )
- );
-
- register_setting(
- 'reading',
- 'page_for_posts',
- array(
- 'show_in_rest' => true,
- 'type' => 'number',
- 'description' => __( 'The ID of the page that should display the latest posts', 'gutenberg' ),
- )
- );
-}
-add_action( 'rest_api_init', 'gutenberg_register_site_settings', 10 );
diff --git a/lib/compat/wordpress-6.0/site-editor.php b/lib/compat/wordpress-6.0/site-editor.php
deleted file mode 100644
index 60dc9f2a1ee6b..0000000000000
--- a/lib/compat/wordpress-6.0/site-editor.php
+++ /dev/null
@@ -1,75 +0,0 @@
- 'page',
- 'postId' => $front_page_id,
- );
- }
-
- $hierarchy = array( 'front-page', 'home', 'index' );
- $template = resolve_block_template( 'home', $hierarchy, '' );
-
- if ( ! $template ) {
- return null;
- }
-
- return array(
- 'postType' => 'wp_template',
- 'postId' => $template->id,
- );
-}
-
-/**
- * Do a server-side redirection if missing `postType` and `postId`
- * query args when visiting site editor.
- *
- * Note: This is a backward compatibility redirect for WP 5.9.
- *
- * @return void
- */
-function gutenberg_site_editor_maybe_redirect() {
- // Skip redirection for WP 6.0 and later.
- if ( function_exists( '_resolve_home_block_template' ) ) {
- return;
- }
-
- // Check theme support. The action runs before checks in the Site Editor.
- if ( ! wp_is_block_theme() ) {
- return;
- }
-
- if ( empty( $_GET['postType'] ) && empty( $_GET['postId'] ) ) {
- $template = gutenberg_resolve_home_template();
- if ( ! empty( $_GET['styles'] ) ) {
- $template['styles'] = sanitize_key( $_GET['styles'] );
- }
-
- $redirect_url = add_query_arg(
- $template,
- admin_url( 'site-editor.php' )
- );
- wp_safe_redirect( $redirect_url );
- exit;
- }
-}
-add_action( 'load-site-editor.php', 'gutenberg_site_editor_maybe_redirect' );
diff --git a/lib/compat/wordpress-6.0/theme-i18n.json b/lib/compat/wordpress-6.0/theme-i18n.json
deleted file mode 100644
index 282e520c338b4..0000000000000
--- a/lib/compat/wordpress-6.0/theme-i18n.json
+++ /dev/null
@@ -1,72 +0,0 @@
-{
- "title": "Style variation name",
- "settings": {
- "typography": {
- "fontSizes": [
- {
- "name": "Font size name"
- }
- ],
- "fontFamilies": [
- {
- "name": "Font family name"
- }
- ]
- },
- "color": {
- "palette": [
- {
- "name": "Color name"
- }
- ],
- "gradients": [
- {
- "name": "Gradient name"
- }
- ],
- "duotone": [
- {
- "name": "Duotone name"
- }
- ]
- },
- "blocks": {
- "*": {
- "typography": {
- "fontSizes": [
- {
- "name": "Font size name"
- }
- ],
- "fontFamilies": [
- {
- "name": "Font family name"
- }
- ]
- },
- "color": {
- "palette": [
- {
- "name": "Color name"
- }
- ],
- "gradients": [
- {
- "name": "Gradient name"
- }
- ]
- }
- }
- }
- },
- "customTemplates": [
- {
- "title": "Custom template name"
- }
- ],
- "templateParts": [
- {
- "title": "Template part name"
- }
- ]
-}
diff --git a/lib/compat/wordpress-6.0/theme.json b/lib/compat/wordpress-6.0/theme.json
deleted file mode 100644
index 7691aa4a64e6a..0000000000000
--- a/lib/compat/wordpress-6.0/theme.json
+++ /dev/null
@@ -1,245 +0,0 @@
-{
- "version": 2,
- "settings": {
- "appearanceTools": false,
- "border": {
- "color": false,
- "radius": false,
- "style": false,
- "width": false
- },
- "color": {
- "background": true,
- "custom": true,
- "customDuotone": true,
- "customGradient": true,
- "defaultDuotone": true,
- "defaultGradients": true,
- "defaultPalette": true,
- "duotone": [
- {
- "name": "Dark grayscale",
- "colors": [ "#000000", "#7f7f7f" ],
- "slug": "dark-grayscale"
- },
- {
- "name": "Grayscale",
- "colors": [ "#000000", "#ffffff" ],
- "slug": "grayscale"
- },
- {
- "name": "Purple and yellow",
- "colors": [ "#8c00b7", "#fcff41" ],
- "slug": "purple-yellow"
- },
- {
- "name": "Blue and red",
- "colors": [ "#000097", "#ff4747" ],
- "slug": "blue-red"
- },
- {
- "name": "Midnight",
- "colors": [ "#000000", "#00a5ff" ],
- "slug": "midnight"
- },
- {
- "name": "Magenta and yellow",
- "colors": [ "#c7005a", "#fff278" ],
- "slug": "magenta-yellow"
- },
- {
- "name": "Purple and green",
- "colors": [ "#a60072", "#67ff66" ],
- "slug": "purple-green"
- },
- {
- "name": "Blue and orange",
- "colors": [ "#1900d8", "#ffa96b" ],
- "slug": "blue-orange"
- }
- ],
- "gradients": [
- {
- "name": "Vivid cyan blue to vivid purple",
- "gradient": "linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)",
- "slug": "vivid-cyan-blue-to-vivid-purple"
- },
- {
- "name": "Light green cyan to vivid green cyan",
- "gradient": "linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)",
- "slug": "light-green-cyan-to-vivid-green-cyan"
- },
- {
- "name": "Luminous vivid amber to luminous vivid orange",
- "gradient": "linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)",
- "slug": "luminous-vivid-amber-to-luminous-vivid-orange"
- },
- {
- "name": "Luminous vivid orange to vivid red",
- "gradient": "linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%)",
- "slug": "luminous-vivid-orange-to-vivid-red"
- },
- {
- "name": "Very light gray to cyan bluish gray",
- "gradient": "linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%)",
- "slug": "very-light-gray-to-cyan-bluish-gray"
- },
- {
- "name": "Cool to warm spectrum",
- "gradient": "linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%)",
- "slug": "cool-to-warm-spectrum"
- },
- {
- "name": "Blush light purple",
- "gradient": "linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%)",
- "slug": "blush-light-purple"
- },
- {
- "name": "Blush bordeaux",
- "gradient": "linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)",
- "slug": "blush-bordeaux"
- },
- {
- "name": "Luminous dusk",
- "gradient": "linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%)",
- "slug": "luminous-dusk"
- },
- {
- "name": "Pale ocean",
- "gradient": "linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%)",
- "slug": "pale-ocean"
- },
- {
- "name": "Electric grass",
- "gradient": "linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%)",
- "slug": "electric-grass"
- },
- {
- "name": "Midnight",
- "gradient": "linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%)",
- "slug": "midnight"
- }
- ],
- "link": false,
- "palette": [
- {
- "name": "Black",
- "slug": "black",
- "color": "#000000"
- },
- {
- "name": "Cyan bluish gray",
- "slug": "cyan-bluish-gray",
- "color": "#abb8c3"
- },
- {
- "name": "White",
- "slug": "white",
- "color": "#ffffff"
- },
- {
- "name": "Pale pink",
- "slug": "pale-pink",
- "color": "#f78da7"
- },
- {
- "name": "Vivid red",
- "slug": "vivid-red",
- "color": "#cf2e2e"
- },
- {
- "name": "Luminous vivid orange",
- "slug": "luminous-vivid-orange",
- "color": "#ff6900"
- },
- {
- "name": "Luminous vivid amber",
- "slug": "luminous-vivid-amber",
- "color": "#fcb900"
- },
- {
- "name": "Light green cyan",
- "slug": "light-green-cyan",
- "color": "#7bdcb5"
- },
- {
- "name": "Vivid green cyan",
- "slug": "vivid-green-cyan",
- "color": "#00d084"
- },
- {
- "name": "Pale cyan blue",
- "slug": "pale-cyan-blue",
- "color": "#8ed1fc"
- },
- {
- "name": "Vivid cyan blue",
- "slug": "vivid-cyan-blue",
- "color": "#0693e3"
- },
- {
- "name": "Vivid purple",
- "slug": "vivid-purple",
- "color": "#9b51e0"
- }
- ],
- "text": true
- },
- "spacing": {
- "blockGap": null,
- "margin": false,
- "padding": false,
- "units": [ "px", "em", "rem", "vh", "vw", "%" ]
- },
- "typography": {
- "customFontSize": true,
- "dropCap": true,
- "fontSizes": [
- {
- "name": "Small",
- "slug": "small",
- "size": "13px"
- },
- {
- "name": "Medium",
- "slug": "medium",
- "size": "20px"
- },
- {
- "name": "Large",
- "slug": "large",
- "size": "36px"
- },
- {
- "name": "Extra Large",
- "slug": "x-large",
- "size": "42px"
- }
- ],
- "fontStyle": true,
- "fontWeight": true,
- "letterSpacing": true,
- "lineHeight": false,
- "textDecoration": true,
- "textTransform": true
- },
- "blocks": {
- "core/button": {
- "border": {
- "radius": true
- }
- },
- "core/pullquote": {
- "border": {
- "color": true,
- "radius": true,
- "style": true,
- "width": true
- }
- }
- }
- },
- "styles": {
- "spacing": { "blockGap": "24px" }
- }
-}
diff --git a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php
index e965e0e824677..0c0ec0451aec4 100644
--- a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php
+++ b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php
@@ -14,7 +14,7 @@
*
* @access private
*/
-class WP_Theme_JSON_6_1 extends WP_Theme_JSON_6_0 {
+class WP_Theme_JSON_6_1 extends WP_Theme_JSON {
/**
* Defines which pseudo selectors are enabled for which elements.
*
diff --git a/lib/compat/wordpress-6.1/class-wp-theme-json-resolver-6-1.php b/lib/compat/wordpress-6.1/class-wp-theme-json-resolver-6-1.php
index 73e012f33d1c7..1d4a83e3406fb 100644
--- a/lib/compat/wordpress-6.1/class-wp-theme-json-resolver-6-1.php
+++ b/lib/compat/wordpress-6.1/class-wp-theme-json-resolver-6-1.php
@@ -15,7 +15,7 @@
*
* @access private
*/
-class WP_Theme_JSON_Resolver_6_1 extends WP_Theme_JSON_Resolver_6_0 {
+class WP_Theme_JSON_Resolver_6_1 extends WP_Theme_JSON_Resolver {
/**
* Container for data coming from core.
diff --git a/lib/compat/wordpress-6.2/class-gutenberg-rest-pattern-directory-controller-6-2.php b/lib/compat/wordpress-6.2/class-gutenberg-rest-pattern-directory-controller-6-2.php
index ab845f3c38de1..e8e456676e974 100644
--- a/lib/compat/wordpress-6.2/class-gutenberg-rest-pattern-directory-controller-6-2.php
+++ b/lib/compat/wordpress-6.2/class-gutenberg-rest-pattern-directory-controller-6-2.php
@@ -9,7 +9,7 @@
/**
* Controller which provides REST endpoint for block patterns from wordpress.org/patterns.
*/
-class Gutenberg_REST_Pattern_Directory_Controller_6_2 extends Gutenberg_REST_Pattern_Directory_Controller_6_0 {
+class Gutenberg_REST_Pattern_Directory_Controller_6_2 extends WP_REST_Pattern_Directory_Controller {
/**
* Registers the necessary REST API routes.
*
diff --git a/lib/experiments-page.php b/lib/experiments-page.php
index 1296cdd03b89f..6051aed56bc40 100644
--- a/lib/experiments-page.php
+++ b/lib/experiments-page.php
@@ -126,22 +126,3 @@ function gutenberg_display_experiment_section() {
(int) get_option( 'use_balanceTags' ) !== 1 || is_wp_version_compatible( '5.9' ),
- );
- return array_merge( $settings, $experiments_settings );
-}
-
-add_filter( 'block_editor_settings_all', 'gutenberg_experiments_editor_settings' );
diff --git a/lib/load.php b/lib/load.php
index 11830fb9a0c4d..3c9f458fcd388 100644
--- a/lib/load.php
+++ b/lib/load.php
@@ -35,15 +35,6 @@ function gutenberg_is_experiment_enabled( $name ) {
require_once __DIR__ . '/experimental/class-wp-rest-block-editor-settings-controller.php';
}
- // WordPress 6.0 compat.
- require_once __DIR__ . '/compat/wordpress-6.0/class-gutenberg-rest-global-styles-controller.php';
- require_once __DIR__ . '/compat/wordpress-6.0/class-gutenberg-rest-pattern-directory-controller-6-0.php';
- require_once __DIR__ . '/compat/wordpress-6.0/class-gutenberg-rest-edit-site-export-controller.php';
- if ( ! class_exists( 'WP_REST_Block_Pattern_Categories_Controller' ) ) {
- require_once __DIR__ . '/compat/wordpress-6.0/class-wp-rest-block-pattern-categories-controller.php';
- }
- require_once __DIR__ . '/compat/wordpress-6.0/rest-api.php';
-
// WordPress 6.1 compat.
require_once __DIR__ . '/compat/wordpress-6.1/class-gutenberg-rest-block-patterns-controller.php';
require_once __DIR__ . '/compat/wordpress-6.1/class-gutenberg-rest-templates-controller.php';
@@ -67,23 +58,6 @@ function gutenberg_is_experiment_enabled( $name ) {
// Gutenberg plugin compat.
require __DIR__ . '/compat/plugin/edit-site-routes-backwards-compat.php';
-// WordPress 6.0 compat.
-require __DIR__ . '/compat/wordpress-6.0/block-gallery.php';
-require __DIR__ . '/compat/wordpress-6.0/block-editor-settings.php';
-require __DIR__ . '/compat/wordpress-6.0/get-global-styles-and-settings.php';
-require __DIR__ . '/compat/wordpress-6.0/render-svg-filters.php';
-require __DIR__ . '/compat/wordpress-6.0/post-lock.php';
-require __DIR__ . '/compat/wordpress-6.0/blocks.php';
-require __DIR__ . '/compat/wordpress-6.0/block-template-utils.php';
-require __DIR__ . '/compat/wordpress-6.0/functions.php';
-require __DIR__ . '/compat/wordpress-6.0/class-wp-theme-json-6-0.php';
-require __DIR__ . '/compat/wordpress-6.0/class-wp-theme-json-resolver-6-0.php';
-require __DIR__ . '/compat/wordpress-6.0/block-patterns.php';
-require __DIR__ . '/compat/wordpress-6.0/site-editor.php';
-require __DIR__ . '/compat/wordpress-6.0/edit-form-blocks.php';
-require __DIR__ . '/compat/wordpress-6.0/block-patterns-update.php';
-require __DIR__ . '/compat/wordpress-6.0/client-assets.php';
-
// WordPress 6.1 compat.
require __DIR__ . '/compat/wordpress-6.1/blocks.php';
require __DIR__ . '/compat/wordpress-6.1/block-editor-settings.php';
diff --git a/packages/block-library/src/gallery/shared.js b/packages/block-library/src/gallery/shared.js
index f3142bbbaf9da..f6a614f1e2466 100644
--- a/packages/block-library/src/gallery/shared.js
+++ b/packages/block-library/src/gallery/shared.js
@@ -49,18 +49,9 @@ function getGalleryBlockV2Enabled() {
* can be removed when minimum supported WP version >=5.9.
*/
export function isGalleryV2Enabled() {
- // The logic for the native version is located in a different if statement
- // due to a lint rule that prohibits a single conditional combining
- // `process.env.IS_GUTENBERG_PLUGIN` with a native platform check.
if ( Platform.isNative ) {
return getGalleryBlockV2Enabled();
}
- // Only run the Gallery version compat check if the plugin is running, otherwise
- // assume we are in 5.9 core and enable by default.
- if ( process.env.IS_GUTENBERG_PLUGIN ) {
- return getGalleryBlockV2Enabled();
- }
-
return true;
}