Skip to content

Commit

Permalink
Merge pull request #1183 from Automattic/valid-site
Browse files Browse the repository at this point in the history
Test AMP compatibility of entire site
  • Loading branch information
westonruter committed Aug 29, 2018
2 parents a6f8eae + 19ead16 commit c539a18
Show file tree
Hide file tree
Showing 14 changed files with 1,280 additions and 8 deletions.
6 changes: 6 additions & 0 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,13 @@ function amp_init() {
add_rewrite_endpoint( amp_get_slug(), EP_PERMALINK );

AMP_Theme_Support::init();
AMP_Validation_Manager::init();
AMP_Post_Type_Support::add_post_type_support();

if ( defined( 'WP_CLI' ) ) {
WP_CLI::add_command( 'amp', new AMP_CLI() );
}

add_filter( 'request', 'amp_force_query_var_value' );
add_action( 'admin_init', 'AMP_Options_Manager::register_settings' );
add_action( 'wp_loaded', 'amp_editor_core_blocks' );
Expand Down
10 changes: 10 additions & 0 deletions includes/amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,16 @@ function is_amp_endpoint() {
return false;
}

/*
* If this is a URL for validation, and validation is forced for all URLs, return true.
* Normally, this would be false if the user has deselected a template,
* like by unchecking 'Categories' in 'AMP Settings' > 'Supported Templates'.
* But there's a flag for the WP-CLI command that sets this query var to validate all URLs.
*/
if ( AMP_Validation_Manager::is_theme_support_forced() ) {
return true;
}

$availability = AMP_Theme_Support::get_template_availability();
return amp_is_canonical() ? $availability['supported'] : ( $has_amp_query_var && $availability['supported'] );
}
Expand Down
1 change: 1 addition & 0 deletions includes/class-amp-autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class AMP_Autoloader {
'AMP_Validation_Manager' => 'includes/validation/class-amp-validation-manager',
'AMP_Invalid_URL_Post_Type' => 'includes/validation/class-amp-invalid-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',
'AMP_WP_Utils' => 'includes/utils/class-amp-wp-utils',
'AMP_Widget_Archives' => 'includes/widgets/class-amp-widget-archives',
Expand Down
Loading

0 comments on commit c539a18

Please sign in to comment.