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


Generated : Sat Aug 8 08:20:21 2026 Cross-referenced by PHPXref