Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename AMP Invalid URLs to AMP Validated URLs #1487

Merged
merged 11 commits into from
Oct 4, 2018
Merged
12 changes: 12 additions & 0 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ function amp_init() {

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

// Broadcast plugin updates.
$old_version = AMP_Options_Manager::get_option( 'version', '0.0' );
if ( version_compare( $old_version, AMP__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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion includes/amp-helper-functions.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading