Ticket #15898: 15898.8.diff
File 15898.8.diff, 6.7 KB (added by , 14 years ago) |
---|
-
wp-includes/script-loader.php
306 306 'noPerm' => __('You do not have permission to do that.'), 307 307 'broken' => __('An unidentified error has occurred.'), 308 308 'l10n_print_after' => 'try{convertEntities(tagsl10n);}catch(e){};' 309 ) );309 ) ); 310 310 311 311 $scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' ); 312 312 $scripts->add_data( 'admin-custom-fields', 'group', 1 ); … … 315 315 $scripts->add_data( 'admin-comments', 'group', 1 ); 316 316 $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( 317 317 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 318 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']) 318 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']), 319 'replyApprove' => __( 'Approve and Reply' ), 320 'reply' => __( 'Reply' ) 319 321 ) ); 320 322 321 323 $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), '20100403' ); -
wp-admin/admin-ajax.php
666 666 $comment = get_comment($comment_id); 667 667 if ( ! $comment ) die('1'); 668 668 669 $parent = get_comment( $comment_parent ); 670 669 671 $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; 670 672 671 673 $x = new WP_Ajax_Response(); … … 685 687 $comment_list_item = ob_get_contents(); 686 688 ob_end_clean(); 687 689 688 $ x->add(array(690 $response = array( 689 691 'what' => 'comment', 690 692 'id' => $comment->comment_ID, 691 693 'data' => $comment_list_item, 692 694 'position' => $position 693 ) );695 ); 694 696 697 // automatically approve parent comment if user has privileges 698 if ( !( $parent->comment_approved ) && current_user_can( 'moderate_comments' ) ) { 699 if ( wp_update_comment( array( 'comment_ID' => $comment_parent, 'comment_approved' => 'approve' ) ) ) 700 $response['supplemental'] = array( 'parent_approved' => $parent->comment_ID ); 701 else 702 die( '1' ); 703 } 704 705 $x->add( $response ); 695 706 $x->send(); 696 707 break; 697 708 case 'edit-comment' : -
wp-admin/js/edit-comments.dev.js
1 var theList, theExtraList, toggleWithKeyboard = false ;1 var theList, theExtraList, toggleWithKeyboard = false, getCount, updateCount, dashboardTotals; 2 2 (function($) { 3 3 4 4 setCommentsList = function() { … … 9 9 pageInput = $('input[name="_page"]', '#comments-form'); 10 10 11 11 dimAfter = function( r, settings ) { 12 var c = $('#' + settings.element) ;12 var c = $('#' + settings.element), editRow, replyID, replyButton; 13 13 14 if ( c.is('.unapproved') ) 15 c.find('div.comment_status').html('0') 16 else 17 c.find('div.comment_status').html('1') 14 editRow = $('#replyrow'); 15 replyID = $('#comment_ID', editRow).val(); 16 replyButton = $('#replybtn', editRow); 18 17 18 if ( c.is('.unapproved') ) { 19 if (settings.data.id == replyID) 20 replyButton.text(adminCommentsL10n.replyApprove); 21 22 c.find('div.comment_status').html('0'); 23 } else { 24 if (settings.data.id == replyID) 25 replyButton.text(adminCommentsL10n.reply); 26 27 c.find('div.comment_status').html('1'); 28 } 29 30 19 31 $('span.pending-count').each( function() { 20 32 var a = $(this), n, dif; 21 33 n = a.html().replace(/[^0-9]+/g, ''); … … 99 111 }); 100 112 }; 101 113 102 function dashboardTotals(n) {114 dashboardTotals = function dashboardTotals(n) { 103 115 var dash = $('#dashboard_right_now'), total, appr, totalN, apprN; 104 116 105 117 n = n || 0; … … 115 127 updateCount(total, totalN); 116 128 updateCount(appr, apprN); 117 129 118 } 130 }; 119 131 120 function getCount(el) {132 getCount = function getCount(el) { 121 133 var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 ); 122 134 if ( isNaN(n) ) 123 135 return 0; 124 136 return n; 125 } 137 }; 126 138 127 function updateCount(el, n) {139 updateCount = function updateCount(el, n) { 128 140 var n1 = ''; 129 141 if ( isNaN(n) ) 130 142 return; … … 137 149 n = n + n1; 138 150 } 139 151 el.html(n); 140 } 152 }; 141 153 142 154 // In admin-ajax.php, we send back the unix time stamp instead of 1 on success 143 155 delAfter = function( r, settings ) { … … 355 367 }, 356 368 357 369 open : function(id, p, a) { 358 var t = this, editRow, rowData, act, h, c = $('#comment-' + id); 370 var t = this, editRow, rowData, act, h, c = $('#comment-' + id), replyButton; 371 359 372 t.close(); 360 373 t.cid = id; 361 374 … … 387 400 $('#replyrow').fadeIn(300, function(){ $(this).show() }); 388 401 }); 389 402 } else { 403 replyButton = $('#replybtn', editRow); 390 404 $('#edithead, #savebtn', editRow).hide(); 391 405 $('#replyhead, #replybtn', editRow).show(); 392 406 c.after(editRow); 407 408 if (c.hasClass('unapproved')) { 409 replyButton.text(adminCommentsL10n.replyApprove); 410 } else { 411 replyButton.text(adminCommentsL10n.reply); 412 } 413 393 414 $('#replyrow').fadeIn(300, function(){ $(this).show() }); 394 415 } 395 416 … … 453 474 }, 454 475 455 476 show : function(xml) { 456 var r, c, id, bg;477 var t = this, r, c, id, bg, pid; 457 478 458 479 if ( typeof(xml) == 'string' ) { 459 t his.error({'responseText': xml});480 t.error({'responseText': xml}); 460 481 return false; 461 482 } 462 483 463 484 r = wpAjax.parseAjaxResponse(xml); 464 485 if ( r.errors ) { 465 t his.error({'responseText': wpAjax.broken});486 t.error({'responseText': wpAjax.broken}); 466 487 return false; 467 488 } 468 489 469 490 r = r.responses[0]; 470 491 c = r.data; 471 492 id = '#comment-' + r.id; 472 if ( 'edit-comment' == t his.act )493 if ( 'edit-comment' == t.act ) 473 494 $(id).remove(); 474 495 475 496 $(c).hide() 476 497 $('#replyrow').after(c); 477 498 478 this.revert(); 479 this.addEvents($(id)); 499 if ( r.supplemental.parent_approved ) { 500 pid = '#comment-' + r.supplemental.parent_approved; 501 502 $('span.pending-count').each( function() { 503 var a = $(this), n = getCount(a); 504 if (! isNaN(n)) { 505 n = n - 1; 506 if ( n < 0 ) { n = 0; } 507 a.closest('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); 508 updateCount(a, n); 509 dashboardTotals(); 510 } 511 }); 512 } 513 514 t.revert(); 515 t.addEvents($(id)); 480 516 bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff'; 481 517 482 518 $(id) 483 519 .animate( { 'backgroundColor':'#CCEEBB' }, 600 ) 484 .animate( { 'backgroundColor': bg }, 600 ); 520 .animate( { 'backgroundColor': bg }, 600, function() { 521 if ( pid ) { 522 pid = $(pid) 523 .animate( { 'backgroundColor':'#CCEEBB' }, 600 ) 524 .animate( { 'backgroundColor': '#FFFFFF' }, 600 ); 485 525 486 // $.fn.wpList.process($(id)); 526 pid.find('.row-actions .approve').hide(); 527 pid.find('.row-actions .unapprove').show(); 528 } 529 }); 530 487 531 }, 488 532 489 533 error : function(r) {