Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Commit

Permalink
Rename should_validate_front_end to should_validate_response
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Mar 8, 2018
1 parent bf82b8d commit 1548d37
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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,
) );
Expand Down
4 changes: 2 additions & 2 deletions includes/utils/class-amp-validation-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

Expand Down
12 changes: 6 additions & 6 deletions tests/test-class-amp-validation-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
}

/**
Expand Down

0 comments on commit 1548d37

Please sign in to comment.