: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
} else if ( action == 'add' ) {
$('#addhead, #addbtn', editRow).show();
$( '#replyhead, #replybtn, #edithead, #editlegend, #savebtn', editRow ) .hide();
$('#the-comment-list').prepend(editRow);
$('#replyrow').fadeIn(300);
replyButton = $('#replybtn', editRow);
$( '#edithead, #editlegend, #savebtn, #addhead, #addbtn', editRow ).hide();
$('#replyhead, #replybtn', editRow).show();
if ( c.hasClass('unapproved') ) {
replyButton.text( __( 'Approve and Reply' ) );
replyButton.text( __( 'Reply' ) );
$('#replyrow').fadeIn(300, function(){ $(this).show(); });
var rtop, rbottom, scrollTop, vp, scrollBottom,
rtop = $('#replyrow').offset().top;
rbottom = rtop + $('#replyrow').height();
scrollTop = window.pageYOffset || document.documentElement.scrollTop;
vp = document.documentElement.clientHeight || window.innerHeight || 0;
scrollBottom = scrollTop + vp;
if ( scrollBottom - 20 < rbottom )
window.scroll(0, rbottom - vp + 35);
else if ( rtop - 20 < scrollTop )
window.scroll(0, rtop - 35);
.on( 'keyup', function( e ) {
// Close on Escape except when Input Method Editors (IMEs) are in use.
if ( e.which === 27 && ! isComposing ) {
.on( 'compositionstart', function() {
* Submits the comment quick edit or reply form.
$errorNotice = $( '#replysubmit .error-notice' );
$errorNotice.addClass( 'hidden' );
$( '#replysubmit .spinner' ).addClass( 'is-active' );
$('#replyrow input').not(':button').each(function() {
post[ t.attr('name') ] = t.val();
post.content = $('#replycontent').val();
post.id = post.comment_post_ID;
post.comments_listing = this.comments_listing;
post.p = $('[name="p"]').val();
if ( $('#comment-' + $('#comment_ID').val()).hasClass('unapproved') )
success : function(x) { commentReply.show(x); },
error : function(r) { commentReply.error(r); }
* Shows the new or updated comment or reply.
* This function needs to be passed the ajax result as received from the server.
* It will handle the response and show the comment that has just been saved to
* @param {Object} xml Ajax response object.
var t = this, r, c, id, bg, pid;
if ( typeof(xml) == 'string' ) {
t.error({'responseText': xml});
r = wpAjax.parseAjaxResponse(xml);
t.error({'responseText': wpAjax.broken});
if ( 'edit-comment' == t.act )
if ( r.supplemental.parent_approved ) {
pid = $('#comment-' + r.supplemental.parent_approved);
updatePending( -1, r.supplemental.parent_post_id );
if ( this.comments_listing == 'moderated' ) {
pid.animate( { 'backgroundColor':'#CCEEBB' }, 400, function(){
if ( r.supplemental.i18n_comments_text ) {
updateDashboardText( r.supplemental );
updateInModerationText( r.supplemental );
updateApproved( 1, r.supplemental.parent_post_id );
updateCountText( 'span.all-count', 1 );
c = r.data.toString().trim(); // Trim leading whitespaces.
bg = id.hasClass('unapproved') ? '#FFFFE0' : id.closest('.widefat, .postbox').css('backgroundColor');
id.animate( { 'backgroundColor':'#CCEEBB' }, 300 )
.animate( { 'backgroundColor': bg }, 300, function() {
if ( pid && pid.length ) {
pid.animate( { 'backgroundColor':'#CCEEBB' }, 300 )
.animate( { 'backgroundColor': bg }, 300 )
.removeClass('unapproved').addClass('approved')
.find('div.comment_status').html('1');
* Shows an error for the failed comment update or reply.
* @param {string} r The Ajax response.
$errorNotice = $( '#replysubmit .notice-error' ),
$error = $errorNotice.find( '.error' );
$( '#replysubmit .spinner' ).removeClass( 'is-active' );
er = r.responseText.replace( /<.[^<>]*?>/g, '' );
$errorNotice.removeClass( 'hidden' );
* Opens the add comments form in the comments metabox on the post edit page.
* @param {number} post_id The post ID.
addcomment: function(post_id) {
$('#add-new-comment').fadeOut(200, function(){
t.open(0, post_id, 'add');
$('table.comments-box').css('display', '');
$('#no-comments').remove();
* Alert the user if they have unsaved changes on a comment that will be lost if
* they proceed with the intended action.
* @return {boolean} Whether it is safe the continue with the intended action.
discardCommentChanges: function() {
var editRow = $( '#replyrow' );
if ( '' === $( '#replycontent', editRow ).val() || this.originalContent === $( '#replycontent', editRow ).val() ) {
return window.confirm( __( 'Are you sure you want to do this?\nThe comment changes you made will be lost.' ) );
var make_hotkeys_redirect, edit_comment, toggle_all, make_bulk;
$(document).on( 'click', 'span.delete a.delete', function( e ) {
if ( typeof $.table_hotkeys != 'undefined' ) {
* Creates a function that navigates to a previous or next page.
* @param {string} which What page to navigate to: either next or prev.
* @return {Function} The function that executes the navigation.
make_hotkeys_redirect = function(which) {
first_last = 'next' == which? 'first' : 'last';
l = $('.tablenav-pages .'+which+'-page:not(.disabled)');
window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1';
* Navigates to the edit page for the selected comment.
* @param {Object} event The event that triggered this action.
* @param {Object} current_row A jQuery object of the selected row.
edit_comment = function(event, current_row) {
window.location = $('span.edit a', current_row).attr('href');
* Toggles all comments on the screen, for bulk actions.
toggle_all = function() {
$('#cb-select-all-1').data( 'wp-toggle', 1 ).trigger( 'click' ).removeData( 'wp-toggle' );
* Creates a bulk action function that is executed on all selected comments.
* @param {string} value The name of the action to execute.
* @return {Function} The function that executes the bulk action.
make_bulk = function(value) {
var scope = $('select[name="action"]');
$('option[value="' + value + '"]', scope).prop('selected', true);
$('#doaction').trigger( 'click' );
'a', 'u', 's', 'd', 'r', 'q', 'z',
['shift+a', make_bulk('approve')],
['shift+s', make_bulk('spam')],
['shift+d', make_bulk('delete')],
['shift+t', make_bulk('trash')],
['shift+z', make_bulk('untrash')],
['shift+u', make_bulk('unapprove')]
highlight_first: adminCommentsSettings.hotkeys_highlight_first,
highlight_last: adminCommentsSettings.hotkeys_highlight_last,
prev_page_link_cb: make_hotkeys_redirect('prev'),
next_page_link_cb: make_hotkeys_redirect('next'),
noDisable: '.check-column input[type="checkbox"]'
cycle_expr: '#the-comment-list tr',
// Quick Edit and Reply have an inline comment editor.
$( '#the-comment-list' ).on( 'click', '.comment-inline', function() {
if ( 'undefined' !== typeof $el.data( 'action' ) ) {
action = $el.data( 'action' );
$( this ).attr( 'aria-expanded', 'true' );
commentReply.open( $el.data( 'commentId' ), $el.data( 'postId' ), action );