[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-includes/ -> script-loader.php (source)

   1  <?php
   2  /**
   3   * WordPress scripts and styles default loader.
   4   *
   5   * Several constants are used to manage the loading, concatenating and compression of scripts and CSS:
   6   * define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation,
   7   * define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS,
   8   * define('COMPRESS_SCRIPTS', false); disables compression of scripts,
   9   * define('COMPRESS_CSS', false); disables compression of CSS,
  10   * define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate).
  11   *
  12   * The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins
  13   * to temporarily override the above settings. Also a compression test is run once and the result is saved
  14   * as option 'can_compress_scripts' (0/1). The test will run again if that option is deleted.
  15   *
  16   * @package WordPress
  17   */
  18  
  19  /** WordPress Dependency Class */
  20  require ( ABSPATH . WPINC . '/class-wp-dependency.php' );
  21  
  22  /** WordPress Dependencies Class */
  23  require ( ABSPATH . WPINC . '/class.wp-dependencies.php' );
  24  
  25  /** WordPress Scripts Class */
  26  require ( ABSPATH . WPINC . '/class.wp-scripts.php' );
  27  
  28  /** WordPress Scripts Functions */
  29  require ( ABSPATH . WPINC . '/functions.wp-scripts.php' );
  30  
  31  /** WordPress Styles Class */
  32  require ( ABSPATH . WPINC . '/class.wp-styles.php' );
  33  
  34  /** WordPress Styles Functions */
  35  require ( ABSPATH . WPINC . '/functions.wp-styles.php' );
  36  
  37  /**
  38   * Registers TinyMCE scripts.
  39   *
  40   * @since 5.0.0
  41   *
  42   * @param WP_Scripts $scripts WP_Scripts object.
  43   */
  44  function wp_register_tinymce_scripts( &$scripts, $force_uncompressed = false ) {
  45      global $tinymce_version, $concatenate_scripts, $compress_scripts;
  46      $suffix     = wp_scripts_get_suffix();
  47      $dev_suffix = wp_scripts_get_suffix( 'dev' );
  48  
  49      script_concat_settings();
  50  
  51      $compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] )
  52          && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed;
  53  
  54      // Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production) or
  55      // tinymce.min.js (when SCRIPT_DEBUG is true).
  56      if ( $compressed ) {
  57          $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version );
  58      } else {
  59          $scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$dev_suffix.js", array(), $tinymce_version );
  60          $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$dev_suffix.js", array( 'wp-tinymce-root' ), $tinymce_version );
  61      }
  62  
  63      $scripts->add( 'wp-tinymce-lists', includes_url( "js/tinymce/plugins/lists/plugin$suffix.js" ), array( 'wp-tinymce' ), $tinymce_version );
  64  }
  65  
  66  /**
  67   * Registers all the WordPress vendor scripts that are in the standardized
  68   * `js/dist/vendor/` location.
  69   *
  70   * For the order of `$scripts->add` see `wp_default_scripts`.
  71   *
  72   * @since 5.0.0
  73   *
  74   * @param WP_Scripts $scripts WP_Scripts object.
  75   */
  76  function wp_default_packages_vendor( &$scripts ) {
  77      global $wp_locale;
  78  
  79      $suffix = wp_scripts_get_suffix();
  80  
  81      $vendor_scripts = array(
  82          'react'     => array( 'wp-polyfill' ),
  83          'react-dom' => array( 'react' ),
  84          'moment',
  85          'lodash',
  86          'wp-polyfill-fetch',
  87          'wp-polyfill-formdata',
  88          'wp-polyfill-node-contains',
  89          'wp-polyfill-element-closest',
  90          'wp-polyfill',
  91      );
  92  
  93      $vendor_scripts_versions = array(
  94          'react'                       => '16.9.0',
  95          'react-dom'                   => '16.9.0',
  96          'moment'                      => '2.22.2',
  97          'lodash'                      => '4.17.15',
  98          'wp-polyfill-fetch'           => '3.0.0',
  99          'wp-polyfill-formdata'        => '3.0.12',
 100          'wp-polyfill-node-contains'   => '3.26.0-0',
 101          'wp-polyfill-element-closest' => '2.0.2',
 102          'wp-polyfill'                 => '7.4.4',
 103      );
 104  
 105      foreach ( $vendor_scripts as $handle => $dependencies ) {
 106          if ( is_string( $dependencies ) ) {
 107              $handle       = $dependencies;
 108              $dependencies = array();
 109          }
 110  
 111          $path    = "/wp-includes/js/dist/vendor/$handle$suffix.js";
 112          $version = $vendor_scripts_versions[ $handle ];
 113  
 114          $scripts->add( $handle, $path, $dependencies, $version, 1 );
 115      }
 116  
 117      $scripts->add( 'wp-polyfill', null, array( 'wp-polyfill' ) );
 118      did_action( 'init' ) && $scripts->add_inline_script(
 119          'wp-polyfill',
 120          wp_get_script_polyfill(
 121              $scripts,
 122              array(
 123                  '\'fetch\' in window' => 'wp-polyfill-fetch',
 124                  'document.contains'   => 'wp-polyfill-node-contains',
 125                  'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata',
 126                  'Element.prototype.matches && Element.prototype.closest' => 'wp-polyfill-element-closest',
 127              )
 128          )
 129      );
 130  
 131      did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
 132  
 133      did_action( 'init' ) && $scripts->add_inline_script(
 134          'moment',
 135          sprintf(
 136              "moment.locale( '%s', %s );",
 137              get_user_locale(),
 138              wp_json_encode(
 139                  array(
 140                      'months'         => array_values( $wp_locale->month ),
 141                      'monthsShort'    => array_values( $wp_locale->month_abbrev ),
 142                      'weekdays'       => array_values( $wp_locale->weekday ),
 143                      'weekdaysShort'  => array_values( $wp_locale->weekday_abbrev ),
 144                      'week'           => array(
 145                          'dow' => (int) get_option( 'start_of_week', 0 ),
 146                      ),
 147                      'longDateFormat' => array(
 148                          'LT'   => get_option( 'time_format', __( 'g:i a', 'default' ) ),
 149                          'LTS'  => null,
 150                          'L'    => null,
 151                          'LL'   => get_option( 'date_format', __( 'F j, Y', 'default' ) ),
 152                          'LLL'  => __( 'F j, Y g:i a', 'default' ),
 153                          'LLLL' => null,
 154                      ),
 155                  )
 156              )
 157          ),
 158          'after'
 159      );
 160  }
 161  
 162  /**
 163   * Returns contents of an inline script used in appending polyfill scripts for
 164   * browsers which fail the provided tests. The provided array is a mapping from
 165   * a condition to verify feature support to its polyfill script handle.
 166   *
 167   * @since 5.0.0
 168   *
 169   * @param WP_Scripts $scripts WP_Scripts object.
 170   * @param array      $tests   Features to detect.
 171   * @return string Conditional polyfill inline script.
 172   */
 173  function wp_get_script_polyfill( &$scripts, $tests ) {
 174      $polyfill = '';
 175      foreach ( $tests as $test => $handle ) {
 176          if ( ! array_key_exists( $handle, $scripts->registered ) ) {
 177              continue;
 178          }
 179  
 180          $src = $scripts->registered[ $handle ]->src;
 181          $ver = $scripts->registered[ $handle ]->ver;
 182  
 183          if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $scripts->content_url && 0 === strpos( $src, $scripts->content_url ) ) ) {
 184              $src = $scripts->base_url . $src;
 185          }
 186  
 187          if ( ! empty( $ver ) ) {
 188              $src = add_query_arg( 'ver', $ver, $src );
 189          }
 190  
 191          /** This filter is documented in wp-includes/class.wp-scripts.php */
 192          $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
 193  
 194          if ( ! $src ) {
 195              continue;
 196          }
 197  
 198          $polyfill .= (
 199              // Test presence of feature...
 200              '( ' . $test . ' ) || ' .
 201              // ...appending polyfill on any failures. Cautious viewers may balk
 202              // at the `document.write`. Its caveat of synchronous mid-stream
 203              // blocking write is exactly the behavior we need though.
 204              'document.write( \'<script src="' .
 205              $src .
 206              '"></scr\' + \'ipt>\' );'
 207          );
 208      }
 209  
 210      return $polyfill;
 211  }
 212  
 213  /**
 214   * Registers all the WordPress packages scripts that are in the standardized
 215   * `js/dist/` location.
 216   *
 217   * For the order of `$scripts->add` see `wp_default_scripts`.
 218   *
 219   * @since 5.0.0
 220   *
 221   * @param WP_Scripts $scripts WP_Scripts object.
 222   */
 223  function wp_default_packages_scripts( &$scripts ) {
 224      $suffix = wp_scripts_get_suffix();
 225  
 226      $packages_versions = array(
 227          'a11y'                               => '2.5.1',
 228          'annotations'                        => '1.7.2',
 229          'api-fetch'                          => '3.6.3',
 230          'autop'                              => '2.5.1',
 231          'blob'                               => '2.5.1',
 232          'block-editor'                       => '3.2.3',
 233          'block-library'                      => '2.9.3',
 234          'block-serialization-default-parser' => '3.4.1',
 235          'blocks'                             => '6.7.2',
 236          'components'                         => '8.3.2',
 237          'compose'                            => '3.7.2',
 238          'core-data'                          => '2.7.3',
 239          'data-controls'                      => '1.3.3',
 240          'data'                               => '4.9.2',
 241          'date'                               => '3.5.0',
 242          'deprecated'                         => '2.6.1',
 243          'dom-ready'                          => '2.5.1',
 244          'dom'                                => '2.5.2',
 245          'edit-post'                          => '3.8.3',
 246          'editor'                             => '9.7.3',
 247          'element'                            => '2.8.2',
 248          'escape-html'                        => '1.5.1',
 249          'format-library'                     => '1.9.3',
 250          'hooks'                              => '2.6.0',
 251          'html-entities'                      => '2.5.0',
 252          'i18n'                               => '3.6.1',
 253          'is-shallow-equal'                   => '1.6.1',
 254          'keycodes'                           => '2.6.2',
 255          'list-reusable-blocks'               => '1.8.3',
 256          'media-utils'                        => '1.2.3',
 257          'notices'                            => '1.8.2',
 258          'nux'                                => '3.7.2',
 259          'plugins'                            => '2.7.2',
 260          'priority-queue'                     => '1.3.1',
 261          'redux-routine'                      => '3.6.2',
 262          'rich-text'                          => '3.7.2',
 263          'shortcode'                          => '2.4.1',
 264          'server-side-render'                 => '1.3.3',
 265          'token-list'                         => '1.6.1',
 266          'url'                                => '2.8.2',
 267          'viewport'                           => '2.8.2',
 268          'wordcount'                          => '2.6.2',
 269      );
 270  
 271      $packages_dependencies = array(
 272          'a11y'                               => array(
 273              'wp-dom-ready',
 274              'wp-polyfill',
 275          ),
 276          'annotations'                        => array(
 277              'lodash',
 278              'wp-data',
 279              'wp-hooks',
 280              'wp-i18n',
 281              'wp-polyfill',
 282              'wp-rich-text',
 283          ),
 284          'api-fetch'                          => array(
 285              'wp-i18n',
 286              'wp-polyfill',
 287              'wp-url',
 288          ),
 289          'autop'                              => array(
 290              'wp-polyfill',
 291          ),
 292          'blob'                               => array(
 293              'wp-polyfill',
 294          ),
 295          'block-editor'                       => array(
 296              'lodash',
 297              'wp-a11y',
 298              'wp-blob',
 299              'wp-blocks',
 300              'wp-components',
 301              'wp-compose',
 302              'wp-data',
 303              'wp-deprecated',
 304              'wp-dom',
 305              'wp-element',
 306              'wp-hooks',
 307              'wp-html-entities',
 308              'wp-i18n',
 309              'wp-is-shallow-equal',
 310              'wp-keycodes',
 311              'wp-polyfill',
 312              'wp-rich-text',
 313              'wp-token-list',
 314              'wp-url',
 315              'wp-viewport',
 316              'wp-wordcount',
 317          ),
 318          'block-library'                      => array(
 319              'editor',
 320              'lodash',
 321              'moment',
 322              'wp-a11y',
 323              'wp-api-fetch',
 324              'wp-autop',
 325              'wp-blob',
 326              'wp-block-editor',
 327              'wp-blocks',
 328              'wp-components',
 329              'wp-compose',
 330              'wp-core-data',
 331              'wp-data',
 332              'wp-date',
 333              'wp-deprecated',
 334              'wp-editor',
 335              'wp-element',
 336              'wp-i18n',
 337              'wp-is-shallow-equal',
 338              'wp-keycodes',
 339              'wp-polyfill',
 340              'wp-rich-text',
 341              'wp-server-side-render',
 342              'wp-url',
 343              'wp-viewport',
 344          ),
 345          'block-serialization-default-parser' => array(
 346              'wp-polyfill',
 347          ),
 348          'blocks'                             => array(
 349              'lodash',
 350              'wp-autop',
 351              'wp-blob',
 352              'wp-block-serialization-default-parser',
 353              'wp-compose',
 354              'wp-data',
 355              'wp-dom',
 356              'wp-element',
 357              'wp-hooks',
 358              'wp-html-entities',
 359              'wp-i18n',
 360              'wp-is-shallow-equal',
 361              'wp-polyfill',
 362              'wp-shortcode',
 363          ),
 364          'components'                         => array(
 365              'lodash',
 366              'moment',
 367              'wp-a11y',
 368              'wp-compose',
 369              'wp-deprecated',
 370              'wp-dom',
 371              'wp-element',
 372              'wp-hooks',
 373              'wp-i18n',
 374              'wp-is-shallow-equal',
 375              'wp-keycodes',
 376              'wp-polyfill',
 377              'wp-rich-text',
 378          ),
 379          'compose'                            => array(
 380              'lodash',
 381              'wp-element',
 382              'wp-is-shallow-equal',
 383              'wp-polyfill',
 384          ),
 385          'core-data'                          => array(
 386              'lodash',
 387              'wp-api-fetch',
 388              'wp-data',
 389              'wp-deprecated',
 390              'wp-is-shallow-equal',
 391              'wp-polyfill',
 392              'wp-url',
 393          ),
 394          'data'                               => array(
 395              'lodash',
 396              'wp-compose',
 397              'wp-deprecated',
 398              'wp-element',
 399              'wp-is-shallow-equal',
 400              'wp-polyfill',
 401              'wp-priority-queue',
 402              'wp-redux-routine',
 403          ),
 404          'data-controls'                      => array(
 405              'wp-api-fetch',
 406              'wp-data',
 407              'wp-polyfill',
 408          ),
 409          'date'                               => array(
 410              'moment',
 411              'wp-polyfill',
 412          ),
 413          'deprecated'                         => array(
 414              'wp-hooks',
 415              'wp-polyfill',
 416          ),
 417          'dom'                                => array(
 418              'lodash',
 419              'wp-polyfill',
 420          ),
 421          'dom-ready'                          => array(
 422              'wp-polyfill',
 423          ),
 424          'edit-post'                          => array(
 425              'lodash',
 426              'postbox',
 427              'media-models',
 428              'media-views',
 429              'wp-a11y',
 430              'wp-api-fetch',
 431              'wp-block-editor',
 432              'wp-block-library',
 433              'wp-blocks',
 434              'wp-components',
 435              'wp-compose',
 436              'wp-core-data',
 437              'wp-data',
 438              'wp-dom-ready',
 439              'wp-editor',
 440              'wp-element',
 441              'wp-hooks',
 442              'wp-i18n',
 443              'wp-keycodes',
 444              'wp-media-utils',
 445              'wp-notices',
 446              'wp-nux',
 447              'wp-plugins',
 448              'wp-polyfill',
 449              'wp-url',
 450              'wp-viewport',
 451          ),
 452          'editor'                             => array(
 453              'lodash',
 454              'wp-api-fetch',
 455              'wp-autop',
 456              'wp-block-editor',
 457              'wp-blocks',
 458              'wp-components',
 459              'wp-compose',
 460              'wp-core-data',
 461              'wp-data',
 462              'wp-data-controls',
 463              'wp-date',
 464              'wp-deprecated',
 465              'wp-element',
 466              'wp-hooks',
 467              'wp-html-entities',
 468              'wp-i18n',
 469              'wp-is-shallow-equal',
 470              'wp-keycodes',
 471              'wp-media-utils',
 472              'wp-notices',
 473              'wp-nux',
 474              'wp-polyfill',
 475              'wp-rich-text',
 476              'wp-server-side-render',
 477              'wp-url',
 478              'wp-viewport',
 479              'wp-wordcount',
 480          ),
 481          'element'                            => array(
 482              'lodash',
 483              'react',
 484              'react-dom',
 485              'wp-escape-html',
 486              'wp-polyfill',
 487          ),
 488          'escape-html'                        => array(
 489              'wp-polyfill',
 490          ),
 491          'format-library'                     => array(
 492              'lodash',
 493              'wp-block-editor',
 494              'wp-components',
 495              'wp-dom',
 496              'wp-element',
 497              'wp-html-entities',
 498              'wp-i18n',
 499              'wp-keycodes',
 500              'wp-polyfill',
 501              'wp-rich-text',
 502              'wp-url',
 503          ),
 504          'hooks'                              => array(
 505              'wp-polyfill',
 506          ),
 507          'html-entities'                      => array(
 508              'wp-polyfill',
 509          ),
 510          'i18n'                               => array(
 511              'wp-polyfill',
 512          ),
 513          'is-shallow-equal'                   => array(
 514              'wp-polyfill',
 515          ),
 516          'keycodes'                           => array(
 517              'lodash',
 518              'wp-i18n',
 519              'wp-polyfill',
 520          ),
 521          'list-reusable-blocks'               => array(
 522              'lodash',
 523              'wp-api-fetch',
 524              'wp-components',
 525              'wp-compose',
 526              'wp-element',
 527              'wp-i18n',
 528              'wp-polyfill',
 529          ),
 530          'media-utils'                        => array(
 531              'lodash',
 532              'wp-api-fetch',
 533              'wp-blob',
 534              'wp-element',
 535              'wp-i18n',
 536              'wp-polyfill',
 537          ),
 538          'notices'                            => array(
 539              'lodash',
 540              'wp-a11y',
 541              'wp-data',
 542              'wp-polyfill',
 543          ),
 544          'nux'                                => array(
 545              'lodash',
 546              'wp-components',
 547              'wp-compose',
 548              'wp-data',
 549              'wp-element',
 550              'wp-i18n',
 551              'wp-polyfill',
 552          ),
 553          'plugins'                            => array(
 554              'lodash',
 555              'wp-compose',
 556              'wp-element',
 557              'wp-hooks',
 558              'wp-polyfill',
 559          ),
 560          'priority-queue'                     => array(
 561              'wp-polyfill',
 562          ),
 563          'redux-routine'                      => array(
 564              'lodash',
 565              'wp-polyfill',
 566          ),
 567          'rich-text'                          => array(
 568              'lodash',
 569              'wp-compose',
 570              'wp-data',
 571              'wp-element',
 572              'wp-escape-html',
 573              'wp-hooks',
 574              'wp-is-shallow-equal',
 575              'wp-keycodes',
 576              'wp-polyfill',
 577          ),
 578          'server-side-render'                 => array(
 579              'lodash',
 580              'wp-api-fetch',
 581              'wp-components',
 582              'wp-data',
 583              'wp-deprecated',
 584              'wp-element',
 585              'wp-i18n',
 586              'wp-polyfill',
 587              'wp-url',
 588          ),
 589          'shortcode'                          => array(
 590              'lodash',
 591              'wp-polyfill',
 592          ),
 593          'token-list'                         => array(
 594              'lodash',
 595              'wp-polyfill',
 596          ),
 597          'url'                                => array(
 598              'wp-polyfill',
 599          ),
 600          'viewport'                           => array(
 601              'lodash',
 602              'wp-compose',
 603              'wp-data',
 604              'wp-polyfill',
 605          ),
 606          'wordcount'                          => array(
 607              'lodash',
 608              'wp-polyfill',
 609          ),
 610      );
 611  
 612      $package_translations = array(
 613          'api-fetch',
 614          'blocks',
 615          'block-editor',
 616          'block-library',
 617          'components',
 618          'edit-post',
 619          'editor',
 620          'format-library',
 621          'keycodes',
 622          'list-reusable-blocks',
 623          'nux',
 624      );
 625  
 626      foreach ( $packages_dependencies as $package => $dependencies ) {
 627          $handle  = 'wp-' . $package;
 628          $path    = "/wp-includes/js/dist/$package$suffix.js";
 629          $version = $packages_versions[ $package ];
 630  
 631          $scripts->add( $handle, $path, $dependencies, $version, 1 );
 632  
 633          if ( in_array( $package, $package_translations, true ) ) {
 634              $scripts->set_translations( $handle );
 635          }
 636      }
 637  }
 638  
 639  /**
 640   * Adds inline scripts required for the WordPress JavaScript packages.
 641   *
 642   * @since 5.0.0
 643   *
 644   * @param WP_Scripts $scripts WP_Scripts object.
 645   */
 646  function wp_default_packages_inline_scripts( &$scripts ) {
 647      global $wp_locale;
 648  
 649      if ( isset( $scripts->registered['wp-api-fetch'] ) ) {
 650          $scripts->registered['wp-api-fetch']->deps[] = 'wp-hooks';
 651      }
 652      $scripts->add_inline_script(
 653          'wp-api-fetch',
 654          implode(
 655              "\n",
 656              array(
 657                  sprintf(
 658                      'wp.apiFetch.nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );',
 659                      ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' )
 660                  ),
 661                  'wp.apiFetch.use( wp.apiFetch.nonceMiddleware );',
 662                  'wp.apiFetch.use( wp.apiFetch.mediaUploadMiddleware );',
 663                  sprintf(
 664                      'wp.apiFetch.nonceEndpoint = "%s";',
 665                      admin_url( 'admin-ajax.php?action=rest-nonce' )
 666                  ),
 667              )
 668          ),
 669          'after'
 670      );
 671      $scripts->add_inline_script(
 672          'wp-api-fetch',
 673          sprintf(
 674              'wp.apiFetch.use( wp.apiFetch.createRootURLMiddleware( "%s" ) );',
 675              esc_url_raw( get_rest_url() )
 676          ),
 677          'after'
 678      );
 679  
 680      $scripts->add_inline_script(
 681          'wp-data',
 682          implode(
 683              "\n",
 684              array(
 685                  '( function() {',
 686                  '    var userId = ' . get_current_user_ID() . ';',
 687                  '    var storageKey = "WP_DATA_USER_" + userId;',
 688                  '    wp.data',
 689                  '        .use( wp.data.plugins.persistence, { storageKey: storageKey } );',
 690                  '    wp.data.plugins.persistence.__unstableMigrate( { storageKey: storageKey } );',
 691                  '} )();',
 692              )
 693          )
 694      );
 695  
 696      $scripts->add_inline_script(
 697          'wp-date',
 698          sprintf(
 699              'wp.date.setSettings( %s );',
 700              wp_json_encode(
 701                  array(
 702                      'l10n'     => array(
 703                          'locale'        => get_user_locale(),
 704                          'months'        => array_values( $wp_locale->month ),
 705                          'monthsShort'   => array_values( $wp_locale->month_abbrev ),
 706                          'weekdays'      => array_values( $wp_locale->weekday ),
 707                          'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
 708                          'meridiem'      => (object) $wp_locale->meridiem,
 709                          'relative'      => array(
 710                              /* translators: %s: Duration. */
 711                              'future' => __( '%s from now' ),
 712                              /* translators: %s: Duration. */
 713                              'past'   => __( '%s ago' ),
 714                          ),
 715                      ),
 716                      'formats'  => array(
 717                          /* translators: Time format, see https://secure.php.net/date */
 718                          'time'                => get_option( 'time_format', __( 'g:i a' ) ),
 719                          /* translators: Date format, see https://secure.php.net/date */
 720                          'date'                => get_option( 'date_format', __( 'F j, Y' ) ),
 721                          /* translators: Date/Time format, see https://secure.php.net/date */
 722                          'datetime'            => __( 'F j, Y g:i a' ),
 723                          /* translators: Abbreviated date/time format, see https://secure.php.net/date */
 724                          'datetimeAbbreviated' => __( 'M j, Y g:i a' ),
 725                      ),
 726                      'timezone' => array(
 727                          'offset' => get_option( 'gmt_offset', 0 ),
 728                          'string' => get_option( 'timezone_string', 'UTC' ),
 729                      ),
 730                  )
 731              )
 732          ),
 733          'after'
 734      );
 735  
 736      // Loading the old editor and its config to ensure the classic block works as expected.
 737      $scripts->add_inline_script(
 738          'editor',
 739          'window.wp.oldEditor = window.wp.editor;',
 740          'after'
 741      );
 742  }
 743  
 744  /**
 745   * Adds inline scripts required for the TinyMCE in the block editor.
 746   *
 747   * These TinyMCE init settings are used to extend and override the default settings
 748   * from `_WP_Editors::default_settings()` for the Classic block.
 749   *
 750   * @since 5.0.0
 751   *
 752   * @global WP_Scripts $wp_scripts
 753   */
 754  function wp_tinymce_inline_scripts() {
 755      global $wp_scripts;
 756  
 757      /** This filter is documented in wp-includes/class-wp-editor.php */
 758      $editor_settings = apply_filters( 'wp_editor_settings', array( 'tinymce' => true ), 'classic-block' );
 759  
 760      $tinymce_plugins = array(
 761          'charmap',
 762          'colorpicker',
 763          'hr',
 764          'lists',
 765          'media',
 766          'paste',
 767          'tabfocus',
 768          'textcolor',
 769          'fullscreen',
 770          'wordpress',
 771          'wpautoresize',
 772          'wpeditimage',
 773          'wpemoji',
 774          'wpgallery',
 775          'wplink',
 776          'wpdialogs',
 777          'wptextpattern',
 778          'wpview',
 779      );
 780  
 781      /* This filter is documented in wp-includes/class-wp-editor.php */
 782      $tinymce_plugins = apply_filters( 'tiny_mce_plugins', $tinymce_plugins, 'classic-block' );
 783      $tinymce_plugins = array_unique( $tinymce_plugins );
 784  
 785      $disable_captions = false;
 786      // Runs after `tiny_mce_plugins` but before `mce_buttons`.
 787      /** This filter is documented in wp-admin/includes/media.php */
 788      if ( apply_filters( 'disable_captions', '' ) ) {
 789          $disable_captions = true;
 790      }
 791  
 792      $toolbar1 = array(
 793          'formatselect',
 794          'bold',
 795          'italic',
 796          'bullist',
 797          'numlist',
 798          'blockquote',
 799          'alignleft',
 800          'aligncenter',
 801          'alignright',
 802          'link',
 803          'unlink',
 804          'wp_more',
 805          'spellchecker',
 806          'wp_add_media',
 807          'wp_adv',
 808      );
 809  
 810      /* This filter is documented in wp-includes/class-wp-editor.php */
 811      $toolbar1 = apply_filters( 'mce_buttons', $toolbar1, 'classic-block' );
 812  
 813      $toolbar2 = array(
 814          'strikethrough',
 815          'hr',
 816          'forecolor',
 817          'pastetext',
 818          'removeformat',
 819          'charmap',
 820          'outdent',
 821          'indent',
 822          'undo',
 823          'redo',
 824          'wp_help',
 825      );
 826  
 827      /* This filter is documented in wp-includes/class-wp-editor.php */
 828      $toolbar2 = apply_filters( 'mce_buttons_2', $toolbar2, 'classic-block' );
 829      /* This filter is documented in wp-includes/class-wp-editor.php */
 830      $toolbar3 = apply_filters( 'mce_buttons_3', array(), 'classic-block' );
 831      /* This filter is documented in wp-includes/class-wp-editor.php */
 832      $toolbar4 = apply_filters( 'mce_buttons_4', array(), 'classic-block' );
 833      /* This filter is documented in wp-includes/class-wp-editor.php */
 834      $external_plugins = apply_filters( 'mce_external_plugins', array(), 'classic-block' );
 835  
 836      $tinymce_settings = array(
 837          'plugins'              => implode( ',', $tinymce_plugins ),
 838          'toolbar1'             => implode( ',', $toolbar1 ),
 839          'toolbar2'             => implode( ',', $toolbar2 ),
 840          'toolbar3'             => implode( ',', $toolbar3 ),
 841          'toolbar4'             => implode( ',', $toolbar4 ),
 842          'external_plugins'     => wp_json_encode( $external_plugins ),
 843          'classic_block_editor' => true,
 844      );
 845  
 846      if ( $disable_captions ) {
 847          $tinymce_settings['wpeditimage_disable_captions'] = true;
 848      }
 849  
 850      if ( ! empty( $editor_settings['tinymce'] ) && is_array( $editor_settings['tinymce'] ) ) {
 851          array_merge( $tinymce_settings, $editor_settings['tinymce'] );
 852      }
 853  
 854      /* This filter is documented in wp-includes/class-wp-editor.php */
 855      $tinymce_settings = apply_filters( 'tiny_mce_before_init', $tinymce_settings, 'classic-block' );
 856  
 857      // Do "by hand" translation from PHP array to js object.
 858      // Prevents breakage in some custom settings.
 859      $init_obj = '';
 860      foreach ( $tinymce_settings as $key => $value ) {
 861          if ( is_bool( $value ) ) {
 862              $val       = $value ? 'true' : 'false';
 863              $init_obj .= $key . ':' . $val . ',';
 864              continue;
 865          } elseif ( ! empty( $value ) && is_string( $value ) && (
 866              ( '{' === $value[0] && '}' === $value[ strlen( $value ) - 1 ] ) ||
 867              ( '[' === $value[0] && ']' === $value[ strlen( $value ) - 1 ] ) ||
 868              preg_match( '/^\(?function ?\(/', $value ) ) ) {
 869              $init_obj .= $key . ':' . $value . ',';
 870              continue;
 871          }
 872          $init_obj .= $key . ':"' . $value . '",';
 873      }
 874  
 875      $init_obj = '{' . trim( $init_obj, ' ,' ) . '}';
 876  
 877      $script = 'window.wpEditorL10n = {
 878          tinymce: {
 879              baseURL: ' . wp_json_encode( includes_url( 'js/tinymce' ) ) . ',
 880              suffix: ' . ( SCRIPT_DEBUG ? '""' : '".min"' ) . ',
 881              settings: ' . $init_obj . ',
 882          }
 883      }';
 884  
 885      $wp_scripts->add_inline_script( 'wp-block-library', $script, 'before' );
 886  }
 887  
 888  /**
 889   * Registers all the WordPress packages scripts.
 890   *
 891   * @since 5.0.0
 892   *
 893   * @param WP_Scripts $scripts WP_Scripts object.
 894   */
 895  function wp_default_packages( &$scripts ) {
 896      wp_default_packages_vendor( $scripts );
 897      wp_register_tinymce_scripts( $scripts );
 898      wp_default_packages_scripts( $scripts );
 899  
 900      if ( did_action( 'init' ) ) {
 901          wp_default_packages_inline_scripts( $scripts );
 902      }
 903  }
 904  
 905  /**
 906   * Returns the suffix that can be used for the scripts.
 907   *
 908   * There are two suffix types, the normal one and the dev suffix.
 909   *
 910   * @since 5.0.0
 911   *
 912   * @param string $type The type of suffix to retrieve.
 913   * @return string The script suffix.
 914   */
 915  function wp_scripts_get_suffix( $type = '' ) {
 916      static $suffixes;
 917  
 918      if ( $suffixes === null ) {
 919          include ( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
 920  
 921          $develop_src = false !== strpos( $wp_version, '-src' );
 922  
 923          if ( ! defined( 'SCRIPT_DEBUG' ) ) {
 924              define( 'SCRIPT_DEBUG', $develop_src );
 925          }
 926          $suffix     = SCRIPT_DEBUG ? '' : '.min';
 927          $dev_suffix = $develop_src ? '' : '.min';
 928  
 929          $suffixes = array(
 930              'suffix'     => $suffix,
 931              'dev_suffix' => $dev_suffix,
 932          );
 933      }
 934  
 935      if ( $type === 'dev' ) {
 936          return $suffixes['dev_suffix'];
 937      }
 938  
 939      return $suffixes['suffix'];
 940  }
 941  
 942  /**
 943   * Register all WordPress scripts.
 944   *
 945   * Localizes some of them.
 946   * args order: `$scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 );`
 947   * when last arg === 1 queues the script for the footer
 948   *
 949   * @since 2.6.0
 950   *
 951   * @param WP_Scripts $scripts WP_Scripts object.
 952   */
 953  function wp_default_scripts( &$scripts ) {
 954      $suffix     = wp_scripts_get_suffix();
 955      $dev_suffix = wp_scripts_get_suffix( 'dev' );
 956      $guessurl   = site_url();
 957  
 958      if ( ! $guessurl ) {
 959          $guessed_url = true;
 960          $guessurl    = wp_guess_url();
 961      }
 962  
 963      $scripts->base_url        = $guessurl;
 964      $scripts->content_url     = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : '';
 965      $scripts->default_version = get_bloginfo( 'version' );
 966      $scripts->default_dirs    = array( '/wp-admin/js/', '/wp-includes/js/' );
 967  
 968      $scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" );
 969      did_action( 'init' ) && $scripts->localize(
 970          'utils',
 971          'userSettings',
 972          array(
 973              'url'    => (string) SITECOOKIEPATH,
 974              'uid'    => (string) get_current_user_id(),
 975              'time'   => (string) time(),
 976              'secure' => (string) ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ),
 977          )
 978      );
 979  
 980      $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hoverIntent', 'utils' ), false, 1 );
 981      did_action( 'init' ) && $scripts->localize(
 982          'common',
 983          'commonL10n',
 984          array(
 985              'warnDelete'   => __( "You are about to permanently delete these items from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
 986              'dismiss'      => __( 'Dismiss this notice.' ),
 987              'collapseMenu' => __( 'Collapse Main menu' ),
 988              'expandMenu'   => __( 'Expand Main menu' ),
 989          )
 990      );
 991  
 992      $scripts->add( 'wp-sanitize', "/wp-includes/js/wp-sanitize$suffix.js", array(), false, 1 );
 993  
 994      $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 );
 995  
 996      $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 );
 997      did_action( 'init' ) && $scripts->localize(
 998          'quicktags',
 999          'quicktagsL10n',
1000          array(
1001              'closeAllOpenTags'      => __( 'Close all open tags' ),
1002              'closeTags'             => __( 'close tags' ),
1003              'enterURL'              => __( 'Enter the URL' ),
1004              'enterImageURL'         => __( 'Enter the URL of the image' ),
1005              'enterImageDescription' => __( 'Enter a description of the image' ),
1006              'textdirection'         => __( 'text direction' ),
1007              'toggleTextdirection'   => __( 'Toggle Editor Text Direction' ),
1008              'dfw'                   => __( 'Distraction-free writing mode' ),
1009              'strong'                => __( 'Bold' ),
1010              'strongClose'           => __( 'Close bold tag' ),
1011              'em'                    => __( 'Italic' ),
1012              'emClose'               => __( 'Close italic tag' ),
1013              'link'                  => __( 'Insert link' ),
1014              'blockquote'            => __( 'Blockquote' ),
1015              'blockquoteClose'       => __( 'Close blockquote tag' ),
1016              'del'                   => __( 'Deleted text (strikethrough)' ),
1017              'delClose'              => __( 'Close deleted text tag' ),
1018              'ins'                   => __( 'Inserted text' ),
1019              'insClose'              => __( 'Close inserted text tag' ),
1020              'image'                 => __( 'Insert image' ),
1021              'ul'                    => __( 'Bulleted list' ),
1022              'ulClose'               => __( 'Close bulleted list tag' ),
1023              'ol'                    => __( 'Numbered list' ),
1024              'olClose'               => __( 'Close numbered list tag' ),
1025              'li'                    => __( 'List item' ),
1026              'liClose'               => __( 'Close list item tag' ),
1027              'code'                  => __( 'Code' ),
1028              'codeClose'             => __( 'Close code tag' ),
1029              'more'                  => __( 'Insert Read More tag' ),
1030          )
1031      );
1032  
1033      $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array( 'prototype' ), '3517m' );
1034  
1035      $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array( 'utils', 'jquery' ), false, 1 );
1036  
1037      $scripts->add( 'clipboard', "/wp-includes/js/clipboard$suffix.js", array(), false, 1 );
1038  
1039      // Back-compat for old DFW. To-do: remove at the end of 2016.
1040      $scripts->add( 'wp-fullscreen-stub', "/wp-admin/js/wp-fullscreen-stub$suffix.js", array(), false, 1 );
1041  
1042      $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array( 'jquery' ), false, 1 );
1043      did_action( 'init' ) && $scripts->localize(
1044          'wp-ajax-response',
1045          'wpAjax',
1046          array(
1047              'noPerm' => __( 'Sorry, you are not allowed to do that.' ),
1048              'broken' => __( 'Something went wrong.' ),
1049          )
1050      );
1051  
1052      $scripts->add( 'wp-api-request', "/wp-includes/js/api-request$suffix.js", array( 'jquery' ), false, 1 );
1053      // `wpApiSettings` is also used by `wp-api`, which depends on this script.
1054      did_action( 'init' ) && $scripts->localize(
1055          'wp-api-request',
1056          'wpApiSettings',
1057          array(
1058              'root'          => esc_url_raw( get_rest_url() ),
1059              'nonce'         => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ),
1060              'versionString' => 'wp/v2/',
1061          )
1062      );
1063  
1064      $scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), '20111129a', 1 );
1065      did_action( 'init' ) && $scripts->localize(
1066          'wp-pointer',
1067          'wpPointerL10n',
1068          array(
1069              'dismiss' => __( 'Dismiss' ),
1070          )
1071      );
1072  
1073      $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array( 'heartbeat' ), false, 1 );
1074  
1075      $scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array( 'jquery', 'wp-hooks' ), false, 1 );
1076      did_action( 'init' ) && $scripts->localize(
1077          'heartbeat',
1078          'heartbeatSettings',
1079          /**
1080           * Filters the Heartbeat settings.
1081           *
1082           * @since 3.6.0
1083           *
1084           * @param array $settings Heartbeat settings array.
1085           */
1086          apply_filters( 'heartbeat_settings', array() )
1087      );
1088  
1089      $scripts->add( 'wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array( 'heartbeat' ), false, 1 );
1090      did_action( 'init' ) && $scripts->localize(
1091          'wp-auth-check',
1092          'authcheckL10n',
1093          array(
1094              'beforeunload' => __( 'Your session has expired. You can log in again from this page or go to the login page.' ),
1095  
1096              /**
1097               * Filters the authentication check interval.
1098               *
1099               * @since 3.6.0
1100               *
1101               * @param int $interval The interval in which to check a user's authentication.
1102               *                      Default 3 minutes in seconds, or 180.
1103               */
1104              'interval'     => apply_filters( 'wp_auth_check_interval', 3 * MINUTE_IN_SECONDS ),
1105          )
1106      );
1107  
1108      $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 );
1109  
1110      // WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source.
1111      $scripts->add( 'prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1' );
1112      $scripts->add( 'scriptaculous-root', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array( 'prototype' ), '1.9.0' );
1113      $scripts->add( 'scriptaculous-builder', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array( 'scriptaculous-root' ), '1.9.0' );
1114      $scripts->add( 'scriptaculous-dragdrop', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array( 'scriptaculous-builder', 'scriptaculous-effects' ), '1.9.0' );
1115      $scripts->add( 'scriptaculous-effects', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array( 'scriptaculous-root' ), '1.9.0' );
1116      $scripts->add( 'scriptaculous-slider', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array( 'scriptaculous-effects' ), '1.9.0' );
1117      $scripts->add( 'scriptaculous-sound', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' );
1118      $scripts->add( 'scriptaculous-controls', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array( 'scriptaculous-root' ), '1.9.0' );
1119      $scripts->add( 'scriptaculous', false, array( 'scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls' ) );
1120  
1121      // not used in core, replaced by Jcrop.js
1122      $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array( 'scriptaculous-dragdrop' ) );
1123  
1124      // jQuery
1125      $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.12.4-wp' );
1126      $scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.12.4-wp' );
1127      $scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.4.1' );
1128  
1129      // full jQuery UI
1130      $scripts->add( 'jquery-ui-core', "/wp-includes/js/jquery/ui/core$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
1131      $scripts->add( 'jquery-effects-core', "/wp-includes/js/jquery/ui/effect$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
1132  
1133      $scripts->add( 'jquery-effects-blind', "/wp-includes/js/jquery/ui/effect-blind$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1134      $scripts->add( 'jquery-effects-bounce', "/wp-includes/js/jquery/ui/effect-bounce$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1135      $scripts->add( 'jquery-effects-clip', "/wp-includes/js/jquery/ui/effect-clip$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1136      $scripts->add( 'jquery-effects-drop', "/wp-includes/js/jquery/ui/effect-drop$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1137      $scripts->add( 'jquery-effects-explode', "/wp-includes/js/jquery/ui/effect-explode$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1138      $scripts->add( 'jquery-effects-fade', "/wp-includes/js/jquery/ui/effect-fade$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1139      $scripts->add( 'jquery-effects-fold', "/wp-includes/js/jquery/ui/effect-fold$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1140      $scripts->add( 'jquery-effects-highlight', "/wp-includes/js/jquery/ui/effect-highlight$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1141      $scripts->add( 'jquery-effects-puff', "/wp-includes/js/jquery/ui/effect-puff$dev_suffix.js", array( 'jquery-effects-core', 'jquery-effects-scale' ), '1.11.4', 1 );
1142      $scripts->add( 'jquery-effects-pulsate', "/wp-includes/js/jquery/ui/effect-pulsate$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1143      $scripts->add( 'jquery-effects-scale', "/wp-includes/js/jquery/ui/effect-scale$dev_suffix.js", array( 'jquery-effects-core', 'jquery-effects-size' ), '1.11.4', 1 );
1144      $scripts->add( 'jquery-effects-shake', "/wp-includes/js/jquery/ui/effect-shake$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1145      $scripts->add( 'jquery-effects-size', "/wp-includes/js/jquery/ui/effect-size$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1146      $scripts->add( 'jquery-effects-slide', "/wp-includes/js/jquery/ui/effect-slide$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1147      $scripts->add( 'jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
1148  
1149      $scripts->add( 'jquery-ui-accordion', "/wp-includes/js/jquery/ui/accordion$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 );
1150      $scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$dev_suffix.js", array( 'jquery-ui-menu', 'wp-a11y' ), '1.11.4', 1 );
1151      $scripts->add( 'jquery-ui-button', "/wp-includes/js/jquery/ui/button$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 );
1152      $scripts->add( 'jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$dev_suffix.js", array( 'jquery-ui-core' ), '1.11.4', 1 );
1153      $scripts->add( 'jquery-ui-dialog', "/wp-includes/js/jquery/ui/dialog$dev_suffix.js", array( 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position' ), '1.11.4', 1 );
1154      $scripts->add( 'jquery-ui-draggable', "/wp-includes/js/jquery/ui/draggable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
1155      $scripts->add( 'jquery-ui-droppable', "/wp-includes/js/jquery/ui/droppable$dev_suffix.js", array( 'jquery-ui-draggable' ), '1.11.4', 1 );
1156      $scripts->add( 'jquery-ui-menu', "/wp-includes/js/jquery/ui/menu$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.4', 1 );
1157      $scripts->add( 'jquery-ui-mouse', "/wp-includes/js/jquery/ui/mouse$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 );
1158      $scripts->add( 'jquery-ui-position', "/wp-includes/js/jquery/ui/position$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
1159      $scripts->add( 'jquery-ui-progressbar', "/wp-includes/js/jquery/ui/progressbar$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 );
1160      $scripts->add( 'jquery-ui-resizable', "/wp-includes/js/jquery/ui/resizable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
1161      $scripts->add( 'jquery-ui-selectable', "/wp-includes/js/jquery/ui/selectable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
1162      $scripts->add( 'jquery-ui-selectmenu', "/wp-includes/js/jquery/ui/selectmenu$dev_suffix.js", array( 'jquery-ui-menu' ), '1.11.4', 1 );
1163      $scripts->add( 'jquery-ui-slider', "/wp-includes/js/jquery/ui/slider$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
1164      $scripts->add( 'jquery-ui-sortable', "/wp-includes/js/jquery/ui/sortable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
1165      $scripts->add( 'jquery-ui-spinner', "/wp-includes/js/jquery/ui/spinner$dev_suffix.js", array( 'jquery-ui-button' ), '1.11.4', 1 );
1166      $scripts->add( 'jquery-ui-tabs', "/wp-includes/js/jquery/ui/tabs$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 );
1167      $scripts->add( 'jquery-ui-tooltip', "/wp-includes/js/jquery/ui/tooltip$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.4', 1 );
1168      $scripts->add( 'jquery-ui-widget', "/wp-includes/js/jquery/ui/widget$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
1169  
1170      // Strings for 'jquery-ui-autocomplete' live region messages
1171      did_action( 'init' ) && $scripts->localize(
1172          'jquery-ui-autocomplete',
1173          'uiAutocompleteL10n',
1174          array(
1175              'noResults'    => __( 'No results found.' ),
1176              /* translators: Number of results found when using jQuery UI Autocomplete. */
1177              'oneResult'    => __( '1 result found. Use up and down arrow keys to navigate.' ),
1178              /* translators: %d: Number of results found when using jQuery UI Autocomplete. */
1179              'manyResults'  => __( '%d results found. Use up and down arrow keys to navigate.' ),
1180              'itemSelected' => __( 'Item selected.' ),
1181          )
1182      );
1183  
1184      // deprecated, not used in core, most functionality is included in jQuery 1.3
1185      $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array( 'jquery' ), '4.2.1', 1 );
1186  
1187      // jQuery plugins
1188      $scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.min.js', array( 'jquery' ), '2.1.2', 1 );
1189      $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array( 'jquery' ), '20m', 1 );
1190      $scripts->add( 'jquery-query', '/wp-includes/js/jquery/jquery.query.js', array( 'jquery' ), '2.1.7', 1 );
1191      $scripts->add( 'jquery-serialize-object', '/wp-includes/js/jquery/jquery.serialize-object.js', array( 'jquery' ), '0.2', 1 );
1192      $scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array( 'jquery' ), '0.0.2m', 1 );
1193      $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array( 'jquery', 'jquery-hotkeys' ), false, 1 );
1194      $scripts->add( 'jquery-touch-punch', '/wp-includes/js/jquery/jquery.ui.touch-punch.js', array( 'jquery-ui-widget', 'jquery-ui-mouse' ), '0.2.2', 1 );
1195  
1196      // Not used any more, registered for backward compatibility.
1197      $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array( 'jquery' ), '1.1-20110113', 1 );
1198  
1199      // Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv.
1200      // It sets jQuery as a dependency, as the theme may have been implicitly loading it this way.
1201      $scripts->add( 'imagesloaded', '/wp-includes/js/imagesloaded.min.js', array(), '3.2.0', 1 );
1202      $scripts->add( 'masonry', '/wp-includes/js/masonry.min.js', array( 'imagesloaded' ), '3.3.2', 1 );
1203      $scripts->add( 'jquery-masonry', "/wp-includes/js/jquery/jquery.masonry$dev_suffix.js", array( 'jquery', 'masonry' ), '3.1.2b', 1 );
1204  
1205      $scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array( 'jquery' ), '3.1-20121105', 1 );
1206      did_action( 'init' ) && $scripts->localize(
1207          'thickbox',
1208          'thickboxL10n',
1209          array(
1210              'next'             => __( 'Next &gt;' ),
1211              'prev'             => __( '&lt; Prev' ),
1212              'image'            => __( 'Image' ),
1213              'of'               => __( 'of' ),
1214              'close'            => __( 'Close' ),
1215              'noiframes'        => __( 'This feature requires inline frames. You have iframes disabled or your browser does not support them.' ),
1216              'loadingAnimation' => includes_url( 'js/thickbox/loadingAnimation.gif' ),
1217          )
1218      );
1219  
1220      $scripts->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.js', array( 'jquery' ), '0.9.12' );
1221  
1222      $scripts->add( 'swfobject', '/wp-includes/js/swfobject.js', array(), '2.2-20120417' );
1223  
1224      // Error messages for Plupload.
1225      $uploader_l10n = array(
1226          'queue_limit_exceeded'      => __( 'You have attempted to queue too many files.' ),
1227          /* translators: %s: File name. */
1228          'file_exceeds_size_limit'   => __( '%s exceeds the maximum upload size for this site.' ),
1229          'zero_byte_file'            => __( 'This file is empty. Please try another.' ),
1230          'invalid_filetype'          => __( 'Sorry, this file type is not permitted for security reasons.' ),
1231          'not_an_image'              => __( 'This file is not an image. Please try another.' ),
1232          'image_memory_exceeded'     => __( 'Memory exceeded. Please try another smaller file.' ),
1233          'image_dimensions_exceeded' => __( 'This is larger than the maximum size. Please try another.' ),
1234          'default_error'             => __( 'An error occurred in the upload. Please try again later.' ),
1235          'missing_upload_url'        => __( 'There was a configuration error. Please contact the server administrator.' ),
1236          'upload_limit_exceeded'     => __( 'You may only upload 1 file.' ),
1237          'http_error'                => __( 'Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.' ),
1238          'http_error_image'          => __( 'Post-processing of the image failed. If this is a photo or a large image, please scale it down to 2500 pixels and upload it again.' ),
1239          'upload_failed'             => __( 'Upload failed.' ),
1240          /* translators: 1: Opening link tag, 2: Closing link tag. */
1241          'big_upload_failed'         => __( 'Please try uploading this file with the %1$sbrowser uploader%2$s.' ),
1242          /* translators: %s: File name. */
1243          'big_upload_queued'         => __( '%s exceeds the maximum upload size for the multi-file uploader when used in your browser.' ),
1244          'io_error'                  => __( 'IO error.' ),
1245          'security_error'            => __( 'Security error.' ),
1246          'file_cancelled'            => __( 'File canceled.' ),
1247          'upload_stopped'            => __( 'Upload stopped.' ),
1248          'dismiss'                   => __( 'Dismiss' ),
1249          'crunching'                 => __( 'Crunching&hellip;' ),
1250          'deleted'                   => __( 'moved to the trash.' ),
1251          /* translators: %s: File name. */
1252          'error_uploading'           => __( '&#8220;%s&#8221; has failed to upload.' ),
1253      );
1254  
1255      $scripts->add( 'moxiejs', "/wp-includes/js/plupload/moxie$suffix.js", array(), '1.3.5' );
1256      $scripts->add( 'plupload', "/wp-includes/js/plupload/plupload$suffix.js", array( 'moxiejs' ), '2.1.9' );
1257      // Back compat handles:
1258      foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) {
1259          $scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' );
1260      }
1261  
1262      $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'plupload', 'jquery' ) );
1263      did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
1264  
1265      $scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 );
1266      did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n );
1267  
1268      // keep 'swfupload' for back-compat.
1269      $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', array(), '2201-20110113' );
1270      $scripts->add( 'swfupload-all', false, array( 'swfupload' ), '2201' );
1271      $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array( 'swfupload-all', 'jquery' ), '2201-20110524' );
1272      did_action( 'init' ) && $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', $uploader_l10n );
1273  
1274      $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 );
1275  
1276      $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' );
1277      did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' );
1278  
1279      $scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.8.3', 1 );
1280      $scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.4.0', 1 );
1281  
1282      $scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array( 'underscore', 'jquery' ), false, 1 );
1283      did_action( 'init' ) && $scripts->localize(
1284          'wp-util',
1285          '_wpUtilSettings',
1286          array(
1287              'ajax' => array(
1288                  'url' => admin_url( 'admin-ajax.php', 'relative' ),
1289              ),
1290          )
1291      );
1292  
1293      $scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array( 'backbone', 'wp-util' ), false, 1 );
1294  
1295      $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverIntent' ), false, 1 );
1296  
1297      $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array( 'jquery' ), false, 1 );
1298  
1299      $scripts->add( 'mediaelement', false, array( 'jquery', 'mediaelement-core', 'mediaelement-migrate' ), '4.2.13-9993131', 1 );
1300      $scripts->add( 'mediaelement-core', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array(), '4.2.13-9993131', 1 );
1301      $scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1 );
1302  
1303      did_action( 'init' ) && $scripts->add_inline_script(
1304          'mediaelement-core',
1305          sprintf(
1306              'var mejsL10n = %s;',
1307              wp_json_encode(
1308                  array(
1309                      'language' => strtolower( strtok( determine_locale(), '_-' ) ),
1310                      'strings'  => array(
1311                          'mejs.install-flash'       => __( 'You are using a browser that does not have Flash player enabled or installed. Please turn on your Flash player plugin or download the latest version from https://get.adobe.com/flashplayer/' ),
1312                          'mejs.fullscreen-off'      => __( 'Turn off Fullscreen' ),
1313                          'mejs.fullscreen-on'       => __( 'Go Fullscreen' ),
1314                          'mejs.download-video'      => __( 'Download Video' ),
1315                          'mejs.fullscreen'          => __( 'Fullscreen' ),
1316                          'mejs.time-jump-forward'   => array( __( 'Jump forward 1 second' ), __( 'Jump forward %1 seconds' ) ),
1317                          'mejs.loop'                => __( 'Toggle Loop' ),
1318                          'mejs.play'                => __( 'Play' ),
1319                          'mejs.pause'               => __( 'Pause' ),
1320                          'mejs.close'               => __( 'Close' ),
1321                          'mejs.time-slider'         => __( 'Time Slider' ),
1322                          'mejs.time-help-text'      => __( 'Use Left/Right Arrow keys to advance one second, Up/Down arrows to advance ten seconds.' ),
1323                          'mejs.time-skip-back'      => array( __( 'Skip back 1 second' ), __( 'Skip back %1 seconds' ) ),
1324                          'mejs.captions-subtitles'  => __( 'Captions/Subtitles' ),
1325                          'mejs.captions-chapters'   => __( 'Chapters' ),
1326                          'mejs.none'                => __( 'None' ),
1327                          'mejs.mute-toggle'         => __( 'Mute Toggle' ),
1328                          'mejs.volume-help-text'    => __( 'Use Up/Down Arrow keys to increase or decrease volume.' ),
1329                          'mejs.unmute'              => __( 'Unmute' ),
1330                          'mejs.mute'                => __( 'Mute' ),
1331                          'mejs.volume-slider'       => __( 'Volume Slider' ),
1332                          'mejs.video-player'        => __( 'Video Player' ),
1333                          'mejs.audio-player'        => __( 'Audio Player' ),
1334                          'mejs.ad-skip'             => __( 'Skip ad' ),
1335                          'mejs.ad-skip-info'        => array( __( 'Skip in 1 second' ), __( 'Skip in %1 seconds' ) ),
1336                          'mejs.source-chooser'      => __( 'Source Chooser' ),
1337                          'mejs.stop'                => __( 'Stop' ),
1338                          'mejs.speed-rate'          => __( 'Speed Rate' ),
1339                          'mejs.live-broadcast'      => __( 'Live Broadcast' ),
1340                          'mejs.afrikaans'           => __( 'Afrikaans' ),
1341                          'mejs.albanian'            => __( 'Albanian' ),
1342                          'mejs.arabic'              => __( 'Arabic' ),
1343                          'mejs.belarusian'          => __( 'Belarusian' ),
1344                          'mejs.bulgarian'           => __( 'Bulgarian' ),
1345                          'mejs.catalan'             => __( 'Catalan' ),
1346                          'mejs.chinese'             => __( 'Chinese' ),
1347                          'mejs.chinese-simplified'  => __( 'Chinese (Simplified)' ),
1348                          'mejs.chinese-traditional' => __( 'Chinese (Traditional)' ),
1349                          'mejs.croatian'            => __( 'Croatian' ),
1350                          'mejs.czech'               => __( 'Czech' ),
1351                          'mejs.danish'              => __( 'Danish' ),
1352                          'mejs.dutch'               => __( 'Dutch' ),
1353                          'mejs.english'             => __( 'English' ),
1354                          'mejs.estonian'            => __( 'Estonian' ),
1355                          'mejs.filipino'            => __( 'Filipino' ),
1356                          'mejs.finnish'             => __( 'Finnish' ),
1357                          'mejs.french'              => __( 'French' ),
1358                          'mejs.galician'            => __( 'Galician' ),
1359                          'mejs.german'              => __( 'German' ),
1360                          'mejs.greek'               => __( 'Greek' ),
1361                          'mejs.haitian-creole'      => __( 'Haitian Creole' ),
1362                          'mejs.hebrew'              => __( 'Hebrew' ),
1363                          'mejs.hindi'               => __( 'Hindi' ),
1364                          'mejs.hungarian'           => __( 'Hungarian' ),
1365                          'mejs.icelandic'           => __( 'Icelandic' ),
1366                          'mejs.indonesian'          => __( 'Indonesian' ),
1367                          'mejs.irish'               => __( 'Irish' ),
1368                          'mejs.italian'             => __( 'Italian' ),
1369                          'mejs.japanese'            => __( 'Japanese' ),
1370                          'mejs.korean'              => __( 'Korean' ),
1371                          'mejs.latvian'             => __( 'Latvian' ),
1372                          'mejs.lithuanian'          => __( 'Lithuanian' ),
1373                          'mejs.macedonian'          => __( 'Macedonian' ),
1374                          'mejs.malay'               => __( 'Malay' ),
1375                          'mejs.maltese'             => __( 'Maltese' ),
1376                          'mejs.norwegian'           => __( 'Norwegian' ),
1377                          'mejs.persian'             => __( 'Persian' ),
1378                          'mejs.polish'              => __( 'Polish' ),
1379                          'mejs.portuguese'          => __( 'Portuguese' ),
1380                          'mejs.romanian'            => __( 'Romanian' ),
1381                          'mejs.russian'             => __( 'Russian' ),
1382                          'mejs.serbian'             => __( 'Serbian' ),
1383                          'mejs.slovak'              => __( 'Slovak' ),
1384                          'mejs.slovenian'           => __( 'Slovenian' ),
1385                          'mejs.spanish'             => __( 'Spanish' ),
1386                          'mejs.swahili'             => __( 'Swahili' ),
1387                          'mejs.swedish'             => __( 'Swedish' ),
1388                          'mejs.tagalog'             => __( 'Tagalog' ),
1389                          'mejs.thai'                => __( 'Thai' ),
1390                          'mejs.turkish'             => __( 'Turkish' ),
1391                          'mejs.ukrainian'           => __( 'Ukrainian' ),
1392                          'mejs.vietnamese'          => __( 'Vietnamese' ),
1393                          'mejs.welsh'               => __( 'Welsh' ),
1394                          'mejs.yiddish'             => __( 'Yiddish' ),
1395                      ),
1396                  )
1397              )
1398          ),
1399          'before'
1400      );
1401  
1402      $scripts->add( 'mediaelement-vimeo', '/wp-includes/js/mediaelement/renderers/vimeo.min.js', array( 'mediaelement' ), '4.2.13-9993131', 1 );
1403      $scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.js", array( 'mediaelement' ), false, 1 );
1404      $mejs_settings = array(
1405          'pluginPath'  => includes_url( 'js/mediaelement/', 'relative' ),
1406          'classPrefix' => 'mejs-',
1407          'stretching'  => 'responsive',
1408      );
1409      did_action( 'init' ) && $scripts->localize(
1410          'mediaelement',
1411          '_wpmejsSettings',
1412          /**
1413           * Filters the MediaElement configuration settings.
1414           *
1415           * @since 4.4.0
1416           *
1417           * @param array $mejs_settings MediaElement settings array.
1418           */
1419          apply_filters( 'mejs_settings', $mejs_settings )
1420      );
1421  
1422      $scripts->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.js', array(), '5.29.1-alpha-ee20357' );
1423      $scripts->add( 'csslint', '/wp-includes/js/codemirror/csslint.js', array(), '1.0.5' );
1424      $scripts->add( 'esprima', '/wp-includes/js/codemirror/esprima.js', array(), '4.0.0' );
1425      $scripts->add( 'jshint', '/wp-includes/js/codemirror/fakejshint.js', array( 'esprima' ), '2.9.5' );
1426      $scripts->add( 'jsonlint', '/wp-includes/js/codemirror/jsonlint.js', array(), '1.6.2' );
1427      $scripts->add( 'htmlhint', '/wp-includes/js/codemirror/htmlhint.js', array(), '0.9.14-xwp' );
1428      $scripts->add( 'htmlhint-kses', '/wp-includes/js/codemirror/htmlhint-kses.js', array( 'htmlhint' ) );
1429      $scripts->add( 'code-editor', "/wp-admin/js/code-editor$suffix.js", array( 'jquery', 'wp-codemirror', 'underscore' ) );
1430      $scripts->add( 'wp-theme-plugin-editor', "/wp-admin/js/theme-plugin-editor$suffix.js", array( 'wp-util', 'wp-sanitize', 'jquery', 'jquery-ui-core', 'wp-a11y', 'underscore' ) );
1431      did_action( 'init' ) && $scripts->add_inline_script(
1432          'wp-theme-plugin-editor',
1433          sprintf(
1434              'wp.themePluginEditor.l10n = %s;',
1435              wp_json_encode(
1436                  array(
1437                      'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
1438                      'saveError' => __( 'Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP.' ),
1439                      'lintError' => array(
1440                          /* translators: %d: Error count. */
1441                          'singular' => _n( 'There is %d error which must be fixed before you can update this file.', 'There are %d errors which must be fixed before you can update this file.', 1 ),
1442                          /* translators: %d: Error count. */
1443                          'plural'   => _n( 'There is %d error which must be fixed before you can update this file.', 'There are %d errors which must be fixed before you can update this file.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
1444                      ),
1445                  )
1446              )
1447          )
1448      );
1449  
1450      $scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist$suffix.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 );
1451  
1452      $scripts->add( 'zxcvbn-async', "/wp-includes/js/zxcvbn-async$suffix.js", array(), '1.0' );
1453      did_action( 'init' ) && $scripts->localize(
1454          'zxcvbn-async',
1455          '_zxcvbnSettings',
1456          array(
1457              'src' => empty( $guessed_url ) ? includes_url( '/js/zxcvbn.min.js' ) : $scripts->base_url . '/wp-includes/js/zxcvbn.min.js',
1458          )
1459      );
1460  
1461      $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 );
1462      did_action( 'init' ) && $scripts->localize(
1463          'password-strength-meter',
1464          'pwsL10n',
1465          array(
1466              'unknown'  => _x( 'Password strength unknown', 'password strength' ),
1467              'short'    => _x( 'Very weak', 'password strength' ),
1468              'bad'      => _x( 'Weak', 'password strength' ),
1469              'good'     => _x( 'Medium', 'password strength' ),
1470              'strong'   => _x( 'Strong', 'password strength' ),
1471              'mismatch' => _x( 'Mismatch', 'password mismatch' ),
1472          )
1473      );
1474  
1475      $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 );
1476      did_action( 'init' ) && $scripts->localize(
1477          'user-profile',
1478          'userProfileL10n',
1479          array(
1480              'warn'     => __( 'Your new password has not been saved.' ),
1481              'warnWeak' => __( 'Confirm use of weak password' ),
1482              'show'     => __( 'Show' ),
1483              'hide'     => __( 'Hide' ),
1484              'cancel'   => __( 'Cancel' ),
1485              'ariaShow' => esc_attr__( 'Show password' ),
1486              'ariaHide' => esc_attr__( 'Hide password' ),
1487          )
1488      );
1489  
1490      $scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 );
1491  
1492      $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
1493  
1494      $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 );
1495  
1496      $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
1497      did_action( 'init' ) && $scripts->localize(
1498          'wplink',
1499          'wpLinkL10n',
1500          array(
1501              'title'          => __( 'Insert/edit link' ),
1502              'update'         => __( 'Update' ),
1503              'save'           => __( 'Add Link' ),
1504              'noTitle'        => __( '(no title)' ),
1505              'noMatchesFound' => __( 'No results found.' ),
1506              'linkSelected'   => __( 'Link selected.' ),
1507              'linkInserted'   => __( 'Link inserted.' ),
1508          )
1509      );
1510  
1511      $scripts->add( 'wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 );
1512  
1513      $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 );
1514  
1515      $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 );
1516  
1517      $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array( 'jquery' ), '1.8.1', 1 );
1518  
1519      $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 );
1520      $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 );
1521      $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'wp-a11y', 'customize-base' ), false, 1 );
1522      $scripts->add( 'customize-models', '/wp-includes/js/customize-models.js', array( 'underscore', 'backbone' ), false, 1 );
1523      $scripts->add( 'customize-views', '/wp-includes/js/customize-views.js', array( 'jquery', 'underscore', 'imgareaselect', 'customize-models', 'media-editor', 'media-views' ), false, 1 );
1524      $scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base', 'wp-a11y', 'wp-util', 'jquery-ui-core' ), false, 1 );
1525      did_action( 'init' ) && $scripts->localize(
1526          'customize-controls',
1527          '_wpCustomizeControlsL10n',
1528          array(
1529              'activate'                => __( 'Activate &amp; Publish' ),
1530              'save'                    => __( 'Save &amp; Publish' ), // @todo Remove as not required.
1531              'publish'                 => __( 'Publish' ),
1532              'published'               => __( 'Published' ),
1533              'saveDraft'               => __( 'Save Draft' ),
1534              'draftSaved'              => __( 'Draft Saved' ),
1535              'updating'                => __( 'Updating' ),
1536              'schedule'                => _x( 'Schedule', 'customizer changeset action/button label' ),
1537              'scheduled'               => _x( 'Scheduled', 'customizer changeset status' ),
1538              'invalid'                 => __( 'Invalid' ),
1539              'saveBeforeShare'         => __( 'Please save your changes in order to share the preview.' ),
1540              'futureDateError'         => __( 'You must supply a future date to schedule.' ),
1541              'saveAlert'               => __( 'The changes you made will be lost if you navigate away from this page.' ),
1542              'saved'                   => __( 'Saved' ),
1543              'cancel'                  => __( 'Cancel' ),
1544              'close'                   => __( 'Close' ),
1545              'action'                  => __( 'Action' ),
1546              'discardChanges'          => __( 'Discard changes' ),
1547              'cheatin'                 => __( 'Something went wrong.' ),
1548              'notAllowedHeading'       => __( 'You need a higher level of permission.' ),
1549              'notAllowed'              => __( 'Sorry, you are not allowed to customize this site.' ),
1550              'previewIframeTitle'      => __( 'Site Preview' ),
1551              'loginIframeTitle'        => __( 'Session expired' ),
1552              'collapseSidebar'         => _x( 'Hide Controls', 'label for hide controls button without length constraints' ),
1553              'expandSidebar'           => _x( 'Show Controls', 'label for hide controls button without length constraints' ),
1554              'untitledBlogName'        => __( '(Untitled)' ),
1555              'unknownRequestFail'      => __( 'Looks like something&#8217;s gone wrong. Wait a couple seconds, and then try again.' ),
1556              'themeDownloading'        => __( 'Downloading your new theme&hellip;' ),
1557              'themePreviewWait'        => __( 'Setting up your live preview. This may take a bit.' ),
1558              'revertingChanges'        => __( 'Reverting unpublished changes&hellip;' ),
1559              'trashConfirm'            => __( 'Are you sure you want to discard your unpublished changes?' ),
1560              /* translators: %s: Display name of the user who has taken over the changeset in customizer. */
1561              'takenOverMessage'        => __( '%s has taken over and is currently customizing.' ),
1562              /* translators: %s: URL to the Customizer to load the autosaved version. */
1563              'autosaveNotice'          => __( 'There is a more recent autosave of your changes than the one you are previewing. <a href="%s">Restore the autosave</a>' ),
1564              'videoHeaderNotice'       => __( 'This theme doesn&#8217;t support video headers on this page. Navigate to the front page or another page that supports video headers.' ),
1565              // Used for overriding the file types allowed in plupload.
1566              'allowedFiles'            => __( 'Allowed Files' ),
1567              'customCssError'          => array(
1568                  /* translators: %d: Error count. */
1569                  'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ),
1570                  /* translators: %d: Error count. */
1571                  'plural'   => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
1572              ),
1573              'pageOnFrontError'        => __( 'Homepage and posts page must be different.' ),
1574              'saveBlockedError'        => array(
1575                  /* translators: %s: Number of invalid settings. */
1576                  'singular' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 1 ),
1577                  /* translators: %s: Number of invalid settings. */
1578                  'plural'   => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
1579              ),
1580              'scheduleDescription'     => __( 'Schedule your customization changes to publish ("go live") at a future date.' ),
1581              'themePreviewUnavailable' => __( 'Sorry, you can&#8217;t preview new themes when you have changes scheduled or saved as a draft. Please publish your changes, or wait until they publish to preview new themes.' ),
1582              'themeInstallUnavailable' => sprintf(
1583                  /* translators: %s: URL to Add Themes admin screen. */
1584                  __( 'You won&#8217;t be able to install new themes from here yet since your install requires SFTP credentials. For now, please <a href="%s">add themes in the admin</a>.' ),
1585                  esc_url( admin_url( 'theme-install.php' ) )
1586              ),
1587              'publishSettings'         => __( 'Publish Settings' ),
1588              'invalidDate'             => __( 'Invalid date.' ),
1589              'invalidValue'            => __( 'Invalid value.' ),
1590          )
1591      );
1592      $scripts->add( 'customize-selective-refresh', "/wp-includes/js/customize-selective-refresh$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 );
1593  
1594      $scripts->add( 'customize-widgets', "/wp-admin/js/customize-widgets$suffix.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-backbone', 'customize-controls' ), false, 1 );
1595      $scripts->add( 'customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 );
1596  
1597      $scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu', 'wp-sanitize' ), false, 1 );
1598      $scripts->add( 'customize-preview-nav-menus', "/wp-includes/js/customize-preview-nav-menus$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 );
1599  
1600      $scripts->add( 'wp-custom-header', "/wp-includes/js/wp-custom-header$suffix.js", array( 'wp-a11y' ), false, 1 );
1601  
1602      $scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 );
1603  
1604      $scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 );
1605      $scripts->add( 'media-models', "/wp-includes/js/media-models$suffix.js", array( 'wp-backbone' ), false, 1 );
1606      did_action( 'init' ) && $scripts->localize(
1607          'media-models',
1608          '_wpMediaModelsL10n',
1609          array(
1610              'settings' => array(
1611                  'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
1612                  'post'    => array( 'id' => 0 ),
1613              ),
1614          )
1615      );
1616  
1617      $scripts->add( 'wp-embed', "/wp-includes/js/wp-embed$suffix.js" );
1618  
1619      // To enqueue media-views or media-editor, call wp_enqueue_media().
1620      // Both rely on numerous settings, styles, and templates to operate correctly.
1621      $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'wp-api-request', 'wp-a11y', 'wp-i18n' ), false, 1 );
1622      $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
1623      $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
1624      $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 );
1625  
1626      $scripts->add( 'wp-api', "/wp-includes/js/wp-api$suffix.js", array( 'jquery', 'backbone', 'underscore', 'wp-api-request' ), false, 1 );
1627  
1628      if ( is_admin() ) {
1629          $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 );
1630          did_action( 'init' ) && $scripts->localize(
1631              'admin-tags',
1632              'tagsl10n',
1633              array(
1634                  'noPerm' => __( 'Sorry, you are not allowed to do that.' ),
1635                  'broken' => __( 'Something went wrong.' ),
1636              )
1637          );
1638  
1639          $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array( 'wp-lists', 'quicktags', 'jquery-query' ), false, 1 );
1640          did_action( 'init' ) && $scripts->localize(
1641              'admin-comments',
1642              'adminCommentsL10n',
1643              array(
1644                  'hotkeys_highlight_first' => isset( $_GET['hotkeys_highlight_first'] ),
1645                  'hotkeys_highlight_last'  => isset( $_GET['hotkeys_highlight_last'] ),
1646                  'replyApprove'            => __( 'Approve and Reply' ),
1647                  'reply'                   => __( 'Reply' ),
1648                  'warnQuickEdit'           => __( "Are you sure you want to edit this comment?\nThe changes you made will be lost." ),
1649                  'warnCommentChanges'      => __( "Are you sure you want to do this?\nThe comment changes you made will be lost." ),
1650                  'docTitleComments'        => __( 'Comments' ),
1651                  /* translators: %s: Comments count. */
1652                  'docTitleCommentsCount'   => __( 'Comments (%s)' ),
1653              )
1654          );
1655  
1656          $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array( 'jquery' ), false, 1 );
1657  
1658          $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array( 'jquery-ui-sortable' ), false, 1 );
1659          did_action( 'init' ) && $scripts->localize(
1660              'postbox',
1661              'postBoxL10n',
1662              array(
1663                  'postBoxEmptyString' => __( 'Drag boxes here' ),
1664              )
1665          );
1666  
1667          $scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'tags-suggest' ), false, 1 );
1668  
1669          $scripts->add( 'tags-suggest', "/wp-admin/js/tags-suggest$suffix.js", array( 'jquery-ui-autocomplete', 'wp-a11y' ), false, 1 );
1670          did_action( 'init' ) && $scripts->localize(
1671              'tags-suggest',
1672              'tagsSuggestL10n',
1673              array(
1674                  'tagDelimiter' => _x( ',', 'tag delimiter' ),
1675                  'removeTerm'   => __( 'Remove term:' ),
1676                  'termSelected' => __( 'Term selected.' ),
1677                  'termAdded'    => __( 'Term added.' ),
1678                  'termRemoved'  => __( 'Term removed.' ),
1679              )
1680          );
1681  
1682          $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y', 'wp-sanitize' ), false, 1 );
1683          did_action( 'init' ) && $scripts->localize(
1684              'post',
1685              'postL10n',
1686              array(
1687                  'ok'                 => __( 'OK' ),
1688                  'cancel'             => __( 'Cancel' ),
1689                  'publishOn'          => __( 'Publish on:' ),
1690                  'publishOnFuture'    => __( 'Schedule for:' ),
1691                  'publishOnPast'      => __( 'Published on:' ),
1692                  /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
1693                  'dateFormat'         => __( '%1$s %2$s, %3$s at %4$s:%5$s' ),
1694                  'showcomm'           => __( 'Show more comments' ),
1695                  'endcomm'            => __( 'No more comments found.' ),
1696                  'publish'            => __( 'Publish' ),
1697                  'schedule'           => _x( 'Schedule', 'post action/button label' ),
1698                  'update'             => __( 'Update' ),
1699                  'savePending'        => __( 'Save as Pending' ),
1700                  'saveDraft'          => __( 'Save Draft' ),
1701                  'private'            => __( 'Private' ),
1702                  'public'             => __( 'Public' ),
1703                  'publicSticky'       => __( 'Public, Sticky' ),
1704                  'password'           => __( 'Password Protected' ),
1705                  'privatelyPublished' => __( 'Privately Published' ),
1706                  'published'          => __( 'Published' ),
1707                  'saveAlert'          => __( 'The changes you made will be lost if you navigate away from this page.' ),
1708                  'savingText'         => __( 'Saving Draft&#8230;' ),
1709                  'permalinkSaved'     => __( 'Permalink saved' ),
1710              )
1711          );
1712  
1713          $scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery', 'underscore' ), false, 1 );
1714  
1715          $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
1716  
1717          $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ) );
1718          $scripts->add_data( 'comment', 'group', 1 );
1719          did_action( 'init' ) && $scripts->localize(
1720              'comment',
1721              'commentL10n',
1722              array(
1723                  'submittedOn' => __( 'Submitted on:' ),
1724                  /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
1725                  'dateFormat'  => __( '%1$s %2$s, %3$s at %4$s:%5$s' ),
1726              )
1727          );
1728  
1729          $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) );
1730  
1731          $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 );
1732          did_action( 'init' ) && $scripts->add_inline_script(
1733              'admin-widgets',
1734              sprintf(
1735                  'wpWidgets.l10n = %s;',
1736                  wp_json_encode(
1737                      array(
1738                          'save'      => __( 'Save' ),
1739                          'saved'     => __( 'Saved' ),
1740                          'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
1741                      )
1742                  )
1743              )
1744          );
1745  
1746          $scripts->add( 'media-widgets', "/wp-admin/js/widgets/media-widgets$suffix.js", array( 'jquery', 'media-models', 'media-views', 'wp-api-request' ) );
1747          $scripts->add_inline_script( 'media-widgets', 'wp.mediaWidgets.init();', 'after' );
1748  
1749          $scripts->add( 'media-audio-widget', "/wp-admin/js/widgets/media-audio-widget$suffix.js", array( 'media-widgets', 'media-audiovideo' ) );
1750          $scripts->add( 'media-image-widget', "/wp-admin/js/widgets/media-image-widget$suffix.js", array( 'media-widgets' ) );
1751          $scripts->add( 'media-gallery-widget', "/wp-admin/js/widgets/media-gallery-widget$suffix.js", array( 'media-widgets' ) );
1752          $scripts->add( 'media-video-widget', "/wp-admin/js/widgets/media-video-widget$suffix.js", array( 'media-widgets', 'media-audiovideo', 'wp-api-request' ) );
1753          $scripts->add( 'text-widgets', "/wp-admin/js/widgets/text-widgets$suffix.js", array( 'jquery', 'backbone', 'editor', 'wp-util', 'wp-a11y' ) );
1754          $scripts->add( 'custom-html-widgets', "/wp-admin/js/widgets/custom-html-widgets$suffix.js", array( 'jquery', 'backbone', 'wp-util', 'jquery-ui-core', 'wp-a11y' ) );
1755  
1756          $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y', 'customize-base' ), false, 1 );
1757  
1758          $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'tags-suggest', 'wp-a11y' ), false, 1 );
1759          did_action( 'init' ) && $scripts->localize(
1760              'inline-edit-post',
1761              'inlineEditL10n',
1762              array(
1763                  'error'      => __( 'Error while saving the changes.' ),
1764                  'ntdeltitle' => __( 'Remove From Bulk Edit' ),
1765                  'notitle'    => __( '(no title)' ),
1766                  'comma'      => trim( _x( ',', 'tag delimiter' ) ),
1767                  'saved'      => __( 'Changes saved.' ),
1768              )
1769          );
1770  
1771          $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
1772          did_action( 'init' ) && $scripts->localize(
1773              'inline-edit-tax',
1774              'inlineEditL10n',
1775              array(
1776                  'error' => __( 'Error while saving the changes.' ),
1777                  'saved' => __( 'Changes saved.' ),
1778              )
1779          );
1780  
1781          $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 );
1782          did_action( 'init' ) && $scripts->localize(
1783              'plugin-install',
1784              'plugininstallL10n',
1785              array(
1786                  'plugin_information' => __( 'Plugin:' ),
1787                  'plugin_modal_label' => __( 'Plugin details' ),
1788                  'ays'                => __( 'Are you sure you want to install this plugin?' ),
1789              )
1790          );
1791  
1792          $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-i18n' ), false, 1 );
1793          $scripts->set_translations( 'site-health' );
1794  
1795          $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery' ), false, 1 );
1796          did_action( 'init' ) && $scripts->localize(
1797              'privacy-tools',
1798              'privacyToolsL10n',
1799              array(
1800                  'noDataFound'     => __( 'No personal data was found for this user.' ),
1801                  'foundAndRemoved' => __( 'All of the personal data found for this user was erased.' ),
1802                  'noneRemoved'     => __( 'Personal data was found for this user but was not erased.' ),
1803                  'someNotRemoved'  => __( 'Personal data was found for this user but some of the personal data found was not erased.' ),
1804                  'removalError'    => __( 'An error occurred while attempting to find and erase personal data.' ),
1805                  'emailSent'       => __( 'The personal data export link for this user was sent.' ),
1806                  'noExportFile'    => __( 'No personal data export file was generated.' ),
1807                  'exportError'     => __( 'An error occurred while attempting to export personal data.' ),
1808              )
1809          );
1810  
1811          $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 );
1812          did_action( 'init' ) && $scripts->localize(
1813              'updates',
1814              '_wpUpdatesSettings',
1815              array(
1816                  'ajax_nonce' => wp_create_nonce( 'updates' ),
1817                  'l10n'       => array(
1818                      /* translators: %s: Search query. */
1819                      'searchResults'            => __( 'Search results for &#8220;%s&#8221;' ),
1820                      'searchResultsLabel'       => __( 'Search Results' ),
1821                      'noPlugins'                => __( 'You do not appear to have any plugins available at this time.' ),
1822                      'noItemsSelected'          => __( 'Please select at least one item to perform this action on.' ),
1823                      'updating'                 => __( 'Updating...' ), // No ellipsis.
1824                      'pluginUpdated'            => _x( 'Updated!', 'plugin' ),
1825                      'themeUpdated'             => _x( 'Updated!', 'theme' ),
1826                      'update'                   => __( 'Update' ),
1827                      'updateNow'                => __( 'Update Now' ),
1828                      /* translators: %s: Plugin name and version. */
1829                      'pluginUpdateNowLabel'     => _x( 'Update %s now', 'plugin' ),
1830                      'updateFailedShort'        => __( 'Update Failed!' ),
1831                      /* translators: %s: Error string for a failed update. */
1832                      'updateFailed'             => __( 'Update Failed: %s' ),
1833                      /* translators: %s: Plugin name and version. */
1834                      'pluginUpdatingLabel'      => _x( 'Updating %s...', 'plugin' ), // No ellipsis.
1835                      /* translators: %s: Plugin name and version. */
1836                      'pluginUpdatedLabel'       => _x( '%s updated!', 'plugin' ),
1837                      /* translators: %s: Plugin name and version. */
1838                      'pluginUpdateFailedLabel'  => _x( '%s update failed', 'plugin' ),
1839                      /* translators: Accessibility text. */
1840                      'updatingMsg'              => __( 'Updating... please wait.' ), // No ellipsis.
1841                      /* translators: Accessibility text. */
1842                      'updatedMsg'               => __( 'Update completed successfully.' ),
1843                      /* translators: Accessibility text. */
1844                      'updateCancel'             => __( 'Update canceled.' ),
1845                      'beforeunload'             => __( 'Updates may not complete if you navigate away from this page.' ),
1846                      'installNow'               => __( 'Install Now' ),
1847                      /* translators: %s: Plugin name. */
1848                      'pluginInstallNowLabel'    => _x( 'Install %s now', 'plugin' ),
1849                      'installing'               => __( 'Installing...' ),
1850                      'pluginInstalled'          => _x( 'Installed!', 'plugin' ),
1851                      'themeInstalled'           => _x( 'Installed!', 'theme' ),
1852                      'installFailedShort'       => __( 'Installation Failed!' ),
1853                      /* translators: %s: Error string for a failed installation. */
1854                      'installFailed'            => __( 'Installation failed: %s' ),
1855                      /* translators: %s: Plugin name and version. */
1856                      'pluginInstallingLabel'    => _x( 'Installing %s...', 'plugin' ), // no ellipsis
1857                      /* translators: %s: Theme name and version. */
1858                      'themeInstallingLabel'     => _x( 'Installing %s...', 'theme' ), // no ellipsis
1859                      /* translators: %s: Plugin name and version. */
1860                      'pluginInstalledLabel'     => _x( '%s installed!', 'plugin' ),
1861                      /* translators: %s: Theme name and version. */
1862                      'themeInstalledLabel'      => _x( '%s installed!', 'theme' ),
1863                      /* translators: %s: Plugin name and version. */
1864                      'pluginInstallFailedLabel' => _x( '%s installation failed', 'plugin' ),
1865                      /* translators: %s: Theme name and version. */
1866                      'themeInstallFailedLabel'  => _x( '%s installation failed', 'theme' ),
1867                      'installingMsg'            => __( 'Installing... please wait.' ),
1868                      'installedMsg'             => __( 'Installation completed successfully.' ),
1869                      /* translators: %s: Activation URL. */
1870                      'importerInstalledMsg'     => __( 'Importer installed successfully. <a href="%s">Run importer</a>' ),
1871                      /* translators: %s: Theme name. */
1872                      'aysDelete'                => __( 'Are you sure you want to delete %s?' ),
1873                      /* translators: %s: Plugin name. */
1874                      'aysDeleteUninstall'       => __( 'Are you sure you want to delete %s and its data?' ),
1875                      'aysBulkDelete'            => __( 'Are you sure you want to delete the selected plugins and their data?' ),
1876                      'aysBulkDeleteThemes'      => __( 'Caution: These themes may be active on other sites in the network. Are you sure you want to proceed?' ),
1877                      'deleting'                 => __( 'Deleting...' ),
1878                      /* translators: %s: Error string for a failed deletion. */
1879                      'deleteFailed'             => __( 'Deletion failed: %s' ),
1880                      'pluginDeleted'            => _x( 'Deleted!', 'plugin' ),
1881                      'themeDeleted'             => _x( 'Deleted!', 'theme' ),
1882                      'livePreview'              => __( 'Live Preview' ),
1883                      'activatePlugin'           => is_network_admin() ? __( 'Network Activate' ) : __( 'Activate' ),
1884                      'activateTheme'            => is_network_admin() ? __( 'Network Enable' ) : __( 'Activate' ),
1885                      /* translators: %s: Plugin name. */
1886                      'activatePluginLabel'      => is_network_admin() ? _x( 'Network Activate %s', 'plugin' ) : _x( 'Activate %s', 'plugin' ),
1887                      /* translators: %s: Theme name. */
1888                      'activateThemeLabel'       => is_network_admin() ? _x( 'Network Activate %s', 'theme' ) : _x( 'Activate %s', 'theme' ),
1889                      'activateImporter'         => __( 'Run Importer' ),
1890                      /* translators: %s: Importer name. */
1891                      'activateImporterLabel'    => __( 'Run %s' ),
1892                      'unknownError'             => __( 'Something went wrong.' ),
1893                      'connectionError'          => __( 'Connection lost or the server is busy. Please try again later.' ),
1894                      'nonceError'               => __( 'An error has occurred. Please reload the page and try again.' ),
1895                      /* translators: %s: Number of plugins. */
1896                      'pluginsFound'             => __( 'Number of plugins found: %d' ),
1897                      'noPluginsFound'           => __( 'No plugins found. Try a different search.' ),
1898                  ),
1899              )
1900          );
1901  
1902          $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array( 'jquery' ), '1.2' );
1903  
1904          $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.0.7', 1 );
1905          $scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 );
1906          did_action( 'init' ) && $scripts->localize(
1907              'wp-color-picker',
1908              'wpColorPickerL10n',
1909              array(
1910                  'clear'            => __( 'Clear' ),
1911                  'clearAriaLabel'   => __( 'Clear color' ),
1912                  'defaultString'    => __( 'Default' ),
1913                  'defaultAriaLabel' => __( 'Select default color' ),
1914                  'pick'             => __( 'Select Color' ),
1915                  'defaultLabel'     => __( 'Color value' ),
1916              )
1917          );
1918  
1919          $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y' ), false, 1 );
1920  
1921          $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" );
1922  
1923          $scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 );
1924          $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 );
1925          did_action( 'init' ) && $scripts->localize(
1926              'media',
1927              'attachMediaBoxL10n',
1928              array(
1929                  'error' => __( 'An error has occurred. Please reload the page and try again.' ),
1930              )
1931          );
1932  
1933          $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'json2', 'imgareaselect' ), false, 1 );
1934          did_action( 'init' ) && $scripts->localize(
1935              'image-edit',
1936              'imageEditL10n',
1937              array(
1938                  'error' => __( 'Could not load the preview image. Please reload the page and try again.' ),
1939              )
1940          );
1941  
1942          $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
1943          did_action( 'init' ) && $scripts->localize(
1944              'set-post-thumbnail',
1945              'setPostThumbnailL10n',
1946              array(
1947                  'setThumbnail' => __( 'Use as featured image' ),
1948                  'saving'       => __( 'Saving...' ), // no ellipsis
1949                  'error'        => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
1950                  'done'         => __( 'Done' ),
1951              )
1952          );
1953  
1954          /*
1955           * Navigation Menus: Adding underscore as a dependency to utilize _.debounce
1956           * see https://core.trac.wordpress.org/ticket/42321
1957           */
1958          $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'json2', 'underscore' ) );
1959          did_action( 'init' ) && $scripts->localize(
1960              'nav-menu',
1961              'navMenuL10n',
1962              array(
1963                  'noResultsFound' => __( 'No results found.' ),
1964                  'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
1965                  'saveAlert'      => __( 'The changes you made will be lost if you navigate away from this page.' ),
1966                  'untitled'       => _x( '(no label)', 'missing menu item navigation label' ),
1967              )
1968          );
1969  
1970          $scripts->add( 'custom-header', '/wp-admin/js/custom-header.js', array( 'jquery-masonry' ), false, 1 );
1971          $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 );
1972          $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array( 'jquery' ), false, 1 );
1973  
1974          $scripts->add( 'svg-painter', '/wp-admin/js/svg-painter.js', array( 'jquery' ), false, 1 );
1975      }
1976  }
1977  
1978  /**
1979   * Assign default styles to $styles object.
1980   *
1981   * Nothing is returned, because the $styles parameter is passed by reference.
1982   * Meaning that whatever object is passed will be updated without having to
1983   * reassign the variable that was passed back to the same value. This saves
1984   * memory.
1985   *
1986   * Adding default styles is not the only task, it also assigns the base_url
1987   * property, the default version, and text direction for the object.
1988   *
1989   * @since 2.6.0
1990   *
1991   * @param WP_Styles $styles
1992   */
1993  function wp_default_styles( &$styles ) {
1994      include ( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
1995  
1996      if ( ! defined( 'SCRIPT_DEBUG' ) ) {
1997          define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) );
1998      }
1999  
2000      $guessurl = site_url();
2001  
2002      if ( ! $guessurl ) {
2003          $guessurl = wp_guess_url();
2004      }
2005  
2006      $styles->base_url        = $guessurl;
2007      $styles->content_url     = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : '';
2008      $styles->default_version = get_bloginfo( 'version' );
2009      $styles->text_direction  = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
2010      $styles->default_dirs    = array( '/wp-admin/', '/wp-includes/css/' );
2011  
2012      // Open Sans is no longer used by core, but may be relied upon by themes and plugins.
2013      $open_sans_font_url = '';
2014  
2015      /*
2016       * translators: If there are characters in your language that are not supported
2017       * by Open Sans, translate this to 'off'. Do not translate into your own language.
2018       */
2019      if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) {
2020          $subsets = 'latin,latin-ext';
2021  
2022          /*
2023           * translators: To add an additional Open Sans character subset specific to your language,
2024           * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language.
2025           */
2026          $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' );
2027  
2028          if ( 'cyrillic' === $subset ) {
2029              $subsets .= ',cyrillic,cyrillic-ext';
2030          } elseif ( 'greek' === $subset ) {
2031              $subsets .= ',greek,greek-ext';
2032          } elseif ( 'vietnamese' === $subset ) {
2033              $subsets .= ',vietnamese';
2034          }
2035  
2036          // Hotlink Open Sans, for now
2037          $open_sans_font_url = "https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets&display=fallback";
2038      }
2039  
2040      // Register a stylesheet for the selected admin color scheme.
2041      $styles->add( 'colors', true, array( 'wp-admin', 'buttons' ) );
2042  
2043      $suffix = SCRIPT_DEBUG ? '' : '.min';
2044  
2045      // Admin CSS
2046      $styles->add( 'common', "/wp-admin/css/common$suffix.css" );
2047      $styles->add( 'forms', "/wp-admin/css/forms$suffix.css" );
2048      $styles->add( 'admin-menu', "/wp-admin/css/admin-menu$suffix.css" );
2049      $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css" );
2050      $styles->add( 'list-tables', "/wp-admin/css/list-tables$suffix.css" );
2051      $styles->add( 'edit', "/wp-admin/css/edit$suffix.css" );
2052      $styles->add( 'revisions', "/wp-admin/css/revisions$suffix.css" );
2053      $styles->add( 'media', "/wp-admin/css/media$suffix.css" );
2054      $styles->add( 'themes', "/wp-admin/css/themes$suffix.css" );
2055      $styles->add( 'about', "/wp-admin/css/about$suffix.css" );
2056      $styles->add( 'nav-menus', "/wp-admin/css/nav-menus$suffix.css" );
2057      $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array( 'wp-pointer' ) );
2058      $styles->add( 'site-icon', "/wp-admin/css/site-icon$suffix.css" );
2059      $styles->add( 'l10n', "/wp-admin/css/l10n$suffix.css" );
2060      $styles->add( 'code-editor', "/wp-admin/css/code-editor$suffix.css", array( 'wp-codemirror' ) );
2061      $styles->add( 'site-health', "/wp-admin/css/site-health$suffix.css" );
2062  
2063      $styles->add( 'wp-admin', false, array( 'dashicons', 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n' ) );
2064  
2065      $styles->add( 'login', "/wp-admin/css/login$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) );
2066      $styles->add( 'install', "/wp-admin/css/install$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) );
2067      $styles->add( 'wp-color-picker', "/wp-admin/css/color-picker$suffix.css" );
2068      $styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie', 'imgareaselect' ) );
2069      $styles->add( 'customize-widgets', "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) );
2070      $styles->add( 'customize-nav-menus', "/wp-admin/css/customize-nav-menus$suffix.css", array( 'wp-admin', 'colors' ) );
2071  
2072      $styles->add( 'ie', "/wp-admin/css/ie$suffix.css" );
2073      $styles->add_data( 'ie', 'conditional', 'lte IE 7' );
2074  
2075      // Common dependencies
2076      $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" );
2077      $styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" );
2078  
2079      // Includes CSS
2080      $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array( 'dashicons' ) );
2081      $styles->add( 'wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) );
2082      $styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) );
2083      $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) );
2084      $styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) );
2085      $styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) );
2086      $styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" );
2087      $styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' );
2088  
2089      // External libraries and friends
2090      $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' );
2091      $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) );
2092      $styles->add( 'mediaelement', '/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css', array(), '4.2.13-9993131' );
2093      $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) );
2094      $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) );
2095      $styles->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.css', array(), '5.29.1-alpha-ee20357' );
2096  
2097      // Deprecated CSS
2098      $styles->add( 'deprecated-media', "/wp-admin/css/deprecated-media$suffix.css" );
2099      $styles->add( 'farbtastic', "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1' );
2100      $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.css', array(), '0.9.12' );
2101      $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle.
2102      $styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6
2103  
2104      // Packages styles
2105      $fonts_url = '';
2106  
2107      /*
2108       * translators: Use this to specify the proper Google Font name and variants
2109       * to load that is supported by your language. Do not translate.
2110       * Set to 'off' to disable loading.
2111       */
2112      $font_family = _x( 'Noto Serif:400,400i,700,700i', 'Google Font Name and Variants' );
2113      if ( 'off' !== $font_family ) {
2114          $fonts_url = 'https://fonts.googleapis.com/css?family=' . urlencode( $font_family );
2115      }
2116      $styles->add( 'wp-editor-font', $fonts_url );
2117  
2118      $styles->add( 'wp-block-library-theme', "/wp-includes/css/dist/block-library/theme$suffix.css" );
2119  
2120      $styles->add(
2121          'wp-edit-blocks',
2122          "/wp-includes/css/dist/block-library/editor$suffix.css",
2123          array(
2124              'wp-components',
2125              'wp-editor',
2126              'wp-block-library',
2127              // Always include visual styles so the editor never appears broken.
2128              'wp-block-library-theme',
2129          )
2130      );
2131  
2132      $package_styles = array(
2133          'block-editor'         => array(
2134              'wp-components',
2135              'wp-editor-font',
2136          ),
2137          'block-library'        => array(),
2138          'components'           => array(),
2139          'edit-post'            => array(
2140              'wp-components',
2141              'wp-block-editor',
2142              'wp-editor',
2143              'wp-edit-blocks',
2144              'wp-block-library',
2145              'wp-nux',
2146          ),
2147          'editor'               => array(
2148              'wp-components',
2149              'wp-block-editor',
2150              'wp-nux',
2151          ),
2152          'format-library'       => array(),
2153          'list-reusable-blocks' => array( 'wp-components' ),
2154          'nux'                  => array( 'wp-components' ),
2155      );
2156  
2157      foreach ( $package_styles as $package => $dependencies ) {
2158          $handle = 'wp-' . $package;
2159          $path   = "/wp-includes/css/dist/$package/style$suffix.css";
2160  
2161          $styles->add( $handle, $path, $dependencies );
2162      }
2163  
2164      // RTL CSS
2165      $rtl_styles = array(
2166          // Admin CSS
2167          'common',
2168          'forms',
2169          'admin-menu',
2170          'dashboard',
2171          'list-tables',
2172          'edit',
2173          'revisions',
2174          'media',
2175          'themes',
2176          'about',
2177          'nav-menus',
2178          'widgets',
2179          'site-icon',
2180          'l10n',
2181          'install',
2182          'wp-color-picker',
2183          'customize-controls',
2184          'customize-widgets',
2185          'customize-nav-menus',
2186          'customize-preview',
2187          'ie',
2188          'login',
2189          'site-health',
2190          // Includes CSS
2191          'buttons',
2192          'admin-bar',
2193          'wp-auth-check',
2194          'editor-buttons',
2195          'media-views',
2196          'wp-pointer',
2197          'wp-jquery-ui-dialog',
2198          // Package styles
2199          'wp-block-library-theme',
2200          'wp-edit-blocks',
2201          'wp-block-editor',
2202          'wp-block-library',
2203          'wp-components',
2204          'wp-edit-post',
2205          'wp-editor',
2206          'wp-format-library',
2207          'wp-list-reusable-blocks',
2208          'wp-nux',
2209          // Deprecated CSS
2210          'deprecated-media',
2211          'farbtastic',
2212      );
2213  
2214      foreach ( $rtl_styles as $rtl_style ) {
2215          $styles->add_data( $rtl_style, 'rtl', 'replace' );
2216          if ( $suffix ) {
2217              $styles->add_data( $rtl_style, 'suffix', $suffix );
2218          }
2219      }
2220  }
2221  
2222  /**
2223   * Reorder JavaScript scripts array to place prototype before jQuery.
2224   *
2225   * @since 2.3.1
2226   *
2227   * @param array $js_array JavaScript scripts array
2228   * @return array Reordered array, if needed.
2229   */
2230  function wp_prototype_before_jquery( $js_array ) {
2231      $prototype = array_search( 'prototype', $js_array, true );
2232  
2233      if ( false === $prototype ) {
2234          return $js_array;
2235      }
2236  
2237      $jquery = array_search( 'jquery', $js_array, true );
2238  
2239      if ( false === $jquery ) {
2240          return $js_array;
2241      }
2242  
2243      if ( $prototype < $jquery ) {
2244          return $js_array;
2245      }
2246  
2247      unset( $js_array[ $prototype ] );
2248  
2249      array_splice( $js_array, $jquery, 0, 'prototype' );
2250  
2251      return $js_array;
2252  }
2253  
2254  /**
2255   * Load localized data on print rather than initialization.
2256   *
2257   * These localizations require information that may not be loaded even by init.
2258   *
2259   * @since 2.5.0
2260   */
2261  function wp_just_in_time_script_localization() {
2262  
2263      wp_localize_script(
2264          'autosave',
2265          'autosaveL10n',
2266          array(
2267              'autosaveInterval' => AUTOSAVE_INTERVAL,
2268              'blog_id'          => get_current_blog_id(),
2269          )
2270      );
2271  
2272      wp_localize_script(
2273          'mce-view',
2274          'mceViewL10n',
2275          array(
2276              'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(),
2277          )
2278      );
2279  
2280      wp_localize_script(
2281          'word-count',
2282          'wordCountL10n',
2283          array(
2284              /*
2285               * translators: If your word count is based on single characters (e.g. East Asian characters),
2286               * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
2287               * Do not translate into your own language.
2288               */
2289              'type'       => _x( 'words', 'Word count type. Do not translate!' ),
2290              'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(),
2291          )
2292      );
2293  }
2294  
2295  /**
2296   * Localizes the jQuery UI datepicker.
2297   *
2298   * @since 4.6.0
2299   *
2300   * @link https://api.jqueryui.com/datepicker/#options
2301   *
2302   * @global WP_Locale $wp_locale WordPress date and time locale object.
2303   */
2304  function wp_localize_jquery_ui_datepicker() {
2305      global $wp_locale;
2306  
2307      if ( ! wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) {
2308          return;
2309      }
2310  
2311      // Convert the PHP date format into jQuery UI's format.
2312      $datepicker_date_format = str_replace(
2313          array(
2314              'd',
2315              'j',
2316              'l',
2317              'z', // Day.
2318              'F',
2319              'M',
2320              'n',
2321              'm', // Month.
2322              'Y',
2323              'y',            // Year.
2324          ),
2325          array(
2326              'dd',
2327              'd',
2328              'DD',
2329              'o',
2330              'MM',
2331              'M',
2332              'm',
2333              'mm',
2334              'yy',
2335              'y',
2336          ),
2337          get_option( 'date_format' )
2338      );
2339  
2340      $datepicker_defaults = wp_json_encode(
2341          array(
2342              'closeText'       => __( 'Close' ),
2343              'currentText'     => __( 'Today' ),
2344              'monthNames'      => array_values( $wp_locale->month ),
2345              'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
2346              'nextText'        => __( 'Next' ),
2347              'prevText'        => __( 'Previous' ),
2348              'dayNames'        => array_values( $wp_locale->weekday ),
2349              'dayNamesShort'   => array_values( $wp_locale->weekday_abbrev ),
2350              'dayNamesMin'     => array_values( $wp_locale->weekday_initial ),
2351              'dateFormat'      => $datepicker_date_format,
2352              'firstDay'        => absint( get_option( 'start_of_week' ) ),
2353              'isRTL'           => $wp_locale->is_rtl(),
2354          )
2355      );
2356  
2357      wp_add_inline_script( 'jquery-ui-datepicker', "jQuery(document).ready(function(jQuery){jQuery.datepicker.setDefaults({$datepicker_defaults});});" );
2358  }
2359  
2360  /**
2361   * Localizes community events data that needs to be passed to dashboard.js.
2362   *
2363   * @since 4.8.0
2364   */
2365  function wp_localize_community_events() {
2366      if ( ! wp_script_is( 'dashboard' ) ) {
2367          return;
2368      }
2369  
2370      require_once ( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' );
2371  
2372      $user_id            = get_current_user_id();
2373      $saved_location     = get_user_option( 'community-events-location', $user_id );
2374      $saved_ip_address   = isset( $saved_location['ip'] ) ? $saved_location['ip'] : false;
2375      $current_ip_address = WP_Community_Events::get_unsafe_client_ip();
2376  
2377      /*
2378       * If the user's location is based on their IP address, then update their
2379       * location when their IP address changes. This allows them to see events
2380       * in their current city when travelling. Otherwise, they would always be
2381       * shown events in the city where they were when they first loaded the
2382       * Dashboard, which could have been months or years ago.
2383       */
2384      if ( $saved_ip_address && $current_ip_address && $current_ip_address !== $saved_ip_address ) {
2385          $saved_location['ip'] = $current_ip_address;
2386          update_user_option( $user_id, 'community-events-location', $saved_location, true );
2387      }
2388  
2389      $events_client = new WP_Community_Events( $user_id, $saved_location );
2390  
2391      wp_localize_script(
2392          'dashboard',
2393          'communityEventsData',
2394          array(
2395              'nonce' => wp_create_nonce( 'community_events' ),
2396              'cache' => $events_client->get_cached_events(),
2397  
2398              'l10n'  => array(
2399                  'enter_closest_city'              => __( 'Enter your closest city to find nearby events.' ),
2400                  'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ),
2401                  'attend_event_near_generic'       => __( 'Attend an upcoming event near you.' ),
2402  
2403                  /*
2404                   * These specific examples were chosen to highlight the fact that a
2405                   * state is not needed, even for cities whose name is not unique.
2406                   * It would be too cumbersome to include that in the instructions
2407                   * to the user, so it's left as an implication.
2408                   */
2409                  /*
2410                   * translators: %s is the name of the city we couldn't locate.
2411                   * Replace the examples with cities related to your locale. Test that
2412                   * they match the expected location and have upcoming events before
2413                   * including them. If no cities related to your locale have events,
2414                   * then use cities related to your locale that would be recognizable
2415                   * to most users. Use only the city name itself, without any region
2416                   * or country. Use the endonym (native locale name) instead of the
2417                   * English name if possible.
2418                   */
2419                  'could_not_locate_city'           => __( 'We couldn&#8217;t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
2420  
2421                  // This one is only used with wp.a11y.speak(), so it can/should be more brief.
2422                  /* translators: %s: The name of a city. */
2423                  'city_updated'                    => __( 'City updated. Listing events near %s.' ),
2424              ),
2425          )
2426      );
2427  }
2428  
2429  /**
2430   * Administration Screen CSS for changing the styles.
2431   *
2432   * If installing the 'wp-admin/' directory will be replaced with './'.
2433   *
2434   * The $_wp_admin_css_colors global manages the Administration Screens CSS
2435   * stylesheet that is loaded. The option that is set is 'admin_color' and is the
2436   * color and key for the array. The value for the color key is an object with
2437   * a 'url' parameter that has the URL path to the CSS file.
2438   *
2439   * The query from $src parameter will be appended to the URL that is given from
2440   * the $_wp_admin_css_colors array value URL.
2441   *
2442   * @since 2.6.0
2443   * @global array $_wp_admin_css_colors
2444   *
2445   * @param string $src    Source URL.
2446   * @param string $handle Either 'colors' or 'colors-rtl'.
2447   * @return string|false URL path to CSS stylesheet for Administration Screens.
2448   */
2449  function wp_style_loader_src( $src, $handle ) {
2450      global $_wp_admin_css_colors;
2451  
2452      if ( wp_installing() ) {
2453          return preg_replace( '#^wp-admin/#', './', $src );
2454      }
2455  
2456      if ( 'colors' === $handle ) {
2457          $color = get_user_option( 'admin_color' );
2458  
2459          if ( empty( $color ) || ! isset( $_wp_admin_css_colors[ $color ] ) ) {
2460              $color = 'fresh';
2461          }
2462  
2463          $color = $_wp_admin_css_colors[ $color ];
2464          $url   = $color->url;
2465  
2466          if ( ! $url ) {
2467              return false;
2468          }
2469  
2470          $parsed = parse_url( $src );
2471          if ( isset( $parsed['query'] ) && $parsed['query'] ) {
2472              wp_parse_str( $parsed['query'], $qv );
2473              $url = add_query_arg( $qv, $url );
2474          }
2475  
2476          return $url;
2477      }
2478  
2479      return $src;
2480  }
2481  
2482  /**
2483   * Prints the script queue in the HTML head on admin pages.
2484   *
2485   * Postpones the scripts that were queued for the footer.
2486   * print_footer_scripts() is called in the footer to print these scripts.
2487   *
2488   * @since 2.8.0
2489   *
2490   * @see wp_print_scripts()
2491   *
2492   * @global bool $concatenate_scripts
2493   *
2494   * @return array
2495   */
2496  function print_head_scripts() {
2497      global $concatenate_scripts;
2498  
2499      if ( ! did_action( 'wp_print_scripts' ) ) {
2500          /** This action is documented in wp-includes/functions.wp-scripts.php */
2501          do_action( 'wp_print_scripts' );
2502      }
2503  
2504      $wp_scripts = wp_scripts();
2505  
2506      script_concat_settings();
2507      $wp_scripts->do_concat = $concatenate_scripts;
2508      $wp_scripts->do_head_items();
2509  
2510      /**
2511       * Filters whether to print the head scripts.
2512       *
2513       * @since 2.8.0
2514       *
2515       * @param bool $print Whether to print the head scripts. Default true.
2516       */
2517      if ( apply_filters( 'print_head_scripts', true ) ) {
2518          _print_scripts();
2519      }
2520  
2521      $wp_scripts->reset();
2522      return $wp_scripts->done;
2523  }
2524  
2525  /**
2526   * Prints the scripts that were queued for the footer or too late for the HTML head.
2527   *
2528   * @since 2.8.0
2529   *
2530   * @global WP_Scripts $wp_scripts
2531   * @global bool       $concatenate_scripts
2532   *
2533   * @return array
2534   */
2535  function print_footer_scripts() {
2536      global $wp_scripts, $concatenate_scripts;
2537  
2538      if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
2539          return array(); // No need to run if not instantiated.
2540      }
2541      script_concat_settings();
2542      $wp_scripts->do_concat = $concatenate_scripts;
2543      $wp_scripts->do_footer_items();
2544  
2545      /**
2546       * Filters whether to print the footer scripts.
2547       *
2548       * @since 2.8.0
2549       *
2550       * @param bool $print Whether to print the footer scripts. Default true.
2551       */
2552      if ( apply_filters( 'print_footer_scripts', true ) ) {
2553          _print_scripts();
2554      }
2555  
2556      $wp_scripts->reset();
2557      return $wp_scripts->done;
2558  }
2559  
2560  /**
2561   * Print scripts (internal use only)
2562   *
2563   * @ignore
2564   *
2565   * @global WP_Scripts $wp_scripts
2566   * @global bool       $compress_scripts
2567   */
2568  function _print_scripts() {
2569      global $wp_scripts, $compress_scripts;
2570  
2571      $zip = $compress_scripts ? 1 : 0;
2572      if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) {
2573          $zip = 'gzip';
2574      }
2575  
2576      $concat    = trim( $wp_scripts->concat, ', ' );
2577      $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : " type='text/javascript'";
2578  
2579      if ( $concat ) {
2580          if ( ! empty( $wp_scripts->print_code ) ) {
2581              echo "\n<script{$type_attr}>\n";
2582              echo "/* <![CDATA[ */\n"; // not needed in HTML 5
2583              echo $wp_scripts->print_code;
2584              echo "/* ]]> */\n";
2585              echo "</script>\n";
2586          }
2587  
2588          $concat       = str_split( $concat, 128 );
2589          $concatenated = '';
2590  
2591          foreach ( $concat as $key => $chunk ) {
2592              $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}";
2593          }
2594  
2595          $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version;
2596          echo "<script{$type_attr} src='" . esc_attr( $src ) . "'></script>\n";
2597      }
2598  
2599      if ( ! empty( $wp_scripts->print_html ) ) {
2600          echo $wp_scripts->print_html;
2601      }
2602  }
2603  
2604  /**
2605   * Prints the script queue in the HTML head on the front end.
2606   *
2607   * Postpones the scripts that were queued for the footer.
2608   * wp_print_footer_scripts() is called in the footer to print these scripts.
2609   *
2610   * @since 2.8.0
2611   *
2612   * @global WP_Scripts $wp_scripts
2613   *
2614   * @return array
2615   */
2616  function wp_print_head_scripts() {
2617      if ( ! did_action( 'wp_print_scripts' ) ) {
2618          /** This action is documented in wp-includes/functions.wp-scripts.php */
2619          do_action( 'wp_print_scripts' );
2620      }
2621  
2622      global $wp_scripts;
2623  
2624      if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
2625          return array(); // no need to run if nothing is queued
2626      }
2627      return print_head_scripts();
2628  }
2629  
2630  /**
2631   * Private, for use in *_footer_scripts hooks
2632   *
2633   * @since 3.3.0
2634   */
2635  function _wp_footer_scripts() {
2636      print_late_styles();
2637      print_footer_scripts();
2638  }
2639  
2640  /**
2641   * Hooks to print the scripts and styles in the footer.
2642   *
2643   * @since 2.8.0
2644   */
2645  function wp_print_footer_scripts() {
2646      /**
2647       * Fires when footer scripts are printed.
2648       *
2649       * @since 2.8.0
2650       */
2651      do_action( 'wp_print_footer_scripts' );
2652  }
2653  
2654  /**
2655   * Wrapper for do_action('wp_enqueue_scripts')
2656   *
2657   * Allows plugins to queue scripts for the front end using wp_enqueue_script().
2658   * Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.
2659   *
2660   * @since 2.8.0
2661   */
2662  function wp_enqueue_scripts() {
2663      /**
2664       * Fires when scripts and styles are enqueued.
2665       *
2666       * @since 2.8.0
2667       */
2668      do_action( 'wp_enqueue_scripts' );
2669  }
2670  
2671  /**
2672   * Prints the styles queue in the HTML head on admin pages.
2673   *
2674   * @since 2.8.0
2675   *
2676   * @global bool $concatenate_scripts
2677   *
2678   * @return array
2679   */
2680  function print_admin_styles() {
2681      global $concatenate_scripts;
2682  
2683      $wp_styles = wp_styles();
2684  
2685      script_concat_settings();
2686      $wp_styles->do_concat = $concatenate_scripts;
2687      $wp_styles->do_items( false );
2688  
2689      /**
2690       * Filters whether to print the admin styles.
2691       *
2692       * @since 2.8.0
2693       *
2694       * @param bool $print Whether to print the admin styles. Default true.
2695       */
2696      if ( apply_filters( 'print_admin_styles', true ) ) {
2697          _print_styles();
2698      }
2699  
2700      $wp_styles->reset();
2701      return $wp_styles->done;
2702  }
2703  
2704  /**
2705   * Prints the styles that were queued too late for the HTML head.
2706   *
2707   * @since 3.3.0
2708   *
2709   * @global WP_Styles $wp_styles
2710   * @global bool      $concatenate_scripts
2711   *
2712   * @return array|void
2713   */
2714  function print_late_styles() {
2715      global $wp_styles, $concatenate_scripts;
2716  
2717      if ( ! ( $wp_styles instanceof WP_Styles ) ) {
2718          return;
2719      }
2720  
2721      script_concat_settings();
2722      $wp_styles->do_concat = $concatenate_scripts;
2723      $wp_styles->do_footer_items();
2724  
2725      /**
2726       * Filters whether to print the styles queued too late for the HTML head.
2727       *
2728       * @since 3.3.0
2729       *
2730       * @param bool $print Whether to print the 'late' styles. Default true.
2731       */
2732      if ( apply_filters( 'print_late_styles', true ) ) {
2733          _print_styles();
2734      }
2735  
2736      $wp_styles->reset();
2737      return $wp_styles->done;
2738  }
2739  
2740  /**
2741   * Print styles (internal use only)
2742   *
2743   * @ignore
2744   * @since 3.3.0
2745   *
2746   * @global bool $compress_css
2747   */
2748  function _print_styles() {
2749      global $compress_css;
2750  
2751      $wp_styles = wp_styles();
2752  
2753      $zip = $compress_css ? 1 : 0;
2754      if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) {
2755          $zip = 'gzip';
2756      }
2757  
2758      $concat    = trim( $wp_styles->concat, ', ' );
2759      $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
2760  
2761      if ( $concat ) {
2762          $dir = $wp_styles->text_direction;
2763          $ver = $wp_styles->default_version;
2764  
2765          $concat       = str_split( $concat, 128 );
2766          $concatenated = '';
2767  
2768          foreach ( $concat as $key => $chunk ) {
2769              $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}";
2770          }
2771  
2772          $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}" . $concatenated . '&ver=' . $ver;
2773          echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "'{$type_attr} media='all' />\n";
2774  
2775          if ( ! empty( $wp_styles->print_code ) ) {
2776              echo "<style{$type_attr}>\n";
2777              echo $wp_styles->print_code;
2778              echo "\n</style>\n";
2779          }
2780      }
2781  
2782      if ( ! empty( $wp_styles->print_html ) ) {
2783          echo $wp_styles->print_html;
2784      }
2785  }
2786  
2787  /**
2788   * Determine the concatenation and compression settings for scripts and styles.
2789   *
2790   * @since 2.8.0
2791   *
2792   * @global bool $concatenate_scripts
2793   * @global bool $compress_scripts
2794   * @global bool $compress_css
2795   */
2796  function script_concat_settings() {
2797      global $concatenate_scripts, $compress_scripts, $compress_css;
2798  
2799      $compressed_output = ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) );
2800  
2801      if ( ! isset( $concatenate_scripts ) ) {
2802          $concatenate_scripts = defined( 'CONCATENATE_SCRIPTS' ) ? CONCATENATE_SCRIPTS : true;
2803          if ( ( ! is_admin() && ! did_action( 'login_init' ) ) || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) {
2804              $concatenate_scripts = false;
2805          }
2806      }
2807  
2808      if ( ! isset( $compress_scripts ) ) {
2809          $compress_scripts = defined( 'COMPRESS_SCRIPTS' ) ? COMPRESS_SCRIPTS : true;
2810          if ( $compress_scripts && ( ! get_site_option( 'can_compress_scripts' ) || $compressed_output ) ) {
2811              $compress_scripts = false;
2812          }
2813      }
2814  
2815      if ( ! isset( $compress_css ) ) {
2816          $compress_css = defined( 'COMPRESS_CSS' ) ? COMPRESS_CSS : true;
2817          if ( $compress_css && ( ! get_site_option( 'can_compress_scripts' ) || $compressed_output ) ) {
2818              $compress_css = false;
2819          }
2820      }
2821  }
2822  
2823  /**
2824   * Handles the enqueueing of block scripts and styles that are common to both
2825   * the editor and the front-end.
2826   *
2827   * @since 5.0.0
2828   *
2829   * @global WP_Screen $current_screen WordPress current screen object.
2830   */
2831  function wp_common_block_scripts_and_styles() {
2832      global $current_screen;
2833  
2834      if ( is_admin() && ( $current_screen instanceof WP_Screen ) && ! $current_screen->is_block_editor() ) {
2835          return;
2836      }
2837  
2838      wp_enqueue_style( 'wp-block-library' );
2839  
2840      if ( current_theme_supports( 'wp-block-styles' ) ) {
2841          wp_enqueue_style( 'wp-block-library-theme' );
2842      }
2843  
2844      /**
2845       * Fires after enqueuing block assets for both editor and front-end.
2846       *
2847       * Call `add_action` on any hook before 'wp_enqueue_scripts'.
2848       *
2849       * In the function call you supply, simply use `wp_enqueue_script` and
2850       * `wp_enqueue_style` to add your functionality to the Gutenberg editor.
2851       *
2852       * @since 5.0.0
2853       */
2854      do_action( 'enqueue_block_assets' );
2855  }
2856  
2857  /**
2858   * Enqueues registered block scripts and styles, depending on current rendered
2859   * context (only enqueuing editor scripts while in context of the editor).
2860   *
2861   * @since 5.0.0
2862   *
2863   * @global WP_Screen $current_screen WordPress current screen object.
2864   */
2865  function wp_enqueue_registered_block_scripts_and_styles() {
2866      global $current_screen;
2867  
2868      $is_editor = ( ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor() );
2869  
2870      $block_registry = WP_Block_Type_Registry::get_instance();
2871      foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {
2872          // Front-end styles.
2873          if ( ! empty( $block_type->style ) ) {
2874              wp_enqueue_style( $block_type->style );
2875          }
2876  
2877          // Front-end script.
2878          if ( ! empty( $block_type->script ) ) {
2879              wp_enqueue_script( $block_type->script );
2880          }
2881  
2882          // Editor styles.
2883          if ( $is_editor && ! empty( $block_type->editor_style ) ) {
2884              wp_enqueue_style( $block_type->editor_style );
2885          }
2886  
2887          // Editor script.
2888          if ( $is_editor && ! empty( $block_type->editor_script ) ) {
2889              wp_enqueue_script( $block_type->editor_script );
2890          }
2891      }
2892  }
2893  
2894  /**
2895   * Function responsible for enqueuing the styles required for block styles functionality on the editor and on the frontend.
2896   *
2897   * @since 5.3.0
2898   */
2899  function enqueue_block_styles_assets() {
2900      $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
2901  
2902      foreach ( $block_styles as $styles ) {
2903          foreach ( $styles as $style_properties ) {
2904              if ( isset( $style_properties['style_handle'] ) ) {
2905                  wp_enqueue_style( $style_properties['style_handle'] );
2906              }
2907              if ( isset( $style_properties['inline_style'] ) ) {
2908                  wp_add_inline_style( 'wp-block-library', $style_properties['inline_style'] );
2909              }
2910          }
2911      }
2912  }
2913  
2914  /**
2915   * Function responsible for enqueuing the assets required for block styles functionality on the editor.
2916   *
2917   * @since 5.3.0
2918   */
2919  function enqueue_editor_block_styles_assets() {
2920      $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
2921  
2922      $register_script_lines = array( '( function() {' );
2923      foreach ( $block_styles as $block_name => $styles ) {
2924          foreach ( $styles as $style_properties ) {
2925              $register_script_lines[] = sprintf(
2926                  '    wp.blocks.registerBlockStyle( \'%s\', %s );',
2927                  $block_name,
2928                  wp_json_encode(
2929                      array(
2930                          'name'  => $style_properties['name'],
2931                          'label' => $style_properties['label'],
2932                      )
2933                  )
2934              );
2935          }
2936      }
2937      $register_script_lines[] = '} )();';
2938      $inline_script           = implode( "\n", $register_script_lines );
2939  
2940      wp_register_script( 'wp-block-styles', false, array( 'wp-blocks' ), true, true );
2941      wp_add_inline_script( 'wp-block-styles', $inline_script );
2942      wp_enqueue_script( 'wp-block-styles' );
2943  }


Generated: Fri Oct 25 08:20:01 2019 Cross-referenced by PHPXref 0.7