AMP for WordPress - Version 1.1.1

Version Description

Download this release

Release Info

Developer westonruter
Plugin Icon 128x128 AMP for WordPress
Version 1.1.1
Comparing to
See all releases

Code changes from version 1.1.0 to 1.1.1

amp.php CHANGED
@@ -5,7 +5,7 @@
5
  * Plugin URI: https://amp-wp.org
6
  * Author: AMP Project Contributors
7
  * Author URI: https://github.com/ampproject/amp-wp/graphs/contributors
8
- * Version: 1.1.0
9
  * Text Domain: amp
10
  * Domain Path: /languages/
11
  * License: GPLv2 or later
@@ -115,7 +115,7 @@ if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) || ! file_exists( __DIR__
115
 
116
  define( 'AMP__FILE__', __FILE__ );
117
  define( 'AMP__DIR__', dirname( __FILE__ ) );
118
- define( 'AMP__VERSION', '1.1.0' );
119
 
120
  /**
121
  * Print admin notice if plugin installed with incorrect slug (which impacts WordPress's auto-update system).
5
  * Plugin URI: https://amp-wp.org
6
  * Author: AMP Project Contributors
7
  * Author URI: https://github.com/ampproject/amp-wp/graphs/contributors
8
+ * Version: 1.1.1
9
  * Text Domain: amp
10
  * Domain Path: /languages/
11
  * License: GPLv2 or later
115
 
116
  define( 'AMP__FILE__', __FILE__ );
117
  define( 'AMP__DIR__', dirname( __FILE__ ) );
118
+ define( 'AMP__VERSION', '1.1.1' );
119
 
120
  /**
121
  * Print admin notice if plugin installed with incorrect slug (which impacts WordPress's auto-update system).
includes/class-amp-comment-walker.php CHANGED
@@ -6,7 +6,8 @@
6
  * @package AMP
7
  */
8
 
9
- _deprecated_file( __FILE__, '1.1', null, esc_html__( 'AMP_Comment_Walker functionality has been moved to AMP_Comments_Sanitizer.', 'amp' ) );
 
10
 
11
  /**
12
  * Class AMP_Comment_Walker
6
  * @package AMP
7
  */
8
 
9
+ /* translators: 1: AMP_Comment_Walker. 2: AMP_Comments_Sanitizer. */
10
+ _deprecated_file( __FILE__, '1.1', null, sprintf( esc_html__( '%1$s functionality has been moved to %2$s.', 'amp' ), 'AMP_Comment_Walker', 'AMP_Comments_Sanitizer' ) );
11
 
12
  /**
13
  * Class AMP_Comment_Walker
includes/class-amp-service-worker.php CHANGED
@@ -83,7 +83,8 @@ class AMP_Service_Worker {
83
  */
84
  public static function add_cdn_script_caching( $service_workers ) {
85
  if ( ! ( $service_workers instanceof WP_Service_Worker_Scripts ) ) {
86
- _doing_it_wrong( __METHOD__, esc_html__( 'Please update to PWA v0.2. Expected argument to be WP_Service_Worker_Cache_Registry.', 'amp' ), '1.1' );
 
87
  return;
88
  }
89
 
83
  */
84
  public static function add_cdn_script_caching( $service_workers ) {
85
  if ( ! ( $service_workers instanceof WP_Service_Worker_Scripts ) ) {
86
+ /* translators: %s: WP_Service_Worker_Cache_Registry. */
87
+ _doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Please update to PWA v0.2. Expected argument to be %s.', 'amp' ), 'WP_Service_Worker_Cache_Registry' ), '1.1' );
88
  return;
89
  }
90
 
includes/options/class-amp-options-manager.php CHANGED
@@ -537,7 +537,7 @@ class AMP_Options_Manager {
537
  if ( is_wp_error( $validation ) ) {
538
  $review_messages[] = esc_html(
539
  sprintf(
540
- /* translators: %1$s is the error message, %2$s is the error code */
541
  __( 'However, there was an error when checking the AMP validity for your site.', 'amp' ),
542
  $validation->get_error_message(),
543
  $validation->get_error_code()
@@ -616,7 +616,7 @@ class AMP_Options_Manager {
616
  if ( $new_errors > 0 && $invalid_url_screen_url ) {
617
  $message .= ' ' . wp_kses_post(
618
  sprintf(
619
- /* translators: %1$s is URL to review issues, %2$s is count of new errors */
620
  _n(
621
  'Please also <a href="%1$s">review %2$s issue</a> which may need to be fixed (for one URL at least).',
622
  'Please also <a href="%1$s">review %2$s issues</a> which may need to be fixed (for one URL at least).',
537
  if ( is_wp_error( $validation ) ) {
538
  $review_messages[] = esc_html(
539
  sprintf(
540
+ /* translators: 1: error message. 2: error code. */
541
  __( 'However, there was an error when checking the AMP validity for your site.', 'amp' ),
542
  $validation->get_error_message(),
543
  $validation->get_error_code()
616
  if ( $new_errors > 0 && $invalid_url_screen_url ) {
617
  $message .= ' ' . wp_kses_post(
618
  sprintf(
619
+ /* translators: 1: URL to review issues. 2: count of new errors. */
620
  _n(
621
  'Please also <a href="%1$s">review %2$s issue</a> which may need to be fixed (for one URL at least).',
622
  'Please also <a href="%1$s">review %2$s issues</a> which may need to be fixed (for one URL at least).',
includes/options/class-amp-options-menu.php CHANGED
@@ -210,7 +210,7 @@ class AMP_Options_Menu {
210
  <?php
211
  echo wp_kses_post(
212
  sprintf(
213
- /* translators: %1$s is link to invalid URLs and %2$s is link to validation errors */
214
  __( 'View current site compatibility results for native and transitional modes: %1$s and %2$s.', 'amp' ),
215
  sprintf(
216
  '<a href="%s">%s</a>',
210
  <?php
211
  echo wp_kses_post(
212
  sprintf(
213
+ /* translators: %1: link to invalid URLs. 2: link to validation errors. */
214
  __( 'View current site compatibility results for native and transitional modes: %1$s and %2$s.', 'amp' ),
215
  sprintf(
216
  '<a href="%s">%s</a>',
includes/options/views/class-amp-analytics-options-submenu-page.php CHANGED
@@ -106,7 +106,7 @@ class AMP_Analytics_Options_Submenu_Page {
106
  /* translators: 1: AMP Analytics docs URL. 2: AMP for WordPress analytics docs URL. 3: AMP analytics code reference. 4: amp-analytics, 5: {. 6: }. 7: <script>, 8: googleanalytics. 9: AMP analytics vendor docs URL. 10: UA-XXXXX-Y. */
107
  __( 'For Google Analytics, please see <a href="%1$s" target="_blank">Adding Analytics to your AMP pages</a>; see also the <a href="%2$s" target="_blank">Analytics wiki page</a> and the AMP project\'s <a href="%3$s" target="_blank">%4$s documentation</a>. The analytics configuration supplied below must take the form of JSON objects, which begin with a %5$s and end with a %6$s. Do not include any HTML tags like %4$s or %7$s. A common entry would have the type %8$s (see <a href="%9$s" target="_blank">available vendors</a>) and a configuration that looks like the following (where %10$s is replaced with your own site\'s account number):', 'amp' ),
108
  __( 'https://developers.google.com/analytics/devguides/collection/amp-analytics/', 'amp' ),
109
- __( 'https://github.com/ampproject/amp-wp/wiki/Analytics', 'amp' ),
110
  __( 'https://www.ampproject.org/docs/reference/components/amp-analytics', 'amp' ),
111
  '<code>amp-analytics</code>',
112
  '<code>{</code>',
106
  /* translators: 1: AMP Analytics docs URL. 2: AMP for WordPress analytics docs URL. 3: AMP analytics code reference. 4: amp-analytics, 5: {. 6: }. 7: <script>, 8: googleanalytics. 9: AMP analytics vendor docs URL. 10: UA-XXXXX-Y. */
107
  __( 'For Google Analytics, please see <a href="%1$s" target="_blank">Adding Analytics to your AMP pages</a>; see also the <a href="%2$s" target="_blank">Analytics wiki page</a> and the AMP project\'s <a href="%3$s" target="_blank">%4$s documentation</a>. The analytics configuration supplied below must take the form of JSON objects, which begin with a %5$s and end with a %6$s. Do not include any HTML tags like %4$s or %7$s. A common entry would have the type %8$s (see <a href="%9$s" target="_blank">available vendors</a>) and a configuration that looks like the following (where %10$s is replaced with your own site\'s account number):', 'amp' ),
108
  __( 'https://developers.google.com/analytics/devguides/collection/amp-analytics/', 'amp' ),
109
+ __( 'https://amp-wp.org/documentation/playbooks/analytics/', 'amp' ),
110
  __( 'https://www.ampproject.org/docs/reference/components/amp-analytics', 'amp' ),
111
  '<code>amp-analytics</code>',
112
  '<code>{</code>',
includes/sanitizers/class-amp-style-sanitizer.php CHANGED
@@ -2404,7 +2404,7 @@ class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
2404
  ) . "\n" . implode( "\n", $included_sources ) . "\n";
2405
  if ( self::has_required_php_css_parser() ) {
2406
  $comment .= sprintf(
2407
- /* translators: %1$d is number of included bytes, %2$d is percentage of total CSS actually included after tree shaking, %3$d is total included size */
2408
  esc_html__( 'Total included size: %1$s bytes (%2$d%% of %3$s total after tree shaking)', 'amp' ),
2409
  number_format_i18n( $included_size ),
2410
  $included_size / $included_original_size * 100,
@@ -2412,8 +2412,8 @@ class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
2412
  ) . "\n";
2413
  } else {
2414
  $comment .= sprintf(
2415
- /* translators: %1$d is number of included bytes */
2416
- esc_html__( 'Total included size: %1$s bytes', 'amp' ),
2417
  number_format_i18n( $included_size ),
2418
  $included_size / $included_original_size * 100,
2419
  number_format_i18n( $included_original_size )
2404
  ) . "\n" . implode( "\n", $included_sources ) . "\n";
2405
  if ( self::has_required_php_css_parser() ) {
2406
  $comment .= sprintf(
2407
+ /* translators: 1: number of included bytes. 2: percentage of total CSS actually included after tree shaking. 3: total included size. */
2408
  esc_html__( 'Total included size: %1$s bytes (%2$d%% of %3$s total after tree shaking)', 'amp' ),
2409
  number_format_i18n( $included_size ),
2410
  $included_size / $included_original_size * 100,
2412
  ) . "\n";
2413
  } else {
2414
  $comment .= sprintf(
2415
+ /* translators: %s: number of included bytes. */
2416
+ esc_html__( 'Total included size: %s bytes', 'amp' ),
2417
  number_format_i18n( $included_size ),
2418
  $included_size / $included_original_size * 100,
2419
  number_format_i18n( $included_original_size )
includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php CHANGED
@@ -1841,7 +1841,7 @@ class AMP_Tag_And_Attribute_Sanitizer extends AMP_Base_Sanitizer {
1841
  }
1842
 
1843
  // If the first element is not of the required type, invalidate the entire element.
1844
- if ( isset( $child_tags['first_child_tag_name_oneof'] ) && ( empty( $child_elements[0] ) || ! in_array( $child_elements[0]->nodeName, $child_tags['first_child_tag_name_oneof'], true ) ) ) {
1845
  return false;
1846
  }
1847
 
1841
  }
1842
 
1843
  // If the first element is not of the required type, invalidate the entire element.
1844
+ if ( isset( $child_tags['first_child_tag_name_oneof'] ) && ! empty( $child_elements[0] ) && ! in_array( $child_elements[0]->nodeName, $child_tags['first_child_tag_name_oneof'], true ) ) {
1845
  return false;
1846
  }
1847
 
includes/validation/class-amp-validated-url-post-type.php CHANGED
@@ -457,7 +457,7 @@ class AMP_Validated_URL_Post_Type {
457
  $result = array();
458
  if ( $counts['new_rejected'] ) {
459
  $result[] = sprintf(
460
- /* translators: %1$s is the status, %2$s is the count */
461
  '<span class="status-text new new-rejected">%1$s: %2$s</span>',
462
  esc_html__( 'New Rejected', 'amp' ),
463
  number_format_i18n( $counts['new_rejected'] )
@@ -465,7 +465,7 @@ class AMP_Validated_URL_Post_Type {
465
  }
466
  if ( $counts['new_accepted'] ) {
467
  $result[] = sprintf(
468
- /* translators: %1$s is the status, %2$s is the count */
469
  '<span class="status-text new new-accepted">%1$s: %2$s</span>',
470
  esc_html__( 'New Accepted', 'amp' ),
471
  number_format_i18n( $counts['new_accepted'] )
@@ -653,9 +653,14 @@ class AMP_Validated_URL_Post_Type {
653
  $stored_validation_errors = array();
654
 
655
  // Prevent Kses from corrupting JSON in description.
656
- $has_pre_term_description_filter = has_filter( 'pre_term_description', 'wp_filter_kses' );
657
- if ( false !== $has_pre_term_description_filter ) {
658
- remove_filter( 'pre_term_description', 'wp_filter_kses', $has_pre_term_description_filter );
 
 
 
 
 
659
  }
660
 
661
  $terms = array();
@@ -713,8 +718,10 @@ class AMP_Validated_URL_Post_Type {
713
  }
714
 
715
  // Finish preventing Kses from corrupting JSON in description.
716
- if ( false !== $has_pre_term_description_filter ) {
717
- add_filter( 'pre_term_description', 'wp_filter_kses', $has_pre_term_description_filter );
 
 
718
  }
719
 
720
  $post_content = wp_json_encode( $stored_validation_errors );
457
  $result = array();
458
  if ( $counts['new_rejected'] ) {
459
  $result[] = sprintf(
460
+ /* translators: 1: status. 2: count. */
461
  '<span class="status-text new new-rejected">%1$s: %2$s</span>',
462
  esc_html__( 'New Rejected', 'amp' ),
463
  number_format_i18n( $counts['new_rejected'] )
465
  }
466
  if ( $counts['new_accepted'] ) {
467
  $result[] = sprintf(
468
+ /* translators: 1: status. 2: count. */
469
  '<span class="status-text new new-accepted">%1$s: %2$s</span>',
470
  esc_html__( 'New Accepted', 'amp' ),
471
  number_format_i18n( $counts['new_accepted'] )
653
  $stored_validation_errors = array();
654
 
655
  // Prevent Kses from corrupting JSON in description.
656
+ $pre_term_description_filters = array(
657
+ 'wp_filter_kses' => has_filter( 'pre_term_description', 'wp_filter_kses' ),
658
+ 'wp_targeted_link_rel' => has_filter( 'pre_term_description', 'wp_targeted_link_rel' ),
659
+ );
660
+ foreach ( $pre_term_description_filters as $callback => $priority ) {
661
+ if ( false !== $priority ) {
662
+ remove_filter( 'pre_term_description', $callback, $priority );
663
+ }
664
  }
665
 
666
  $terms = array();
718
  }
719
 
720
  // Finish preventing Kses from corrupting JSON in description.
721
+ foreach ( $pre_term_description_filters as $callback => $priority ) {
722
+ if ( false !== $priority ) {
723
+ add_filter( 'pre_term_description', $callback, $priority );
724
+ }
725
  }
726
 
727
  $post_content = wp_json_encode( $stored_validation_errors );
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: automattic, xwp, google, westonruter, ryankienstra, batmoo, stubgo, albertomedina, tweetythierry, joshuawold, postphotos
3
  Tags: amp, mobile
4
  Requires at least: 4.9
5
- Tested up to: 5.1
6
- Stable tag: 1.1.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Requires PHP: 5.4
2
  Contributors: automattic, xwp, google, westonruter, ryankienstra, batmoo, stubgo, albertomedina, tweetythierry, joshuawold, postphotos
3
  Tags: amp, mobile
4
  Requires at least: 4.9
5
+ Tested up to: 5.2
6
+ Stable tag: 1.1.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Requires PHP: 5.4