Make WordPress Core

Ticket #27533: 27533.2.diff

File 27533.2.diff, 2.9 KB (added by aubreypwd, 11 years ago)

Update per @wonderboymusic suggestion with delegation.

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

    diff --git src/wp-admin/includes/class-wp-comments-list-table.php src/wp-admin/includes/class-wp-comments-list-table.php
    index 08b709b..02dd49a 100644
    class WP_Comments_List_Table extends WP_List_Table { 
    459459                        }
    460460
    461461                        if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
     462                               
     463                                // Add "Edit" link to comment
    462464                                $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';
    463                                 $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>';
    464                                 $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>';
     465                               
     466                                // Add "Quick Edit" link to comment
     467                                $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>';
     468                               
     469                                // Add "Reply" link to comment
     470                                $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>';
    465471                        }
    466472
    467473                        /** This filter is documented in wp-admin/includes/dashboard.php */
  • src/wp-admin/js/edit-comments.js

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