Skip to content

Commit

Permalink
Fix usage of gutenberg_get_jed_locale_data() for WP 5.0
Browse files Browse the repository at this point in the history
Fixes #1618
  • Loading branch information
westonruter committed Nov 16, 2018
1 parent 34301c1 commit c5b505a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion includes/admin/class-amp-editor-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}
Expand Down
5 changes: 1 addition & 4 deletions includes/admin/class-amp-post-meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion includes/validation/class-amp-validation-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
) );
Expand Down
2 changes: 1 addition & 1 deletion tests/test-class-amp-meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}

Expand Down

0 comments on commit c5b505a

Please sign in to comment.