Skip to content

Commit

Permalink
Merge pull request #1189 from Automattic/update/changelog-1.0-alpha
Browse files Browse the repository at this point in the history
Add PRs and issues from the 1.0 milestone to the changelog
  • Loading branch information
westonruter authored Jun 9, 2018
2 parents 8a9113f + 51ace17 commit 0f3491a
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 34 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://github.com/automattic/amp-wp
* Author: WordPress.com VIP, XWP, Google, and contributors
* Author URI: https://github.com/Automattic/amp-wp/graphs/contributors
* Version: 1.0-alpha
* Version: 1.0-alpha1
* Text Domain: amp
* Domain Path: /languages/
* License: GPLv2 or later
Expand Down Expand Up @@ -49,7 +49,7 @@ function _amp_print_composer_install_admin_notice() {

define( 'AMP__FILE__', __FILE__ );
define( 'AMP__DIR__', dirname( __FILE__ ) );
define( 'AMP__VERSION', '1.0-alpha' );
define( 'AMP__VERSION', '1.0-alpha1' );

require_once AMP__DIR__ . '/includes/class-amp-autoloader.php';
AMP_Autoloader::register();
Expand Down
12 changes: 7 additions & 5 deletions includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -1227,11 +1227,13 @@ public static function prepare_response( $response, $args = array() ) {
} else {
$current_url = amp_get_current_url();
$ampless_url = amp_remove_endpoint( $current_url );
$ampless_url = add_query_arg(
AMP_Validation_Manager::VALIDATION_ERRORS_QUERY_VAR,
$blocking_error_count,
$ampless_url
);
if ( AMP_Validation_Manager::has_cap() ) {
$ampless_url = add_query_arg(
AMP_Validation_Manager::VALIDATION_ERRORS_QUERY_VAR,
$blocking_error_count,
$ampless_url
);
}

/*
* Temporary redirect because AMP URL may return when blocking validation errors
Expand Down
37 changes: 31 additions & 6 deletions includes/validation/class-amp-invalid-url-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,19 @@ public static function store_validation_errors( $validation_errors, $url, $post
}
$term_id = $r['term_id'];
update_term_meta( $term_id, 'created_date_gmt', current_time( 'mysql', true ) );

/*
* When sanitization is forced by filter, make sure the term is created with the filtered status.
* For some reason, the wp_insert_term() function doesn't work with the term_group being passed in.
*/
$sanitization = AMP_Validation_Error_Taxonomy::get_validation_error_sanitization( $data );
if ( 'with_filter' === $sanitization['forced'] ) {
wp_update_term( $term_id, AMP_Validation_Error_Taxonomy::TAXONOMY_SLUG, array(
'term_group' => $sanitization['status'],
) );
$term_data['term_group'] = $sanitization['status'];
}

$term = get_term( $term_id );
}
$terms[ $term_slug ] = $term;
Expand Down Expand Up @@ -861,7 +874,7 @@ public static function handle_validate_request() {
throw new Exception( esc_html( $validity->get_error_code() ) );
}

$stored = self::store_validation_errors( $validity['validation_errors'], $validity['url'], $post->ID );
$stored = self::store_validation_errors( $validity['validation_errors'], $validity['url'], $post );
if ( is_wp_error( $stored ) ) {
throw new Exception( esc_html( $stored->get_error_code() ) );
}
Expand Down Expand Up @@ -1010,6 +1023,10 @@ public static function add_meta_boxes() {
* @return void
*/
public static function print_status_meta_box( $post ) {
$is_sanitization_forcibly_accepted_by_filter = AMP_Validation_Error_Taxonomy::is_validation_error_sanitized( array(
'code' => 'does_not_exist',
) );

?>
<style>
#amp_validation_status .inside {
Expand All @@ -1029,7 +1046,7 @@ public static function print_status_meta_box( $post ) {
<?php esc_html_e( 'Re-check', 'amp' ); ?>
</a>
</div>
<?php if ( ! AMP_Validation_Manager::is_sanitization_forcibly_accepted() ) : ?>
<?php if ( ! ( AMP_Validation_Manager::is_sanitization_forcibly_accepted() || $is_sanitization_forcibly_accepted_by_filter ) ) : ?>
<div id="preview-action">
<button type="button" name="action" class="preview button" id="preview_validation_errors"><?php esc_html_e( 'Preview Changes', 'default' ); ?></button>
</div>
Expand Down Expand Up @@ -1096,6 +1113,11 @@ public static function print_validation_errors_meta_box( $post ) {
$has_unaccepted_errors = 0 !== count( array_filter( $validation_errors, function( $validation_error ) {
return AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACCEPTED_STATUS !== $validation_error['term_status'];
} ) );

$is_sanitization_forcibly_accepted_by_filter = AMP_Validation_Error_Taxonomy::is_validation_error_sanitized( array(
'code' => 'does_not_exist',
) );

?>
<style>
.amp-validation-errors .detailed,
Expand All @@ -1108,7 +1130,7 @@ public static function print_validation_errors_meta_box( $post ) {
</style>

<?php if ( $has_unaccepted_errors ) : ?>
<?php if ( AMP_Validation_Manager::is_sanitization_forcibly_accepted() ) : ?>
<?php if ( $is_sanitization_forcibly_accepted_by_filter || AMP_Validation_Manager::is_sanitization_forcibly_accepted() ) : ?>
<div class="notice notice-warning notice-alt inline">
<p>
<?php esc_html_e( 'This URL will be served served as valid AMP but some of the markup will be stripped from the response since it is not valid.', 'amp' ); ?>
Expand Down Expand Up @@ -1185,23 +1207,26 @@ public static function print_validation_errors_meta_box( $post ) {
</label>
<select class="amp-validation-error-status" id="<?php echo esc_attr( $select_name ); ?>" name="<?php echo esc_attr( $select_name ); ?>">
<?php if ( AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_NEW_STATUS === $error['term']->term_group ) : ?>
<option value=""><?php esc_html_e( 'New', 'amp' ); ?></option>
<option value="">
&#x2753;
<?php esc_html_e( 'New', 'amp' ); ?>
</option>
<?php endif; ?>
<option value="<?php echo esc_attr( AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACCEPTED_STATUS ); ?>" <?php selected( AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACCEPTED_STATUS, $error['term']->term_group ); ?>>
<?php esc_html_e( 'Accepted', 'amp' ); ?>
<?php if ( $error['forced'] && AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_REJECTED_STATUS === $error['status'] ) : ?>
&#x1F6A9;
<?php else : ?>
&#x2705;
<?php endif; ?>
<?php esc_html_e( 'Accepted', 'amp' ); ?>
</option>
<option style="text-decoration: line-through" value="<?php echo esc_attr( AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_REJECTED_STATUS ); ?>" <?php selected( AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_REJECTED_STATUS, $error['term']->term_group ); ?>>
<?php esc_html_e( 'Rejected', 'amp' ); ?>
<?php if ( amp_is_canonical() || ( $error['forced'] && AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACCEPTED_STATUS === $error['status'] ) ) : ?>
&#x1F6A9;
<?php else : ?>
&#x274C;
<?php endif; ?>
<?php esc_html_e( 'Rejected', 'amp' ); ?>
</option>
</select>
<code><?php echo esc_html( $error['data']['code'] ); ?></code>
Expand Down
6 changes: 4 additions & 2 deletions includes/validation/class-amp-validation-error-taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ public static function get_validation_error_sanitization( $error ) {
}

$is_forced_with_option = (
amp_is_canonical()
||
AMP_Style_Sanitizer::TREE_SHAKING_ERROR_CODE === $error['code'] && AMP_Options_Manager::get_option( 'accept_tree_shaking' )
||
AMP_Options_Manager::get_option( 'force_sanitization' )
Expand Down Expand Up @@ -678,7 +680,7 @@ public static function filter_tag_row_actions( $actions, WP_Term $tag ) {
unset( $actions['delete'] );

$sanitization = self::get_validation_error_sanitization( json_decode( $term->description, true ) );
if ( self::VALIDATION_ERROR_REJECTED_STATUS !== $sanitization['status'] ) {
if ( self::VALIDATION_ERROR_REJECTED_STATUS !== $sanitization['term_status'] ) {
$actions[ self::VALIDATION_ERROR_REJECT_ACTION ] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
wp_nonce_url(
Expand All @@ -689,7 +691,7 @@ public static function filter_tag_row_actions( $actions, WP_Term $tag ) {
esc_html__( 'Reject', 'amp' )
);
}
if ( self::VALIDATION_ERROR_ACCEPTED_STATUS !== $sanitization['status'] ) {
if ( self::VALIDATION_ERROR_ACCEPTED_STATUS !== $sanitization['term_status'] ) {
$actions[ self::VALIDATION_ERROR_ACCEPT_ACTION ] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
wp_nonce_url(
Expand Down
17 changes: 0 additions & 17 deletions includes/validation/class-amp-validation-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,6 @@ public static function init( $args = array() ) {

add_action( 'admin_bar_menu', array( __CLASS__, 'add_admin_bar_menu_items' ), 100 );

/*
* Set sanitization options on the frontend. These filters get added only on the frontend so that
* the user is able to keep track of the errors that they haven't seen before and decide whether
* they need to get fixed (rejected) or not (accepted).
*/
add_action( 'template_redirect', function() {
if ( AMP_Validation_Manager::is_sanitization_forcibly_accepted() ) {
AMP_Validation_Error_Taxonomy::accept_validation_errors( true );
} elseif ( AMP_Options_Manager::get_option( 'accept_tree_shaking' ) ) {
AMP_Validation_Error_Taxonomy::accept_validation_errors(
array(
AMP_Style_Sanitizer::TREE_SHAKING_ERROR_CODE => true,
)
);
}
} );

if ( self::$should_locate_sources ) {
self::add_validation_error_sourcing();
}
Expand Down
40 changes: 39 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,45 @@ Follow along with or [contribute](https://github.com/Automattic/amp-wp/blob/deve
## Changelog ##

### 1.0 (unreleased) ###
- Prefer the Custom Logo as the schema.org publisher icon, over the Site Icon. See [#1144](https://github.com/Automattic/amp-wp/pull/1144). Props kienstra, westonruter.
- Add runtime CSS minification, `!important` replacement, and tree shaking. See [#1048](https://github.com/Automattic/amp-wp/pull/1048), [#1111](https://github.com/Automattic/amp-wp/pull/1111), [#1142](https://github.com/Automattic/amp-wp/pull/1142). Props westonruter, amedina, pbakaus, igrigorik, camelburrito.
- Add ability to acknowledge and suppress/ignore specific validation errors. See [#1003](https://github.com/Automattic/amp-wp/issues/1003). Props westonruter.
- Extend admin screen options to add `amp` theme support without any coding required. Toggle between classic, paired, and native. Includes options for whether sanitization should be done by default and whether tree shaking should always be allowed. See [#1199](https://github.com/Automattic/amp-wp/pull/1199). Props westonruter.
- Add support for three core themes (Twenty Fifteen, Twenty Sixteen, Twenty Seventeen) so that they can be used out of the box with AMP theme support added without needing to create a child theme. See [#1074](https://github.com/Automattic/amp-wp/pull/1074). Props westonruter, DavidCramer, kienstra.
- Add AMP menu item to admin bar on frontend with indication of AMP validation status; accessing an AMP URL that has unaccepted validation errors will redirect to the non-AMP page and cause the AMP admin bar item to indicate the failure, along with a link to access the validation results. See [#1199](https://github.com/Automattic/amp-wp/pull/1199). Props westonruter.
- Add dynamic handling of validation errors. See [#1093](https://github.com/Automattic/amp-wp/pull/1093), [#1063](https://github.com/Automattic/amp-wp/pull/1063), [#1087](https://github.com/Automattic/amp-wp/issues/1087). Props westonruter.
- Add AMP validation of blocks. See [#1019](https://github.com/Automattic/amp-wp/pull/1019). Props westonruter.
- Add AMP-specific functionality to core blocks. See [#1026](https://github.com/Automattic/amp-wp/pull/1026), [#1008](https://github.com/Automattic/amp-wp/issues/1008). Props miina.
- Add AMP media blocks (when in native AMP mode). See [#1155](https://github.com/Automattic/amp-wp/pull/1155). Props miina.
- Add embed handler for Gfycat. See [#1136](https://github.com/Automattic/amp-wp/pull/1136). Props miina.
- Add amp-mathml block. See [#1165](https://github.com/Automattic/amp-wp/pull/1165). Props miina.
- Add Gutenberg amp-timeago block. See [#1168](https://github.com/Automattic/amp-wp/pull/1168). Props miina.
- Add `amp-fit-text` support to text blocks. See [#1151](https://github.com/Automattic/amp-wp/pull/1151). Props miina.
- Fix handling of font stylesheets with non-HTTPS scheme or scheme-less URLs. See [#1077](https://github.com/Automattic/amp-wp/pull/1077). Props westonruter.
- Fix issues in displaying native blocks. See [#1022](https://github.com/Automattic/amp-wp/pull/1022). Props miina.
- Gutenberg: Add AMP Carousel for Gallery and AMP Lightbox features for Gallery and Image. See [#1121](https://github.com/Automattic/amp-wp/pull/1121), [#1065](https://github.com/Automattic/amp-wp/issues/1065), [#1187](https://github.com/Automattic/amp-wp/pull/1187). Props miina, westonruter.
- Cache post processor response. See [#1156](https://github.com/Automattic/amp-wp/pull/1156), [#959](https://github.com/Automattic/amp-wp/issues/959). Props ThierryA.
- Automatically redirect to `?amp` from `/amp/` URLs when `amp` theme support is present. See [#1203](https://github.com/Automattic/amp-wp/pull/1203), [#1194](https://github.com/Automattic/amp-wp/pull/1194). Props westonruter.
- Incorporate Server Timing API. See [#990](https://github.com/Automattic/amp-wp/issues/990). Props westonruter.
- Add information about stylesheets included and excluded in `style[amp-custom]`. See [#1135](https://github.com/Automattic/amp-wp/pull/1135). Props westonruter.
- Fetch (local) stylesheets with `@import`, instead of removing them. See [#1181](https://github.com/Automattic/amp-wp/pull/1181). Props miina.
- Fetch external stylesheets (which aren't from whitelisted font CDNs) to include in amp-custom style. See [#1174](https://github.com/Automattic/amp-wp/pull/1174). Props miina.
- Transform CSS selectors according to sanitizer HTML element to AMP component conversions. See [#1175](https://github.com/Automattic/amp-wp/pull/1175). Props miina, westonruter.
- Ensure layout attributes are only allowed on supporting elements. See [#1075](https://github.com/Automattic/amp-wp/pull/1075). Props westonruter.
- Correct the width attribute in `col` tags to the equivalent CSS rule. See [#1064](https://github.com/Automattic/amp-wp/pull/1064). Props amedina.
- Remove space from `data: url()` in stylesheets. See [#1164](https://github.com/Automattic/amp-wp/pull/1164/), [#1089](https://github.com/Automattic/amp-wp/issues/1089). Props amedina, JonHendershot, westonruter, mehigh, davisshaver, Mte90.
- Fix inconsistency between singular and plural. See [#1114](https://github.com/Automattic/amp-wp/pull/1114). Props garrett-eclipse.
- Allow spaces around commas in value property lists. See [#1112](https://github.com/Automattic/amp-wp/pull/1112). Props westonruter.
- Display admin notice if there's no persistent object caching. See [#1050](https://github.com/Automattic/amp-wp/pull/1050). Props oscarssanchez.
- Add workaround to preserve CSS `calc()` functions. See [#1116](https://github.com/Automattic/amp-wp/pull/1116). Props westonruter.
- PHPCS fixes, including PHP DocBlocks and strict comparisons. See [#1002](https://github.com/Automattic/amp-wp/pull/1002). Props paulschreiber.
- Fix handling of amp-bind attributes to ensure that `“>”` can appear inside attribute values. See [#1119](https://github.com/Automattic/amp-wp/pull/1119). Props westonruter.
- Eliminate `amp-wp-enforced-sizes` style from theme support stylesheet. See [#1153](https://github.com/Automattic/amp-wp/pull/1153). Props westonruter.
- Add support for extracting (pixel) dimensions from SVG images. See [#1150](https://github.com/Automattic/amp-wp/pull/1150). Props westonruter.
- Deprecate `AMP_WP_Utils`, in favor of `wp_parse_url()`. See [#995](https://github.com/Automattic/amp-wp/pull/995). Props paulschreiber.
- Add WP-CLI script to test support for blocks. See [#845](https://github.com/Automattic/amp-wp/issues/845). Props kienstra.
- Ensure translatable strings in blocks can actually be translated. See [#1173](https://github.com/Automattic/amp-wp/pull/1173). Props miina, swissspidy, westonruter.

For a full list of the closed issues and merged pull requests in this release, see the [1.0 milestone](https://github.com/Automattic/amp-wp/milestone/7?closed=1).

### 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.
Expand Down
Loading

0 comments on commit 0f3491a

Please sign in to comment.