From f33e00d0a76da06bda5e1608c00b598d434edf48 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Wed, 4 Mar 2020 16:55:08 +0000 Subject: [PATCH 1/6] Plugin: Bump minimum WordPress version to 5.3 --- gutenberg.php | 4 +- lib/client-assets.php | 51 --------------------- phpunit/class-extend-preload-paths-test.php | 44 ------------------ readme.txt | 2 +- 4 files changed, 3 insertions(+), 98 deletions(-) delete mode 100644 phpunit/class-extend-preload-paths-test.php diff --git a/gutenberg.php b/gutenberg.php index f46c44e33b472f..bdd7d4ebce6c2d 100644 --- a/gutenberg.php +++ b/gutenberg.php @@ -99,7 +99,7 @@ function gutenberg_menu() { function gutenberg_wordpress_version_notice() { echo '

'; /* translators: %s: Minimum required version */ - printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), '5.2.0' ); + printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), '5.3.0' ); echo '

'; deactivate_plugins( array( 'gutenberg/gutenberg.php' ) ); @@ -134,7 +134,7 @@ function gutenberg_pre_init() { // Strip '-src' from the version string. Messes up version_compare(). $version = str_replace( '-src', '', $wp_version ); - if ( version_compare( $version, '5.2.0', '<' ) ) { + if ( version_compare( $version, '5.3.0', '<' ) ) { add_action( 'admin_notices', 'gutenberg_wordpress_version_notice' ); return; } diff --git a/lib/client-assets.php b/lib/client-assets.php index 590fbcc9ad0264..660ff3d1e64939 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -627,57 +627,6 @@ function gutenberg_extend_block_editor_styles( $settings ) { } add_filter( 'block_editor_settings', 'gutenberg_extend_block_editor_styles' ); -/** - * Extends block editor preload paths to preload additional data. Note that any - * additions here should be complemented with a corresponding core ticket to - * reconcile the change upstream for future removal from Gutenberg. - * - * @param array $preload_paths Array of paths to preload. - * @param WP_Post $post Post being edited. - * - * @return array Filtered array of paths to preload. - */ -function gutenberg_extend_block_editor_preload_paths( $preload_paths, $post ) { - /* - * Preload any autosaves for the post. (see https://github.com/WordPress/gutenberg/pull/7945) - * - * Trac ticket: https://core.trac.wordpress.org/ticket/46974 - * - * At the time of writing, the change is not committed or released - * in core. This path should be removed from Gutenberg when the code is - * released in core, and the corresponding release version becomes - * the minimum supported version. - */ - $post_type_object = get_post_type_object( $post->post_type ); - - if ( isset( $post_type_object ) ) { - $rest_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name; - $autosaves_path = sprintf( '/wp/v2/%s/%d/autosaves?context=edit', $rest_base, $post->ID ); - - if ( ! in_array( $autosaves_path, $preload_paths, true ) ) { - $preload_paths[] = $autosaves_path; - } - } - - /* - * Used in considering user permissions for creating and updating blocks, - * as condition for displaying relevant actions in the interface. - * - * Trac ticket: https://core.trac.wordpress.org/ticket/46429 - * - * This is present in WordPress 5.2 and should be removed from Gutenberg - * once WordPress 5.2 is the minimum supported version. - */ - $blocks_path = array( '/wp/v2/blocks', 'OPTIONS' ); - - if ( ! in_array( $blocks_path, $preload_paths, true ) ) { - $preload_paths[] = $blocks_path; - } - - return $preload_paths; -} -add_filter( 'block_editor_preload_paths', 'gutenberg_extend_block_editor_preload_paths', 10, 2 ); - /** * Extends block editor settings to include a list of image dimensions per size. * diff --git a/phpunit/class-extend-preload-paths-test.php b/phpunit/class-extend-preload-paths-test.php deleted file mode 100644 index 357eda859b06fa..00000000000000 --- a/phpunit/class-extend-preload-paths-test.php +++ /dev/null @@ -1,44 +0,0 @@ -post->create_and_get(); - } - - /** - * Tests paths added if missing. - */ - function test_localizes_script() { - $preload_paths = gutenberg_extend_block_editor_preload_paths( array(), self::$post ); - - $expected_blocks_path = array( '/wp/v2/blocks', 'OPTIONS' ); - $expected_autosaves_path = sprintf( '/wp/v2/%s/%d/autosaves?context=edit', 'posts', self::$post->ID ); - - $this->assertEquals( array( $expected_autosaves_path, $expected_blocks_path ), $preload_paths ); - } - - /** - * Tests paths not added if present. - */ - function test_replaces_registered_properties() { - $existing_blocks_path = array( '/wp/v2/blocks', 'OPTIONS' ); - $existing_autosaves_path = sprintf( '/wp/v2/%s/%d/autosaves?context=edit', 'posts', self::$post->ID ); - $existing_preload_paths = array( $existing_blocks_path, $existing_autosaves_path ); - - $preload_paths = gutenberg_extend_block_editor_preload_paths( $existing_preload_paths, self::$post ); - - $this->assertEquals( $existing_preload_paths, $preload_paths ); - } -} diff --git a/readme.txt b/readme.txt index 4e2cd399d48614..f740b842fa4e21 100644 --- a/readme.txt +++ b/readme.txt @@ -1,6 +1,6 @@ === Gutenberg === Contributors: matveb, joen, karmatosed -Requires at least: 5.2.0 +Requires at least: 5.3.0 Tested up to: 5.3 Stable tag: V.V.V License: GPLv2 or later From 1018968de4a86d6c1adb7c581d036d59f9060489 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Thu, 5 Mar 2020 14:43:07 +0000 Subject: [PATCH 2/6] Compat: Remove gutenberg_safe_style_css_column_flex_basis --- lib/compat.php | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/lib/compat.php b/lib/compat.php index 3e4affe6a8937c..9fc297fbf73776 100644 --- a/lib/compat.php +++ b/lib/compat.php @@ -8,28 +8,6 @@ * @package gutenberg */ -/** - * Filters allowed CSS attributes to include `flex-basis`, included in saved - * markup of the Column block. - * - * This can be removed when plugin support requires WordPress 5.3.0+. - * - * @see https://core.trac.wordpress.org/ticket/47281 - * @see https://core.trac.wordpress.org/changeset/45363 - * - * @since 5.7.0 - * - * @param string[] $attr Array of allowed CSS attributes. - * - * @return string[] Filtered array of allowed CSS attributes. - */ -function gutenberg_safe_style_css_column_flex_basis( $attr ) { - $attr[] = 'flex-basis'; - - return $attr; -} -add_filter( 'safe_style_css', 'gutenberg_safe_style_css_column_flex_basis' ); - /** * Adds a polyfill for the WHATWG URL in environments which do not support it. * The intention in how this action is handled is under the assumption that this From 9ac1e2a20db3c45c6fdabb9bf91d37cb17b61680 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Thu, 5 Mar 2020 15:02:40 +0000 Subject: [PATCH 3/6] Remove overriding of lodash script --- lib/client-assets.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index 660ff3d1e64939..75ce017ea08057 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -229,14 +229,6 @@ function gutenberg_register_vendor_scripts( &$scripts ) { '16.9.0', true ); - gutenberg_register_vendor_script( - $scripts, - 'lodash', - 'https://unpkg.com/lodash@4.17.15/lodash' . $suffix . '.js', - array(), - '4.17.15', - true - ); } add_action( 'wp_default_scripts', 'gutenberg_register_vendor_scripts' ); From 1be218b6c704994321fa0d9908bd2bcc49c0617a Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Thu, 5 Mar 2020 19:09:15 +0000 Subject: [PATCH 4/6] Remove overriding of react and react-dom scripts --- lib/client-assets.php | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index 75ce017ea08057..a0cfa6621240d0 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -206,29 +206,6 @@ function gutenberg_override_style( &$styles, $handle, $src, $deps = array(), $ve * @param WP_Scripts $scripts WP_Scripts instance (passed by reference). */ function gutenberg_register_vendor_scripts( &$scripts ) { - $suffix = SCRIPT_DEBUG ? '' : '.min'; - - // Vendor Scripts. - $react_suffix = ( SCRIPT_DEBUG ? '.development' : '.production' ) . $suffix; - - // TODO: Overrides for react, react-dom and lodash are necessary - // until WordPress 5.3 is released. - gutenberg_register_vendor_script( - $scripts, - 'react', - 'https://unpkg.com/react@16.9.0/umd/react' . $react_suffix . '.js', - array( 'wp-polyfill' ), - '16.9.0', - true - ); - gutenberg_register_vendor_script( - $scripts, - 'react-dom', - 'https://unpkg.com/react-dom@16.9.0/umd/react-dom' . $react_suffix . '.js', - array( 'react' ), - '16.9.0', - true - ); } add_action( 'wp_default_scripts', 'gutenberg_register_vendor_scripts' ); From d457ecf0f2382bb13d8fe653bac722dc11eea7b2 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Thu, 5 Mar 2020 22:09:35 +0000 Subject: [PATCH 5/6] Explain emptying of gutenberg_register_vendor_scripts --- lib/client-assets.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/client-assets.php b/lib/client-assets.php index a0cfa6621240d0..b65c8cb3811666 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -206,6 +206,13 @@ function gutenberg_override_style( &$styles, $handle, $src, $deps = array(), $ve * @param WP_Scripts $scripts WP_Scripts instance (passed by reference). */ function gutenberg_register_vendor_scripts( &$scripts ) { + // This function is intentionally left empty. + // + // Scripts such as react and react-dom are expected to be overridden soon, + // and it is preferred to keep this function in place so as not to disturb + // tooling related to the plugin build process. + // + // See https://github.com/WordPress/gutenberg/pull/20628 } add_action( 'wp_default_scripts', 'gutenberg_register_vendor_scripts' ); From 904bf9bafe7cc46e856b67fb5d6f23a2f6a84c3c Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Thu, 5 Mar 2020 22:53:29 +0000 Subject: [PATCH 6/6] Appease phpcs --- lib/client-assets.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index b65c8cb3811666..a814643fc7b4d8 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -205,14 +205,17 @@ function gutenberg_override_style( &$styles, $handle, $src, $deps = array(), $ve * * @param WP_Scripts $scripts WP_Scripts instance (passed by reference). */ -function gutenberg_register_vendor_scripts( &$scripts ) { +function gutenberg_register_vendor_scripts( &$scripts ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable // This function is intentionally left empty. // // Scripts such as react and react-dom are expected to be overridden soon, // and it is preferred to keep this function in place so as not to disturb // tooling related to the plugin build process. // - // See https://github.com/WordPress/gutenberg/pull/20628 + // TODO: Remove phpcs exception in function signature once this function + // regains its use. + // + // See https://github.com/WordPress/gutenberg/pull/20628. } add_action( 'wp_default_scripts', 'gutenberg_register_vendor_scripts' );