[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/js/ -> inline-edit-post.js (source)

   1  /**
   2   * This file contains the functions needed for the inline editing of posts.
   3   *
   4   * @since 2.7.0
   5   * @output wp-admin/js/inline-edit-post.js
   6   */
   7  
   8  /* global ajaxurl, typenow, inlineEditPost */
   9  
  10  window.wp = window.wp || {};
  11  
  12  /**
  13   * Manages the quick edit and bulk edit windows for editing posts or pages.
  14   *
  15   * @namespace inlineEditPost
  16   *
  17   * @since 2.7.0
  18   *
  19   * @type {Object}
  20   *
  21   * @property {string}       type The type of inline editor.
  22   * @property {string}       what The prefix before the post ID.
  23   *
  24   * @param    {JQueryStatic} $    The jQuery object.
  25   * @param    {wp}           wp   The WordPress global object.
  26   *
  27   */
  28  ( function( $, wp ) {
  29  
  30      window.inlineEditPost = {
  31  
  32      /**
  33       * Initializes the inline and bulk post editor.
  34       *
  35       * Binds event handlers to the Escape key to close the inline editor
  36       * and to the save and close buttons. Changes DOM to be ready for inline
  37       * editing. Adds event handler to bulk edit.
  38       *
  39       * @since 2.7.0
  40       *
  41       * @memberof inlineEditPost
  42       *
  43       * @return {void}
  44       */
  45      init : function(){
  46          var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
  47  
  48          t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post';
  49          // Post ID prefix.
  50          t.what = '#post-';
  51  
  52          /**
  53           * Binds the Escape key to revert the changes and close the quick editor.
  54           *
  55           * @return {boolean} The result of revert.
  56           */
  57          qeRow.on( 'keyup', function(e){
  58              // Revert changes if Escape key is pressed.
  59              if ( e.which === 27 ) {
  60                  return inlineEditPost.revert();
  61              }
  62          });
  63  
  64          /**
  65           * Binds the Escape key to revert the changes and close the bulk editor.
  66           *
  67           * @return {boolean} The result of revert.
  68           */
  69          bulkRow.on( 'keyup', function(e){
  70              // Revert changes if Escape key is pressed.
  71              if ( e.which === 27 ) {
  72                  return inlineEditPost.revert();
  73              }
  74          });
  75  
  76          /**
  77           * Reverts changes and close the quick editor if the cancel button is clicked.
  78           *
  79           * @return {boolean} The result of revert.
  80           */
  81          $( '.cancel', qeRow ).on( 'click', function() {
  82              return inlineEditPost.revert();
  83          });
  84  
  85          /**
  86           * Saves changes in the quick editor if the save(named: update) button is clicked.
  87           *
  88           * @return {boolean} The result of save.
  89           */
  90          $( '.save', qeRow ).on( 'click', function() {
  91              return inlineEditPost.save(this);
  92          });
  93  
  94          /**
  95           * If Enter is pressed, and the target is not the cancel button, save the post.
  96           *
  97           * @return {boolean} The result of save.
  98           */
  99          $('td', qeRow).on( 'keydown', function(e){
 100              if ( e.which === 13 && ! $( e.target ).hasClass( 'cancel' ) ) {
 101                  return inlineEditPost.save(this);
 102              }
 103          });
 104  
 105          /**
 106           * Reverts changes and close the bulk editor if the cancel button is clicked.
 107           *
 108           * @return {boolean} The result of revert.
 109           */
 110          $( '.cancel', bulkRow ).on( 'click', function() {
 111              return inlineEditPost.revert();
 112          });
 113  
 114          /**
 115           * Disables the password input field when the private post checkbox is checked.
 116           */
 117          $('#inline-edit .inline-edit-private input[value="private"]').on( 'click', function(){
 118              var pw = $('input.inline-edit-password-input');
 119              if ( $(this).prop('checked') ) {
 120                  pw.val('').prop('disabled', true);
 121              } else {
 122                  pw.prop('disabled', false);
 123              }
 124          });
 125  
 126          /**
 127           * Binds click event to the .editinline button which opens the quick editor.
 128           */
 129          $( '#the-list' ).on( 'click', '.editinline', function() {
 130              $( this ).attr( 'aria-expanded', 'true' );
 131              inlineEditPost.edit( this );
 132          });
 133  
 134          // Clone quick edit categories for the bulk editor.
 135          var beCategories = $( '#inline-edit fieldset.inline-edit-categories' ).clone();
 136  
 137          // Make "id" attributes globally unique.
 138          beCategories.find( '*[id]' ).each( function() {
 139              this.id = 'bulk-edit-' + this.id;
 140          });
 141  
 142          $('#bulk-edit').find('fieldset:first').after(
 143              beCategories
 144          ).siblings( 'fieldset:last' ).prepend(
 145              $( '#inline-edit .inline-edit-tags-wrap' ).clone()
 146          );
 147  
 148          $('select[name="_status"] option[value="future"]', bulkRow).remove();
 149  
 150          /**
 151           * Adds onclick events to the apply buttons.
 152           */
 153          $('#doaction').on( 'click', function(e){
 154              var n,
 155                  $itemsSelected = $( '#posts-filter .check-column input[type="checkbox"]:checked' );
 156  
 157              if ( $itemsSelected.length < 1 ) {
 158                  return;
 159              }
 160  
 161              t.whichBulkButtonId = $( this ).attr( 'id' );
 162              n = t.whichBulkButtonId.substr( 2 );
 163  
 164              if ( 'edit' === $( 'select[name="' + n + '"]' ).val() ) {
 165                  e.preventDefault();
 166                  t.setBulk();
 167              } else if ( $('form#posts-filter tr.inline-editor').length > 0 ) {
 168                  t.revert();
 169              }
 170          });
 171      },
 172  
 173      /**
 174       * Toggles the quick edit window, hiding it when it's active and showing it when
 175       * inactive.
 176       *
 177       * @since 2.7.0
 178       *
 179       * @memberof inlineEditPost
 180       *
 181       * @param {Object} el Element within a post table row.
 182       */
 183      toggle : function(el){
 184          var t = this;
 185          $( t.what + t.getId( el ) ).css( 'display' ) === 'none' ? t.revert() : t.edit( el );
 186      },
 187  
 188      /**
 189       * Creates the bulk editor row to edit multiple posts at once.
 190       *
 191       * @since 2.7.0
 192       *
 193       * @memberof inlineEditPost
 194       *
 195       * @return {void|false} Returns false if no checkboxes are checked, otherwise does not return anything.
 196       */
 197      setBulk : function(){
 198          var te = '', type = this.type, c = true;
 199          var checkedPosts = $( 'tbody .check-column input[type="checkbox"]:checked' );
 200          var categories = {};
 201          this.revert();
 202  
 203          $( '#bulk-edit td' ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
 204  
 205          // Insert the editor at the top of the table with an empty row above to maintain zebra striping.
 206          $('table.widefat tbody').prepend( $('#bulk-edit') ).prepend('<tr class="hidden"></tr>');
 207          $('#bulk-edit').addClass('inline-editor').show();
 208  
 209          /**
 210           * Create a HTML div with the title and a link(delete-icon) for each selected
 211           * post.
 212           *
 213           * Get the selected posts based on the checked checkboxes in the post table.
 214           */
 215          $( 'tbody .check-column input[type="checkbox"]' ).each( function() {
 216  
 217              // If the checkbox for a post is selected, add the post to the edit list.
 218              if ( $(this).prop('checked') ) {
 219                  c = false;
 220                  var id = $( this ).val(),
 221                      theTitle = $( '#inline_' + id + ' .post_title' ).html() || wp.i18n.__( '(no title)' ),
 222                      buttonVisuallyHiddenText = wp.i18n.sprintf(
 223                          /* translators: %s: Post title. */
 224                          wp.i18n.__( 'Remove &#8220;%s&#8221; from Bulk Edit' ),
 225                          theTitle
 226                      );
 227  
 228                  te += '<li class="ntdelitem"><button type="button" id="_' + id + '" class="button-link ntdelbutton"><span class="screen-reader-text">' + buttonVisuallyHiddenText + '</span></button><span class="ntdeltitle" aria-hidden="true">' + theTitle + '</span></li>';
 229              }
 230          });
 231  
 232          // If no checkboxes where checked, just hide the quick/bulk edit rows.
 233          if ( c ) {
 234              return this.revert();
 235          }
 236  
 237          // Populate the list of items to bulk edit.
 238          $( '#bulk-titles' ).html( '<ul id="bulk-titles-list" role="list">' + te + '</ul>' );
 239  
 240          // Gather up some statistics on which of these checked posts are in which categories.
 241          checkedPosts.each( function() {
 242              var id      = $( this ).val();
 243              var checked = $( '#category_' + id ).text().split( ',' );
 244  
 245              checked.map( function( cid ) {
 246                  categories[ cid ] || ( categories[ cid ] = 0 );
 247                  // Just record that this category is checked.
 248                  categories[ cid ]++;
 249              } );
 250          } );
 251  
 252          // Compute initial states.
 253          $( '.inline-edit-categories input[name="post_category[]"]' ).each( function() {
 254              if ( categories[ $( this ).val() ] == checkedPosts.length ) {
 255                  // If the number of checked categories matches the number of selected posts, then all posts are in this category.
 256                  $( this ).prop( 'checked', true );
 257              } else if ( categories[ $( this ).val() ] > 0 ) {
 258                  // If the number is less than the number of selected posts, then it's indeterminate.
 259                  $( this ).prop( 'indeterminate', true );
 260                  if ( ! $( this ).parent().find( 'input[name="indeterminate_post_category[]"]' ).length ) {
 261                      // Get the term label text.
 262                      var label = $( this ).parent().text();
 263                      // Set indeterminate states for the backend. Add accessible text for indeterminate inputs.
 264                      $( this ).after( '<input type="hidden" name="indeterminate_post_category[]" value="' + $( this ).val() + '">' ).attr( 'aria-label', label.trim() + ': ' + wp.i18n.__( 'Some selected posts have this category' ) );
 265                  }
 266              }
 267          } );
 268  
 269          $( '.inline-edit-categories input[name="post_category[]"]:indeterminate' ).on( 'change', function() {
 270              // Remove accessible label text. Remove the indeterminate flags as there was a specific state change.
 271              $( this ).removeAttr( 'aria-label' ).parent().find( 'input[name="indeterminate_post_category[]"]' ).remove();
 272          } );
 273  
 274          $( '.inline-edit-save button' ).on( 'click', function() {
 275              $( '.inline-edit-categories input[name="post_category[]"]' ).prop( 'indeterminate', false );
 276          } );
 277  
 278          /**
 279           * Binds on click events to handle the list of items to bulk edit.
 280           *
 281           * @listens click
 282           */
 283          $( '#bulk-titles .ntdelbutton' ).click( function() {
 284              var $this = $( this ),
 285                  id = $this.attr( 'id' ).substr( 1 ),
 286                  $prev = $this.parent().prev().children( '.ntdelbutton' ),
 287                  $next = $this.parent().next().children( '.ntdelbutton' );
 288  
 289              $( 'input#cb-select-all-1, input#cb-select-all-2' ).prop( 'checked', false );
 290              $( 'table.widefat input[value="' + id + '"]' ).prop( 'checked', false );
 291              $( '#_' + id ).parent().remove();
 292              wp.a11y.speak( wp.i18n.__( 'Item removed.' ), 'assertive' );
 293  
 294              // Move focus to a proper place when items are removed.
 295              if ( $next.length ) {
 296                  $next.focus();
 297              } else if ( $prev.length ) {
 298                  $prev.focus();
 299              } else {
 300                  $( '#bulk-titles-list' ).remove();
 301                  inlineEditPost.revert();
 302                  wp.a11y.speak( wp.i18n.__( 'All selected items have been removed. Select new items to use Bulk Actions.' ) );
 303              }
 304          });
 305  
 306          // Enable auto-complete for tags when editing posts.
 307          if ( 'post' === type ) {
 308              $( 'tr.inline-editor textarea[data-wp-taxonomy]' ).each( function ( i, element ) {
 309                  /*
 310                   * While Quick Edit clones the form each time, Bulk Edit always re-uses
 311                   * the same form. Let's check if an autocomplete instance already exists.
 312                   */
 313                  if ( $( element ).autocomplete( 'instance' ) ) {
 314                      // jQuery equivalent of `continue` within an `each()` loop.
 315                      return;
 316                  }
 317  
 318                  $( element ).wpTagsSuggest();
 319              } );
 320          }
 321  
 322          // Set initial focus on the Bulk Edit region.
 323          $( '#bulk-edit .inline-edit-wrapper' ).attr( 'tabindex', '-1' ).focus();
 324          // Scrolls to the top of the table where the editor is rendered.
 325          $('html, body').animate( { scrollTop: 0 }, 'fast' );
 326      },
 327  
 328      /**
 329       * Creates a quick edit window for the post that has been clicked.
 330       *
 331       * @since 2.7.0
 332       *
 333       * @memberof inlineEditPost
 334       *
 335       * @param {number|Object} id The ID of the clicked post or an element within a post
 336       *                           table row.
 337       * @return {boolean} Always returns false at the end of execution.
 338       */
 339      edit : function(id) {
 340          var t = this, fields, editRow, rowData, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, f, val, pw;
 341          t.revert();
 342  
 343          if ( typeof(id) === 'object' ) {
 344              id = t.getId(id);
 345          }
 346  
 347          fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password', 'post_format', 'menu_order', 'page_template'];
 348          if ( t.type === 'page' ) {
 349              fields.push('post_parent');
 350          }
 351  
 352          // Add the new edit row with an extra blank row underneath to maintain zebra striping.
 353          editRow = $('#inline-edit').clone(true);
 354          $( 'td', editRow ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
 355  
 356          // Remove the ID from the copied row and let the `for` attribute reference the hidden ID.
 357          $( 'td', editRow ).find('#quick-edit-legend').removeAttr('id');
 358          $( 'td', editRow ).find('p[id^="quick-edit-"]').removeAttr('id');
 359  
 360          $(t.what+id).removeClass('is-expanded').hide().after(editRow).after('<tr class="hidden"></tr>');
 361  
 362          // Populate fields in the quick edit window.
 363          rowData = $('#inline_'+id);
 364          if ( !$(':input[name="post_author"] option[value="' + $('.post_author', rowData).text() + '"]', editRow).val() ) {
 365  
 366              // The post author no longer has edit capabilities, so we need to add them to the list of authors.
 367              $(':input[name="post_author"]', editRow).prepend(
 368                  new Option(
 369                      $('#post-' + id + ' .author').text(),
 370                      $('.post_author', rowData).text()
 371                  )
 372              );
 373          }
 374          if ( $( ':input[name="post_author"] option', editRow ).length === 1 ) {
 375              $('label.inline-edit-author', editRow).hide();
 376          }
 377  
 378          for ( f = 0; f < fields.length; f++ ) {
 379              val = $('.'+fields[f], rowData);
 380  
 381              /**
 382               * Replaces the image for a Twemoji(Twitter emoji) with it's alternate text.
 383               *
 384               * @return {string} Alternate text from the image.
 385               */
 386              val.find( 'img' ).replaceWith( function() { return this.alt; } );
 387              val = val.text();
 388              $(':input[name="' + fields[f] + '"]', editRow).val( val );
 389          }
 390  
 391          if ( $( '.comment_status', rowData ).text() === 'open' ) {
 392              $( 'input[name="comment_status"]', editRow ).prop( 'checked', true );
 393          }
 394          if ( $( '.ping_status', rowData ).text() === 'open' ) {
 395              $( 'input[name="ping_status"]', editRow ).prop( 'checked', true );
 396          }
 397          if ( $( '.sticky', rowData ).text() === 'sticky' ) {
 398              $( 'input[name="sticky"]', editRow ).prop( 'checked', true );
 399          }
 400  
 401          /**
 402           * Creates the select boxes for the categories.
 403           */
 404          $('.post_category', rowData).each(function(){
 405              var taxname,
 406                  term_ids = $(this).text();
 407  
 408              if ( term_ids ) {
 409                  taxname = $(this).attr('id').replace('_'+id, '');
 410                  $('ul.'+taxname+'-checklist :checkbox', editRow).val(term_ids.split(','));
 411              }
 412          });
 413  
 414          /**
 415           * Gets all the taxonomies for live auto-fill suggestions when typing the name
 416           * of a tag.
 417           */
 418          $('.tags_input', rowData).each(function(){
 419              var terms = $(this),
 420                  taxname = $(this).attr('id').replace('_' + id, ''),
 421                  textarea = $('textarea.tax_input_' + taxname, editRow),
 422                  comma = wp.i18n._x( ',', 'tag delimiter' ).trim();
 423  
 424              // Ensure the textarea exists.
 425              if ( ! textarea.length ) {
 426                  return;
 427              }
 428  
 429              terms.find( 'img' ).replaceWith( function() { return this.alt; } );
 430              terms = terms.text();
 431  
 432              if ( terms ) {
 433                  if ( ',' !== comma ) {
 434                      terms = terms.replace(/,/g, comma);
 435                  }
 436                  textarea.val(terms);
 437              }
 438  
 439              textarea.wpTagsSuggest();
 440          });
 441  
 442          // Handle the post status.
 443          var post_date_string = $(':input[name="aa"]').val() + '-' + $(':input[name="mm"]').val() + '-' + $(':input[name="jj"]').val();
 444          post_date_string += ' ' + $(':input[name="hh"]').val() + ':' + $(':input[name="mn"]').val() + ':' + $(':input[name="ss"]').val();
 445          var post_date = new Date( post_date_string );
 446          status = $('._status', rowData).text();
 447          if ( 'future' !== status && Date.now() > post_date ) {
 448              $('select[name="_status"] option[value="future"]', editRow).remove();
 449          } else {
 450              $('select[name="_status"] option[value="publish"]', editRow).remove();
 451          }
 452  
 453          pw = $( '.inline-edit-password-input' ).prop( 'disabled', false );
 454          if ( 'private' === status ) {
 455              $('input[name="keep_private"]', editRow).prop('checked', true);
 456              pw.val( '' ).prop( 'disabled', true );
 457          }
 458  
 459          // Remove the current page and children from the parent dropdown.
 460          pageOpt = $('select[name="post_parent"] option[value="' + id + '"]', editRow);
 461          if ( pageOpt.length > 0 ) {
 462              pageLevel = pageOpt[0].className.split('-')[1];
 463              nextPage = pageOpt;
 464              while ( pageLoop ) {
 465                  nextPage = nextPage.next('option');
 466                  if ( nextPage.length === 0 ) {
 467                      break;
 468                  }
 469  
 470                  nextLevel = nextPage[0].className.split('-')[1];
 471  
 472                  if ( nextLevel <= pageLevel ) {
 473                      pageLoop = false;
 474                  } else {
 475                      nextPage.remove();
 476                      nextPage = pageOpt;
 477                  }
 478              }
 479              pageOpt.remove();
 480          }
 481  
 482          $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
 483          $('.ptitle', editRow).trigger( 'focus' );
 484  
 485          return false;
 486      },
 487  
 488      /**
 489       * Saves the changes made in the quick edit window to the post.
 490       * Ajax saving is only for Quick Edit and not for bulk edit.
 491       *
 492       * @since 2.7.0
 493       *
 494       * @param {number} id The ID for the post that has been changed.
 495       * @return {boolean} False, so the form does not submit when pressing
 496       *                   Enter on a focused field.
 497       */
 498      save : function(id) {
 499          var params, fields, page = $('.post_status_page').val() || '';
 500  
 501          if ( typeof(id) === 'object' ) {
 502              id = this.getId(id);
 503          }
 504  
 505          $( 'table.widefat .spinner' ).addClass( 'is-active' );
 506  
 507          params = {
 508              action: 'inline-save',
 509              post_type: typenow,
 510              post_ID: id,
 511              edit_date: 'true',
 512              post_status: page
 513          };
 514  
 515          fields = $('#edit-'+id).find(':input').serialize();
 516          params = fields + '&' + $.param(params);
 517  
 518          // Make Ajax request.
 519          $.post( ajaxurl, params,
 520              function(r) {
 521                  var $errorNotice = $( '#edit-' + id + ' .inline-edit-save .notice-error' ),
 522                      $error = $errorNotice.find( '.error' );
 523  
 524                  $( 'table.widefat .spinner' ).removeClass( 'is-active' );
 525  
 526                  if (r) {
 527                      if ( -1 !== r.indexOf( '<tr' ) ) {
 528                          $(inlineEditPost.what+id).siblings('tr.hidden').addBack().remove();
 529                          $('#edit-'+id).before(r).remove();
 530                          $( inlineEditPost.what + id ).hide().fadeIn( 400, function() {
 531                              // Move focus back to the Quick Edit button. $( this ) is the row being animated.
 532                              $( this ).find( '.editinline' )
 533                                  .attr( 'aria-expanded', 'false' )
 534                                  .trigger( 'focus' );
 535                              wp.a11y.speak( wp.i18n.__( 'Changes saved.' ) );
 536                          });
 537                      } else {
 538                          r = r.replace( /<.[^<>]*?>/g, '' );
 539                          $errorNotice.removeClass( 'hidden' );
 540                          $error.html( r );
 541                          wp.a11y.speak( $error.text() );
 542                      }
 543                  } else {
 544                      $errorNotice.removeClass( 'hidden' );
 545                      $error.text( wp.i18n.__( 'Error while saving the changes.' ) );
 546                      wp.a11y.speak( wp.i18n.__( 'Error while saving the changes.' ) );
 547                  }
 548              },
 549          'html');
 550  
 551          // Prevent submitting the form when pressing Enter on a focused field.
 552          return false;
 553      },
 554  
 555      /**
 556       * Hides and empties the Quick Edit and/or Bulk Edit windows.
 557       *
 558       * @since 2.7.0
 559       *
 560       * @memberof inlineEditPost
 561       *
 562       * @return {boolean} Always returns false.
 563       */
 564      revert : function(){
 565          var $tableWideFat = $( '.widefat' ),
 566              id = $( '.inline-editor', $tableWideFat ).attr( 'id' );
 567  
 568          if ( id ) {
 569              $( '.spinner', $tableWideFat ).removeClass( 'is-active' );
 570  
 571              if ( 'bulk-edit' === id ) {
 572  
 573                  // Hide the bulk editor.
 574                  $( '#bulk-edit', $tableWideFat ).removeClass( 'inline-editor' ).hide().siblings( '.hidden' ).remove();
 575                  $('#bulk-titles').empty();
 576  
 577                  // Store the empty bulk editor in a hidden element.
 578                  $('#inlineedit').append( $('#bulk-edit') );
 579  
 580                  // Move focus back to the Bulk Action button that was activated.
 581                  $( '#' + inlineEditPost.whichBulkButtonId ).trigger( 'focus' );
 582              } else {
 583  
 584                  // Remove both the inline-editor and its hidden tr siblings.
 585                  $('#'+id).siblings('tr.hidden').addBack().remove();
 586                  id = id.substr( id.lastIndexOf('-') + 1 );
 587  
 588                  // Show the post row and move focus back to the Quick Edit button.
 589                  $( this.what + id ).show().find( '.editinline' )
 590                      .attr( 'aria-expanded', 'false' )
 591                      .trigger( 'focus' );
 592              }
 593          }
 594  
 595          return false;
 596      },
 597  
 598      /**
 599       * Gets the ID for a the post that you want to quick edit from the row in the quick
 600       * edit table.
 601       *
 602       * @since 2.7.0
 603       *
 604       * @memberof inlineEditPost
 605       *
 606       * @param {Object} o DOM row object to get the ID for.
 607       * @return {string} The post ID extracted from the table row in the object.
 608       */
 609      getId : function(o) {
 610          var id = $(o).closest('tr').attr('id'),
 611              parts = id.split('-');
 612          return parts[parts.length - 1];
 613      }
 614  };
 615  
 616  $( function() { inlineEditPost.init(); } );
 617  
 618  // Show/hide locks on posts.
 619  $( function() {
 620  
 621      // Set the heartbeat interval to 10 seconds.
 622      if ( typeof wp !== 'undefined' && wp.heartbeat ) {
 623          wp.heartbeat.interval( 10 );
 624      }
 625  }).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
 626      var locked = data['wp-check-locked-posts'] || {},
 627          lockedClass = 'wp-locked';
 628  
 629      $('#the-list tr').each( function(i, el) {
 630          var key = el.id, row = $(el), lock_data, avatar;
 631  
 632          if ( locked.hasOwnProperty( key ) ) {
 633              if ( ! row.hasClass( lockedClass ) ) {
 634                  lock_data = locked[key];
 635                  row.find('.column-title .locked-text').text( lock_data.text );
 636                  row.find('.check-column checkbox').prop('checked', false);
 637  
 638                  if ( lock_data.avatar_src ) {
 639                      avatar = $( '<img />', {
 640                          'class': 'avatar avatar-18 photo',
 641                          width: 18,
 642                          height: 18,
 643                          alt: '',
 644                          src: lock_data.avatar_src,
 645                          srcset: lock_data.avatar_src_2x ? lock_data.avatar_src_2x + ' 2x' : undefined
 646                      } );
 647                      row.find('.column-title .locked-avatar').empty().append( avatar );
 648                  }
 649                  row.addClass( lockedClass );
 650              }
 651          } else if ( row.hasClass( lockedClass ) ) {
 652              row.removeClass( lockedClass ).find( '.locked-info span' ).empty();
 653          }
 654      });
 655  }).on( 'heartbeat-send.wp-check-locked-posts', function( e, data ) {
 656      var check = [];
 657  
 658      $('#the-list tr').each( function(i, el) {
 659          if ( el.id ) {
 660              check.push( el.id );
 661          }
 662      });
 663  
 664      if ( check.length ) {
 665          data['wp-check-locked-posts'] = check;
 666      }
 667  });
 668  
 669  })( jQuery, window.wp );


Generated : Fri Sep 18 08:20:28 2026 Cross-referenced by PHPXref