[ Index ]

PHP Cross Reference of WordPress

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


Generated: Tue Dec 10 01:00:04 2019 Cross-referenced by PHPXref 0.7.1