-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[not verified] Apply a similar change to the Comment Likes module
Don't enqueue scripts if likes aren't enabled, and move the dependencies to the footer, as the script that depends on them, 'jetpack_likes_queuehandler', is in the footer. It doesn't seem necessary for these to be above the footer.
- Loading branch information
Showing
3 changed files
with
53 additions
and
2 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
44 changes: 44 additions & 0 deletions
44
tests/php/modules/comment-likes/test-class.comment-likes.php
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,44 @@ | ||
<?php | ||
/** | ||
* Tests for the WP_Test_Comment_Likes class. | ||
* | ||
* @package Jetpack | ||
* @since 8.4.0 | ||
*/ | ||
|
||
require dirname( __FILE__ ) . '/../../../../modules/comment-likes.php'; | ||
|
||
/** | ||
* Test class for Jetpack_Comment_Likes. | ||
* | ||
* @since 8.4.0 | ||
*/ | ||
class WP_Test_Comment_Likes extends WP_UnitTestCase { | ||
|
||
/** | ||
* Test that the assets are not enqueued if likes are not visible. | ||
* | ||
* @since 8.4.0 | ||
*/ | ||
public function test_load_styles_register_scripts_likes_not_visible() { | ||
$instance = Jetpack_Comment_Likes::init(); | ||
$instance->load_styles_register_scripts(); | ||
|
||
$this->assertFalse( wp_style_is( 'jetpack_likes' ) ); | ||
$this->assertFalse( wp_script_is( 'postmessage' ) ); | ||
} | ||
|
||
/** | ||
* Test that the assets are enqueued if likes are visible. | ||
* | ||
* @since 8.4.0 | ||
*/ | ||
public function test_load_styles_register_scripts_likes_visible() { | ||
add_filter( 'wpl_is_likes_visible', '__return_false' ); | ||
$instance = Jetpack_Comment_Likes::init(); | ||
$instance->load_styles_register_scripts(); | ||
|
||
$this->assertFalse( wp_style_is( 'jetpack_likes' ) ); | ||
$this->assertFalse( wp_script_is( 'postmessage' ) ); | ||
} | ||
} |