-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #864: Remove dequeuing of scripts, and create comment subclass.
As Weston mentioned, the plugin already prevents scripts in: 'wp_print_footer_scripts'. Also, move the comment filter to a subclass of WP_Widget_Recent_Comments. Includes PHPUnit tests for all of these changes.
- Loading branch information
Ryan Kienstra
committed
Jan 17, 2018
1 parent
3faab47
commit be58d02
Showing
7 changed files
with
89 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* Class AMP_Widget_Recent_Comments | ||
* | ||
* @package AMP | ||
*/ | ||
|
||
/** | ||
* Class AMP_Widget_Recent_Comments | ||
* | ||
* @package AMP | ||
*/ | ||
class AMP_Widget_Recent_Comments extends WP_Widget_Recent_Comments { | ||
|
||
/** | ||
* Instantiates the widget, and prevents inline styling. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(); | ||
add_filter( 'show_recent_comments_widget_style', '__return_false' ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Tests for class AMP_Widget_Recent_Comments. | ||
* | ||
* @package AMP | ||
*/ | ||
|
||
/** | ||
* Tests for class AMP_Widget_Recent_Comments. | ||
* | ||
* @package AMP | ||
*/ | ||
class Test_AMP_Widget_Recent_Comments extends WP_UnitTestCase { | ||
|
||
/** | ||
* Instance of the widget. | ||
* | ||
* @var object | ||
*/ | ||
public $instance; | ||
|
||
/** | ||
* Setup. | ||
* | ||
* @inheritdoc | ||
*/ | ||
public function setUp() { | ||
parent::setUp(); | ||
$amp_widgets = new AMP_Widgets(); | ||
$amp_widgets->register_widgets(); | ||
$this->instance = new AMP_Widget_Recent_Comments(); | ||
} | ||
|
||
/** | ||
* Test construct(). | ||
* | ||
* @see AMP_Widget_Recent_Comments::__construct(). | ||
*/ | ||
public function test_construct() { | ||
global $wp_widget_factory; | ||
$amp_categories = $wp_widget_factory->widgets['AMP_Widget_Recent_Comments']; | ||
|
||
$this->assertEquals( 'recent-comments', $amp_categories->id_base ); | ||
$this->assertEquals( 'Recent Comments', $amp_categories->name ); | ||
$this->assertEquals( 'widget_recent_comments', $amp_categories->widget_options['classname'] ); | ||
$this->assertEquals( true, $amp_categories->widget_options['customize_selective_refresh'] ); | ||
$this->assertEquals( 'Your site’s most recent comments.', $amp_categories->widget_options['description'] ); | ||
$this->assertFalse( apply_filters( 'show_recent_comments_widget_style', true ) ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters