mirror of
https://github.com/Automattic/wordpress-activitypub
synced 2024-10-18 21:43:33 +00:00
Enqueue reply assets only if there is anything to reply to on the page (#706)
This commit is contained in:
parent
e4ea69ca6f
commit
343a3b5c67
1 changed files with 15 additions and 1 deletions
|
@ -13,6 +13,14 @@ use function Activitypub\is_user_disabled;
|
||||||
* methods that are used to handle comments.
|
* methods that are used to handle comments.
|
||||||
*/
|
*/
|
||||||
class Comment {
|
class Comment {
|
||||||
|
/**
|
||||||
|
* Enqueue reply assets only if the reply feature is needed
|
||||||
|
* for the current request.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private static $remote_reply_assets_needed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the class, registering WordPress hooks
|
* Initialize the class, registering WordPress hooks
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +48,8 @@ class Comment {
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self::$remote_reply_assets_needed = true; // Request script and styles for remote reply feature.
|
||||||
|
|
||||||
$attrs = array(
|
$attrs = array(
|
||||||
'selectedComment' => self::generate_id( $comment ),
|
'selectedComment' => self::generate_id( $comment ),
|
||||||
'commentId' => $comment->comment_ID,
|
'commentId' => $comment->comment_ID,
|
||||||
|
@ -351,7 +361,11 @@ class Comment {
|
||||||
* Enqueue scripts for remote comments
|
* Enqueue scripts for remote comments
|
||||||
*/
|
*/
|
||||||
public static function enqueue_scripts() {
|
public static function enqueue_scripts() {
|
||||||
if ( ! is_singular() ) {
|
$assets_needed = \apply_filters(
|
||||||
|
'activitypub_remote_reply_assets_needed',
|
||||||
|
self::$remote_reply_assets_needed
|
||||||
|
);
|
||||||
|
if ( ! $assets_needed ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$handle = 'activitypub-remote-reply';
|
$handle = 'activitypub-remote-reply';
|
||||||
|
|
Loading…
Reference in a new issue