diff --git a/assets/js/amp-block-validation.js b/assets/js/amp-block-validation.js index 0c1f02dc48f..10b2b825343 100644 --- a/assets/js/amp-block-validation.js +++ b/assets/js/amp-block-validation.js @@ -145,7 +145,7 @@ var ampBlockValidation = ( function() { // eslint-disable-line no-unused-vars * @return {void} */ handleValidationErrorsStateChange: function handleValidationErrorsStateChange() { - var currentPost, validationErrors, blockValidationErrors, noticeElement, noticeMessage, blockErrorCount, ampValidity; + var currentPost, validationErrors, blockValidationErrors, noticeOptions, noticeMessage, blockErrorCount, ampValidity; if ( ! module.isAMPEnabled() ) { if ( ! module.lastStates.noticesAreReset ) { @@ -249,16 +249,20 @@ var ampBlockValidation = ( function() { // eslint-disable-line no-unused-vars noticeMessage += wp.i18n.__( 'Non-accepted validation errors prevent AMP from being served, and the user will be redirected to the non-AMP version.', 'amp' ); } - noticeElement = wp.element.createElement( 'p', {}, [ - noticeMessage + ' ', - ampValidity.review_link && wp.element.createElement( - 'a', - { key: 'review_link', href: ampValidity.review_link, target: '_blank' }, - wp.i18n.__( 'Review issues', 'amp' ) - ) - ] ); + noticeOptions = { + id: 'amp-errors-notice' + }; + if ( ampValidity.review_link ) { + noticeOptions.actions = [ + { + label: wp.i18n.__( 'Review issues', 'amp' ), + url: ampValidity.review_link + } + ]; + } - module.validationWarningNoticeId = wp.data.dispatch( 'core/editor' ).createWarningNotice( noticeElement, { spokenMessage: noticeMessage } ).notice.id; + wp.data.dispatch( 'core/notices' ).createNotice( 'warning', noticeMessage, noticeOptions ); + module.validationWarningNoticeId = noticeOptions.id; }, /** @@ -303,7 +307,7 @@ var ampBlockValidation = ( function() { // eslint-disable-line no-unused-vars */ resetWarningNotice: function resetWarningNotice() { if ( module.validationWarningNoticeId ) { - wp.data.dispatch( 'core/editor' ).removeNotice( module.validationWarningNoticeId ); + wp.data.dispatch( 'core/notices' ).removeNotice( module.validationWarningNoticeId ); module.validationWarningNoticeId = null; } }, diff --git a/includes/admin/class-amp-editor-blocks.php b/includes/admin/class-amp-editor-blocks.php index 5707a9231ac..c25713fd699 100644 --- a/includes/admin/class-amp-editor-blocks.php +++ b/includes/admin/class-amp-editor-blocks.php @@ -155,9 +155,10 @@ public function enqueue_block_editor_assets() { ) ) ) ); + $locale_data = function_exists( 'wp_get_jed_locale_data' ) ? wp_get_jed_locale_data( 'amp' ) : gutenberg_get_jed_locale_data( 'amp' ); wp_add_inline_script( 'wp-i18n', - 'wp.i18n.setLocaleData( ' . wp_json_encode( gutenberg_get_jed_locale_data( 'amp' ) ) . ', "amp" );', + 'wp.i18n.setLocaleData( ' . wp_json_encode( $locale_data ) . ', "amp" );', 'after' ); } diff --git a/includes/admin/class-amp-post-meta-box.php b/includes/admin/class-amp-post-meta-box.php index 477276f830f..f1185a19e16 100644 --- a/includes/admin/class-amp-post-meta-box.php +++ b/includes/admin/class-amp-post-meta-box.php @@ -176,7 +176,6 @@ public function enqueue_admin_assets() { /** * Enqueues block assets. - * The name of gutenberg_get_jed_locale_data() may change, as the Gutenberg Core merge approaches. * * @since 1.0 */ @@ -203,9 +202,7 @@ public function enqueue_block_assets() { 'errorMessages' => $error_messages, ); - if ( function_exists( 'gutenberg_get_jed_locale_data' ) ) { - $script_data['i18n'] = gutenberg_get_jed_locale_data( 'amp' ); - } + $script_data['i18n'] = function_exists( 'wp_get_jed_locale_data' ) ? wp_get_jed_locale_data( 'amp' ) : gutenberg_get_jed_locale_data( 'amp' ); wp_add_inline_script( self::BLOCK_ASSET_HANDLE, diff --git a/includes/validation/class-amp-validation-manager.php b/includes/validation/class-amp-validation-manager.php index aed654edfbd..c4debbe27e0 100644 --- a/includes/validation/class-amp-validation-manager.php +++ b/includes/validation/class-amp-validation-manager.php @@ -1916,7 +1916,7 @@ public static function enqueue_block_validation() { ); $data = wp_json_encode( array( - 'i18n' => gutenberg_get_jed_locale_data( 'amp' ), + 'i18n' => function_exists( 'wp_get_jed_locale_data' ) ? wp_get_jed_locale_data( 'amp' ) : gutenberg_get_jed_locale_data( 'amp' ), 'ampValidityRestField' => self::VALIDITY_REST_FIELD_NAME, 'isCanonical' => amp_is_canonical(), ) ); diff --git a/tests/test-class-amp-meta-box.php b/tests/test-class-amp-meta-box.php index 35b61032cdc..5f386a9f14a 100644 --- a/tests/test-class-amp-meta-box.php +++ b/tests/test-class-amp-meta-box.php @@ -77,7 +77,7 @@ public function test_enqueue_admin_assets() { * @see AMP_Post_Meta_Box::enqueue_block_assets() */ public function test_enqueue_block_assets() { - if ( ! function_exists( 'gutenberg_get_jed_locale_data' ) ) { + if ( ! function_exists( 'wp_get_jed_locale_data' ) && ! function_exists( 'gutenberg_get_jed_locale_data' ) ) { $this->markTestSkipped( 'Gutenberg is not available' ); }