From 5b9af35c4cd0340af61ed449b50e77b3b226f341 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 24 Sep 2015 15:53:25 +0000 Subject: [PATCH] Comments: update Comment counts dynamically in the Right Now widget based on moderation actions in the Activity widget. Fixes #10422. Built from https://develop.svn.wordpress.org/trunk@34500 git-svn-id: http://core.svn.wordpress.org/trunk@34464 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 32 +++++++++++++++++++++++++--- wp-admin/includes/dashboard.php | 18 +++++++++------- wp-admin/js/edit-comments.js | 34 +++++++++++++++++++++++++----- wp-admin/js/edit-comments.min.js | 2 +- wp-includes/version.php | 2 +- 5 files changed, 70 insertions(+), 18 deletions(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 289d959224..c380583207 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -351,6 +351,8 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { $time = time(); $comment = get_comment( $comment_id ); + $counts = wp_count_comments(); + $x = new WP_Ajax_Response( array( 'what' => 'comment', // Here for completeness - not used. @@ -358,7 +360,16 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { 'supplemental' => array( 'status' => $comment ? $comment->comment_approved : '', 'postId' => $comment ? $comment->comment_post_ID : '', - 'time' => $time + 'time' => $time, + 'in_moderation' => $counts->moderated, + 'i18n_comments_text' => sprintf( + _n( '%s Comment', '%s Comments', $counts->approved ), + number_format_i18n( $counts->approved ) + ), + 'i18n_moderation_text' => sprintf( + _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ), + number_format_i18n( $counts->moderated ) + ) ) ) ); $x->send(); @@ -1049,8 +1060,23 @@ function wp_ajax_replyto_comment( $action ) { 'position' => $position ); - if ( $comment_auto_approved ) - $response['supplemental'] = array( 'parent_approved' => $parent->comment_ID, 'parent_post_id' => $parent->comment_post_ID ); + $counts = wp_count_comments(); + $response['supplemental'] = array( + 'in_moderation' => $counts->moderated, + 'i18n_comments_text' => sprintf( + _n( '%s Comment', '%s Comments', $counts->approved ), + number_format_i18n( $counts->approved ) + ), + 'i18n_moderation_text' => sprintf( + _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ), + number_format_i18n( $counts->moderated ) + ) + ); + + if ( $comment_auto_approved ) { + $response['supplemental']['parent_approved'] = $parent->comment_ID; + $response['supplemental']['parent_post_id'] = $parent->comment_post_ID; + } $x = new WP_Ajax_Response(); $x->add( $response ); diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 806f6d938b..f09c7796b5 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -259,13 +259,15 @@ function wp_dashboard_right_now() { ?>
  • moderated ) { - /* translators: Number of comments in moderation */ - $text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), number_format_i18n( $num_comm->moderated ) ); - ?> -
  • - moderated, 'comments' ), number_format_i18n( $num_comm->moderated ) ); + ?> +
  • + comment_post_ID > 0 && current_user_can( 'edit_post', $comment->comment_post_ID ) ) { $comment_post_title = _draft_or_post_title( $comment->comment_post_ID ); diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index e06f93a9d6..fe2a38b8e1 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -3,7 +3,7 @@ var setCommentsList, theList, theExtraList, commentReply; (function($) { var getCount, updateCount, updateCountText, updatePending, updateApproved, - updateHtmlTitle, adminTitle = document.title; + updateHtmlTitle, updateDashboardText, adminTitle = document.title; setCommentsList = function() { var totalInput, perPageInput, pageInput, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList, diff, @@ -19,6 +19,10 @@ setCommentsList = function() { var editRow, replyID, replyButton, response, c = $( '#' + settings.element ); + if ( true !== settings.parsed ) { + response = settings.parsed.responses[0]; + } + editRow = $('#replyrow'); replyID = $('#comment_ID', editRow).val(); replyButton = $('#replybtn', editRow); @@ -36,10 +40,10 @@ setCommentsList = function() { } diff = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1; - if ( true !== settings.parsed && settings.parsed.responses.length ) { - response = settings.parsed.responses[0].supplemental; - updatePending( diff, response.postId ); - updateApproved( -1 * diff, response.postId ); + if ( response ) { + updateDashboardText( response.supplemental ); + updatePending( diff, response.supplemental.postId ); + updateApproved( -1 * diff, response.supplemental.postId ); } else { updatePending( diff ); updateApproved( -1 * diff ); @@ -277,12 +281,26 @@ setCommentsList = function() { }); }; + updateDashboardText = function ( response ) { + if ( ! isDashboard || ! response || ! response.i18n_comments_text ) { + return; + } + + var rightNow = $( '#dashboard_right_now' ); + + $( '.comment-count a', rightNow ).text( response.i18n_comments_text ); + $( '.comment-mod-count a', rightNow ).text( response.i18n_moderation_text ) + .parent() + [ response.in_moderation > 0 ? 'removeClass' : 'addClass' ]( 'hidden' ); + }; + // In admin-ajax.php, we send back the unix time stamp instead of 1 on success delAfter = function( r, settings ) { var total_items_i18n, total, animated, animatedCallback, response = true === settings.parsed ? {} : settings.parsed.responses[0], commentStatus = true === settings.parsed ? '' : response.supplemental.status, commentPostId = true === settings.parsed ? '' : response.supplemental.postId, + newTotal = true === settings.parsed ? '' : response.supplemental, targetParent = $( settings.target ).parent(), commentRow = $('#' + settings.element), @@ -294,6 +312,8 @@ setCommentsList = function() { spammed = commentRow.hasClass( 'spam' ), trashed = commentRow.hasClass( 'trash' ); + updateDashboardText( newTotal ); + // the order of these checks is important // .unspam can also have .approve or .unapprove // .untrash can also have .approve or .unapprove @@ -771,6 +791,10 @@ commentReply = { } } + if ( r.supplemental.i18n_comments_text ) { + updateDashboardText( r.supplemental ); + } + c = $.trim(r.data); // Trim leading whitespaces $(c).hide(); $('#replyrow').after(c); diff --git a/wp-admin/js/edit-comments.min.js b/wp-admin/js/edit-comments.min.js index 778afbb7be..4f6865317a 100644 --- a/wp-admin/js/edit-comments.min.js +++ b/wp-admin/js/edit-comments.min.js @@ -1 +1 @@ -var setCommentsList,theList,theExtraList,commentReply;!function(a){var b,c,d,e,f,g,h=document.title;setCommentsList=function(){var i,j,k,l,m,n,o,p,q,r,s,t=0,u=a("#dashboard_right_now").length;i=a('input[name="_total"]',"#comments-form"),j=a('input[name="_per_page"]',"#comments-form"),k=a('input[name="_page"]',"#comments-form"),l=function(b,c){var d,g,h,i,j=a("#"+c.element);d=a("#replyrow"),g=a("#comment_ID",d).val(),h=a("#replybtn",d),j.is(".unapproved")?(c.data.id==g&&h.text(adminCommentsL10n.replyApprove),j.find("div.comment_status").html("0")):(c.data.id==g&&h.text(adminCommentsL10n.reply),j.find("div.comment_status").html("1")),q=a("#"+c.element).is("."+c.dimClass)?1:-1,!0!==c.parsed&&c.parsed.responses.length?(i=c.parsed.responses[0].supplemental,e(q,i.postId),f(-1*q,i.postId)):(e(q),f(-1*q))},m=function(b,c){var d,e,f,g,h,l,m,n=!1,o=a(b.target).attr("data-wp-lists");return b.data._total=i.val()||0,b.data._per_page=j.val()||0,b.data._page=k.val()||0,b.data._url=document.location.href,b.data.comment_status=a('input[name="comment_status"]',"#comments-form").val(),-1!=o.indexOf(":trash=1")?n="trash":-1!=o.indexOf(":spam=1")&&(n="spam"),n&&(e=o.replace(/.*?comment-([0-9]+).*/,"$1"),f=a("#comment-"+e),d=a("#"+n+"-undo-holder").html(),f.find(".check-column :checkbox").prop("checked",!1),f.siblings("#replyrow").length&&commentReply.cid==e&&commentReply.close(),f.is("tr")?(g=f.children(":visible").length,m=a(".author strong",f).text(),h=a(''+d+"")):(m=a(".comment-author",f).text(),h=a('")),f.before(h),a("strong","#undo-"+e).text(m),l=a(".undo a","#undo-"+e),l.attr("href","comment.php?action=un"+n+"comment&c="+e+"&_wpnonce="+b.data._ajax_nonce),l.attr("data-wp-lists","delete:the-comment-list:comment-"+e+"::un"+n+"=1"),l.attr("class","vim-z vim-destructive"),a(".avatar",f).first().clone().prependTo("#undo-"+e+" ."+n+"-undo-inside"),l.click(function(){return c.wpList.del(this),a("#undo-"+e).css({backgroundColor:"#ceb"}).fadeOut(350,function(){a(this).remove(),a("#comment-"+e).css("backgroundColor","").fadeIn(300,function(){a(this).show()})}),!1})),b},n=function(a,b,c){t>b||(c&&(t=b),i.val(a.toString()))},b=function(a){var b=parseInt(a.html().replace(/[^0-9]+/g,""),10);return isNaN(b)?0:b},c=function(a,b){var c="";if(!isNaN(b)){if(b=1>b?"0":b.toString(),b.length>3){for(;b.length>3;)c=thousandsSeparator+b.substr(b.length-3)+c,b=b.substr(0,b.length-3);b+=c}a.html(b)}},g=function(d){var e,f,g,i;s=s||new RegExp("Comments (\\([0-9"+thousandsSeparator+"]+\\))?"),r=r||a("
    "),e=h,i=s.exec(document.title),i?(i=i[0],r.html(i),g=b(r)+d):(r.html(0),g=d),g>=1?(c(r,g),f=s.exec(document.title),f&&(e=document.title.replace(f[0],"Comments ("+r.text()+") "))):(f=s.exec(e),f&&(e=e.replace(f[0],"Comments"))),document.title=e},e=function(d,e){var f,h,i=".post-com-count-"+e,j="comment-count-no-pending",k="post-com-count-no-pending",l="comment-count-pending";u||g(d),a("span.pending-count").each(function(){var e=a(this),f=b(e)+d;1>f&&(f=0),e.closest(".awaiting-mod")[0===f?"addClass":"removeClass"]("count-0"),c(e,f)}),e&&(f=a("span."+l,i),h=a("span."+j,i),f.each(function(){var e=a(this),f=b(e)+d;1>f&&(f=0),0===f?(e.parent().addClass(k),e.removeClass(l).addClass(j)):(e.parent().removeClass(k),e.addClass(l).removeClass(j)),c(e,f)}),h.each(function(){var b=a(this);d>0?(b.parent().removeClass(k),b.removeClass(j).addClass(l)):(b.parent().addClass(k),b.addClass(j).removeClass(l)),c(b,d)}))},f=function(e,f){var g,h,i=".post-com-count-"+f,j="comment-count-no-comments",k="comment-count-approved";d("span.approved-count",e),f&&(g=a("span."+k,i),h=a("span."+j,i),g.each(function(){var d=a(this),f=b(d)+e;1>f&&(f=0),0===f?d.removeClass(k).addClass(j):d.addClass(k).removeClass(j),c(d,f)}),h.each(function(){var b=a(this);e>0?b.removeClass(j).addClass(k):b.addClass(j).removeClass(k),c(b,e)}))},d=function(d,e){a(d).each(function(){var d=a(this),f=b(d)+e;1>f&&(f=0),c(d,f)})},o=function(b,c){var g,h,j,k,l,m,o,q,r=!0===c.parsed?{}:c.parsed.responses[0],s=!0===c.parsed?"":r.supplemental.status,v=!0===c.parsed?"":r.supplemental.postId,w=a(c.target).parent(),x=a("#"+c.element),y=x.hasClass("approved"),z=x.hasClass("unapproved"),A=x.hasClass("spam"),B=x.hasClass("trash");w.is("span.undo")?w.hasClass("unspam")?(l=-1,"trash"===s?m=1:"1"===s?q=1:"0"===s&&(o=1)):w.hasClass("untrash")&&(m=-1,"spam"===s?l=1:"1"===s?q=1:"0"===s&&(o=1)):w.is("span.spam")?(y?q=-1:z?o=-1:B&&(m=-1),l=1):w.is("span.unspam")?(y?o=1:z?q=1:B?w.hasClass("approve")?q=1:w.hasClass("unapprove")&&(o=1):A&&(w.hasClass("approve")?q=1:w.hasClass("unapprove")&&(o=1)),l=-1):w.is("span.trash")?(y?q=-1:z?o=-1:A&&(l=-1),m=1):w.is("span.untrash")?(y?o=1:z?q=1:B&&(w.hasClass("approve")?q=1:w.hasClass("unapprove")&&(o=1)),m=-1):w.is("span.approve:not(.unspam):not(.untrash)")?(q=1,o=-1):w.is("span.unapprove:not(.unspam):not(.untrash)")?(q=-1,o=1):w.is("span.delete")&&(A?l=-1:B&&(m=-1)),o&&e(o,v),q&&f(q,v),l&&d("span.spam-count",l),m&&d("span.trash-count",m),u||(h=i.val()?parseInt(i.val(),10):0,a(c.target).parent().is("span.undo")?h++:h--,0>h&&(h=0),"object"==typeof b?r.supplemental.total_items_i18n&&td||(b?(theExtraList.empty(),c.number=Math.min(8,e)):(c.number=1,c.offset=Math.min(8,e)-1),c.no_placeholder=!0,c.paged++,!0===c.comment_type&&(c.comment_type=""),c=a.extend(c,{action:"fetch-list",list_args:list_args,_ajax_fetch_list_nonce:a("#_ajax_fetch_list_nonce").val()}),a.ajax({url:ajaxurl,global:!1,dataType:"json",data:c,success:function(a){theExtraList.get(0).wpList.add(a.rows)}}))},theExtraList=a("#the-extra-comment-list").wpList({alt:"",delColor:"none",addColor:"none"}),theList=a("#the-comment-list").wpList({alt:"",delBefore:m,dimAfter:l,delAfter:o,addColor:"none"}).bind("wpListDelEnd",function(b,c){var d=a(c.target).attr("data-wp-lists"),e=c.element.replace(/[^0-9]+/g,"");(-1!=d.indexOf(":trash=1")||-1!=d.indexOf(":spam=1"))&&a("#undo-"+e).fadeIn(300,function(){a(this).show()})})},commentReply={cid:"",act:"",init:function(){var b=a("#replyrow");a("a.cancel",b).click(function(){return commentReply.revert()}),a("a.save",b).click(function(){return commentReply.send()}),a("input#author-name, input#author-email, input#author-url",b).keypress(function(a){return 13==a.which?(commentReply.send(),a.preventDefault(),!1):void 0}),a("#the-comment-list .column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())}),a("#doaction, #doaction2, #post-query-submit").click(function(){a("#the-comment-list #replyrow").length>0&&commentReply.close()}),this.comments_listing=a('#comments-form > input[name="comment_status"]').val()||""},addEvents:function(b){b.each(function(){a(this).find(".column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())})})},toggle:function(b){"none"!==a(b).css("display")&&(a("#replyrow").parent().is("#com-reply")||window.confirm(adminCommentsL10n.warnQuickEdit))&&a(b).find("a.vim-q").click()},revert:function(){return a("#the-comment-list #replyrow").length<1?!1:(a("#replyrow").fadeOut("fast",function(){commentReply.close()}),!1)},close:function(){var b,c=a("#replyrow");c.parent().is("#com-reply")||(this.cid&&"edit-comment"==this.act&&(b=a("#comment-"+this.cid),b.fadeIn(300,function(){b.show()}).css("backgroundColor","")),"undefined"!=typeof QTags&&QTags.closeAllTags("replycontent"),a("#add-new-comment").css("display",""),c.hide(),a("#com-reply").append(c),a("#replycontent").css("height","").val(""),a("#edithead input").val(""),a(".error",c).empty().hide(),a(".spinner",c).removeClass("is-active"),this.cid="")},open:function(b,c,d){var e,f,g,h,i,j=this,k=a("#comment-"+b),l=k.height(),m=0;return j.close(),j.cid=b,e=a("#replyrow"),f=a("#inline-"+b),d=d||"replyto",g="edit"==d?"edit":"replyto",g=j.act=g+"-comment",m=a("th:visible, td:visible",k).length,e.hasClass("inline-edit-row")&&0!==m&&a("td",e).attr("colspan",m),a("#action",e).val(g),a("#comment_post_ID",e).val(c),a("#comment_ID",e).val(b),"edit"==d?(a("#author-name",e).val(a("div.author",f).text()),a("#author-email",e).val(a("div.author-email",f).text()),a("#author-url",e).val(a("div.author-url",f).text()),a("#status",e).val(a("div.comment_status",f).text()),a("#replycontent",e).val(a("textarea.comment",f).val()),a("#edithead, #savebtn",e).show(),a("#replyhead, #replybtn, #addhead, #addbtn",e).hide(),l>120&&(i=l>500?500:l,a("#replycontent",e).css("height",i+"px")),k.after(e).fadeOut("fast",function(){a("#replyrow").fadeIn(300,function(){a(this).show()})})):"add"==d?(a("#addhead, #addbtn",e).show(),a("#replyhead, #replybtn, #edithead, #savebtn",e).hide(),a("#the-comment-list").prepend(e),a("#replyrow").fadeIn(300)):(h=a("#replybtn",e),a("#edithead, #savebtn, #addhead, #addbtn",e).hide(),a("#replyhead, #replybtn",e).show(),k.after(e),k.hasClass("unapproved")?h.text(adminCommentsL10n.replyApprove):h.text(adminCommentsL10n.reply),a("#replyrow").fadeIn(300,function(){a(this).show()})),setTimeout(function(){var b,c,d,e,f;b=a("#replyrow").offset().top,c=b+a("#replyrow").height(),d=window.pageYOffset||document.documentElement.scrollTop,e=document.documentElement.clientHeight||window.innerHeight||0,f=d+e,c>f-20?window.scroll(0,c-e+35):d>b-20&&window.scroll(0,b-35),a("#replycontent").focus().keyup(function(a){27==a.which&&commentReply.revert()})},600),!1},send:function(){var b={};return a("#replysubmit .error").hide(),a("#replysubmit .spinner").addClass("is-active"),a("#replyrow input").not(":button").each(function(){var c=a(this);b[c.attr("name")]=c.val()}),b.content=a("#replycontent").val(),b.id=b.comment_post_ID,b.comments_listing=this.comments_listing,b.p=a('[name="p"]').val(),a("#comment-"+a("#comment_ID").val()).hasClass("unapproved")&&(b.approve_parent=1),a.ajax({type:"POST",url:ajaxurl,data:b,success:function(a){commentReply.show(a)},error:function(a){commentReply.error(a)}}),!1},show:function(b){var c,d,f,g,h,i=this;return"string"==typeof b?(i.error({responseText:b}),!1):(c=wpAjax.parseAjaxResponse(b),c.errors?(i.error({responseText:wpAjax.broken}),!1):(i.revert(),c=c.responses[0],f="#comment-"+c.id,"edit-comment"==i.act&&a(f).remove(),c.supplemental.parent_approved&&(h=a("#comment-"+c.supplemental.parent_approved),e(-1,c.supplemental.parent_post_id),"moderated"==this.comments_listing)?void h.animate({backgroundColor:"#CCEEBB"},400,function(){h.fadeOut()}):(d=a.trim(c.data),a(d).hide(),a("#replyrow").after(d),f=a(f),i.addEvents(f),g=f.hasClass("unapproved")?"#FFFFE0":f.closest(".widefat, .postbox").css("backgroundColor"),void f.animate({backgroundColor:"#CCEEBB"},300).animate({backgroundColor:g},300,function(){h&&h.length&&h.animate({backgroundColor:"#CCEEBB"},300).animate({backgroundColor:g},300).removeClass("unapproved").addClass("approved").find("div.comment_status").html("1")}))))},error:function(b){var c=b.statusText;a("#replysubmit .spinner").removeClass("is-active"),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#replysubmit .error").html(c).show()},addcomment:function(b){var c=this;a("#add-new-comment").fadeOut(200,function(){c.open(0,b,"add"),a("table.comments-box").css("display",""),a("#no-comments").remove()})}},a(document).ready(function(){var b,c,d,e;setCommentsList(),commentReply.init(),a(document).delegate("span.delete a.delete","click",function(){return!1}),"undefined"!=typeof a.table_hotkeys&&(b=function(b){return function(){var c,d;c="next"==b?"first":"last",d=a(".tablenav-pages ."+b+"-page:not(.disabled)"),d.length&&(window.location=d[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g,"")+"&hotkeys_highlight_"+c+"=1")}},c=function(b,c){window.location=a("span.edit a",c).attr("href")},d=function(){a("#cb-select-all-1").data("wp-toggle",1).trigger("click").removeData("wp-toggle")},e=function(b){return function(){var c=a('select[name="action"]');a('option[value="'+b+'"]',c).prop("selected",!0),a("#doaction").click()}},a.table_hotkeys(a("table.widefat"),["a","u","s","d","r","q","z",["e",c],["shift+x",d],["shift+a",e("approve")],["shift+s",e("spam")],["shift+d",e("delete")],["shift+t",e("trash")],["shift+z",e("untrash")],["shift+u",e("unapprove")]],{highlight_first:adminCommentsL10n.hotkeys_highlight_first,highlight_last:adminCommentsL10n.hotkeys_highlight_last,prev_page_link_cb:b("prev"),next_page_link_cb:b("next"),hotkeys_opts:{disableInInput:!0,type:"keypress",noDisable:'.check-column input[type="checkbox"]'},cycle_expr:"#the-comment-list tr",start_row_index:0})),a("#the-comment-list").on("click",".comment-inline",function(b){b.preventDefault();var c=a(this),d="replyto";"undefined"!=typeof c.data("action")&&(d=c.data("action")),commentReply.open(c.data("commentId"),c.data("postId"),d)})})}(jQuery); \ No newline at end of file +var setCommentsList,theList,theExtraList,commentReply;!function(a){var b,c,d,e,f,g,h,i=document.title;setCommentsList=function(){var j,k,l,m,n,o,p,q,r,s,t,u=0,v=a("#dashboard_right_now").length;j=a('input[name="_total"]',"#comments-form"),k=a('input[name="_per_page"]',"#comments-form"),l=a('input[name="_page"]',"#comments-form"),m=function(b,c){var d,g,i,j,k=a("#"+c.element);!0!==c.parsed&&(j=c.parsed.responses[0]),d=a("#replyrow"),g=a("#comment_ID",d).val(),i=a("#replybtn",d),k.is(".unapproved")?(c.data.id==g&&i.text(adminCommentsL10n.replyApprove),k.find("div.comment_status").html("0")):(c.data.id==g&&i.text(adminCommentsL10n.reply),k.find("div.comment_status").html("1")),r=a("#"+c.element).is("."+c.dimClass)?1:-1,j?(h(j.supplemental),e(r,j.supplemental.postId),f(-1*r,j.supplemental.postId)):(e(r),f(-1*r))},n=function(b,c){var d,e,f,g,h,i,m,n=!1,o=a(b.target).attr("data-wp-lists");return b.data._total=j.val()||0,b.data._per_page=k.val()||0,b.data._page=l.val()||0,b.data._url=document.location.href,b.data.comment_status=a('input[name="comment_status"]',"#comments-form").val(),-1!=o.indexOf(":trash=1")?n="trash":-1!=o.indexOf(":spam=1")&&(n="spam"),n&&(e=o.replace(/.*?comment-([0-9]+).*/,"$1"),f=a("#comment-"+e),d=a("#"+n+"-undo-holder").html(),f.find(".check-column :checkbox").prop("checked",!1),f.siblings("#replyrow").length&&commentReply.cid==e&&commentReply.close(),f.is("tr")?(g=f.children(":visible").length,m=a(".author strong",f).text(),h=a(''+d+"")):(m=a(".comment-author",f).text(),h=a('")),f.before(h),a("strong","#undo-"+e).text(m),i=a(".undo a","#undo-"+e),i.attr("href","comment.php?action=un"+n+"comment&c="+e+"&_wpnonce="+b.data._ajax_nonce),i.attr("data-wp-lists","delete:the-comment-list:comment-"+e+"::un"+n+"=1"),i.attr("class","vim-z vim-destructive"),a(".avatar",f).first().clone().prependTo("#undo-"+e+" ."+n+"-undo-inside"),i.click(function(){return c.wpList.del(this),a("#undo-"+e).css({backgroundColor:"#ceb"}).fadeOut(350,function(){a(this).remove(),a("#comment-"+e).css("backgroundColor","").fadeIn(300,function(){a(this).show()})}),!1})),b},o=function(a,b,c){u>b||(c&&(u=b),j.val(a.toString()))},b=function(a){var b=parseInt(a.html().replace(/[^0-9]+/g,""),10);return isNaN(b)?0:b},c=function(a,b){var c="";if(!isNaN(b)){if(b=1>b?"0":b.toString(),b.length>3){for(;b.length>3;)c=thousandsSeparator+b.substr(b.length-3)+c,b=b.substr(0,b.length-3);b+=c}a.html(b)}},g=function(d){var e,f,g,h;t=t||new RegExp("Comments (\\([0-9"+thousandsSeparator+"]+\\))?"),s=s||a("
    "),e=i,h=t.exec(document.title),h?(h=h[0],s.html(h),g=b(s)+d):(s.html(0),g=d),g>=1?(c(s,g),f=t.exec(document.title),f&&(e=document.title.replace(f[0],"Comments ("+s.text()+") "))):(f=t.exec(e),f&&(e=e.replace(f[0],"Comments"))),document.title=e},e=function(d,e){var f,h,i=".post-com-count-"+e,j="comment-count-no-pending",k="post-com-count-no-pending",l="comment-count-pending";v||g(d),a("span.pending-count").each(function(){var e=a(this),f=b(e)+d;1>f&&(f=0),e.closest(".awaiting-mod")[0===f?"addClass":"removeClass"]("count-0"),c(e,f)}),e&&(f=a("span."+l,i),h=a("span."+j,i),f.each(function(){var e=a(this),f=b(e)+d;1>f&&(f=0),0===f?(e.parent().addClass(k),e.removeClass(l).addClass(j)):(e.parent().removeClass(k),e.addClass(l).removeClass(j)),c(e,f)}),h.each(function(){var b=a(this);d>0?(b.parent().removeClass(k),b.removeClass(j).addClass(l)):(b.parent().addClass(k),b.addClass(j).removeClass(l)),c(b,d)}))},f=function(e,f){var g,h,i=".post-com-count-"+f,j="comment-count-no-comments",k="comment-count-approved";d("span.approved-count",e),f&&(g=a("span."+k,i),h=a("span."+j,i),g.each(function(){var d=a(this),f=b(d)+e;1>f&&(f=0),0===f?d.removeClass(k).addClass(j):d.addClass(k).removeClass(j),c(d,f)}),h.each(function(){var b=a(this);e>0?b.removeClass(j).addClass(k):b.addClass(j).removeClass(k),c(b,e)}))},d=function(d,e){a(d).each(function(){var d=a(this),f=b(d)+e;1>f&&(f=0),c(d,f)})},h=function(b){if(v&&b&&b.i18n_comments_text){var c=a("#dashboard_right_now");a(".comment-count a",c).text(b.i18n_comments_text),a(".comment-mod-count a",c).text(b.i18n_moderation_text).parent()[b.in_moderation>0?"removeClass":"addClass"]("hidden")}},p=function(b,c){var g,i,k,l,m,n,p,r,s=!0===c.parsed?{}:c.parsed.responses[0],t=!0===c.parsed?"":s.supplemental.status,w=!0===c.parsed?"":s.supplemental.postId,x=!0===c.parsed?"":s.supplemental,y=a(c.target).parent(),z=a("#"+c.element),A=z.hasClass("approved"),B=z.hasClass("unapproved"),C=z.hasClass("spam"),D=z.hasClass("trash");h(x),y.is("span.undo")?y.hasClass("unspam")?(m=-1,"trash"===t?n=1:"1"===t?r=1:"0"===t&&(p=1)):y.hasClass("untrash")&&(n=-1,"spam"===t?m=1:"1"===t?r=1:"0"===t&&(p=1)):y.is("span.spam")?(A?r=-1:B?p=-1:D&&(n=-1),m=1):y.is("span.unspam")?(A?p=1:B?r=1:D?y.hasClass("approve")?r=1:y.hasClass("unapprove")&&(p=1):C&&(y.hasClass("approve")?r=1:y.hasClass("unapprove")&&(p=1)),m=-1):y.is("span.trash")?(A?r=-1:B?p=-1:C&&(m=-1),n=1):y.is("span.untrash")?(A?p=1:B?r=1:D&&(y.hasClass("approve")?r=1:y.hasClass("unapprove")&&(p=1)),n=-1):y.is("span.approve:not(.unspam):not(.untrash)")?(r=1,p=-1):y.is("span.unapprove:not(.unspam):not(.untrash)")?(r=-1,p=1):y.is("span.delete")&&(C?m=-1:D&&(n=-1)),p&&e(p,w),r&&f(r,w),m&&d("span.spam-count",m),n&&d("span.trash-count",n),v||(i=j.val()?parseInt(j.val(),10):0,a(c.target).parent().is("span.undo")?i++:i--,0>i&&(i=0),"object"==typeof b?s.supplemental.total_items_i18n&&ud||(b?(theExtraList.empty(),c.number=Math.min(8,e)):(c.number=1,c.offset=Math.min(8,e)-1),c.no_placeholder=!0,c.paged++,!0===c.comment_type&&(c.comment_type=""),c=a.extend(c,{action:"fetch-list",list_args:list_args,_ajax_fetch_list_nonce:a("#_ajax_fetch_list_nonce").val()}),a.ajax({url:ajaxurl,global:!1,dataType:"json",data:c,success:function(a){theExtraList.get(0).wpList.add(a.rows)}}))},theExtraList=a("#the-extra-comment-list").wpList({alt:"",delColor:"none",addColor:"none"}),theList=a("#the-comment-list").wpList({alt:"",delBefore:n,dimAfter:m,delAfter:p,addColor:"none"}).bind("wpListDelEnd",function(b,c){var d=a(c.target).attr("data-wp-lists"),e=c.element.replace(/[^0-9]+/g,"");(-1!=d.indexOf(":trash=1")||-1!=d.indexOf(":spam=1"))&&a("#undo-"+e).fadeIn(300,function(){a(this).show()})})},commentReply={cid:"",act:"",init:function(){var b=a("#replyrow");a("a.cancel",b).click(function(){return commentReply.revert()}),a("a.save",b).click(function(){return commentReply.send()}),a("input#author-name, input#author-email, input#author-url",b).keypress(function(a){return 13==a.which?(commentReply.send(),a.preventDefault(),!1):void 0}),a("#the-comment-list .column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())}),a("#doaction, #doaction2, #post-query-submit").click(function(){a("#the-comment-list #replyrow").length>0&&commentReply.close()}),this.comments_listing=a('#comments-form > input[name="comment_status"]').val()||""},addEvents:function(b){b.each(function(){a(this).find(".column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())})})},toggle:function(b){"none"!==a(b).css("display")&&(a("#replyrow").parent().is("#com-reply")||window.confirm(adminCommentsL10n.warnQuickEdit))&&a(b).find("a.vim-q").click()},revert:function(){return a("#the-comment-list #replyrow").length<1?!1:(a("#replyrow").fadeOut("fast",function(){commentReply.close()}),!1)},close:function(){var b,c=a("#replyrow");c.parent().is("#com-reply")||(this.cid&&"edit-comment"==this.act&&(b=a("#comment-"+this.cid),b.fadeIn(300,function(){b.show()}).css("backgroundColor","")),"undefined"!=typeof QTags&&QTags.closeAllTags("replycontent"),a("#add-new-comment").css("display",""),c.hide(),a("#com-reply").append(c),a("#replycontent").css("height","").val(""),a("#edithead input").val(""),a(".error",c).empty().hide(),a(".spinner",c).removeClass("is-active"),this.cid="")},open:function(b,c,d){var e,f,g,h,i,j=this,k=a("#comment-"+b),l=k.height(),m=0;return j.close(),j.cid=b,e=a("#replyrow"),f=a("#inline-"+b),d=d||"replyto",g="edit"==d?"edit":"replyto",g=j.act=g+"-comment",m=a("th:visible, td:visible",k).length,e.hasClass("inline-edit-row")&&0!==m&&a("td",e).attr("colspan",m),a("#action",e).val(g),a("#comment_post_ID",e).val(c),a("#comment_ID",e).val(b),"edit"==d?(a("#author-name",e).val(a("div.author",f).text()),a("#author-email",e).val(a("div.author-email",f).text()),a("#author-url",e).val(a("div.author-url",f).text()),a("#status",e).val(a("div.comment_status",f).text()),a("#replycontent",e).val(a("textarea.comment",f).val()),a("#edithead, #savebtn",e).show(),a("#replyhead, #replybtn, #addhead, #addbtn",e).hide(),l>120&&(i=l>500?500:l,a("#replycontent",e).css("height",i+"px")),k.after(e).fadeOut("fast",function(){a("#replyrow").fadeIn(300,function(){a(this).show()})})):"add"==d?(a("#addhead, #addbtn",e).show(),a("#replyhead, #replybtn, #edithead, #savebtn",e).hide(),a("#the-comment-list").prepend(e),a("#replyrow").fadeIn(300)):(h=a("#replybtn",e),a("#edithead, #savebtn, #addhead, #addbtn",e).hide(),a("#replyhead, #replybtn",e).show(),k.after(e),k.hasClass("unapproved")?h.text(adminCommentsL10n.replyApprove):h.text(adminCommentsL10n.reply),a("#replyrow").fadeIn(300,function(){a(this).show()})),setTimeout(function(){var b,c,d,e,f;b=a("#replyrow").offset().top,c=b+a("#replyrow").height(),d=window.pageYOffset||document.documentElement.scrollTop,e=document.documentElement.clientHeight||window.innerHeight||0,f=d+e,c>f-20?window.scroll(0,c-e+35):d>b-20&&window.scroll(0,b-35),a("#replycontent").focus().keyup(function(a){27==a.which&&commentReply.revert()})},600),!1},send:function(){var b={};return a("#replysubmit .error").hide(),a("#replysubmit .spinner").addClass("is-active"),a("#replyrow input").not(":button").each(function(){var c=a(this);b[c.attr("name")]=c.val()}),b.content=a("#replycontent").val(),b.id=b.comment_post_ID,b.comments_listing=this.comments_listing,b.p=a('[name="p"]').val(),a("#comment-"+a("#comment_ID").val()).hasClass("unapproved")&&(b.approve_parent=1),a.ajax({type:"POST",url:ajaxurl,data:b,success:function(a){commentReply.show(a)},error:function(a){commentReply.error(a)}}),!1},show:function(b){var c,d,f,g,i,j=this;return"string"==typeof b?(j.error({responseText:b}),!1):(c=wpAjax.parseAjaxResponse(b),c.errors?(j.error({responseText:wpAjax.broken}),!1):(j.revert(),c=c.responses[0],f="#comment-"+c.id,"edit-comment"==j.act&&a(f).remove(),c.supplemental.parent_approved&&(i=a("#comment-"+c.supplemental.parent_approved),e(-1,c.supplemental.parent_post_id),"moderated"==this.comments_listing)?void i.animate({backgroundColor:"#CCEEBB"},400,function(){i.fadeOut()}):(c.supplemental.i18n_comments_text&&h(c.supplemental),d=a.trim(c.data),a(d).hide(),a("#replyrow").after(d),f=a(f),j.addEvents(f),g=f.hasClass("unapproved")?"#FFFFE0":f.closest(".widefat, .postbox").css("backgroundColor"),void f.animate({backgroundColor:"#CCEEBB"},300).animate({backgroundColor:g},300,function(){i&&i.length&&i.animate({backgroundColor:"#CCEEBB"},300).animate({backgroundColor:g},300).removeClass("unapproved").addClass("approved").find("div.comment_status").html("1")}))))},error:function(b){var c=b.statusText;a("#replysubmit .spinner").removeClass("is-active"),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#replysubmit .error").html(c).show()},addcomment:function(b){var c=this;a("#add-new-comment").fadeOut(200,function(){c.open(0,b,"add"),a("table.comments-box").css("display",""),a("#no-comments").remove()})}},a(document).ready(function(){var b,c,d,e;setCommentsList(),commentReply.init(),a(document).delegate("span.delete a.delete","click",function(){return!1}),"undefined"!=typeof a.table_hotkeys&&(b=function(b){return function(){var c,d;c="next"==b?"first":"last",d=a(".tablenav-pages ."+b+"-page:not(.disabled)"),d.length&&(window.location=d[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g,"")+"&hotkeys_highlight_"+c+"=1")}},c=function(b,c){window.location=a("span.edit a",c).attr("href")},d=function(){a("#cb-select-all-1").data("wp-toggle",1).trigger("click").removeData("wp-toggle")},e=function(b){return function(){var c=a('select[name="action"]');a('option[value="'+b+'"]',c).prop("selected",!0),a("#doaction").click()}},a.table_hotkeys(a("table.widefat"),["a","u","s","d","r","q","z",["e",c],["shift+x",d],["shift+a",e("approve")],["shift+s",e("spam")],["shift+d",e("delete")],["shift+t",e("trash")],["shift+z",e("untrash")],["shift+u",e("unapprove")]],{highlight_first:adminCommentsL10n.hotkeys_highlight_first,highlight_last:adminCommentsL10n.hotkeys_highlight_last,prev_page_link_cb:b("prev"),next_page_link_cb:b("next"),hotkeys_opts:{disableInInput:!0,type:"keypress",noDisable:'.check-column input[type="checkbox"]'},cycle_expr:"#the-comment-list tr",start_row_index:0})),a("#the-comment-list").on("click",".comment-inline",function(b){b.preventDefault();var c=a(this),d="replyto";"undefined"!=typeof c.data("action")&&(d=c.data("action")),commentReply.open(c.data("commentId"),c.data("postId"),d)})})}(jQuery); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index 493da70bac..55180c69a0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34499'; +$wp_version = '4.4-alpha-34500'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.