From 633dd26aaad4ca0284aa7f2aa6cab849615f310c Mon Sep 17 00:00:00 2001 From: Daniel Walmsley Date: Tue, 15 May 2018 09:34:05 -0700 Subject: [PATCH 1/6] Deprecate Jetpack helper --- amp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amp.php b/amp.php index 4d6d8e4522f..efe576d4e72 100644 --- a/amp.php +++ b/amp.php @@ -121,7 +121,7 @@ function amp_init() { // Redirect the old url of amp page to the updated url. add_filter( 'old_slug_redirect_url', 'amp_redirect_old_slug_to_new_url' ); - if ( class_exists( 'Jetpack' ) && ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) { + if ( class_exists( 'Jetpack' ) && ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) && version_compare( JETPACK__VERSION, '6.2-alpha', '<' ) ) { require_once AMP__DIR__ . '/jetpack-helper.php'; } From ca228c0b218a26af6ce571950939dd734a853b4c Mon Sep 17 00:00:00 2001 From: Daniel Walmsley Date: Tue, 15 May 2018 11:17:08 -0700 Subject: [PATCH 2/6] Move some wpcom-helper features to Jetpack 6.2 --- wpcom-helper.php | 91 ------------------------------------------------ 1 file changed, 91 deletions(-) diff --git a/wpcom-helper.php b/wpcom-helper.php index 05e9bc8b175..5f65480bbb5 100644 --- a/wpcom-helper.php +++ b/wpcom-helper.php @@ -63,97 +63,6 @@ function jetpack_amp_post_template_metadata( $metadata, $post ) { return $metadata; } -/** - * Add blavatar to metadata. - * - * @since 0.3 - * - * @param array $metadata Metadata. - * @return array Metadata. - */ -function wpcom_amp_add_blavatar_to_metadata( $metadata ) { - if ( ! function_exists( 'blavatar_domain' ) ) { - return $metadata; - } - - $size = 60; - - $metadata['publisher']['logo'] = array( - '@type' => 'ImageObject', - 'url' => blavatar_url( blavatar_domain( site_url() ), 'img', $size, staticize_subdomain( 'https://wordpress.com/i/favicons/apple-touch-icon-60x60.png' ) ), - 'width' => $size, - 'height' => $size, - ); - - return $metadata; -} - -/** - * Add image to metadata. - * - * @since 0.3.2 - * - * @param array $metadata Metadata. - * @param WP_Post $post Post. - * @return array Metadata. - */ -function wpcom_amp_add_image_to_metadata( $metadata, $post ) { - if ( ! class_exists( 'Jetpack_PostImages' ) ) { - return wpcom_amp_add_fallback_image_to_metadata( $metadata ); - } - - $image = Jetpack_PostImages::get_image( $post->ID, array( - 'fallback_to_avatars' => true, - 'avatar_size' => 200, - // AMP already attempts these. - 'from_thumbnail' => false, - 'from_attachment' => false, - ) ); - - if ( empty( $image ) ) { - return wpcom_amp_add_fallback_image_to_metadata( $metadata ); - } - - if ( ! isset( $image['src_width'] ) ) { - $dimensions = wpcom_amp_extract_image_dimensions_from_getimagesize( array( - $image['src'] => false, - ) ); - - if ( false !== $dimensions[ $image['src'] ] ) { - $image['src_width'] = $dimensions['width']; - $image['src_height'] = $dimensions['height']; - } - } - - $metadata['image'] = array( - '@type' => 'ImageObject', - 'url' => $image['src'], - 'width' => $image['src_width'], - 'height' => $image['src_height'], - ); - - return $metadata; -} - -/** - * Add fallback image to metadata. - * - * @since 0.3.2 - * - * @param array $metadata Metadata. - * @return array Metadata. - */ -function wpcom_amp_add_fallback_image_to_metadata( $metadata ) { - $metadata['image'] = array( - '@type' => 'ImageObject', - 'url' => staticize_subdomain( 'https://wordpress.com/i/blank.jpg' ), - 'width' => 200, - 'height' => 200, - ); - - return $metadata; -} - add_action( 'amp_extract_image_dimensions_batch_callbacks_registered', 'wpcom_amp_extract_image_dimensions_batch_add_custom_callbacks' ); /** From 3eabb2d7f743f4bd55ea9489db69222e431817d6 Mon Sep 17 00:00:00 2001 From: Daniel Walmsley Date: Wed, 16 May 2018 14:42:18 -0700 Subject: [PATCH 3/6] Remove filters that have been ported to Jetpack --- wpcom-helper.php | 54 ------------------------------------------------ 1 file changed, 54 deletions(-) diff --git a/wpcom-helper.php b/wpcom-helper.php index 5f65480bbb5..07b7d87d08a 100644 --- a/wpcom-helper.php +++ b/wpcom-helper.php @@ -6,63 +6,9 @@ * @package AMP */ -add_action( 'pre_amp_render_post', 'jetpack_amp_disable_the_content_filters' ); - // Disable admin menu. add_filter( 'amp_options_menu_is_enabled', '__return_false', 9999 ); -/** - * Disable the_content filters for Jetpack. - * - * @since 0.3 - */ -function jetpack_amp_disable_the_content_filters() { - add_filter( 'post_flair_disable', '__return_true', 99 ); - add_filter( 'videopress_show_2015_player', '__return_true' ); - add_filter( 'protected_embeds_use_form_post', '__return_false' ); - - remove_filter( 'the_title', 'widont' ); - - remove_filter( 'pre_kses', array( 'Filter_Embedded_HTML_Objects', 'filter' ), 11 ); - remove_filter( 'pre_kses', array( 'Filter_Embedded_HTML_Objects', 'maybe_create_links' ), 100 ); -} - -add_action( 'amp_post_template_head', 'jetpack_amp_add_og_tags' ); - -/** - * Add Open Graph tags. - * - * @since 0.3 - */ -function jetpack_amp_add_og_tags() { - if ( function_exists( 'jetpack_og_tags' ) ) { - jetpack_og_tags(); - } -} - -add_filter( 'amp_post_template_metadata', 'jetpack_amp_post_template_metadata', 10, 2 ); - -/** - * Add publisher and image metadata. - * - * @since 0.3 - * - * @param array $metadata Metadata array. - * @param WP_Post $post Post. - * @return array Modified metadata array. - */ -function jetpack_amp_post_template_metadata( $metadata, $post ) { - if ( isset( $metadata['publisher'] ) && ! isset( $metadata['publisher']['logo'] ) ) { - $metadata = wpcom_amp_add_blavatar_to_metadata( $metadata ); - } - - if ( ! isset( $metadata['image'] ) ) { - $metadata = wpcom_amp_add_image_to_metadata( $metadata, $post ); - } - - return $metadata; -} - add_action( 'amp_extract_image_dimensions_batch_callbacks_registered', 'wpcom_amp_extract_image_dimensions_batch_add_custom_callbacks' ); /** From 9389701507f8e7bf0b49ff539badef42a8238c5b Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 23 May 2018 13:18:35 -0700 Subject: [PATCH 4/6] Bump 0.7.1 --- amp.php | 4 ++-- readme.md | 5 +++-- readme.txt | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/amp.php b/amp.php index efe576d4e72..d53cf102e12 100644 --- a/amp.php +++ b/amp.php @@ -5,7 +5,7 @@ * Plugin URI: https://github.com/automattic/amp-wp * Author: WordPress.com VIP, XWP, Google, and contributors * Author URI: https://github.com/Automattic/amp-wp/graphs/contributors - * Version: 0.7.1-alpha + * Version: 0.7.1 * Text Domain: amp * Domain Path: /languages/ * License: GPLv2 or later @@ -32,7 +32,7 @@ function _amp_print_php_version_admin_notice() { define( 'AMP__FILE__', __FILE__ ); define( 'AMP__DIR__', dirname( __FILE__ ) ); -define( 'AMP__VERSION', '0.7.1-alpha' ); +define( 'AMP__VERSION', '0.7.1' ); require_once AMP__DIR__ . '/includes/class-amp-autoloader.php'; AMP_Autoloader::register(); diff --git a/readme.md b/readme.md index e9dd08085bf..70f0e228f53 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ Enable Accelerated Mobile Pages (AMP) on your WordPress site. **Tags:** [amp](https://wordpress.org/plugins/tags/amp), [mobile](https://wordpress.org/plugins/tags/mobile) **Requires at least:** 4.7 **Tested up to:** 4.9 -**Stable tag:** 0.7.0 +**Stable tag:** 0.7.1 **License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html) **Requires PHP:** 5.3 @@ -62,13 +62,14 @@ Follow along with or [contribute](https://github.com/Automattic/amp-wp/blob/deve ## Changelog ## -### 0.7.1 (Unreleased) ### +### 0.7.1 (2018-05-23) ### - Limit showing AMP validation warnings to when `amp` theme support is present. See [#1132](https://github.com/Automattic/amp-wp/pull/1132). Props westonruter. - Supply the extracted dimensions to images determined to need them; fixes regression from 0.6 this is key for Gutenberg compat. See [#1117](https://github.com/Automattic/amp-wp/pull/1117). Props westonruter. - Ensure before/after is amended to filtered comment_reply_link. See [#1118](https://github.com/Automattic/amp-wp/pull/1118). Props westonruter. - Force VideoPress to use html5 player for AMP. See [#1125](https://github.com/Automattic/amp-wp/pull/1125). Props yurynix. - Soft-deprecate `AMP_Base_Sanitizer::get_body_node()` instead of hard-deprecating it (with triggered notice). See [#1141](https://github.com/Automattic/amp-wp/pull/1141). Props westonruter. - Pass '/' as an argument to home_url(), preventing possible 404. See [#1158](https://github.com/Automattic/amp-wp/issues/1158), [#1161](https://github.com/Automattic/amp-wp/pull/1161). Props kienstra. +- Deprecate Jetpack helper and some parts of WPCOM helper for Jetpack 6.2. See [#1149](https://github.com/Automattic/amp-wp/pull/1149). Props gravityrail. See [0.7.1 milestone](https://github.com/Automattic/amp-wp/milestone/8?closed=1). diff --git a/readme.txt b/readme.txt index 5733d46547a..46c6456f430 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: batmoo, joen, automattic, potatomaster, albertomedina, google, xwp Tags: amp, mobile Requires at least: 4.7 Tested up to: 4.9 -Stable tag: 0.7.0 +Stable tag: 0.7.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Requires PHP: 5.3 @@ -44,13 +44,15 @@ Follow along with or [contribute](https://github.com/Automattic/amp-wp/blob/deve == Changelog == -= 0.7.1 (Unreleased) = += 0.7.1 (2018-05-23) = + - Limit showing AMP validation warnings to when `amp` theme support is present. See [#1132](https://github.com/Automattic/amp-wp/pull/1132). Props westonruter. - Supply the extracted dimensions to images determined to need them; fixes regression from 0.6 this is key for Gutenberg compat. See [#1117](https://github.com/Automattic/amp-wp/pull/1117). Props westonruter. - Ensure before/after is amended to filtered comment_reply_link. See [#1118](https://github.com/Automattic/amp-wp/pull/1118). Props westonruter. - Force VideoPress to use html5 player for AMP. See [#1125](https://github.com/Automattic/amp-wp/pull/1125). Props yurynix. - Soft-deprecate `AMP_Base_Sanitizer::get_body_node()` instead of hard-deprecating it (with triggered notice). See [#1141](https://github.com/Automattic/amp-wp/pull/1141). Props westonruter. - Pass '/' as an argument to home_url(), preventing possible 404. See [#1158](https://github.com/Automattic/amp-wp/issues/1158), [#1161](https://github.com/Automattic/amp-wp/pull/1161). Props kienstra. +- Deprecate Jetpack helper and some parts of WPCOM helper for Jetpack 6.2. See [#1149](https://github.com/Automattic/amp-wp/pull/1149). Props gravityrail. See [0.7.1 milestone](https://github.com/Automattic/amp-wp/milestone/8?closed=1). From a4dd15cb4b43afba2acdcf7a0947cf0bc05783e1 Mon Sep 17 00:00:00 2001 From: Miina Sikk Date: Wed, 23 May 2018 22:20:59 +0300 Subject: [PATCH 5/6] Add hooks within test. --- tests/test-class-amp-theme-support.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-class-amp-theme-support.php b/tests/test-class-amp-theme-support.php index 2a35a0bdc01..bcf23f239b4 100644 --- a/tests/test-class-amp-theme-support.php +++ b/tests/test-class-amp-theme-support.php @@ -1102,6 +1102,7 @@ public function test_prepare_response_bad_html() { public function test_prepare_response_to_add_html5_doctype_and_amp_attribute() { add_theme_support( 'amp' ); AMP_Theme_Support::init(); + AMP_Theme_Support::add_hooks(); ob_start(); ?> From 77e29aa421756305954f355838026b599957a4a0 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 23 May 2018 13:47:48 -0700 Subject: [PATCH 6/6] Remove print_emoji_detection_script in tests for sake of WordPress 5.0-alpha --- tests/test-class-amp-widget-recent-comments.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test-class-amp-widget-recent-comments.php b/tests/test-class-amp-widget-recent-comments.php index 4d74f160a8b..34185328ace 100644 --- a/tests/test-class-amp-widget-recent-comments.php +++ b/tests/test-class-amp-widget-recent-comments.php @@ -44,6 +44,8 @@ public function test_construct() { * @covers AMP_Widget_Recent_Comments::remove_head_style_in_amp() */ public function test_remove_head_style_in_amp() { + remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); // Workaround for WordPress 5.0-alpha (#43055). + new AMP_Widget_Recent_Comments(); $this->assertTrue( apply_filters( 'show_recent_comments_widget_style', true ) ); ob_start(); @@ -58,6 +60,8 @@ public function test_remove_head_style_in_amp() { * @covers AMP_Widget_Recent_Comments::remove_head_style_in_amp() */ public function test_remove_head_style_in_amp_not() { + remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); // Workaround for WordPress 5.0-alpha (#43055). + remove_theme_support( 'amp' ); new AMP_Widget_Recent_Comments(); $this->assertTrue( apply_filters( 'show_recent_comments_widget_style', true ) );