Skip to content

Commit

Permalink
Plugin: Bump minimum WordPress version to 5.3 (#20628)
Browse files Browse the repository at this point in the history
* Plugin: Bump minimum WordPress version to 5.3

* Compat: Remove gutenberg_safe_style_css_column_flex_basis

* Remove overriding of lodash script

* Remove overriding of react and react-dom scripts

* Explain emptying of gutenberg_register_vendor_scripts

* Appease phpcs
  • Loading branch information
mcsf authored Mar 6, 2020
1 parent b9ead5d commit 3ab3727
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 152 deletions.
4 changes: 2 additions & 2 deletions gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function gutenberg_menu() {
function gutenberg_wordpress_version_notice() {
echo '<div class="error"><p>';
/* 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 '</p></div>';

deactivate_plugins( array( 'gutenberg/gutenberg.php' ) );
Expand Down Expand Up @@ -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;
}
Expand Down
94 changes: 11 additions & 83 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,38 +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 ) {
$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/[email protected]/umd/react' . $react_suffix . '.js',
array( 'wp-polyfill' ),
'16.9.0',
true
);
gutenberg_register_vendor_script(
$scripts,
'react-dom',
'https://unpkg.com/[email protected]/umd/react-dom' . $react_suffix . '.js',
array( 'react' ),
'16.9.0',
true
);
gutenberg_register_vendor_script(
$scripts,
'lodash',
'https://unpkg.com/[email protected]/lodash' . $suffix . '.js',
array(),
'4.17.15',
true
);
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.
//
// 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' );

Expand Down Expand Up @@ -627,57 +606,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.
*
Expand Down
22 changes: 0 additions & 22 deletions lib/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 0 additions & 44 deletions phpunit/class-extend-preload-paths-test.php

This file was deleted.

2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 3ab3727

Please sign in to comment.