Skip to content

Commit

Permalink
Merge tag '1.1.1'
Browse files Browse the repository at this point in the history
* tag '1.1.1':
  Update release instructions
  Bump version to 1.1.1
  Prevent wp_targeted_link_rel() from corrupting JSON in amp_validation_error term_description
  Fix first_child_tag_name_oneof constraint to only apply if first child exists
  Fix some more i18n strings and placeholders
  Fix link to outdated wiki page for AMP analytics
  Bump 1.1 branch to 1.1.1-alpha
  • Loading branch information
westonruter committed Apr 23, 2019
2 parents 4bbd1eb + 885e488 commit 099b979
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 31 deletions.
4 changes: 2 additions & 2 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Plugin URI: https://amp-wp.org
* Author: AMP Project Contributors
* Author URI: https://github.com/ampproject/amp-wp/graphs/contributors
* Version: 1.1.0
* Version: 1.1.1
* Text Domain: amp
* Domain Path: /languages/
* License: GPLv2 or later
Expand Down Expand Up @@ -115,7 +115,7 @@ function _amp_print_build_needed_notice() {

define( 'AMP__FILE__', __FILE__ );
define( 'AMP__DIR__', dirname( __FILE__ ) );
define( 'AMP__VERSION', '1.1.0' );
define( 'AMP__VERSION', '1.1.1' );

/**
* Print admin notice if plugin installed with incorrect slug (which impacts WordPress's auto-update system).
Expand Down
13 changes: 9 additions & 4 deletions bin/tag-built.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

set -e

tag=$(git describe --tags)
tag=$(cat build/amp.php | grep 'Version:' | sed 's/.*: //')
if [[ -z "$tag" ]]; then
echo "Error: Unable to determine tag."
echo "Error: Unable to determine tag from build/amp.php."
exit 1
fi
if ! git rev-parse "$tag" >/dev/null 2>&1; then
echo "Error: Tag does not exist: $tag"
exit 2
fi

built_tag="$tag-built"
if git rev-parse "$built_tag" >/dev/null 2>&1; then
Expand All @@ -19,8 +23,9 @@ if ! git diff-files --quiet || ! git diff-index --quiet --cached HEAD --; then
exit 3
fi

git checkout "$tag"
npm run build
if [[ -e built ]]; then
rm -rf built
fi
mkdir built
git clone . built/
cd built
Expand Down
13 changes: 7 additions & 6 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,10 @@ Contributors who want to make a new release, follow these steps:
7. Run `npm run deploy` to commit the plugin to WordPress.org.
8. Confirm the release is available on WordPress.org; try installing it on a WordPress install and confirm it works.
9. Publish GitHub release.
10. Create built release tag: `git fetch --tags && git checkout $(git tag | tail -n1) && ./bin/tag-built.sh` (then add link from release)
11. Create a new branch off of the release branch (e.g. `update/develop-with-1.0.x`), merge `develop` into it and resolve conflicts (e.g. with version), and then open pull request to merge changes into `develop`.
12. Merge release tag into `master`.
13. Publish release blog post, including link to GitHub release.
14. Close the GitHub milestone and project.
15. Make announcements.
10. Create built release tag (from the just-created `build` directory): `git fetch --tags && ./bin/tag-built.sh` (then add link from release)
11. For new major/minor releases, create a release branch from the tag. Patch versions are made from the release branch.
12. Bump `Stable tag` in the `readme.txt`/`readme.md` in `develop`. Cherry-pick other changes as necessary.
13. Merge release tag into `master`.
14. Publish release blog post, including link to GitHub release.
15. Close the GitHub milestone and project.
16. Make announcements.
3 changes: 2 additions & 1 deletion includes/class-amp-comment-walker.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* @package AMP
*/

_deprecated_file( __FILE__, '1.1', null, esc_html__( 'AMP_Comment_Walker functionality has been moved to AMP_Comments_Sanitizer.', 'amp' ) );
/* translators: 1: AMP_Comment_Walker. 2: AMP_Comments_Sanitizer. */
_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' ) );

/**
* Class AMP_Comment_Walker
Expand Down
3 changes: 2 additions & 1 deletion includes/class-amp-service-worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public static function add_query_var( $vars ) {
*/
public static function add_cdn_script_caching( $service_workers ) {
if ( ! ( $service_workers instanceof WP_Service_Worker_Scripts ) ) {
_doing_it_wrong( __METHOD__, esc_html__( 'Please update to PWA v0.2. Expected argument to be WP_Service_Worker_Cache_Registry.', 'amp' ), '1.1' );
/* translators: %s: WP_Service_Worker_Cache_Registry. */
_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' );
return;
}

Expand Down
4 changes: 2 additions & 2 deletions includes/options/class-amp-options-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ public static function handle_updated_theme_support_option() {
if ( is_wp_error( $validation ) ) {
$review_messages[] = esc_html(
sprintf(
/* translators: %1$s is the error message, %2$s is the error code */
/* translators: 1: error message. 2: error code. */
__( 'However, there was an error when checking the AMP validity for your site.', 'amp' ),
$validation->get_error_message(),
$validation->get_error_code()
Expand Down Expand Up @@ -616,7 +616,7 @@ public static function handle_updated_theme_support_option() {
if ( $new_errors > 0 && $invalid_url_screen_url ) {
$message .= ' ' . wp_kses_post(
sprintf(
/* translators: %1$s is URL to review issues, %2$s is count of new errors */
/* translators: 1: URL to review issues. 2: count of new errors. */
_n(
'Please also <a href="%1$s">review %2$s issue</a> which may need to be fixed (for one URL at least).',
'Please also <a href="%1$s">review %2$s issues</a> which may need to be fixed (for one URL at least).',
Expand Down
2 changes: 1 addition & 1 deletion includes/options/class-amp-options-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function render_theme_support() {
<?php
echo wp_kses_post(
sprintf(
/* translators: %1$s is link to invalid URLs and %2$s is link to validation errors */
/* translators: %1: link to invalid URLs. 2: link to validation errors. */
__( 'View current site compatibility results for native and transitional modes: %1$s and %2$s.', 'amp' ),
sprintf(
'<a href="%s">%s</a>',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function render_title( $has_entries = false ) {
/* 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. */
__( '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' ),
__( 'https://developers.google.com/analytics/devguides/collection/amp-analytics/', 'amp' ),
__( 'https://github.com/ampproject/amp-wp/wiki/Analytics', 'amp' ),
__( 'https://amp-wp.org/documentation/playbooks/analytics/', 'amp' ),
__( 'https://www.ampproject.org/docs/reference/components/amp-analytics', 'amp' ),
'<code>amp-analytics</code>',
'<code>{</code>',
Expand Down
6 changes: 3 additions & 3 deletions includes/sanitizers/class-amp-style-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2404,16 +2404,16 @@ private function finalize_styles() {
) . "\n" . implode( "\n", $included_sources ) . "\n";
if ( self::has_required_php_css_parser() ) {
$comment .= sprintf(
/* 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 */
/* translators: 1: number of included bytes. 2: percentage of total CSS actually included after tree shaking. 3: total included size. */
esc_html__( 'Total included size: %1$s bytes (%2$d%% of %3$s total after tree shaking)', 'amp' ),
number_format_i18n( $included_size ),
$included_size / $included_original_size * 100,
number_format_i18n( $included_original_size )
) . "\n";
} else {
$comment .= sprintf(
/* translators: %1$d is number of included bytes */
esc_html__( 'Total included size: %1$s bytes', 'amp' ),
/* translators: %s: number of included bytes. */
esc_html__( 'Total included size: %s bytes', 'amp' ),
number_format_i18n( $included_size ),
$included_size / $included_original_size * 100,
number_format_i18n( $included_original_size )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ private function check_valid_children( $node, $child_tags ) {
}

// If the first element is not of the required type, invalidate the entire element.
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 ) ) ) {
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 ) ) {
return false;
}

Expand Down
21 changes: 14 additions & 7 deletions includes/validation/class-amp-validated-url-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,15 @@ public static function display_invalid_url_validation_error_counts_summary( $pos
$result = array();
if ( $counts['new_rejected'] ) {
$result[] = sprintf(
/* translators: %1$s is the status, %2$s is the count */
/* translators: 1: status. 2: count. */
'<span class="status-text new new-rejected">%1$s: %2$s</span>',
esc_html__( 'New Rejected', 'amp' ),
number_format_i18n( $counts['new_rejected'] )
);
}
if ( $counts['new_accepted'] ) {
$result[] = sprintf(
/* translators: %1$s is the status, %2$s is the count */
/* translators: 1: status. 2: count. */
'<span class="status-text new new-accepted">%1$s: %2$s</span>',
esc_html__( 'New Accepted', 'amp' ),
number_format_i18n( $counts['new_accepted'] )
Expand Down Expand Up @@ -653,9 +653,14 @@ public static function store_validation_errors( $validation_errors, $url, $args
$stored_validation_errors = array();

// Prevent Kses from corrupting JSON in description.
$has_pre_term_description_filter = has_filter( 'pre_term_description', 'wp_filter_kses' );
if ( false !== $has_pre_term_description_filter ) {
remove_filter( 'pre_term_description', 'wp_filter_kses', $has_pre_term_description_filter );
$pre_term_description_filters = array(
'wp_filter_kses' => has_filter( 'pre_term_description', 'wp_filter_kses' ),
'wp_targeted_link_rel' => has_filter( 'pre_term_description', 'wp_targeted_link_rel' ),
);
foreach ( $pre_term_description_filters as $callback => $priority ) {
if ( false !== $priority ) {
remove_filter( 'pre_term_description', $callback, $priority );
}
}

$terms = array();
Expand Down Expand Up @@ -713,8 +718,10 @@ public static function store_validation_errors( $validation_errors, $url, $args
}

// Finish preventing Kses from corrupting JSON in description.
if ( false !== $has_pre_term_description_filter ) {
add_filter( 'pre_term_description', 'wp_filter_kses', $has_pre_term_description_filter );
foreach ( $pre_term_description_filters as $callback => $priority ) {
if ( false !== $priority ) {
add_filter( 'pre_term_description', $callback, $priority );
}
}

$post_content = wp_json_encode( $stored_validation_errors );
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Enable AMP on your WordPress site, the WordPress way.
**Tags:** [amp](https://wordpress.org/plugins/tags/amp), [mobile](https://wordpress.org/plugins/tags/mobile)
**Requires at least:** 4.9
**Tested up to:** 5.1
**Stable tag:** 1.1.0
**Stable tag:** 1.1.1
**License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html)
**Requires PHP:** 5.4

Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: automattic, xwp, google, westonruter, ryankienstra, batmoo, stubgo
Tags: amp, mobile
Requires at least: 4.9
Tested up to: 5.1
Stable tag: 1.1.0
Stable tag: 1.1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Requires PHP: 5.4
Expand Down
6 changes: 6 additions & 0 deletions tests/test-tag-and-attribute-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,12 @@ function() {
array(),
),

'amp-state-src' => array(
'<amp-state id="myRemoteState" src="https://data.com/articles.json"></amp-state>',
null,
array( 'amp-bind' ),
),

// Adapted from <https://www.ampproject.org/docs/reference/components/amp-selector>.
'reference-points-amp_selector_and_carousel_with_boolean_attributes' => array(
str_replace(
Expand Down
11 changes: 11 additions & 0 deletions tests/validation/test-class-amp-validated-url-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,16 @@ function( $sanitized, $error ) {
),
),
),
array(
'code' => 'rejected',
'evil' => '<script>document.write( \'<a href="#" target="_blank" rel="noopener noreferrer">test</a>\' );</script>', // Test protection against wp_targeted_link_rel JSON corruption.
'sources' => array(
array(
'type' => 'theme',
'name' => 'twentyseventeen',
),
),
),
array(
'code' => 'new',
'sources' => array(
Expand Down Expand Up @@ -451,6 +461,7 @@ function( $stored_error ) {
$error_groups = array(
AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACK_ACCEPTED_STATUS,
AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACK_REJECTED_STATUS,
AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACK_REJECTED_STATUS,
AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_NEW_ACCEPTED_STATUS,
);

Expand Down

0 comments on commit 099b979

Please sign in to comment.