Make WordPress Core

Ticket #27533: 27533.diff

File 27533.diff, 2.8 KB (added by aubreypwd, 11 years ago)

Using unobtrusive JS on comment "Reply," and "Quick Edit."

  • src/wp-admin/includes/class-wp-comments-list-table.php

     
    461461                        }
    462462
    463463                        if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
     464                               
     465                                // Add "Edit" link to comment
    464466                                $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';
    465                                 $actions['quickedit'] = '<a onclick="window.commentReply && commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\' );return false;" class="vim-q" title="'.esc_attr__( 'Quick Edit' ).'" href="#">' . __( 'Quick&nbsp;Edit' ) . '</a>';
    466                                 $actions['reply'] = '<a onclick="window.commentReply && commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\' );return false;" class="vim-r" title="'.esc_attr__( 'Reply to this comment' ).'" href="#">' . __( 'Reply' ) . '</a>';
     467                               
     468                                // Add "Quick Edit" link to comment
     469                                $actions['quickedit'] = '<a data-post-id="'.$post->ID.'" data-comment-id="'.$comment->comment_ID.'" class="vim-q edit-comment-inline" title="'.esc_attr__( 'Quick Edit' ).'" href="#">' . __( 'Quick Edit' ) . '</a>';
     470                               
     471                                // Add "Reply" link to comment
     472                                $actions['reply'] = '<a data-comment-id="'.$comment->comment_ID.'" data-post-id="'.$post->ID.'" class="vim-r reply-comment-inline" title="'.esc_attr__( 'Reply to this comment' ).'" href="#">' . __( 'Reply' ) . '</a>';
    467473                        }
    468474
    469475                        /** This filter is documented in wp-admin/includes/dashboard.php */
  • src/wp-admin/js/edit-comments.js

     
    607607                        }
    608608                );
    609609        }
     610       
     611        if ( typeof commentReply != 'undefined' ) {
     612               
     613                // Each "Quick Edit" link, open the comment editor
     614                $( '.comment .row-actions .quickedit .edit-comment-inline' ).each(
     615                        function() {
     616                                $(this).on('click', function() {
     617                                        var post_id     = $(this).data('post-id');
     618                                        var comment_id  = $(this).data('comment-id');
     619                                       
     620                                        commentReply.open(
     621                                                comment_id,
     622                                                post_id,
     623                                                'edit'
     624                                        );
     625                                       
     626                                });
     627                        }
     628                );
     629       
     630                // Each "Reply" link, open the comment reply
     631                $( '.comment .row-actions .reply .reply-comment-inline' ).each(
     632                        function() {
     633                                $(this).on('click', function() {
     634                                        var post_id     = $(this).data('post-id');
     635                                        var comment_id  = $(this).data('comment-id');
     636                                       
     637                                        commentReply.open(
     638                                                comment_id,
     639                                                post_id
     640                                                // default is 'reply'
     641                                        );
     642                                       
     643                                });
     644                        }
     645                );
     646       
     647        }
     648       
     649       
     650
    610651});
    611652
    612653})(jQuery);