Skip to content

Commit

Permalink
Merge branch '1.0' of https://github.com/Automattic/amp-wp into relea…
Browse files Browse the repository at this point in the history
…se/1.0-rc1
  • Loading branch information
westonruter committed Oct 4, 2018
2 parents a049ffb + 5ce3414 commit 03809b9
Show file tree
Hide file tree
Showing 23 changed files with 456 additions and 407 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Expand Up @@ -110,7 +110,7 @@ module.exports = function( grunt ) {
var commitHash, lsOutput, versionAppend, paths;
commitHash = stdout.shift();
lsOutput = stdout.shift();
versionAppend = commitHash + '-' + new Date().toISOString().replace( /\.\d+/, '' ).replace( /-|:/g, '' );
versionAppend = new Date().toISOString().replace( /\.\d+/, '' ).replace( /-|:/g, '' ) + '-' + commitHash;

paths = lsOutput.trim().split( /\n/ ).filter( function( file ) {
return ! /^(blocks|\.|bin|([^/]+)+\.(md|json|xml)|Gruntfile\.js|tests|wp-assets|dev-lib|readme\.md|composer\..*|webpack.*|languages\/README.*)/.test( file );
Expand Down
18 changes: 18 additions & 0 deletions amp.php
Expand Up @@ -177,6 +177,24 @@ function amp_init() {

// Add actions for legacy post templates.
add_action( 'wp', 'amp_maybe_add_actions' );

/*
* Broadcast plugin updates.
* Note that AMP_Options_Manager::get_option( 'version', '0.0' ) cannot be used because
* version was new option added, and in that case default would never be used for a site
* upgrading from a version prior to 1.0. So this is why get_option() is currently used.
*/
$options = get_option( AMP_Options_Manager::OPTION_NAME, array() );
$old_version = isset( $options['version'] ) ? $options['version'] : '0.0';
if ( AMP__VERSION !== $old_version ) {
/**
* Triggers when after amp_init when the plugin version has updated.
*
* @param string $old_version Old version.
*/
do_action( 'amp_plugin_update', $old_version );
AMP_Options_Manager::update_option( 'version', AMP__VERSION );
}
}

/**
Expand Down
6 changes: 3 additions & 3 deletions assets/css/amp-validation-error-taxonomy.css
Expand Up @@ -203,14 +203,14 @@ details.single-error-detail[open] .single-error-detail-summary::after {
body.taxonomy-amp_validation_error .wp-list-table .new th,
body.taxonomy-amp_validation_error .wp-list-table .new td,
tr.expanded.new + tr > td:first-of-type,
body.post-type-amp_invalid_url .wp-list-table .new th,
body.post-type-amp_invalid_url .wp-list-table .new td {
body.post-type-amp_validated_url .wp-list-table .new th,
body.post-type-amp_validated_url .wp-list-table .new td {
background-color: #fef7f1;
}

body.taxonomy-amp_validation_error .wp-list-table .new th.check-column,
tr.expanded.new + tr > td:first-of-type,
body.post-type-amp_invalid_url .wp-list-table .new th.check-column {
body.post-type-amp_validated_url .wp-list-table .new th.check-column {
border-left: 4px solid #d54e21;
}

Expand Down
2 changes: 1 addition & 1 deletion assets/css/amp-validation-single-error-url.css
Expand Up @@ -110,7 +110,7 @@ table.striped > tbody > tr.even {
display: none;
}

.amp-invalid-url a {
.amp-validated-url a {
text-decoration: none;
}

Expand Down
@@ -1,6 +1,6 @@
/* exported ampInvalidUrlPostEditScreen */
/* exported ampValidatedUrlPostEditScreen */

const ampInvalidUrlPostEditScreen = ( function() { // eslint-disable-line no-unused-vars
const ampValidatedUrlPostEditScreen = ( function() { // eslint-disable-line no-unused-vars
let component = {
data: {
l10n: {
Expand Down
@@ -1,6 +1,6 @@
/* exported ampInvalidUrlsIndex */
/* exported ampValidatedUrlsIndex */

const ampInvalidUrlsIndex = ( function() { // eslint-disable-line no-unused-vars
const ampValidatedUrlsIndex = ( function() { // eslint-disable-line no-unused-vars
let component = {
classes: {}
};
Expand Down
2 changes: 1 addition & 1 deletion includes/amp-helper-functions.php
Expand Up @@ -196,7 +196,7 @@ function amp_add_amphtml_link() {

// Check to see if there are known unaccepted validation errors for this URL.
if ( current_theme_supports( AMP_Theme_Support::SLUG ) ) {
$validation_errors = AMP_Invalid_URL_Post_Type::get_invalid_url_validation_errors( $current_url, array( 'ignore_accepted' => true ) );
$validation_errors = AMP_Validated_URL_Post_Type::get_invalid_url_validation_errors( $current_url, array( 'ignore_accepted' => true ) );
$error_count = count( $validation_errors );
if ( $error_count > 0 ) {
echo "<!--\n";
Expand Down
2 changes: 1 addition & 1 deletion includes/class-amp-autoloader.php
Expand Up @@ -98,7 +98,7 @@ class AMP_Autoloader {
'AMP_HTML_Utils' => 'includes/utils/class-amp-html-utils',
'AMP_Image_Dimension_Extractor' => 'includes/utils/class-amp-image-dimension-extractor',
'AMP_Validation_Manager' => 'includes/validation/class-amp-validation-manager',
'AMP_Invalid_URL_Post_Type' => 'includes/validation/class-amp-invalid-url-post-type',
'AMP_Validated_URL_Post_Type' => 'includes/validation/class-amp-validated-url-post-type',
'AMP_Validation_Error_Taxonomy' => 'includes/validation/class-amp-validation-error-taxonomy',
'AMP_CLI' => 'includes/class-amp-cli',
'AMP_String_Utils' => 'includes/utils/class-amp-string-utils',
Expand Down
14 changes: 7 additions & 7 deletions includes/class-amp-cli.php
Expand Up @@ -256,7 +256,7 @@ public function validate_site( $args, $assoc_args ) {

$url_more_details = add_query_arg(
'post_type',
AMP_Invalid_URL_Post_Type::POST_TYPE_SLUG,
AMP_Validated_URL_Post_Type::POST_TYPE_SLUG,
admin_url( 'edit.php' )
);
/* translators: %s is the URL to the admin */
Expand All @@ -266,7 +266,7 @@ public function validate_site( $args, $assoc_args ) {
/**
* Reset all validation data on a site.
*
* This deletes all amp_invalid_url posts and all amp_validation_error terms.
* This deletes all amp_validated_url posts and all amp_validation_error terms.
*
* ## OPTIONS
*
Expand All @@ -285,16 +285,16 @@ public function validate_site( $args, $assoc_args ) {
public function reset_site_validation( $args, $assoc_args ) {
unset( $args );
global $wpdb;
WP_CLI::confirm( 'Are you sure you want to empty all amp_invalid_url posts and amp_validation_error taxonomy terms?', $assoc_args );
WP_CLI::confirm( 'Are you sure you want to empty all amp_validated_url posts and amp_validation_error taxonomy terms?', $assoc_args );

// Delete all posts.
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = %s", AMP_Invalid_URL_Post_Type::POST_TYPE_SLUG ) );
$query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s", AMP_Invalid_URL_Post_Type::POST_TYPE_SLUG );
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = %s", AMP_Validated_URL_Post_Type::POST_TYPE_SLUG ) );
$query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s", AMP_Validated_URL_Post_Type::POST_TYPE_SLUG );
$posts = new WP_CLI\Iterators\Query( $query, 10000 );

$progress = WP_CLI\Utils\make_progress_bar(
/* translators: %d is the number of posts */
sprintf( __( 'Deleting %d amp_invalid_url posts...', 'amp' ), $count ),
sprintf( __( 'Deleting %d amp_validated_url posts...', 'amp' ), $count ),
$count
);
while ( $posts->valid() ) {
Expand Down Expand Up @@ -640,7 +640,7 @@ public static function validate_and_store_url( $url, $type ) {
}

$validation_errors = wp_list_pluck( $validity['results'], 'error' );
AMP_Invalid_URL_Post_Type::store_validation_errors(
AMP_Validated_URL_Post_Type::store_validation_errors(
$validation_errors,
$validity['url'],
wp_array_slice_assoc( $validity, array( 'queried_object' ) )
Expand Down
3 changes: 2 additions & 1 deletion includes/options/class-amp-options-manager.php
Expand Up @@ -32,6 +32,7 @@ class AMP_Options_Manager {
'all_templates_supported' => true,
'supported_templates' => array( 'is_singular' ),
'enable_response_caching' => true,
'version' => AMP__VERSION,
);

/**
Expand Down Expand Up @@ -519,7 +520,7 @@ public static function handle_updated_theme_support_option() {
}
}

$invalid_url_post_id = AMP_Invalid_URL_Post_Type::store_validation_errors( $errors, $url );
$invalid_url_post_id = AMP_Validated_URL_Post_Type::store_validation_errors( $errors, $url );
$invalid_url_screen_url = ! is_wp_error( $invalid_url_post_id ) ? get_edit_post_link( $invalid_url_post_id, 'raw' ) : null;

if ( $rejected_errors > 0 ) {
Expand Down
10 changes: 5 additions & 5 deletions includes/options/class-amp-options-menu.php
Expand Up @@ -191,7 +191,7 @@ public function render_theme_support() {
<dd>
<?php esc_html_e( 'Display AMP responses in classic (legacy) post templates in a basic design that does not match your theme\'s templates.', 'amp' ); ?>

<?php if ( ! current_theme_supports( AMP_Theme_Support::SLUG ) && wp_count_posts( AMP_Invalid_URL_Post_Type::POST_TYPE_SLUG )->publish > 0 ) : ?>
<?php if ( ! current_theme_supports( AMP_Theme_Support::SLUG ) && wp_count_posts( AMP_Validated_URL_Post_Type::POST_TYPE_SLUG )->publish > 0 ) : ?>
<div class="notice notice-info inline notice-alt">
<p>
<?php
Expand All @@ -201,16 +201,16 @@ public function render_theme_support() {
__( 'View current site compatibility results for native and paired modes: %1$s and %2$s.', 'amp' ),
sprintf(
'<a href="%s">%s</a>',
esc_url( add_query_arg( 'post_type', AMP_Invalid_URL_Post_Type::POST_TYPE_SLUG, admin_url( 'edit.php' ) ) ),
esc_html( get_post_type_object( AMP_Invalid_URL_Post_Type::POST_TYPE_SLUG )->labels->name )
esc_url( add_query_arg( 'post_type', AMP_Validated_URL_Post_Type::POST_TYPE_SLUG, admin_url( 'edit.php' ) ) ),
esc_html( get_post_type_object( AMP_Validated_URL_Post_Type::POST_TYPE_SLUG )->labels->name )
),
sprintf(
'<a href="%s">%s</a>',
esc_url(
add_query_arg(
array(
'taxonomy' => AMP_Validation_Error_Taxonomy::TAXONOMY_SLUG,
'post_type' => AMP_Invalid_URL_Post_Type::POST_TYPE_SLUG,
'post_type' => AMP_Validated_URL_Post_Type::POST_TYPE_SLUG,
),
admin_url( 'edit-tags.php' )
)
Expand Down Expand Up @@ -280,7 +280,7 @@ public function render_validation_handling() {
add_query_arg(
array(
'taxonomy' => AMP_Validation_Error_Taxonomy::TAXONOMY_SLUG,
'post_type' => AMP_Invalid_URL_Post_Type::POST_TYPE_SLUG,
'post_type' => AMP_Validated_URL_Post_Type::POST_TYPE_SLUG,
),
admin_url( 'edit-tags.php' )
)
Expand Down

0 comments on commit 03809b9

Please sign in to comment.