Skip to content

Commit

Permalink
Merge pull request #1170 from Automattic/update/release-0.7.1
Browse files Browse the repository at this point in the history
Release 0.7.1
  • Loading branch information
westonruter committed May 23, 2018
2 parents 62483f0 + 77e29aa commit cfee839
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 152 deletions.
6 changes: 3 additions & 3 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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';
}

Expand Down
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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).

Expand Down
6 changes: 4 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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).

Expand Down
1 change: 1 addition & 0 deletions tests/test-class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Expand Down
4 changes: 4 additions & 0 deletions tests/test-class-amp-widget-recent-comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 ) );
Expand Down
145 changes: 0 additions & 145 deletions wpcom-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,154 +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 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' );

/**
Expand Down

0 comments on commit cfee839

Please sign in to comment.