[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  /**
   2   * @file Contains all dynamic functionality needed on post and term pages.
   3   *
   4   * @output wp-admin/js/post.js
   5   */
   6  
   7   /* global ajaxurl, wpAjax, postboxes, pagenow, tinymce, alert, deleteUserSetting, ClipboardJS */
   8   /* global theList:true, theExtraList:true, getUserSetting, setUserSetting, commentReply, commentsBox */
   9   /* global WPSetThumbnailHTML, wptitlehint */
  10  
  11  // Backward compatibility: prevent fatal errors.
  12  window.makeSlugeditClickable = window.editPermalink = function(){};
  13  
  14  // Make sure the wp object exists.
  15  window.wp = window.wp || {};
  16  
  17  ( function( $ ) {
  18      var titleHasFocus = false,
  19          __ = wp.i18n.__;
  20  
  21      /**
  22       * Control loading of comments on the post and term edit pages.
  23       *
  24       * @type {{st: number, get: commentsBox.get, load: commentsBox.load}}
  25       *
  26       * @namespace commentsBox
  27       */
  28      window.commentsBox = {
  29          // Comment offset to use when fetching new comments.
  30          st : 0,
  31  
  32          /**
  33           * Fetch comments using Ajax and display them in the box.
  34           *
  35           * @memberof commentsBox
  36           *
  37           * @param {int} total Total number of comments for this post.
  38           * @param {int} num   Optional. Number of comments to fetch, defaults to 20.
  39           * @return {boolean} Always returns false.
  40           */
  41          get : function(total, num) {
  42              var st = this.st, data;
  43              if ( ! num )
  44                  num = 20;
  45  
  46              this.st += num;
  47              this.total = total;
  48              $( '#commentsdiv .spinner' ).addClass( 'is-active' );
  49  
  50              data = {
  51                  'action' : 'get-comments',
  52                  'mode' : 'single',
  53                  '_ajax_nonce' : $('#add_comment_nonce').val(),
  54                  'p' : $('#post_ID').val(),
  55                  'start' : st,
  56                  'number' : num
  57              };
  58  
  59              $.post(
  60                  ajaxurl,
  61                  data,
  62                  function(r) {
  63                      r = wpAjax.parseAjaxResponse(r);
  64                      $('#commentsdiv .widefat').show();
  65                      $( '#commentsdiv .spinner' ).removeClass( 'is-active' );
  66  
  67                      if ( 'object' == typeof r && r.responses[0] ) {
  68                          $('#the-comment-list').append( r.responses[0].data );
  69  
  70                          theList = theExtraList = null;
  71                          $( 'a[className*=\':\']' ).unbind();
  72  
  73                          // If the offset is over the total number of comments we cannot fetch any more, so hide the button.
  74                          if ( commentsBox.st > commentsBox.total )
  75                              $('#show-comments').hide();
  76                          else
  77                              $('#show-comments').show().children('a').text( __( 'Show more comments' ) );
  78  
  79                          return;
  80                      } else if ( 1 == r ) {
  81                          $('#show-comments').text( __( 'No more comments found.' ) );
  82                          return;
  83                      }
  84  
  85                      $('#the-comment-list').append('<tr><td colspan="2">'+wpAjax.broken+'</td></tr>');
  86                  }
  87              );
  88  
  89              return false;
  90          },
  91  
  92          /**
  93           * Load the next batch of comments.
  94           *
  95           * @memberof commentsBox
  96           *
  97           * @param {int} total Total number of comments to load.
  98           */
  99          load: function(total){
 100              this.st = jQuery('#the-comment-list tr.comment:visible').length;
 101              this.get(total);
 102          }
 103      };
 104  
 105      /**
 106       * Overwrite the content of the Featured Image postbox
 107       *
 108       * @param {string} html New HTML to be displayed in the content area of the postbox.
 109       *
 110       * @global
 111       */
 112      window.WPSetThumbnailHTML = function(html){
 113          $('.inside', '#postimagediv').html(html);
 114      };
 115  
 116      /**
 117       * Set the Image ID of the Featured Image
 118       *
 119       * @param {int} id The post_id of the image to use as Featured Image.
 120       *
 121       * @global
 122       */
 123      window.WPSetThumbnailID = function(id){
 124          var field = $('input[value="_thumbnail_id"]', '#list-table');
 125          if ( field.length > 0 ) {
 126              $('#meta\\[' + field.attr('id').match(/[0-9]+/) + '\\]\\[value\\]').text(id);
 127          }
 128      };
 129  
 130      /**
 131       * Remove the Featured Image
 132       *
 133       * @param {string} nonce Nonce to use in the request.
 134       *
 135       * @global
 136       */
 137      window.WPRemoveThumbnail = function(nonce){
 138          $.post(ajaxurl, {
 139              action: 'set-post-thumbnail', post_id: $( '#post_ID' ).val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
 140          },
 141              /**
 142               * Handle server response
 143               *
 144               * @param {string} str Response, will be '0' when an error occurred otherwise contains link to add Featured Image.
 145               */
 146              function(str){
 147              if ( str == '0' ) {
 148                  alert( __( 'Could not set that as the thumbnail image. Try a different attachment.' ) );
 149              } else {
 150                  WPSetThumbnailHTML(str);
 151              }
 152          }
 153          );
 154      };
 155  
 156      /**
 157       * Heartbeat locks.
 158       *
 159       * Used to lock editing of an object by only one user at a time.
 160       *
 161       * When the user does not send a heartbeat in a heartbeat-time
 162       * the user is no longer editing and another user can start editing.
 163       */
 164      $(document).on( 'heartbeat-send.refresh-lock', function( e, data ) {
 165          var lock = $('#active_post_lock').val(),
 166              post_id = $('#post_ID').val(),
 167              send = {};
 168  
 169          if ( ! post_id || ! $('#post-lock-dialog').length )
 170              return;
 171  
 172          send.post_id = post_id;
 173  
 174          if ( lock )
 175              send.lock = lock;
 176  
 177          data['wp-refresh-post-lock'] = send;
 178  
 179      }).on( 'heartbeat-tick.refresh-lock', function( e, data ) {
 180          // Post locks: update the lock string or show the dialog if somebody has taken over editing.
 181          var received, wrap, avatar;
 182  
 183          if ( data['wp-refresh-post-lock'] ) {
 184              received = data['wp-refresh-post-lock'];
 185  
 186              if ( received.lock_error ) {
 187                  // Show "editing taken over" message.
 188                  wrap = $('#post-lock-dialog');
 189  
 190                  if ( wrap.length && ! wrap.is(':visible') ) {
 191                      if ( wp.autosave ) {
 192                          // Save the latest changes and disable.
 193                          $(document).one( 'heartbeat-tick', function() {
 194                              wp.autosave.server.suspend();
 195                              wrap.removeClass('saving').addClass('saved');
 196                              $(window).off( 'beforeunload.edit-post' );
 197                          });
 198  
 199                          wrap.addClass('saving');
 200                          wp.autosave.server.triggerSave();
 201                      }
 202  
 203                      if ( received.lock_error.avatar_src ) {
 204                          avatar = $( '<img />', {
 205                              'class': 'avatar avatar-64 photo',
 206                              width: 64,
 207                              height: 64,
 208                              alt: '',
 209                              src: received.lock_error.avatar_src,
 210                              srcset: received.lock_error.avatar_src_2x ? received.lock_error.avatar_src_2x + ' 2x' : undefined
 211                          } );
 212                          wrap.find('div.post-locked-avatar').empty().append( avatar );
 213                      }
 214  
 215                      wrap.show().find('.currently-editing').text( received.lock_error.text );
 216                      wrap.find('.wp-tab-first').focus();
 217                  }
 218              } else if ( received.new_lock ) {
 219                  $('#active_post_lock').val( received.new_lock );
 220              }
 221          }
 222      }).on( 'before-autosave.update-post-slug', function() {
 223          titleHasFocus = document.activeElement && document.activeElement.id === 'title';
 224      }).on( 'after-autosave.update-post-slug', function() {
 225  
 226          /*
 227           * Create slug area only if not already there
 228           * and the title field was not focused (user was not typing a title) when autosave ran.
 229           */
 230          if ( ! $('#edit-slug-box > *').length && ! titleHasFocus ) {
 231              $.post( ajaxurl, {
 232                      action: 'sample-permalink',
 233                      post_id: $('#post_ID').val(),
 234                      new_title: $('#title').val(),
 235                      samplepermalinknonce: $('#samplepermalinknonce').val()
 236                  },
 237                  function( data ) {
 238                      if ( data != '-1' ) {
 239                          $('#edit-slug-box').html(data);
 240                      }
 241                  }
 242              );
 243          }
 244      });
 245  
 246  }(jQuery));
 247  
 248  /**
 249   * Heartbeat refresh nonces.
 250   */
 251  (function($) {
 252      var check, timeout;
 253  
 254      /**
 255       * Only allow to check for nonce refresh every 30 seconds.
 256       */
 257  	function schedule() {
 258          check = false;
 259          window.clearTimeout( timeout );
 260          timeout = window.setTimeout( function(){ check = true; }, 300000 );
 261      }
 262  
 263      $(document).on( 'heartbeat-send.wp-refresh-nonces', function( e, data ) {
 264          var post_id,
 265              $authCheck = $('#wp-auth-check-wrap');
 266  
 267          if ( check || ( $authCheck.length && ! $authCheck.hasClass( 'hidden' ) ) ) {
 268              if ( ( post_id = $('#post_ID').val() ) && $('#_wpnonce').val() ) {
 269                  data['wp-refresh-post-nonces'] = {
 270                      post_id: post_id
 271                  };
 272              }
 273          }
 274      }).on( 'heartbeat-tick.wp-refresh-nonces', function( e, data ) {
 275          var nonces = data['wp-refresh-post-nonces'];
 276  
 277          if ( nonces ) {
 278              schedule();
 279  
 280              if ( nonces.replace ) {
 281                  $.each( nonces.replace, function( selector, value ) {
 282                      $( '#' + selector ).val( value );
 283                  });
 284              }
 285  
 286              if ( nonces.heartbeatNonce )
 287                  window.heartbeatSettings.nonce = nonces.heartbeatNonce;
 288          }
 289      }).ready( function() {
 290          schedule();
 291      });
 292  }(jQuery));
 293  
 294  /**
 295   * All post and postbox controls and functionality.
 296   */
 297  jQuery(document).ready( function($) {
 298      var stamp, visibility, $submitButtons, updateVisibility, updateText,
 299          $textarea = $('#content'),
 300          $document = $(document),
 301          postId = $('#post_ID').val() || 0,
 302          $submitpost = $('#submitpost'),
 303          releaseLock = true,
 304          $postVisibilitySelect = $('#post-visibility-select'),
 305          $timestampdiv = $('#timestampdiv'),
 306          $postStatusSelect = $('#post-status-select'),
 307          isMac = window.navigator.platform ? window.navigator.platform.indexOf( 'Mac' ) !== -1 : false,
 308          copyAttachmentURLClipboard = new ClipboardJS( '.copy-attachment-url.edit-media' ),
 309          copyAttachmentURLSuccessTimeout,
 310          __ = wp.i18n.__, _x = wp.i18n._x;
 311  
 312      postboxes.add_postbox_toggles(pagenow);
 313  
 314      /*
 315       * Clear the window name. Otherwise if this is a former preview window where the user navigated to edit another post,
 316       * and the first post is still being edited, clicking Preview there will use this window to show the preview.
 317       */
 318      window.name = '';
 319  
 320      // Post locks: contain focus inside the dialog. If the dialog is shown, focus the first item.
 321      $('#post-lock-dialog .notification-dialog').on( 'keydown', function(e) {
 322          // Don't do anything when [Tab] is pressed.
 323          if ( e.which != 9 )
 324              return;
 325  
 326          var target = $(e.target);
 327  
 328          // [Shift] + [Tab] on first tab cycles back to last tab.
 329          if ( target.hasClass('wp-tab-first') && e.shiftKey ) {
 330              $(this).find('.wp-tab-last').focus();
 331              e.preventDefault();
 332          // [Tab] on last tab cycles back to first tab.
 333          } else if ( target.hasClass('wp-tab-last') && ! e.shiftKey ) {
 334              $(this).find('.wp-tab-first').focus();
 335              e.preventDefault();
 336          }
 337      }).filter(':visible').find('.wp-tab-first').focus();
 338  
 339      // Set the heartbeat interval to 15 seconds if post lock dialogs are enabled.
 340      if ( wp.heartbeat && $('#post-lock-dialog').length ) {
 341          wp.heartbeat.interval( 15 );
 342      }
 343  
 344      // The form is being submitted by the user.
 345      $submitButtons = $submitpost.find( ':submit, a.submitdelete, #post-preview' ).on( 'click.edit-post', function( event ) {
 346          var $button = $(this);
 347  
 348          if ( $button.hasClass('disabled') ) {
 349              event.preventDefault();
 350              return;
 351          }
 352  
 353          if ( $button.hasClass('submitdelete') || $button.is( '#post-preview' ) ) {
 354              return;
 355          }
 356  
 357          // The form submission can be blocked from JS or by using HTML 5.0 validation on some fields.
 358          // Run this only on an actual 'submit'.
 359          $('form#post').off( 'submit.edit-post' ).on( 'submit.edit-post', function( event ) {
 360              if ( event.isDefaultPrevented() ) {
 361                  return;
 362              }
 363  
 364              // Stop auto save.
 365              if ( wp.autosave ) {
 366                  wp.autosave.server.suspend();
 367              }
 368  
 369              if ( typeof commentReply !== 'undefined' ) {
 370                  /*
 371                   * Warn the user they have an unsaved comment before submitting
 372                   * the post data for update.
 373                   */
 374                  if ( ! commentReply.discardCommentChanges() ) {
 375                      return false;
 376                  }
 377  
 378                  /*
 379                   * Close the comment edit/reply form if open to stop the form
 380                   * action from interfering with the post's form action.
 381                   */
 382                  commentReply.close();
 383              }
 384  
 385              releaseLock = false;
 386              $(window).off( 'beforeunload.edit-post' );
 387  
 388              $submitButtons.addClass( 'disabled' );
 389  
 390              if ( $button.attr('id') === 'publish' ) {
 391                  $submitpost.find( '#major-publishing-actions .spinner' ).addClass( 'is-active' );
 392              } else {
 393                  $submitpost.find( '#minor-publishing .spinner' ).addClass( 'is-active' );
 394              }
 395          });
 396      });
 397  
 398      // Submit the form saving a draft or an autosave, and show a preview in a new tab.
 399      $('#post-preview').on( 'click.post-preview', function( event ) {
 400          var $this = $(this),
 401              $form = $('form#post'),
 402              $previewField = $('input#wp-preview'),
 403              target = $this.attr('target') || 'wp-preview',
 404              ua = navigator.userAgent.toLowerCase();
 405  
 406          event.preventDefault();
 407  
 408          if ( $this.hasClass('disabled') ) {
 409              return;
 410          }
 411  
 412          if ( wp.autosave ) {
 413              wp.autosave.server.tempBlockSave();
 414          }
 415  
 416          $previewField.val('dopreview');
 417          $form.attr( 'target', target ).submit().attr( 'target', '' );
 418  
 419          // Workaround for WebKit bug preventing a form submitting twice to the same action.
 420          // https://bugs.webkit.org/show_bug.cgi?id=28633
 421          if ( ua.indexOf('safari') !== -1 && ua.indexOf('chrome') === -1 ) {
 422              $form.attr( 'action', function( index, value ) {
 423                  return value + '?t=' + ( new Date() ).getTime();
 424              });
 425          }
 426  
 427          $previewField.val('');
 428      });
 429  
 430      // This code is meant to allow tabbing from Title to Post content.
 431      $('#title').on( 'keydown.editor-focus', function( event ) {
 432          var editor;
 433  
 434          if ( event.keyCode === 9 && ! event.ctrlKey && ! event.altKey && ! event.shiftKey ) {
 435              editor = typeof tinymce != 'undefined' && tinymce.get('content');
 436  
 437              if ( editor && ! editor.isHidden() ) {
 438                  editor.focus();
 439              } else if ( $textarea.length ) {
 440                  $textarea.focus();
 441              } else {
 442                  return;
 443              }
 444  
 445              event.preventDefault();
 446          }
 447      });
 448  
 449      // Auto save new posts after a title is typed.
 450      if ( $( '#auto_draft' ).val() ) {
 451          $( '#title' ).blur( function() {
 452              var cancel;
 453  
 454              if ( ! this.value || $('#edit-slug-box > *').length ) {
 455                  return;
 456              }
 457  
 458              // Cancel the auto save when the blur was triggered by the user submitting the form.
 459              $('form#post').one( 'submit', function() {
 460                  cancel = true;
 461              });
 462  
 463              window.setTimeout( function() {
 464                  if ( ! cancel && wp.autosave ) {
 465                      wp.autosave.server.triggerSave();
 466                  }
 467              }, 200 );
 468          });
 469      }
 470  
 471      $document.on( 'autosave-disable-buttons.edit-post', function() {
 472          $submitButtons.addClass( 'disabled' );
 473      }).on( 'autosave-enable-buttons.edit-post', function() {
 474          if ( ! wp.heartbeat || ! wp.heartbeat.hasConnectionError() ) {
 475              $submitButtons.removeClass( 'disabled' );
 476          }
 477      }).on( 'before-autosave.edit-post', function() {
 478          $( '.autosave-message' ).text( __( 'Saving Draft…' ) );
 479      }).on( 'after-autosave.edit-post', function( event, data ) {
 480          $( '.autosave-message' ).text( data.message );
 481  
 482          if ( $( document.body ).hasClass( 'post-new-php' ) ) {
 483              $( '.submitbox .submitdelete' ).show();
 484          }
 485      });
 486  
 487      /*
 488       * When the user is trying to load another page, or reloads current page
 489       * show a confirmation dialog when there are unsaved changes.
 490       */
 491      $(window).on( 'beforeunload.edit-post', function() {
 492          var editor = typeof tinymce !== 'undefined' && tinymce.get('content');
 493  
 494          if ( ( editor && ! editor.isHidden() && editor.isDirty() ) ||
 495              ( wp.autosave && wp.autosave.server.postChanged() ) ) {
 496  
 497              return __( 'The changes you made will be lost if you navigate away from this page.' );
 498          }
 499      }).on( 'unload.edit-post', function( event ) {
 500          if ( ! releaseLock ) {
 501              return;
 502          }
 503  
 504          /*
 505           * Unload is triggered (by hand) on removing the Thickbox iframe.
 506           * Make sure we process only the main document unload.
 507           */
 508          if ( event.target && event.target.nodeName != '#document' ) {
 509              return;
 510          }
 511  
 512          var postID = $('#post_ID').val();
 513          var postLock = $('#active_post_lock').val();
 514  
 515          if ( ! postID || ! postLock ) {
 516              return;
 517          }
 518  
 519          var data = {
 520              action: 'wp-remove-post-lock',
 521              _wpnonce: $('#_wpnonce').val(),
 522              post_ID: postID,
 523              active_post_lock: postLock
 524          };
 525  
 526          if ( window.FormData && window.navigator.sendBeacon ) {
 527              var formData = new window.FormData();
 528  
 529              $.each( data, function( key, value ) {
 530                  formData.append( key, value );
 531              });
 532  
 533              if ( window.navigator.sendBeacon( ajaxurl, formData ) ) {
 534                  return;
 535              }
 536          }
 537  
 538          // Fall back to a synchronous POST request.
 539          // See https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
 540          $.post({
 541              async: false,
 542              data: data,
 543              url: ajaxurl
 544          });
 545      });
 546  
 547      // Multiple taxonomies.
 548      if ( $('#tagsdiv-post_tag').length ) {
 549          window.tagBox && window.tagBox.init();
 550      } else {
 551          $('.meta-box-sortables').children('div.postbox').each(function(){
 552              if ( this.id.indexOf('tagsdiv-') === 0 ) {
 553                  window.tagBox && window.tagBox.init();
 554                  return false;
 555              }
 556          });
 557      }
 558  
 559      // Handle categories.
 560      $('.categorydiv').each( function(){
 561          var this_id = $(this).attr('id'), catAddBefore, catAddAfter, taxonomyParts, taxonomy, settingName;
 562  
 563          taxonomyParts = this_id.split('-');
 564          taxonomyParts.shift();
 565          taxonomy = taxonomyParts.join('-');
 566          settingName = taxonomy + '_tab';
 567  
 568          if ( taxonomy == 'category' ) {
 569              settingName = 'cats';
 570          }
 571  
 572          // @todo Move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.js.
 573          $('a', '#' + taxonomy + '-tabs').click( function( e ) {
 574              e.preventDefault();
 575              var t = $(this).attr('href');
 576              $(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
 577              $('#' + taxonomy + '-tabs').siblings('.tabs-panel').hide();
 578              $(t).show();
 579              if ( '#' + taxonomy + '-all' == t ) {
 580                  deleteUserSetting( settingName );
 581              } else {
 582                  setUserSetting( settingName, 'pop' );
 583              }
 584          });
 585  
 586          if ( getUserSetting( settingName ) )
 587              $('a[href="#' + taxonomy + '-pop"]', '#' + taxonomy + '-tabs').click();
 588  
 589          // Add category button controls.
 590          $('#new' + taxonomy).one( 'focus', function() {
 591              $( this ).val( '' ).removeClass( 'form-input-tip' );
 592          });
 593  
 594          // On [Enter] submit the taxonomy.
 595          $('#new' + taxonomy).keypress( function(event){
 596              if( 13 === event.keyCode ) {
 597                  event.preventDefault();
 598                  $('#' + taxonomy + '-add-submit').click();
 599              }
 600          });
 601  
 602          // After submitting a new taxonomy, re-focus the input field.
 603          $('#' + taxonomy + '-add-submit').click( function() {
 604              $('#new' + taxonomy).focus();
 605          });
 606  
 607          /**
 608           * Before adding a new taxonomy, disable submit button.
 609           *
 610           * @param {Object} s Taxonomy object which will be added.
 611           *
 612           * @return {Object}
 613           */
 614          catAddBefore = function( s ) {
 615              if ( !$('#new'+taxonomy).val() ) {
 616                  return false;
 617              }
 618  
 619              s.data += '&' + $( ':checked', '#'+taxonomy+'checklist' ).serialize();
 620              $( '#' + taxonomy + '-add-submit' ).prop( 'disabled', true );
 621              return s;
 622          };
 623  
 624          /**
 625           * Re-enable submit button after a taxonomy has been added.
 626           *
 627           * Re-enable submit button.
 628           * If the taxonomy has a parent place the taxonomy underneath the parent.
 629           *
 630           * @param {Object} r Response.
 631           * @param {Object} s Taxonomy data.
 632           *
 633           * @return {void}
 634           */
 635          catAddAfter = function( r, s ) {
 636              var sup, drop = $('#new'+taxonomy+'_parent');
 637  
 638              $( '#' + taxonomy + '-add-submit' ).prop( 'disabled', false );
 639              if ( 'undefined' != s.parsed.responses[0] && (sup = s.parsed.responses[0].supplemental.newcat_parent) ) {
 640                  drop.before(sup);
 641                  drop.remove();
 642              }
 643          };
 644  
 645          $('#' + taxonomy + 'checklist').wpList({
 646              alt: '',
 647              response: taxonomy + '-ajax-response',
 648              addBefore: catAddBefore,
 649              addAfter: catAddAfter
 650          });
 651  
 652          // Add new taxonomy button toggles input form visibility.
 653          $('#' + taxonomy + '-add-toggle').click( function( e ) {
 654              e.preventDefault();
 655              $('#' + taxonomy + '-adder').toggleClass( 'wp-hidden-children' );
 656              $('a[href="#' + taxonomy + '-all"]', '#' + taxonomy + '-tabs').click();
 657              $('#new'+taxonomy).focus();
 658          });
 659  
 660          // Sync checked items between "All {taxonomy}" and "Most used" lists.
 661          $('#' + taxonomy + 'checklist, #' + taxonomy + 'checklist-pop').on( 'click', 'li.popular-category > label input[type="checkbox"]', function() {
 662              var t = $(this), c = t.is(':checked'), id = t.val();
 663              if ( id && t.parents('#taxonomy-'+taxonomy).length )
 664                  $('#in-' + taxonomy + '-' + id + ', #in-popular-' + taxonomy + '-' + id).prop( 'checked', c );
 665          });
 666  
 667      }); // End cats.
 668  
 669      // Custom Fields postbox.
 670      if ( $('#postcustom').length ) {
 671          $( '#the-list' ).wpList( {
 672              /**
 673               * Add current post_ID to request to fetch custom fields
 674               *
 675               * @ignore
 676               *
 677               * @param {Object} s Request object.
 678               *
 679               * @return {Object} Data modified with post_ID attached.
 680               */
 681              addBefore: function( s ) {
 682                  s.data += '&post_id=' + $('#post_ID').val();
 683                  return s;
 684              },
 685              /**
 686               * Show the listing of custom fields after fetching.
 687               *
 688               * @ignore
 689               */
 690              addAfter: function() {
 691                  $('table#list-table').show();
 692              }
 693          });
 694      }
 695  
 696      /*
 697       * Publish Post box (#submitdiv)
 698       */
 699      if ( $('#submitdiv').length ) {
 700          stamp = $('#timestamp').html();
 701          visibility = $('#post-visibility-display').html();
 702  
 703          /**
 704           * When the visibility of a post changes sub-options should be shown or hidden.
 705           *
 706           * @ignore
 707           *
 708           * @return {void}
 709           */
 710          updateVisibility = function() {
 711              // Show sticky for public posts.
 712              if ( $postVisibilitySelect.find('input:radio:checked').val() != 'public' ) {
 713                  $('#sticky').prop('checked', false);
 714                  $('#sticky-span').hide();
 715              } else {
 716                  $('#sticky-span').show();
 717              }
 718  
 719              // Show password input field for password protected post.
 720              if ( $postVisibilitySelect.find('input:radio:checked').val() != 'password' ) {
 721                  $('#password-span').hide();
 722              } else {
 723                  $('#password-span').show();
 724              }
 725          };
 726  
 727          /**
 728           * Make sure all labels represent the current settings.
 729           *
 730           * @ignore
 731           *
 732           * @return {boolean} False when an invalid timestamp has been selected, otherwise True.
 733           */
 734          updateText = function() {
 735  
 736              if ( ! $timestampdiv.length )
 737                  return true;
 738  
 739              var attemptedDate, originalDate, currentDate, publishOn, postStatus = $('#post_status'),
 740                  optPublish = $('option[value="publish"]', postStatus), aa = $('#aa').val(),
 741                  mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val();
 742  
 743              attemptedDate = new Date( aa, mm - 1, jj, hh, mn );
 744              originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val() );
 745              currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() );
 746  
 747              // Catch unexpected date problems.
 748              if ( attemptedDate.getFullYear() != aa || (1 + attemptedDate.getMonth()) != mm || attemptedDate.getDate() != jj || attemptedDate.getMinutes() != mn ) {
 749                  $timestampdiv.find('.timestamp-wrap').addClass('form-invalid');
 750                  return false;
 751              } else {
 752                  $timestampdiv.find('.timestamp-wrap').removeClass('form-invalid');
 753              }
 754  
 755              // Determine what the publish should be depending on the date and post status.
 756              if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) {
 757                  publishOn = __( 'Schedule for:' );
 758                  $('#publish').val( _x( 'Schedule', 'post action/button label' ) );
 759              } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) {
 760                  publishOn = __( 'Publish on:' );
 761                  $('#publish').val( __( 'Publish' ) );
 762              } else {
 763                  publishOn = __( 'Published on:' );
 764                  $('#publish').val( __( 'Update' ) );
 765              }
 766  
 767              // If the date is the same, set it to trigger update events.
 768              if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) {
 769                  // Re-set to the current value.
 770                  $('#timestamp').html(stamp);
 771              } else {
 772                  $('#timestamp').html(
 773                      '\n' + publishOn + ' <b>' +
 774                      // translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute.
 775                      __( '%1$s %2$s, %3$s at %4$s:%5$s' )
 776                          .replace( '%1$s', $( 'option[value="' + mm + '"]', '#mm' ).attr( 'data-text' ) )
 777                          .replace( '%2$s', parseInt( jj, 10 ) )
 778                          .replace( '%3$s', aa )
 779                          .replace( '%4$s', ( '00' + hh ).slice( -2 ) )
 780                          .replace( '%5$s', ( '00' + mn ).slice( -2 ) ) +
 781                          '</b> '
 782                  );
 783              }
 784  
 785              // Add "privately published" to post status when applies.
 786              if ( $postVisibilitySelect.find('input:radio:checked').val() == 'private' ) {
 787                  $('#publish').val( __( 'Update' ) );
 788                  if ( 0 === optPublish.length ) {
 789                      postStatus.append('<option value="publish">' + __( 'Privately Published' ) + '</option>');
 790                  } else {
 791                      optPublish.html( __( 'Privately Published' ) );
 792                  }
 793                  $('option[value="publish"]', postStatus).prop('selected', true);
 794                  $('#misc-publishing-actions .edit-post-status').hide();
 795              } else {
 796                  if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) {
 797                      if ( optPublish.length ) {
 798                          optPublish.remove();
 799                          postStatus.val($('#hidden_post_status').val());
 800                      }
 801                  } else {
 802                      optPublish.html( __( 'Published' ) );
 803                  }
 804                  if ( postStatus.is(':hidden') )
 805                      $('#misc-publishing-actions .edit-post-status').show();
 806              }
 807  
 808              // Update "Status:" to currently selected status.
 809              $('#post-status-display').text(
 810                  // Remove any potential tags from post status text.
 811                  wp.sanitize.stripTagsAndEncodeText( $('option:selected', postStatus).text() )
 812              );
 813  
 814              // Show or hide the "Save Draft" button.
 815              if ( $('option:selected', postStatus).val() == 'private' || $('option:selected', postStatus).val() == 'publish' ) {
 816                  $('#save-post').hide();
 817              } else {
 818                  $('#save-post').show();
 819                  if ( $('option:selected', postStatus).val() == 'pending' ) {
 820                      $('#save-post').show().val( __( 'Save as Pending' ) );
 821                  } else {
 822                      $('#save-post').show().val( __( 'Save Draft' ) );
 823                  }
 824              }
 825              return true;
 826          };
 827  
 828          // Show the visibility options and hide the toggle button when opened.
 829          $( '#visibility .edit-visibility').click( function( e ) {
 830              e.preventDefault();
 831              if ( $postVisibilitySelect.is(':hidden') ) {
 832                  updateVisibility();
 833                  $postVisibilitySelect.slideDown( 'fast', function() {
 834                      $postVisibilitySelect.find( 'input[type="radio"]' ).first().focus();
 835                  } );
 836                  $(this).hide();
 837              }
 838          });
 839  
 840          // Cancel visibility selection area and hide it from view.
 841          $postVisibilitySelect.find('.cancel-post-visibility').click( function( event ) {
 842              $postVisibilitySelect.slideUp('fast');
 843              $('#visibility-radio-' + $('#hidden-post-visibility').val()).prop('checked', true);
 844              $('#post_password').val($('#hidden-post-password').val());
 845              $('#sticky').prop('checked', $('#hidden-post-sticky').prop('checked'));
 846              $('#post-visibility-display').html(visibility);
 847              $('#visibility .edit-visibility').show().focus();
 848              updateText();
 849              event.preventDefault();
 850          });
 851  
 852          // Set the selected visibility as current.
 853          $postVisibilitySelect.find('.save-post-visibility').click( function( event ) { // Crazyhorse - multiple OK cancels.
 854              var visibilityLabel = '', selectedVisibility = $postVisibilitySelect.find('input:radio:checked').val();
 855  
 856              $postVisibilitySelect.slideUp('fast');
 857              $('#visibility .edit-visibility').show().focus();
 858              updateText();
 859  
 860              if ( 'public' !== selectedVisibility ) {
 861                  $('#sticky').prop('checked', false);
 862              }
 863  
 864              switch ( selectedVisibility ) {
 865                  case 'public':
 866                      visibilityLabel = $( '#sticky' ).prop( 'checked' ) ? __( 'Public, Sticky' ) : __( 'Public' );
 867                      break;
 868                  case 'private':
 869                      visibilityLabel = __( 'Private' );
 870                      break;
 871                  case 'password':
 872                      visibilityLabel = __( 'Password Protected' );
 873                      break;
 874              }
 875  
 876              $('#post-visibility-display').text( visibilityLabel );
 877              event.preventDefault();
 878          });
 879  
 880          // When the selection changes, update labels.
 881          $postVisibilitySelect.find('input:radio').change( function() {
 882              updateVisibility();
 883          });
 884  
 885          // Edit publish time click.
 886          $timestampdiv.siblings('a.edit-timestamp').click( function( event ) {
 887              if ( $timestampdiv.is( ':hidden' ) ) {
 888                  $timestampdiv.slideDown( 'fast', function() {
 889                      $( 'input, select', $timestampdiv.find( '.timestamp-wrap' ) ).first().focus();
 890                  } );
 891                  $(this).hide();
 892              }
 893              event.preventDefault();
 894          });
 895  
 896          // Cancel editing the publish time and hide the settings.
 897          $timestampdiv.find('.cancel-timestamp').click( function( event ) {
 898              $timestampdiv.slideUp('fast').siblings('a.edit-timestamp').show().focus();
 899              $('#mm').val($('#hidden_mm').val());
 900              $('#jj').val($('#hidden_jj').val());
 901              $('#aa').val($('#hidden_aa').val());
 902              $('#hh').val($('#hidden_hh').val());
 903              $('#mn').val($('#hidden_mn').val());
 904              updateText();
 905              event.preventDefault();
 906          });
 907  
 908          // Save the changed timestamp.
 909          $timestampdiv.find('.save-timestamp').click( function( event ) { // Crazyhorse - multiple OK cancels.
 910              if ( updateText() ) {
 911                  $timestampdiv.slideUp('fast');
 912                  $timestampdiv.siblings('a.edit-timestamp').show().focus();
 913              }
 914              event.preventDefault();
 915          });
 916  
 917          // Cancel submit when an invalid timestamp has been selected.
 918          $('#post').on( 'submit', function( event ) {
 919              if ( ! updateText() ) {
 920                  event.preventDefault();
 921                  $timestampdiv.show();
 922  
 923                  if ( wp.autosave ) {
 924                      wp.autosave.enableButtons();
 925                  }
 926  
 927                  $( '#publishing-action .spinner' ).removeClass( 'is-active' );
 928              }
 929          });
 930  
 931          // Post Status edit click.
 932          $postStatusSelect.siblings('a.edit-post-status').click( function( event ) {
 933              if ( $postStatusSelect.is( ':hidden' ) ) {
 934                  $postStatusSelect.slideDown( 'fast', function() {
 935                      $postStatusSelect.find('select').focus();
 936                  } );
 937                  $(this).hide();
 938              }
 939              event.preventDefault();
 940          });
 941  
 942          // Save the Post Status changes and hide the options.
 943          $postStatusSelect.find('.save-post-status').click( function( event ) {
 944              $postStatusSelect.slideUp( 'fast' ).siblings( 'a.edit-post-status' ).show().focus();
 945              updateText();
 946              event.preventDefault();
 947          });
 948  
 949          // Cancel Post Status editing and hide the options.
 950          $postStatusSelect.find('.cancel-post-status').click( function( event ) {
 951              $postStatusSelect.slideUp( 'fast' ).siblings( 'a.edit-post-status' ).show().focus();
 952              $('#post_status').val( $('#hidden_post_status').val() );
 953              updateText();
 954              event.preventDefault();
 955          });
 956      }
 957  
 958      /**
 959       * Handle the editing of the post_name. Create the required HTML elements and
 960       * update the changes via Ajax.
 961       *
 962       * @global
 963       *
 964       * @return {void}
 965       */
 966  	function editPermalink() {
 967          var i, slug_value,
 968              $el, revert_e,
 969              c = 0,
 970              real_slug = $('#post_name'),
 971              revert_slug = real_slug.val(),
 972              permalink = $( '#sample-permalink' ),
 973              permalinkOrig = permalink.html(),
 974              permalinkInner = $( '#sample-permalink a' ).html(),
 975              buttons = $('#edit-slug-buttons'),
 976              buttonsOrig = buttons.html(),
 977              full = $('#editable-post-name-full');
 978  
 979          // Deal with Twemoji in the post-name.
 980          full.find( 'img' ).replaceWith( function() { return this.alt; } );
 981          full = full.html();
 982  
 983          permalink.html( permalinkInner );
 984  
 985          // Save current content to revert to when cancelling.
 986          $el = $( '#editable-post-name' );
 987          revert_e = $el.html();
 988  
 989          buttons.html( '<button type="button" class="save button button-small">' + __( 'OK' ) + '</button> <button type="button" class="cancel button-link">' + __( 'Cancel' ) + '</button>' );
 990  
 991          // Save permalink changes.
 992          buttons.children( '.save' ).click( function() {
 993              var new_slug = $el.children( 'input' ).val();
 994  
 995              if ( new_slug == $('#editable-post-name-full').text() ) {
 996                  buttons.children('.cancel').click();
 997                  return;
 998              }
 999  
1000              $.post(
1001                  ajaxurl,
1002                  {
1003                      action: 'sample-permalink',
1004                      post_id: postId,
1005                      new_slug: new_slug,
1006                      new_title: $('#title').val(),
1007                      samplepermalinknonce: $('#samplepermalinknonce').val()
1008                  },
1009                  function(data) {
1010                      var box = $('#edit-slug-box');
1011                      box.html(data);
1012                      if (box.hasClass('hidden')) {
1013                          box.fadeIn('fast', function () {
1014                              box.removeClass('hidden');
1015                          });
1016                      }
1017  
1018                      buttons.html(buttonsOrig);
1019                      permalink.html(permalinkOrig);
1020                      real_slug.val(new_slug);
1021                      $( '.edit-slug' ).focus();
1022                      wp.a11y.speak( __( 'Permalink saved' ) );
1023                  }
1024              );
1025          });
1026  
1027          // Cancel editing of permalink.
1028          buttons.children( '.cancel' ).click( function() {
1029              $('#view-post-btn').show();
1030              $el.html(revert_e);
1031              buttons.html(buttonsOrig);
1032              permalink.html(permalinkOrig);
1033              real_slug.val(revert_slug);
1034              $( '.edit-slug' ).focus();
1035          });
1036  
1037          // If more than 1/4th of 'full' is '%', make it empty.
1038          for ( i = 0; i < full.length; ++i ) {
1039              if ( '%' == full.charAt(i) )
1040                  c++;
1041          }
1042          slug_value = ( c > full.length / 4 ) ? '' : full;
1043  
1044          $el.html( '<input type="text" id="new-post-slug" value="' + slug_value + '" autocomplete="off" />' ).children( 'input' ).keydown( function( e ) {
1045              var key = e.which;
1046              // On [Enter], just save the new slug, don't save the post.
1047              if ( 13 === key ) {
1048                  e.preventDefault();
1049                  buttons.children( '.save' ).click();
1050              }
1051              // On [Esc] cancel the editing.
1052              if ( 27 === key ) {
1053                  buttons.children( '.cancel' ).click();
1054              }
1055          } ).keyup( function() {
1056              real_slug.val( this.value );
1057          }).focus();
1058      }
1059  
1060      $( '#titlediv' ).on( 'click', '.edit-slug', function() {
1061          editPermalink();
1062      });
1063  
1064      /**
1065       * Adds screen reader text to the title label when needed.
1066       *
1067       * Use the 'screen-reader-text' class to emulate a placeholder attribute
1068       * and hide the label when entering a value.
1069       *
1070       * @param {string} id Optional. HTML ID to add the screen reader helper text to.
1071       *
1072       * @global
1073       *
1074       * @return {void}
1075       */
1076      window.wptitlehint = function( id ) {
1077          id = id || 'title';
1078  
1079          var title = $( '#' + id ), titleprompt = $( '#' + id + '-prompt-text' );
1080  
1081          if ( '' === title.val() ) {
1082              titleprompt.removeClass( 'screen-reader-text' );
1083          }
1084  
1085          title.on( 'input', function() {
1086              if ( '' === this.value ) {
1087                  titleprompt.removeClass( 'screen-reader-text' );
1088                  return;
1089              }
1090  
1091              titleprompt.addClass( 'screen-reader-text' );
1092          } );
1093      };
1094  
1095      wptitlehint();
1096  
1097      // Resize the WYSIWYG and plain text editors.
1098      ( function() {
1099          var editor, offset, mce,
1100              $handle = $('#post-status-info'),
1101              $postdivrich = $('#postdivrich');
1102  
1103          // If there are no textareas or we are on a touch device, we can't do anything.
1104          if ( ! $textarea.length || 'ontouchstart' in window ) {
1105              // Hide the resize handle.
1106              $('#content-resize-handle').hide();
1107              return;
1108          }
1109  
1110          /**
1111           * Handle drag event.
1112           *
1113           * @param {Object} event Event containing details about the drag.
1114           */
1115  		function dragging( event ) {
1116              if ( $postdivrich.hasClass( 'wp-editor-expand' ) ) {
1117                  return;
1118              }
1119  
1120              if ( mce ) {
1121                  editor.theme.resizeTo( null, offset + event.pageY );
1122              } else {
1123                  $textarea.height( Math.max( 50, offset + event.pageY ) );
1124              }
1125  
1126              event.preventDefault();
1127          }
1128  
1129          /**
1130           * When the dragging stopped make sure we return focus and do a sanity check on the height.
1131           */
1132  		function endDrag() {
1133              var height, toolbarHeight;
1134  
1135              if ( $postdivrich.hasClass( 'wp-editor-expand' ) ) {
1136                  return;
1137              }
1138  
1139              if ( mce ) {
1140                  editor.focus();
1141                  toolbarHeight = parseInt( $( '#wp-content-editor-container .mce-toolbar-grp' ).height(), 10 );
1142  
1143                  if ( toolbarHeight < 10 || toolbarHeight > 200 ) {
1144                      toolbarHeight = 30;
1145                  }
1146  
1147                  height = parseInt( $('#content_ifr').css('height'), 10 ) + toolbarHeight - 28;
1148              } else {
1149                  $textarea.focus();
1150                  height = parseInt( $textarea.css('height'), 10 );
1151              }
1152  
1153              $document.off( '.wp-editor-resize' );
1154  
1155              // Sanity check: normalize height to stay within acceptable ranges.
1156              if ( height && height > 50 && height < 5000 ) {
1157                  setUserSetting( 'ed_size', height );
1158              }
1159          }
1160  
1161          $handle.on( 'mousedown.wp-editor-resize', function( event ) {
1162              if ( typeof tinymce !== 'undefined' ) {
1163                  editor = tinymce.get('content');
1164              }
1165  
1166              if ( editor && ! editor.isHidden() ) {
1167                  mce = true;
1168                  offset = $('#content_ifr').height() - event.pageY;
1169              } else {
1170                  mce = false;
1171                  offset = $textarea.height() - event.pageY;
1172                  $textarea.blur();
1173              }
1174  
1175              $document.on( 'mousemove.wp-editor-resize', dragging )
1176                  .on( 'mouseup.wp-editor-resize mouseleave.wp-editor-resize', endDrag );
1177  
1178              event.preventDefault();
1179          }).on( 'mouseup.wp-editor-resize', endDrag );
1180      })();
1181  
1182      // TinyMCE specific handling of Post Format changes to reflect in the editor.
1183      if ( typeof tinymce !== 'undefined' ) {
1184          // When changing post formats, change the editor body class.
1185          $( '#post-formats-select input.post-format' ).on( 'change.set-editor-class', function() {
1186              var editor, body, format = this.id;
1187  
1188              if ( format && $( this ).prop( 'checked' ) && ( editor = tinymce.get( 'content' ) ) ) {
1189                  body = editor.getBody();
1190                  body.className = body.className.replace( /\bpost-format-[^ ]+/, '' );
1191                  editor.dom.addClass( body, format == 'post-format-0' ? 'post-format-standard' : format );
1192                  $( document ).trigger( 'editor-classchange' );
1193              }
1194          });
1195  
1196          // When changing page template, change the editor body class.
1197          $( '#page_template' ).on( 'change.set-editor-class', function() {
1198              var editor, body, pageTemplate = $( this ).val() || '';
1199  
1200              pageTemplate = pageTemplate.substr( pageTemplate.lastIndexOf( '/' ) + 1, pageTemplate.length )
1201                  .replace( /\.php$/, '' )
1202                  .replace( /\./g, '-' );
1203  
1204              if ( pageTemplate && ( editor = tinymce.get( 'content' ) ) ) {
1205                  body = editor.getBody();
1206                  body.className = body.className.replace( /\bpage-template-[^ ]+/, '' );
1207                  editor.dom.addClass( body, 'page-template-' + pageTemplate );
1208                  $( document ).trigger( 'editor-classchange' );
1209              }
1210          });
1211  
1212      }
1213  
1214      // Save on pressing [Ctrl]/[Command] + [S] in the Text editor.
1215      $textarea.on( 'keydown.wp-autosave', function( event ) {
1216          // Key [S] has code 83.
1217          if ( event.which === 83 ) {
1218              if ( event.shiftKey || event.altKey || ( isMac && ( ! event.metaKey || event.ctrlKey ) ) || ( ! isMac && ! event.ctrlKey ) ) {
1219                  return;
1220              }
1221  
1222              wp.autosave && wp.autosave.server.triggerSave();
1223              event.preventDefault();
1224          }
1225      });
1226  
1227      // If the last status was auto-draft and the save is triggered, edit the current URL.
1228      if ( $( '#original_post_status' ).val() === 'auto-draft' && window.history.replaceState ) {
1229          var location;
1230  
1231          $( '#publish' ).on( 'click', function() {
1232              location = window.location.href;
1233              location += ( location.indexOf( '?' ) !== -1 ) ? '&' : '?';
1234              location += 'wp-post-new-reload=true';
1235  
1236              window.history.replaceState( null, null, location );
1237          });
1238      }
1239  
1240      /**
1241       * Copies the attachment URL in the Edit Media page to the clipboard.
1242       *
1243       * @since 5.5.0
1244       *
1245       * @param {MouseEvent} event A click event.
1246       *
1247       * @return {void}
1248       */
1249      copyAttachmentURLClipboard.on( 'success', function( event ) {
1250          var triggerElement = $( event.trigger ),
1251              successElement = $( '.success', triggerElement.closest( '.copy-to-clipboard-container' ) );
1252  
1253          // Clear the selection and move focus back to the trigger.
1254          event.clearSelection();
1255          // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680
1256          triggerElement.focus();
1257  
1258          // Show success visual feedback.
1259          clearTimeout( copyAttachmentURLSuccessTimeout );
1260          successElement.removeClass( 'hidden' );
1261  
1262          // Hide success visual feedback after 3 seconds since last success.
1263          copyAttachmentURLSuccessTimeout = setTimeout( function() {
1264              successElement.addClass( 'hidden' );
1265          }, 3000 );
1266  
1267          // Handle success audible feedback.
1268          wp.a11y.speak( __( 'The file URL has been copied to your clipboard' ) );
1269      } );
1270  } );
1271  
1272  /**
1273   * TinyMCE word count display
1274   */
1275  ( function( $, counter ) {
1276      $( function() {
1277          var $content = $( '#content' ),
1278              $count = $( '#wp-word-count' ).find( '.word-count' ),
1279              prevCount = 0,
1280              contentEditor;
1281  
1282          /**
1283           * Get the word count from TinyMCE and display it
1284           */
1285  		function update() {
1286              var text, count;
1287  
1288              if ( ! contentEditor || contentEditor.isHidden() ) {
1289                  text = $content.val();
1290              } else {
1291                  text = contentEditor.getContent( { format: 'raw' } );
1292              }
1293  
1294              count = counter.count( text );
1295  
1296              if ( count !== prevCount ) {
1297                  $count.text( count );
1298              }
1299  
1300              prevCount = count;
1301          }
1302  
1303          /**
1304           * Bind the word count update triggers.
1305           *
1306           * When a node change in the main TinyMCE editor has been triggered.
1307           * When a key has been released in the plain text content editor.
1308           */
1309          $( document ).on( 'tinymce-editor-init', function( event, editor ) {
1310              if ( editor.id !== 'content' ) {
1311                  return;
1312              }
1313  
1314              contentEditor = editor;
1315  
1316              editor.on( 'nodechange keyup', _.debounce( update, 1000 ) );
1317          } );
1318  
1319          $content.on( 'input keyup', _.debounce( update, 1000 ) );
1320  
1321          update();
1322      } );
1323  
1324  } )( jQuery, new wp.utils.WordCounter() );


Generated : Thu Jul 9 08:20:02 2020 Cross-referenced by PHPXref