From 848034a1900efb0bcd81700713c3ba47b4167f4d Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 23 Jun 2014 23:54:28 +0000 Subject: [PATCH] Use unobtrusive JS for Comment list table row actions. Props aubreypwd. Fixes #27533. git-svn-id: https://develop.svn.wordpress.org/trunk@28810 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-comments-list-table.php | 8 ++++++-- src/wp-admin/js/edit-comments.js | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 08b709b633..f9cde7ecf5 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -460,8 +460,12 @@ class WP_Comments_List_Table extends WP_List_Table { if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) { $actions['edit'] = "". __( 'Edit' ) . ''; - $actions['quickedit'] = '' . __( 'Quick Edit' ) . ''; - $actions['reply'] = '' . __( 'Reply' ) . ''; + + $format = '%s'; + + $actions['quickedit'] = sprintf( $format, $comment->comment_ID, $post->ID, 'vim-q edit-comment-inline', esc_attr__( 'Quick Edit' ), __( 'Quick Edit' ) ); + + $actions['reply'] = sprintf( $format, $comment->comment_ID, $post->ID, 'vim-r reply-comment-inline', esc_attr__( 'Reply to this comment' ), __( 'Reply' ) ); } /** This filter is documented in wp-admin/includes/dashboard.php */ diff --git a/src/wp-admin/js/edit-comments.js b/src/wp-admin/js/edit-comments.js index ff149e19dc..d8a402ecd6 100644 --- a/src/wp-admin/js/edit-comments.js +++ b/src/wp-admin/js/edit-comments.js @@ -607,6 +607,25 @@ $(document).ready(function(){ } ); } + + if ( typeof commentReply != 'undefined' ) { + + // Each "Quick Edit" link, open the comment editor + $( 'body' ).on( 'click', '.comment .row-actions .quickedit .edit-comment-inline', function (e) { + e.preventDefault(); + + var $el = $( e.currentTarget ); + commentReply.open( $el.data( 'comment-id' ), $el.data( 'post-id' ), 'edit' ); + } ); + + // Each "Reply" link, open the comment reply + $( 'body' ).on( 'click', '.comment .row-actions .reply .reply-comment-inline', function (e) { + e.preventDefault(); + + var $el = $( e.currentTarget ); + commentReply.open( $el.data('comment-id'), $el.data('post-id') ); + } ); + } }); })(jQuery);