Make WordPress Core

Ticket #15898: garyc40-15898-rev3.patch

File garyc40-15898-rev3.patch, 4.9 KB (added by garyc40, 14 years ago)

properly check parent comment's status before approving

  • wp-admin/admin-ajax.php

    diff --git wp-admin/admin-ajax.php wp-admin/admin-ajax.php
    index 5eb33e1..c740291 100644
    case 'replyto-comment' : 
    661661        $comment_id = wp_new_comment( $commentdata );
    662662        $comment = get_comment($comment_id);
    663663        if ( ! $comment ) die('1');
    664 
     664       
     665        $parent = get_comment( $comment_parent );
     666        if ( ! $parent->comment_approved && ! wp_update_comment( array( 'comment_ID' => $comment_parent, 'comment_approved' => 'approve' ) ) ) {
     667                die('1');
     668        }
    665669        $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
    666670
    667671        $x = new WP_Ajax_Response();
  • wp-admin/css/wp-admin.dev.css

    diff --git wp-admin/css/wp-admin.dev.css wp-admin/css/wp-admin.dev.css
    index 1781101..238bef6 100644
    table.fixed { 
    13731373#comments-form .fixed .column-author {
    13741374        width: 20%;
    13751375}
     1376.comments tr.focus th, .comments tr.focus td {
     1377        border-top-width:1px;
     1378        border-top-style:solid;
     1379}
     1380
     1381.comments tr.blur th, .comments tr.blur td {
     1382        border-bottom-width:0;
     1383}
    13761384#commentsdiv.postbox .inside {
    13771385        line-height:1.4em;
    13781386        margin:0;
  • wp-admin/js/edit-comments.dev.js

    diff --git wp-admin/js/edit-comments.dev.js wp-admin/js/edit-comments.dev.js
    index 177dc86..7eadd38 100644
    setCommentsList = function() { 
    252252commentReply = {
    253253        cid : '',
    254254        act : '',
     255       
     256        showOverlay : function(id) {
     257                var c = $('#comment-' + id),
     258                        excluded = c.find('td, th').css('opacity', 1).add('td, th', '#replyrow');
     259                listTable.$tbody.find('td, th').not(excluded).animate({opacity:'0.2'}, 300);
     260                c.addClass('focus');
     261                c.prev().addClass('blur');
     262        },
     263       
     264        hideOverlay : function() {
     265                listTable.$tbody.
     266                        find('.blur').removeClass('blur').end().
     267                        find('.focus').removeClass('focus');
     268        },
    255269
    256270        init : function() {
    257271                var row = $('#replyrow');
    commentReply = { 
    300314
    301315                if ( $('#the-comment-list #replyrow').length < 1 )
    302316                        return false;
     317                       
     318                listTable.$tbody.find('th, td').animate({opacity : 1}, 300);
    303319
    304320                $('#replyrow').fadeOut('fast', function(){
    305321                        commentReply.close();
    commentReply = { 
    323339                        $('input', '#edithead').val('');
    324340                        $('.error', '#replysubmit').html('').hide();
    325341                        $('.waiting', '#replysubmit').hide();
     342                        this.hideOverlay();
    326343
    327344                        if ( $.browser.msie )
    328345                                $('#replycontainer, #replycontent').css('height', '120px');
    commentReply = { 
    334351        },
    335352
    336353        open : function(id, p, a) {
    337                 var t = this, editRow, rowData, act, h, c = $('#comment-' + id);
     354                var t = this, editRow, rowData, act, h, c = $('#comment-' + id), replyButton;
    338355                t.close();
    339356                t.cid = id;
    340357
    commentReply = { 
    345362                $('#action', editRow).val(act);
    346363                $('#comment_post_ID', editRow).val(p);
    347364                $('#comment_ID', editRow).val(id);
    348 
     365                t.showOverlay(id);
     366               
    349367                if ( a == 'edit' ) {
    350368                        $('#author', editRow).val( $('div.author', rowData).text() );
    351369                        $('#author-email', editRow).val( $('div.author-email', rowData).text() );
    commentReply = { 
    366384                                $('#replyrow').fadeIn(300, function(){ $(this).show() });
    367385                        });
    368386                } else {
     387                        replyButton = $('#replybtn', editRow);
    369388                        $('#edithead, #savebtn', editRow).hide();
    370389                        $('#replyhead, #replybtn', editRow).show();
    371390                        c.after(editRow);
     391                        if (c.hasClass('unapproved')) {
     392                                replyButton.text(adminCommentsL10n.replyApprove);
     393                        } else {
     394                                replyButton.text(adminCommentsL10n.reply);
     395                        }
    372396                        $('#replyrow').fadeIn(300, function(){ $(this).show() });
    373397                }
    374398
    commentReply = { 
    406430        },
    407431
    408432        send : function() {
    409                 var post = {};
     433                var post = {}, c;
    410434
    411435                $('#replysubmit .error').hide();
    412436                $('#replysubmit .waiting').show();
    commentReply = { 
    419443                post.id = post.comment_post_ID;
    420444                post.comments_listing = this.comments_listing;
    421445                post.p = $('[name=p]').val();
    422 
     446                c = $('#comment-' + post.comment_ID);
    423447                $.ajax({
    424448                        type : 'POST',
    425449                        url : ajaxurl,
    426450                        data : post,
    427                         success : function(x) { commentReply.show(x); },
     451                        success : function(x) {
     452                                if (c.hasClass('unapproved')) {
     453                                        c.removeClass('unapproved').addClass('approved');
     454                                }
     455                                commentReply.show(x);
     456                        },
    428457                        error : function(r) { commentReply.error(r); }
    429458                });
    430459
  • wp-includes/script-loader.php

    diff --git wp-includes/script-loader.php wp-includes/script-loader.php
    index 706fd0a..0df59e4 100644
    function wp_default_scripts( &$scripts ) { 
    316316                $scripts->add_data( 'admin-comments', 'group', 1 );
    317317                $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
    318318                        'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
    319                         'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last'])
     319                        'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']),
     320                        'replyApprove' => __( 'Approve and Reply' ),
     321                        'reply' => __( 'Reply' ),
    320322                ) );
    321323
    322324                $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), '20100403' );