From be2d6683bbda6fe6e31951da5a556d4997ad5824 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Mon, 6 Nov 2023 14:32:24 +0100 Subject: [PATCH] remove some edit methods --- assets/js/activitypub-reply.js | 35 ---------------------------- includes/class-admin.php | 42 ---------------------------------- includes/functions.php | 12 ---------- 3 files changed, 89 deletions(-) delete mode 100644 assets/js/activitypub-reply.js diff --git a/assets/js/activitypub-reply.js b/assets/js/activitypub-reply.js deleted file mode 100644 index a845265..0000000 --- a/assets/js/activitypub-reply.js +++ /dev/null @@ -1,35 +0,0 @@ -jQuery( function( $ ) { - // Reply from Comment-edit screen & Dashboard. - 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') + ' ' : ''; - setTimeout(function() { - if ( recipients ){ - $('#replycontent').val( recipients ) - } - }, 100); - }) - //Clear @mentions from content on cancel - $('.cancel.button').on('click', function(){ - $('#replycontent').val(''); - }); - } - // Reply from frontend. - if ( $('body').hasClass('logged-in') && $('body').hasClass('single') ) { - //Insert @mentions into comment content on reply - $( '.comment-reply-link' ).on( 'click', function( event ) { - var recipients = $(this).attr('data-recipients') ? $(this).attr('data-recipients') + ' ' : ''; - console.log( 'recipients', recipients ) - setTimeout(function() { - if ( recipients ){ - $('#respond #comment').val( recipients ) - } - }, 100); - }) - //Clear @mentions from content on cancel - $('#cancel-comment-reply-link').on('click', function(){ - $('#respond #comment').val(''); - }); - } -} ); diff --git a/includes/class-admin.php b/includes/class-admin.php index ac121f1..462e394 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -268,52 +268,10 @@ class Admin { } } - /** - * hook comment_row_actions - * Reply to ActivityPub Comments from the edit-comments.php screen - */ - public static function reply_comments_actions( $actions, $comment ) { - $recipients = \Activitypub\reply_recipients( $comment->comment_ID ); - $summary = \Activitypub\get_summary( $comment->comment_ID ); - $reply_button = ''; - $actions['reply'] = \sprintf( - $reply_button, - $comment->comment_ID, - $comment->comment_post_ID, - 'replyto', - 'vim-r comment-inline', - \esc_attr__( 'Reply to this comment', 'activitypub' ), - $recipients, - $summary, - \__( 'Reply', 'activitypub' ) - ); - $remote_comment_link = get_comment_meta( $comment->comment_ID, 'source_url', true ); - if ( $remote_comment_link ) { - $comment_link = esc_url( $remote_comment_link ); - $source_link = '%s'; - $actions['source'] = \sprintf( - $source_link, - $comment_link, - \esc_attr__( 'View this comment on remote server', 'activitypub' ), - \__( 'View source', 'activitypub' ) - ); - } - return $actions; - } - public static function enqueue_scripts( $hook_suffix ) { if ( false !== strpos( $hook_suffix, 'activitypub' ) ) { 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 ); } - if ( ( 'edit-comments.php' === $hook_suffix ) || ( 'index.php' === $hook_suffix ) ) { - wp_enqueue_script( 'activitypub-reply', plugins_url( 'assets/js/activitypub-reply.js', ACTIVITYPUB_PLUGIN_FILE ), array( 'jquery' ), '1.0.0', false ); - } - } - - public static function comment_enqueue_scripts() { - if ( is_singular() ) { - wp_enqueue_script( 'activitypub-reply', plugins_url( 'assets/js/activitypub-reply.js', ACTIVITYPUB_PLUGIN_FILE ), array( 'jquery' ), '1.0.0', false ); - } } } diff --git a/includes/functions.php b/includes/functions.php index c06761f..902333b 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -363,18 +363,6 @@ function reply_recipients( $object_id, $post = null ) { } } -/** - * Add summary to reply - */ -function get_summary( $comment_id ) { - $ap_object = \unserialize( \get_comment_meta( $comment_id, 'ap_object', true ) ); - if ( ! empty( $ap_object ) ) { - if ( ! empty( $ap_object['object']['summary'] ) ) { - return \esc_attr( $ap_object['object']['summary'] ); - } - } -} - /** * @param string $user_url * @return string $webfinger