Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General: update WordPress version requirements to WP 5.6 #18860

Merged
merged 14 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/files/setup-wordpress-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ case "$WP_BRANCH" in
previous)
# We hard-code the version here because there's a time near WP releases where
# we've dropped the old 'previous' but WP hasn't actually released the new 'latest'
git clone --depth=1 --branch 5.5 git://develop.git.wordpress.org/ /tmp/wordpress-previous
git clone --depth=1 --branch 5.6 git://develop.git.wordpress.org/ /tmp/wordpress-previous
;;
esac
echo "::endgroup::"
Expand Down
2 changes: 1 addition & 1 deletion .phpcs.config.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<ruleset>
<config name="minimum_supported_wp_version" value="5.5" />
<config name="minimum_supported_wp_version" value="5.6" />
<config name="testVersion" value="5.6-"/>

<!-- Check all PHP files in directory tree by default. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,6 @@ public function create_upload_object( $file, $parent = 0 ) {
* Test that the wp_get_attachment_image function output gets the lazy treatment.
*/
public function test_wp_get_attachment_image_gets_lazy_treatment() {

// @todo Remove when WordPress 5.6 is the minimum supported version.
if ( ! function_exists( 'is_gd_image' ) && version_compare( PHP_VERSION, '8.0', '>=' ) ) {
$editor = wp_get_image_editor( __DIR__ . '/wp-logo.jpg' );
if ( is_wp_error( $editor ) ) {
$this->markTestSkipped( 'WordPress <5.6 does not properly support the ext-gd in PHP 8.0+' );
}
}

$attachment_id = $this->create_upload_object( __DIR__ . '/wp-logo.jpg', 0 );
add_filter( 'wp_get_attachment_image_attributes', array( 'Automattic\\Jetpack\\Jetpack_Lazy_Images', 'process_image_attributes' ), PHP_INT_MAX );
$image = wp_get_attachment_image( $attachment_id );
Expand Down
10 changes: 0 additions & 10 deletions projects/packages/sync/src/modules/class-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,16 +570,6 @@ public function wp_insert_post( $post_ID, $post = null, $update = null ) {
*/
do_action( 'jetpack_sync_save_post', $post_ID, $post, $update, $state );
unset( $this->previous_status[ $post_ID ] );

/*
* WP 5.6 introduced the wp_after_insert_post hook that triggers when
* the post, meta and terms has been updated. We are migrating send_published
* function to this hook to ensure we have all data for WP.com functionality.
* @todo: remove full if statement when WordPress 5.6 is the minimum required version.
*/
if ( ! function_exists( 'wp_after_insert_post' ) ) {
$this->send_published( $post_ID, $post );
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,6 @@ private static function get_block_definition( $block_name ) {
return self::$supported_blocks[ $block_name ];
}

// @todo This is a fallback definition, it can be removed when WordPress 5.6 is the minimum supported version.
if ( 0 === strpos( $block_name, 'core-embed/' ) ) {
return self::$supported_blocks['core/embed'];
}

return null;
}

Expand Down Expand Up @@ -1200,11 +1195,6 @@ private static function extract_tweet_from_block( $block ) {
return $block['attrs']['url'];
}

// @todo This fallback can be removed when WordPress 5.6 is the minimum supported version.
if ( 'core-embed/twitter' === $block['blockName'] ) {
return $block['attrs']['url'];
}

return '';
}

Expand All @@ -1226,11 +1216,6 @@ private static function extract_embed_from_block( $block ) {
return '';
}

// @todo This fallback can be removed when WordPress 5.6 is the minimum supported version.
if ( 'core-embed/twitter' === $block['blockName'] ) {
return '';
}

$url = '';
if ( 'block-attributes' === $block_def['content_location'] ) {
$url = $block['attrs'][ $block_def['content'][0] ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,8 @@ function process_anchor_params() {
return;
}

$current_screen = \get_current_screen();
// TODO: Replace `$current_screen->is_block_editor()` with `wp_should_load_block_editor_scripts_and_styles()` that is introduced in WP 5.6.
if (
$current_screen instanceof \WP_Screen
&& ! $current_screen->is_block_editor()
) {
// Return early if we are not in the block editor.
// Return early if we are not in the block editor.
if ( ! wp_should_load_block_editor_scripts_and_styles() ) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import classNames from 'classnames';
import { __ } from '@wordpress/i18n';
import { Component, Fragment } from '@wordpress/element';
import { IconButton, TextControl, ToggleControl } from '@wordpress/components';
import { Button, TextControl, ToggleControl } from '@wordpress/components';
import { isEmpty } from 'lodash';

const defaultOpen = '09:00';
Expand Down Expand Up @@ -44,7 +44,7 @@ class DayEdit extends Component {
</div>
<div className="business-hours__remove">
{ day.hours.length > 1 && (
<IconButton
<Button
isSmall
isLink
icon="trash"
Expand All @@ -59,13 +59,9 @@ class DayEdit extends Component {
<div className="business-hours__row business-hours-row__add">
<div className={ classNames( day.name, 'business-hours__day' ) }>&nbsp;</div>
<div className={ classNames( day.name, 'business-hours__hours' ) }>
<IconButton
isLink
label={ __( 'Add Hours', 'jetpack' ) }
onClick={ this.addInterval }
>
<Button isLink label={ __( 'Add Hours', 'jetpack' ) } onClick={ this.addInterval }>
{ __( 'Add Hours', 'jetpack' ) }
</IconButton>
</Button>
</div>
<div className="business-hours__remove">&nbsp;</div>
</div>
Expand Down
14 changes: 9 additions & 5 deletions projects/plugins/jetpack/extensions/blocks/calendly/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External Dependencies
*/
import 'url-polyfill';
import { isEqual, pick } from 'lodash';
import { isEqual } from 'lodash';
import queryString from 'query-string';

/**
Expand All @@ -17,7 +17,8 @@ import {
Placeholder,
Spinner,
ToggleControl,
Toolbar,
ToolbarButton,
ToolbarGroup,
withNotices,
} from '@wordpress/components';
import { useEffect, useState } from '@wordpress/element';
Expand Down Expand Up @@ -84,6 +85,7 @@ function CalendlyEdit( props ) {
setAttributes( { url: undefined } );
setErrorNotice();
} );
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [] );

const parseEmbedCode = event => {
Expand Down Expand Up @@ -242,9 +244,11 @@ function CalendlyEdit( props ) {
<>
{ url && ! isEditingUrl && (
<BlockControls>
<Toolbar>
<Button onClick={ () => setIsEditingUrl( true ) }>{ __( 'Edit', 'jetpack' ) }</Button>
</Toolbar>
<ToolbarGroup>
<ToolbarButton onClick={ () => setIsEditingUrl( true ) }>
{ __( 'Edit', 'jetpack' ) }
</ToolbarButton>
</ToolbarGroup>
</BlockControls>
) }
{ url && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
InspectorControls,
BlockControls,
} from '@wordpress/block-editor';
import { PanelBody, ToggleControl, Toolbar, ToolbarButton, Path } from '@wordpress/components';
import { PanelBody, ToggleControl, ToolbarGroup, ToolbarButton, Path } from '@wordpress/components';

/**
* Internal Dependencies
Expand All @@ -20,7 +20,7 @@ const JetpackFieldControls = ( { setAttributes, width, id, required } ) => {
return (
<>
<BlockControls>
<Toolbar>
<ToolbarGroup>
<ToolbarButton
title={ __( 'Required', 'jetpack' ) }
icon={ renderMaterialIcon(
Expand All @@ -34,7 +34,7 @@ const JetpackFieldControls = ( { setAttributes, width, id, required } ) => {
} }
className={ required ? 'is-pressed' : undefined }
/>
</Toolbar>
</ToolbarGroup>
</BlockControls>

<InspectorControls>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { IconButton } from '@wordpress/components';
import { Button } from '@wordpress/components';
import { Component, createRef } from '@wordpress/element';

class JetpackOption extends Component {
Expand Down Expand Up @@ -65,7 +65,7 @@ class JetpackOption extends Component {
ref={ this.textInput }
/>
{ isSelected && (
<IconButton
<Button
className="jetpack-option__remove"
icon="trash"
label={ __( 'Remove option', 'jetpack' ) }
Expand Down
33 changes: 18 additions & 15 deletions projects/plugins/jetpack/extensions/blocks/contact-form/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
TextareaControl,
TextControl,
ToolbarGroup,
ToolbarItem,
Button,
Dropdown,
Icon,
Expand Down Expand Up @@ -320,21 +321,23 @@ function JetpackContactFormEdit( {

return (
<>
{ ToolbarGroup && (
<BlockControls>
<ToolbarGroup>
<Dropdown
position="bottom right"
className="jetpack-contact-form-settings-selector"
contentClassName="jetpack-contact-form__popover"
renderToggle={ ( { isOpen, onToggle } ) =>
renderFormSettingsToggle( isOpen, onToggle )
}
renderContent={ () => renderFormSettings() }
/>
</ToolbarGroup>
</BlockControls>
) }
<BlockControls>
<ToolbarGroup>
<ToolbarItem>
{ () => (
<Dropdown
position="bottom right"
className="jetpack-contact-form-settings-selector"
contentClassName="jetpack-contact-form__popover"
renderToggle={ ( { isOpen, onToggle } ) =>
renderFormSettingsToggle( isOpen, onToggle )
}
renderContent={ () => renderFormSettings() }
/>
) }
</ToolbarItem>
</ToolbarGroup>
</BlockControls>

<InspectorControls>
<PanelBody title={ __( 'Form Settings', 'jetpack' ) }>{ renderFormSettings() }</PanelBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export function SpeakerEditControl( {
<RichText
tagName="div"
value={ label }
formattingControls={ [] }
allowedFormats={ [] }
withoutInteractiveFormatting={ true }
onChange={ onChangeHandler }
placeholder={ __( 'Speaker', 'jetpack' ) }
Expand Down
87 changes: 46 additions & 41 deletions projects/plugins/jetpack/extensions/blocks/donations/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
PanelBody,
ToggleControl,
ToolbarGroup,
ToolbarItem,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { DOWN } from '@wordpress/keycodes';
Expand Down Expand Up @@ -51,49 +52,53 @@ const Controls = props => {
<>
<BlockControls>
<ToolbarGroup>
<Dropdown
contentClassName="jetpack-donations__currency-popover"
renderToggle={ ( { onToggle, isOpen } ) => {
const openOnArrowDown = event => {
if ( ! isOpen && event.keyCode === DOWN ) {
event.preventDefault();
event.stopPropagation();
onToggle();
}
};
<ToolbarItem>
{ () => (
<Dropdown
contentClassName="jetpack-donations__currency-popover"
renderToggle={ ( { onToggle, isOpen } ) => {
const openOnArrowDown = event => {
if ( ! isOpen && event.keyCode === DOWN ) {
event.preventDefault();
event.stopPropagation();
onToggle();
}
};

return (
<Button
className="jetpack-donations__currency-toggle"
icon={
<>
{ CURRENCIES[ currency ].symbol + ' - ' + currency }
<Dashicon icon="arrow-down" />
</>
}
label={ __( 'Change currency', 'jetpack' ) }
onClick={ onToggle }
onKeyDown={ openOnArrowDown }
/>
);
} }
renderContent={ ( { onClose } ) => (
<MenuGroup>
{ Object.keys( SUPPORTED_CURRENCIES ).map( ccy => (
<MenuItem
isSelected={ ccy === currency }
onClick={ () => {
setAttributes( { currency: ccy } );
onClose();
} }
key={ `jetpack-donations-currency-${ ccy }` }
>
{ CURRENCIES[ ccy ].symbol + ' - ' + ccy }
</MenuItem>
) ) }
</MenuGroup>
return (
<Button
className="jetpack-donations__currency-toggle"
icon={
<>
{ CURRENCIES[ currency ].symbol + ' - ' + currency }
<Dashicon icon="arrow-down" />
</>
}
label={ __( 'Change currency', 'jetpack' ) }
onClick={ onToggle }
onKeyDown={ openOnArrowDown }
/>
);
} }
renderContent={ ( { onClose } ) => (
<MenuGroup>
{ Object.keys( SUPPORTED_CURRENCIES ).map( ccy => (
<MenuItem
isSelected={ ccy === currency }
onClick={ () => {
setAttributes( { currency: ccy } );
onClose();
} }
key={ `jetpack-donations-currency-${ ccy }` }
>
{ CURRENCIES[ ccy ].symbol + ' - ' + ccy }
</MenuItem>
) ) }
</MenuGroup>
) }
/>
) }
/>
</ToolbarItem>
</ToolbarGroup>
</BlockControls>
<InspectorControls>
Expand Down
Loading