diff --git a/includes/class-amp-theme-support.php b/includes/class-amp-theme-support.php index 53db8bff054..ee7da221ad0 100644 --- a/includes/class-amp-theme-support.php +++ b/includes/class-amp-theme-support.php @@ -245,7 +245,7 @@ public static function add_hooks() { add_action( 'comment_form', array( __CLASS__, 'add_amp_comment_form_templates' ), 100 ); remove_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' ); - if ( AMP_Validation_Utils::should_validate_front_end() ) { + if ( AMP_Validation_Utils::should_validate_response() ) { AMP_Validation_Utils::add_validation_hooks(); } @@ -1023,7 +1023,7 @@ public static function prepare_response( $response, $args = array() ) { trigger_error( esc_html( sprintf( __( 'The database has the %s encoding when it needs to be utf-8 to work with AMP.', 'amp' ), get_bloginfo( 'charset' ) ) ), E_USER_WARNING ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error } - if ( AMP_Validation_Utils::should_validate_front_end() ) { + if ( AMP_Validation_Utils::should_validate_response() ) { AMP_Validation_Utils::finalize_validation( $dom, array( 'remove_source_comments' => ! $is_validation_debug_mode, ) ); diff --git a/includes/utils/class-amp-validation-utils.php b/includes/utils/class-amp-validation-utils.php index 548c78e08c4..2ba61273427 100644 --- a/includes/utils/class-amp-validation-utils.php +++ b/includes/utils/class-amp-validation-utils.php @@ -930,9 +930,9 @@ protected static function output_removed_set( $set ) { * * Either the user has the capability and the query var is present. * - * @return boolean + * @return boolean Whether to validate. */ - public static function should_validate_front_end() { + public static function should_validate_response() { return self::has_cap() && isset( $_GET[ self::VALIDATE_QUERY_VAR ] ); // WPCS: CSRF ok. } diff --git a/tests/test-class-amp-validation-utils.php b/tests/test-class-amp-validation-utils.php index 942a0144a65..13f889ce2bd 100644 --- a/tests/test-class-amp-validation-utils.php +++ b/tests/test-class-amp-validation-utils.php @@ -563,18 +563,18 @@ public function get_string() { } /** - * Test should_validate_front_end + * Test should_validate_response. * - * @covers AMP_Validation_Utils::should_validate_front_end() + * @covers AMP_Validation_Utils::should_validate_response() */ - public function test_should_validate_front_end() { + public function test_should_validate_response() { global $post; $post = $this->factory()->post->create(); // WPCS: global override ok. - $this->assertFalse( AMP_Validation_Utils::should_validate_front_end() ); + $this->assertFalse( AMP_Validation_Utils::should_validate_response() ); $_GET[ AMP_Validation_Utils::VALIDATE_QUERY_VAR ] = 1; - $this->assertFalse( AMP_Validation_Utils::should_validate_front_end() ); + $this->assertFalse( AMP_Validation_Utils::should_validate_response() ); $this->set_capability(); - $this->assertTrue( AMP_Validation_Utils::should_validate_front_end() ); + $this->assertTrue( AMP_Validation_Utils::should_validate_response() ); } /**