From 116070e23c26996ff37123d0dc726bae66f74837 Mon Sep 17 00:00:00 2001 From: Django Doucet Date: Fri, 10 Mar 2023 08:43:03 -0700 Subject: [PATCH] Reply to comments from Dashboard --- assets/js/activitypub-admin.js | 2 +- includes/class-admin.php | 2 +- includes/class-comments.php | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/assets/js/activitypub-admin.js b/assets/js/activitypub-admin.js index bf0eb3d..2b43ad2 100644 --- a/assets/js/activitypub-admin.js +++ b/assets/js/activitypub-admin.js @@ -19,7 +19,7 @@ jQuery( function( $ ) { } ); //Reply Comment-edit screen - if ( $('body').hasClass('edit-comments-php') ) { + if ( $('body').hasClass('edit-comments-php') || $('body').hasClass('index-php') ) { //Insert Mentions into comment content on reply $( '.comment-inline.button-link' ).on( 'click', function( event ) { var recipients = $(this).attr('data-recipients') ? $(this).attr('data-recipients') + ' ' : ''; diff --git a/includes/class-admin.php b/includes/class-admin.php index 88c452a..1c2cd51 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -184,7 +184,7 @@ class Admin { } public static function enqueue_scripts( $hook_suffix ) { - if ( false !== strpos( $hook_suffix, 'activitypub' ) || ( 'edit-comments.php' === $hook_suffix ) ) { + if ( false !== strpos( $hook_suffix, 'activitypub' ) || ( 'edit-comments.php' === $hook_suffix ) || ( 'index.php' === $hook_suffix ) ) { wp_enqueue_style( 'activitypub-admin-styles', plugins_url( 'assets/css/activitypub-admin.css', ACTIVITYPUB_PLUGIN_FILE ), array(), '1.0.0' ); wp_enqueue_script( 'activitypub-admin-styles', plugins_url( 'assets/js/activitypub-admin.js', ACTIVITYPUB_PLUGIN_FILE ), array( 'jquery' ), '1.0.0', false ); } diff --git a/includes/class-comments.php b/includes/class-comments.php index 03d8740..88ff47e 100644 --- a/includes/class-comments.php +++ b/includes/class-comments.php @@ -13,6 +13,7 @@ class Comments { public static function init() { \add_filter( 'preprocess_comment', array( '\Activitypub\Comments', 'preprocess_comment' ) ); + \add_filter( 'comment_excerpt', array( '\Activitypub\Comments', 'comment_excerpt' ), 10, 3 ); \add_filter( 'comment_text', array( '\Activitypub\Comments', 'comment_content_filter' ), 10, 3 ); \add_filter( 'comment_post', array( '\Activitypub\Comments', 'postprocess_comment' ), 10, 3 ); \add_filter( 'wp_update_comment_data', array( '\Activitypub\Comments', 'comment_updated_published' ), 20, 3 ); @@ -40,6 +41,21 @@ class Comments { return $commentdata; } + /** + * comment_excerpt( $comment_excerpt, $comment_ID ) + * Filters the comment text for display in the Recently Published Dashboard Widget. + * + * @param string $comment_text + * @param int $comment_ID + * @param array $args + * @return void + */ + public static function comment_excerpt( $comment_excerpt, $comment_ID ) { + $comment = get_comment( $comment_ID ); + $comment_excerpt = \apply_filters( 'the_content', $comment_excerpt, $comment ); + return $comment_excerpt; + } + /** * comment_text( $comment ) * Filters the comment text for display.