Skip to content

Commit

Permalink
Issue #843: Rename class to 'AMP_Validation_Utils'
Browse files Browse the repository at this point in the history
This was previously 'AMP_Mutation_Utils'
The new name describes better what this does.
  • Loading branch information
Ryan Kienstra committed Feb 8, 2018
1 parent f996673 commit f8aeca8
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 99 deletions.
2 changes: 1 addition & 1 deletion amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function amp_after_setup_theme() {
add_action( 'wp_loaded', 'amp_add_options_menu' );
add_action( 'parse_query', 'amp_correct_query_when_is_front_page' );
AMP_Post_Type_Support::add_post_type_support();
AMP_Mutation_Utils::init();
AMP_Validation_Utils::init();
}
add_action( 'after_setup_theme', 'amp_after_setup_theme', 5 );

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 @@ -83,7 +83,7 @@ class AMP_Autoloader {
'AMP_DOM_Utils' => 'includes/utils/class-amp-dom-utils',
'AMP_HTML_Utils' => 'includes/utils/class-amp-html-utils',
'AMP_Image_Dimension_Extractor' => 'includes/utils/class-amp-image-dimension-extractor',
'AMP_Mutation_Utils' => 'includes/utils/class-amp-mutation-utils',
'AMP_Validation_Utils' => 'includes/utils/class-amp-validation-utils',
'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
6 changes: 3 additions & 3 deletions includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ public static function start_output_buffering() {
*/
public static function finish_output_buffering() {
$output = self::prepare_response( ob_get_clean() );
AMP_Mutation_Utils::add_header();
AMP_Validation_Utils::add_header();
echo $output; // WPCS: xss ok.
}

Expand Down Expand Up @@ -787,8 +787,8 @@ public static function prepare_response( $response ) {
'content_max_width' => ! empty( $content_width ) ? $content_width : AMP_Post_Template::CONTENT_MAX_WIDTH, // Back-compat.
'use_document_element' => true,
);
if ( AMP_Mutation_Utils::is_authorized() ) {
$args['mutation_callback'] = 'AMP_Mutation_Utils::track_removed';
if ( AMP_Validation_Utils::is_authorized() ) {
$args['mutation_callback'] = 'AMP_Validation_Utils::track_removed';
}

// First ensure the mandatory amp attribute is present on the html element, as otherwise it will be stripped entirely.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
/**
* Class AMP_Mutation_Utils
* Class AMP_Validation_Utils
*
* @package AMP
*/

/**
* Class AMP_Mutation_Utils
* Class AMP_Validation_Utils
*
* @since 0.7
*/
class AMP_Mutation_Utils {
class AMP_Validation_Utils {

/**
* The argument if an attribute was removed.
Expand Down Expand Up @@ -131,7 +131,7 @@ public static function process_markup( $markup ) {
'content_max_width' => ! empty( $content_width ) ? $content_width : AMP_Post_Template::CONTENT_MAX_WIDTH,
);
if ( self::is_authorized() ) {
$args['mutation_callback'] = 'AMP_Mutation_Utils::track_removed';
$args['mutation_callback'] = 'AMP_Validation_Utils::track_removed';
}
AMP_Content_Sanitizer::sanitize( $markup, amp_get_content_sanitizers(), $args );
}
Expand Down
14 changes: 7 additions & 7 deletions tests/test-class-amp-base-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@ public function test_remove_child() {

$this->assertEquals( $child, $parent->firstChild );
$sanitizer = new AMP_Iframe_Sanitizer( $dom_document, array(
'mutation_callback' => 'AMP_Mutation_Utils::track_removed',
'mutation_callback' => 'AMP_Validation_Utils::track_removed',
) );
$sanitizer->remove_child( $child );
$this->assertEquals( null, $parent->firstChild );
$this->assertEquals( 1, AMP_Mutation_Utils::$removed_nodes[ $child_tag_name ] );
$this->assertEquals( 1, AMP_Validation_Utils::$removed_nodes[ $child_tag_name ] );

$parent->appendChild( $child );
$this->assertEquals( $child, $parent->firstChild );
Expand All @@ -273,7 +273,7 @@ public function test_remove_child() {
$this->assertEquals( null, $parent->firstChild );
$this->assertEquals( null, $child->parentNode );
// @codingStandardsIgnoreEnd
AMP_Mutation_Utils::$removed_nodes = null;
AMP_Validation_Utils::$removed_nodes = null;
}

/**
Expand All @@ -282,7 +282,7 @@ public function test_remove_child() {
* @see AMP_Base_Sanitizer::remove_child()
*/
public function test_remove_attribute() {
AMP_Mutation_Utils::reset_removed();
AMP_Validation_Utils::reset_removed();
$video_name = 'amp-video';
$attribute = 'onload';
$dom_document = new DOMDocument( '1.0', 'utf-8' );
Expand All @@ -292,17 +292,17 @@ public function test_remove_attribute() {
// To ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar.
// @codingStandardsIgnoreStart
$args = array(
'mutation_callback' => 'AMP_Mutation_Utils::track_removed',
'mutation_callback' => 'AMP_Validation_Utils::track_removed',
);
$expected_removed = array(
$attribute => 1,
);
$sanitizer = new AMP_Video_Sanitizer( $dom_document, $args );
$sanitizer->remove_attribute( $video, $attribute );
$this->assertEquals( null, $video->getAttribute( $attribute ) );
$this->assertEquals( $expected_removed, AMP_Mutation_Utils::$removed_attributes );
$this->assertEquals( $expected_removed, AMP_Validation_Utils::$removed_attributes );
// @codingStandardsIgnoreEnd
AMP_Mutation_Utils::reset_removed();
AMP_Validation_Utils::reset_removed();
}

}
Loading

0 comments on commit f8aeca8

Please sign in to comment.