[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

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

   1  <?php
   2  /**
   3   * WordPress scripts and styles default loader.
   4   *
   5   * Several constants are used to manage the loading, concatenating and compression of scripts and CSS:
   6   * define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation,
   7   * define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS,
   8   * define('COMPRESS_SCRIPTS', false); disables compression of scripts,
   9   * define('COMPRESS_CSS', false); disables compression of CSS,
  10   * define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate).
  11   *
  12   * The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins
  13   * to temporarily override the above settings. Also a compression test is run once and the result is saved
  14   * as option 'can_compress_scripts' (0/1). The test will run again if that option is deleted.
  15   *
  16   * @package WordPress
  17   */
  18  
  19  /** WordPress Dependency Class */
  20  require ( ABSPATH . WPINC . '/class-wp-dependency.php' );
  21  
  22  /** WordPress Dependencies Class */
  23  require ( ABSPATH . WPINC . '/class.wp-dependencies.php' );
  24  
  25  /** WordPress Scripts Class */
  26  require ( ABSPATH . WPINC . '/class.wp-scripts.php' );
  27  
  28  /** WordPress Scripts Functions */
  29  require ( ABSPATH . WPINC . '/functions.wp-scripts.php' );
  30  
  31  /** WordPress Styles Class */
  32  require ( ABSPATH . WPINC . '/class.wp-styles.php' );
  33  
  34  /** WordPress Styles Functions */
  35  require ( ABSPATH . WPINC . '/functions.wp-styles.php' );
  36  
  37  /**
  38   * Registers TinyMCE scripts.
  39   *
  40   * @since 5.0.0
  41   *
  42   * @param WP_Scripts $scripts WP_Scripts object.
  43   */
  44  function wp_register_tinymce_scripts( &$scripts, $force_uncompressed = false ) {
  45      global $tinymce_version, $concatenate_scripts, $compress_scripts;
  46      $suffix     = wp_scripts_get_suffix();
  47      $dev_suffix = wp_scripts_get_suffix( 'dev' );
  48  
  49      script_concat_settings();
  50  
  51      $compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] )
  52          && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed;
  53  
  54      // Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production) or
  55      // tinymce.min.js (when SCRIPT_DEBUG is true).
  56      if ( $compressed ) {
  57          $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version );
  58      } else {
  59          $scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$dev_suffix.js", array(), $tinymce_version );
  60          $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$dev_suffix.js", array( 'wp-tinymce-root' ), $tinymce_version );
  61      }
  62  
  63      $scripts->add( 'wp-tinymce-lists', includes_url( "js/tinymce/plugins/lists/plugin$suffix.js" ), array( 'wp-tinymce' ), $tinymce_version );
  64  }
  65  
  66  /**
  67   * Registers all the WordPress vendor scripts that are in the standardized
  68   * `js/dist/vendor/` location.
  69   *
  70   * For the order of `$scripts->add` see `wp_default_scripts`.
  71   *
  72   * @since 5.0.0
  73   *
  74   * @param WP_Scripts $scripts WP_Scripts object.
  75   */
  76  function wp_default_packages_vendor( &$scripts ) {
  77      global $wp_locale;
  78  
  79      $suffix = wp_scripts_get_suffix();
  80  
  81      $vendor_scripts = array(
  82          'react'     => array( 'wp-polyfill' ),
  83          'react-dom' => array( 'react' ),
  84          'moment',
  85          'lodash',
  86          'wp-polyfill-fetch',
  87          'wp-polyfill-formdata',
  88          'wp-polyfill-node-contains',
  89          'wp-polyfill-element-closest',
  90          'wp-polyfill',
  91      );
  92  
  93      $vendor_scripts_versions = array(
  94          'react'                       => '16.9.0',
  95          'react-dom'                   => '16.9.0',
  96          'moment'                      => '2.22.2',
  97          'lodash'                      => '4.17.15',
  98          'wp-polyfill-fetch'           => '3.0.0',
  99          'wp-polyfill-formdata'        => '3.0.12',
 100          'wp-polyfill-node-contains'   => '3.26.0-0',
 101          'wp-polyfill-element-closest' => '2.0.2',
 102          'wp-polyfill'                 => '7.4.4',
 103      );
 104  
 105      foreach ( $vendor_scripts as $handle => $dependencies ) {
 106          if ( is_string( $dependencies ) ) {
 107              $handle       = $dependencies;
 108              $dependencies = array();
 109          }
 110  
 111          $path    = "/wp-includes/js/dist/vendor/$handle$suffix.js";
 112          $version = $vendor_scripts_versions[ $handle ];
 113  
 114          $scripts->add( $handle, $path, $dependencies, $version, 1 );
 115      }
 116  
 117      $scripts->add( 'wp-polyfill', null, array( 'wp-polyfill' ) );
 118      did_action( 'init' ) && $scripts->add_inline_script(
 119          'wp-polyfill',
 120          wp_get_script_polyfill(
 121              $scripts,
 122              array(
 123                  '\'fetch\' in window' => 'wp-polyfill-fetch',
 124                  'document.contains'   => 'wp-polyfill-node-contains',
 125                  'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata',
 126                  'Element.prototype.matches && Element.prototype.closest' => 'wp-polyfill-element-closest',
 127              )
 128          )
 129      );
 130  
 131      did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
 132  
 133      did_action( 'init' ) && $scripts->add_inline_script(
 134          'moment',
 135          sprintf(
 136              "moment.locale( '%s', %s );",
 137              get_user_locale(),
 138              wp_json_encode(
 139                  array(
 140                      'months'         => array_values( $wp_locale->month ),
 141                      'monthsShort'    => array_values( $wp_locale->month_abbrev ),
 142                      'weekdays'       => array_values( $wp_locale->weekday ),
 143                      'weekdaysShort'  => array_values( $wp_locale->weekday_abbrev ),
 144                      'week'           => array(
 145                          'dow' => (int) get_option( 'start_of_week', 0 ),
 146                      ),
 147                      'longDateFormat' => array(
 148                          'LT'   => get_option( 'time_format', __( 'g:i a', 'default' ) ),
 149                          'LTS'  => null,
 150                          'L'    => null,
 151                          'LL'   => get_option( 'date_format', __( 'F j, Y', 'default' ) ),
 152                          'LLL'  => __( 'F j, Y g:i a', 'default' ),
 153                          'LLLL' => null,
 154                      ),
 155                  )
 156              )
 157          ),
 158          'after'
 159      );
 160  }
 161  
 162  /**
 163   * Returns contents of an inline script used in appending polyfill scripts for
 164   * browsers which fail the provided tests. The provided array is a mapping from
 165   * a condition to verify feature support to its polyfill script handle.
 166   *
 167   * @since 5.0.0
 168   *
 169   * @param WP_Scripts $scripts WP_Scripts object.
 170   * @param array      $tests   Features to detect.
 171   * @return string Conditional polyfill inline script.
 172   */
 173  function wp_get_script_polyfill( &$scripts, $tests ) {
 174      $polyfill = '';
 175      foreach ( $tests as $test => $handle ) {
 176          if ( ! array_key_exists( $handle, $scripts->registered ) ) {
 177              continue;
 178          }
 179  
 180          $src = $scripts->registered[ $handle ]->src;
 181          $ver = $scripts->registered[ $handle ]->ver;
 182  
 183          if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $scripts->content_url && 0 === strpos( $src, $scripts->content_url ) ) ) {
 184              $src = $scripts->base_url . $src;
 185          }
 186  
 187          if ( ! empty( $ver ) ) {
 188              $src = add_query_arg( 'ver', $ver, $src );
 189          }
 190  
 191          /** This filter is documented in wp-includes/class.wp-scripts.php */
 192          $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
 193  
 194          if ( ! $src ) {
 195              continue;
 196          }
 197  
 198          $polyfill .= (
 199              // Test presence of feature...
 200              '( ' . $test . ' ) || ' .
 201              // ...appending polyfill on any failures. Cautious viewers may balk
 202              // at the `document.write`. Its caveat of synchronous mid-stream
 203              // blocking write is exactly the behavior we need though.
 204              'document.write( \'<script src="' .
 205              $src .
 206              '"></scr\' + \'ipt>\' );'
 207          );
 208      }
 209  
 210      return $polyfill;
 211  }
 212  
 213  /**
 214   * Registers all the WordPress packages scripts that are in the standardized
 215   * `js/dist/` location.
 216   *
 217   * For the order of `$scripts->add` see `wp_default_scripts`.
 218   *
 219   * @since 5.0.0
 220   *
 221   * @param WP_Scripts $scripts WP_Scripts object.
 222   */
 223  function wp_default_packages_scripts( &$scripts ) {
 224      $suffix = wp_scripts_get_suffix();
 225  
 226      $packages_versions = array(
 227          'a11y'                               => '2.5.1',
 228          'annotations'                        => '1.7.2',
 229          'api-fetch'                          => '3.6.4',
 230          'autop'                              => '2.5.1',
 231          'blob'                               => '2.5.1',
 232          'block-editor'                       => '3.2.4',
 233          'block-library'                      => '2.9.5',
 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.4',
 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.5',
 246          'editor'                             => '9.7.5',
 247          'element'                            => '2.8.2',
 248          'escape-html'                        => '1.5.1',
 249          'format-library'                     => '1.9.4',
 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(), 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      $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 );
1519      $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 );
1520      $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'wp-a11y', 'customize-base' ), false, 1 );
1521      $scripts->add( 'customize-models', '/wp-includes/js/customize-models.js', array( 'underscore', 'backbone' ), false, 1 );
1522      $scripts->add( 'customize-views', '/wp-includes/js/customize-views.js', array( 'jquery', 'underscore', 'imgareaselect', 'customize-models', 'media-editor', 'media-views' ), false, 1 );
1523      $scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base', 'wp-a11y', 'wp-util', 'jquery-ui-core' ), false, 1 );
1524      did_action( 'init' ) && $scripts->localize(
1525          'customize-controls',
1526          '_wpCustomizeControlsL10n',
1527          array(
1528              'activate'                => __( 'Activate &amp; Publish' ),
1529              'save'                    => __( 'Save &amp; Publish' ), // @todo Remove as not required.
1530              'publish'                 => __( 'Publish' ),
1531              'published'               => __( 'Published' ),
1532              'saveDraft'               => __( 'Save Draft' ),
1533              'draftSaved'              => __( 'Draft Saved' ),
1534              'updating'                => __( 'Updating' ),
1535              'schedule'                => _x( 'Schedule', 'customizer changeset action/button label' ),
1536              'scheduled'               => _x( 'Scheduled', 'customizer changeset status' ),
1537              'invalid'                 => __( 'Invalid' ),
1538              'saveBeforeShare'         => __( 'Please save your changes in order to share the preview.' ),
1539              'futureDateError'         => __( 'You must supply a future date to schedule.' ),
1540              'saveAlert'               => __( 'The changes you made will be lost if you navigate away from this page.' ),
1541              'saved'                   => __( 'Saved' ),
1542              'cancel'                  => __( 'Cancel' ),
1543              'close'                   => __( 'Close' ),
1544              'action'                  => __( 'Action' ),
1545              'discardChanges'          => __( 'Discard changes' ),
1546              'cheatin'                 => __( 'Something went wrong.' ),
1547              'notAllowedHeading'       => __( 'You need a higher level of permission.' ),
1548              'notAllowed'              => __( 'Sorry, you are not allowed to customize this site.' ),
1549              'previewIframeTitle'      => __( 'Site Preview' ),
1550              'loginIframeTitle'        => __( 'Session expired' ),
1551              'collapseSidebar'         => _x( 'Hide Controls', 'label for hide controls button without length constraints' ),
1552              'expandSidebar'           => _x( 'Show Controls', 'label for hide controls button without length constraints' ),
1553              'untitledBlogName'        => __( '(Untitled)' ),
1554              'unknownRequestFail'      => __( 'Looks like something&#8217;s gone wrong. Wait a couple seconds, and then try again.' ),
1555              'themeDownloading'        => __( 'Downloading your new theme&hellip;' ),
1556              'themePreviewWait'        => __( 'Setting up your live preview. This may take a bit.' ),
1557              'revertingChanges'        => __( 'Reverting unpublished changes&hellip;' ),
1558              'trashConfirm'            => __( 'Are you sure you want to discard your unpublished changes?' ),
1559              /* translators: %s: Display name of the user who has taken over the changeset in customizer. */
1560              'takenOverMessage'        => __( '%s has taken over and is currently customizing.' ),
1561              /* translators: %s: URL to the Customizer to load the autosaved version. */
1562              'autosaveNotice'          => __( 'There is a more recent autosave of your changes than the one you are previewing. <a href="%s">Restore the autosave</a>' ),
1563              'videoHeaderNotice'       => __( 'This theme doesn&#8217;t support video headers on this page. Navigate to the front page or another page that supports video headers.' ),
1564              // Used for overriding the file types allowed in plupload.
1565              'allowedFiles'            => __( 'Allowed Files' ),
1566              'customCssError'          => array(
1567                  /* translators: %d: Error count. */
1568                  '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 ),
1569                  /* translators: %d: Error count. */
1570                  '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.
1571              ),
1572              'pageOnFrontError'        => __( 'Homepage and posts page must be different.' ),
1573              'saveBlockedError'        => array(
1574                  /* translators: %s: Number of invalid settings. */
1575                  'singular' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 1 ),
1576                  /* translators: %s: Number of invalid settings. */
1577                  '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.
1578              ),
1579              'scheduleDescription'     => __( 'Schedule your customization changes to publish ("go live") at a future date.' ),
1580              '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.' ),
1581              'themeInstallUnavailable' => sprintf(
1582                  /* translators: %s: URL to Add Themes admin screen. */
1583                  __( '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>.' ),
1584                  esc_url( admin_url( 'theme-install.php' ) )
1585              ),
1586              'publishSettings'         => __( 'Publish Settings' ),
1587              'invalidDate'             => __( 'Invalid date.' ),
1588              'invalidValue'            => __( 'Invalid value.' ),
1589          )
1590      );
1591      $scripts->add( 'customize-selective-refresh', "/wp-includes/js/customize-selective-refresh$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 );
1592  
1593      $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 );
1594      $scripts->add( 'customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 );
1595  
1596      $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 );
1597      $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 );
1598  
1599      $scripts->add( 'wp-custom-header', "/wp-includes/js/wp-custom-header$suffix.js", array( 'wp-a11y' ), false, 1 );
1600  
1601      $scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 );
1602  
1603      $scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 );
1604      $scripts->add( 'media-models', "/wp-includes/js/media-models$suffix.js", array( 'wp-backbone' ), false, 1 );
1605      did_action( 'init' ) && $scripts->localize(
1606          'media-models',
1607          '_wpMediaModelsL10n',
1608          array(
1609              'settings' => array(
1610                  'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
1611                  'post'    => array( 'id' => 0 ),
1612              ),
1613          )
1614      );
1615  
1616      $scripts->add( 'wp-embed', "/wp-includes/js/wp-embed$suffix.js" );
1617  
1618      // To enqueue media-views or media-editor, call wp_enqueue_media().
1619      // Both rely on numerous settings, styles, and templates to operate correctly.
1620      $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 );
1621      $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
1622      $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
1623      $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 );
1624  
1625      $scripts->add( 'wp-api', "/wp-includes/js/wp-api$suffix.js", array( 'jquery', 'backbone', 'underscore', 'wp-api-request' ), false, 1 );
1626  
1627      if ( is_admin() ) {
1628          $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 );
1629          did_action( 'init' ) && $scripts->localize(
1630              'admin-tags',
1631              'tagsl10n',
1632              array(
1633                  'noPerm' => __( 'Sorry, you are not allowed to do that.' ),
1634                  'broken' => __( 'Something went wrong.' ),
1635              )
1636          );
1637  
1638          $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array( 'wp-lists', 'quicktags', 'jquery-query' ), false, 1 );
1639          did_action( 'init' ) && $scripts->localize(
1640              'admin-comments',
1641              'adminCommentsL10n',
1642              array(
1643                  'hotkeys_highlight_first' => isset( $_GET['hotkeys_highlight_first'] ),
1644                  'hotkeys_highlight_last'  => isset( $_GET['hotkeys_highlight_last'] ),
1645                  'replyApprove'            => __( 'Approve and Reply' ),
1646                  'reply'                   => __( 'Reply' ),
1647                  'warnQuickEdit'           => __( "Are you sure you want to edit this comment?\nThe changes you made will be lost." ),
1648                  'warnCommentChanges'      => __( "Are you sure you want to do this?\nThe comment changes you made will be lost." ),
1649                  'docTitleComments'        => __( 'Comments' ),
1650                  /* translators: %s: Comments count. */
1651                  'docTitleCommentsCount'   => __( 'Comments (%s)' ),
1652              )
1653          );
1654  
1655          $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array( 'jquery' ), false, 1 );
1656  
1657          $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array( 'jquery-ui-sortable' ), false, 1 );
1658          did_action( 'init' ) && $scripts->localize(
1659              'postbox',
1660              'postBoxL10n',
1661              array(
1662                  'postBoxEmptyString' => __( 'Drag boxes here' ),
1663              )
1664          );
1665  
1666          $scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'tags-suggest' ), false, 1 );
1667  
1668          $scripts->add( 'tags-suggest', "/wp-admin/js/tags-suggest$suffix.js", array( 'jquery-ui-autocomplete', 'wp-a11y' ), false, 1 );
1669          did_action( 'init' ) && $scripts->localize(
1670              'tags-suggest',
1671              'tagsSuggestL10n',
1672              array(
1673                  'tagDelimiter' => _x( ',', 'tag delimiter' ),
1674                  'removeTerm'   => __( 'Remove term:' ),
1675                  'termSelected' => __( 'Term selected.' ),
1676                  'termAdded'    => __( 'Term added.' ),
1677                  'termRemoved'  => __( 'Term removed.' ),
1678              )
1679          );
1680  
1681          $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 );
1682          did_action( 'init' ) && $scripts->localize(
1683              'post',
1684              'postL10n',
1685              array(
1686                  'ok'                 => __( 'OK' ),
1687                  'cancel'             => __( 'Cancel' ),
1688                  'publishOn'          => __( 'Publish on:' ),
1689                  'publishOnFuture'    => __( 'Schedule for:' ),
1690                  'publishOnPast'      => __( 'Published on:' ),
1691                  /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
1692                  'dateFormat'         => __( '%1$s %2$s, %3$s at %4$s:%5$s' ),
1693                  'showcomm'           => __( 'Show more comments' ),
1694                  'endcomm'            => __( 'No more comments found.' ),
1695                  'publish'            => __( 'Publish' ),
1696                  'schedule'           => _x( 'Schedule', 'post action/button label' ),
1697                  'update'             => __( 'Update' ),
1698                  'savePending'        => __( 'Save as Pending' ),
1699                  'saveDraft'          => __( 'Save Draft' ),
1700                  'private'            => __( 'Private' ),
1701                  'public'             => __( 'Public' ),
1702                  'publicSticky'       => __( 'Public, Sticky' ),
1703                  'password'           => __( 'Password Protected' ),
1704                  'privatelyPublished' => __( 'Privately Published' ),
1705                  'published'          => __( 'Published' ),
1706                  'saveAlert'          => __( 'The changes you made will be lost if you navigate away from this page.' ),
1707                  'savingText'         => __( 'Saving Draft&#8230;' ),
1708                  'permalinkSaved'     => __( 'Permalink saved' ),
1709              )
1710          );
1711  
1712          $scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery', 'underscore' ), false, 1 );
1713  
1714          $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
1715  
1716          $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ) );
1717          $scripts->add_data( 'comment', 'group', 1 );
1718          did_action( 'init' ) && $scripts->localize(
1719              'comment',
1720              'commentL10n',
1721              array(
1722                  'submittedOn' => __( 'Submitted on:' ),
1723                  /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
1724                  'dateFormat'  => __( '%1$s %2$s, %3$s at %4$s:%5$s' ),
1725              )
1726          );
1727  
1728          $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) );
1729  
1730          $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 );
1731          did_action( 'init' ) && $scripts->add_inline_script(
1732              'admin-widgets',
1733              sprintf(
1734                  'wpWidgets.l10n = %s;',
1735                  wp_json_encode(
1736                      array(
1737                          'save'      => __( 'Save' ),
1738                          'saved'     => __( 'Saved' ),
1739                          'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
1740                      )
1741                  )
1742              )
1743          );
1744  
1745          $scripts->add( 'media-widgets', "/wp-admin/js/widgets/media-widgets$suffix.js", array( 'jquery', 'media-models', 'media-views', 'wp-api-request' ) );
1746          $scripts->add_inline_script( 'media-widgets', 'wp.mediaWidgets.init();', 'after' );
1747  
1748          $scripts->add( 'media-audio-widget', "/wp-admin/js/widgets/media-audio-widget$suffix.js", array( 'media-widgets', 'media-audiovideo' ) );
1749          $scripts->add( 'media-image-widget', "/wp-admin/js/widgets/media-image-widget$suffix.js", array( 'media-widgets' ) );
1750          $scripts->add( 'media-gallery-widget', "/wp-admin/js/widgets/media-gallery-widget$suffix.js", array( 'media-widgets' ) );
1751          $scripts->add( 'media-video-widget', "/wp-admin/js/widgets/media-video-widget$suffix.js", array( 'media-widgets', 'media-audiovideo', 'wp-api-request' ) );
1752          $scripts->add( 'text-widgets', "/wp-admin/js/widgets/text-widgets$suffix.js", array( 'jquery', 'backbone', 'editor', 'wp-util', 'wp-a11y' ) );
1753          $scripts->add( 'custom-html-widgets', "/wp-admin/js/widgets/custom-html-widgets$suffix.js", array( 'jquery', 'backbone', 'wp-util', 'jquery-ui-core', 'wp-a11y' ) );
1754  
1755          $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y', 'customize-base' ), false, 1 );
1756  
1757          $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'tags-suggest', 'wp-a11y' ), false, 1 );
1758          did_action( 'init' ) && $scripts->localize(
1759              'inline-edit-post',
1760              'inlineEditL10n',
1761              array(
1762                  'error'      => __( 'Error while saving the changes.' ),
1763                  'ntdeltitle' => __( 'Remove From Bulk Edit' ),
1764                  'notitle'    => __( '(no title)' ),
1765                  'comma'      => trim( _x( ',', 'tag delimiter' ) ),
1766                  'saved'      => __( 'Changes saved.' ),
1767              )
1768          );
1769  
1770          $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
1771          did_action( 'init' ) && $scripts->localize(
1772              'inline-edit-tax',
1773              'inlineEditL10n',
1774              array(
1775                  'error' => __( 'Error while saving the changes.' ),
1776                  'saved' => __( 'Changes saved.' ),
1777              )
1778          );
1779  
1780          $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 );
1781          did_action( 'init' ) && $scripts->localize(
1782              'plugin-install',
1783              'plugininstallL10n',
1784              array(
1785                  'plugin_information' => __( 'Plugin:' ),
1786                  'plugin_modal_label' => __( 'Plugin details' ),
1787                  'ays'                => __( 'Are you sure you want to install this plugin?' ),
1788              )
1789          );
1790  
1791          $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-i18n' ), false, 1 );
1792          $scripts->set_translations( 'site-health' );
1793  
1794          $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery' ), false, 1 );
1795          did_action( 'init' ) && $scripts->localize(
1796              'privacy-tools',
1797              'privacyToolsL10n',
1798              array(
1799                  'noDataFound'     => __( 'No personal data was found for this user.' ),
1800                  'foundAndRemoved' => __( 'All of the personal data found for this user was erased.' ),
1801                  'noneRemoved'     => __( 'Personal data was found for this user but was not erased.' ),
1802                  'someNotRemoved'  => __( 'Personal data was found for this user but some of the personal data found was not erased.' ),
1803                  'removalError'    => __( 'An error occurred while attempting to find and erase personal data.' ),
1804                  'emailSent'       => __( 'The personal data export link for this user was sent.' ),
1805                  'noExportFile'    => __( 'No personal data export file was generated.' ),
1806                  'exportError'     => __( 'An error occurred while attempting to export personal data.' ),
1807              )
1808          );
1809  
1810          $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 );
1811          did_action( 'init' ) && $scripts->localize(
1812              'updates',
1813              '_wpUpdatesSettings',
1814              array(
1815                  'ajax_nonce' => wp_create_nonce( 'updates' ),
1816                  'l10n'       => array(
1817                      /* translators: %s: Search query. */
1818                      'searchResults'            => __( 'Search results for &#8220;%s&#8221;' ),
1819                      'searchResultsLabel'       => __( 'Search Results' ),
1820                      'noPlugins'                => __( 'You do not appear to have any plugins available at this time.' ),
1821                      'noItemsSelected'          => __( 'Please select at least one item to perform this action on.' ),
1822                      'updating'                 => __( 'Updating...' ), // No ellipsis.
1823                      'pluginUpdated'            => _x( 'Updated!', 'plugin' ),
1824                      'themeUpdated'             => _x( 'Updated!', 'theme' ),
1825                      'update'                   => __( 'Update' ),
1826                      'updateNow'                => __( 'Update Now' ),
1827                      /* translators: %s: Plugin name and version. */
1828                      'pluginUpdateNowLabel'     => _x( 'Update %s now', 'plugin' ),
1829                      'updateFailedShort'        => __( 'Update Failed!' ),
1830                      /* translators: %s: Error string for a failed update. */
1831                      'updateFailed'             => __( 'Update Failed: %s' ),
1832                      /* translators: %s: Plugin name and version. */
1833                      'pluginUpdatingLabel'      => _x( 'Updating %s...', 'plugin' ), // No ellipsis.
1834                      /* translators: %s: Plugin name and version. */
1835                      'pluginUpdatedLabel'       => _x( '%s updated!', 'plugin' ),
1836                      /* translators: %s: Plugin name and version. */
1837                      'pluginUpdateFailedLabel'  => _x( '%s update failed', 'plugin' ),
1838                      /* translators: Accessibility text. */
1839                      'updatingMsg'              => __( 'Updating... please wait.' ), // No ellipsis.
1840                      /* translators: Accessibility text. */
1841                      'updatedMsg'               => __( 'Update completed successfully.' ),
1842                      /* translators: Accessibility text. */
1843                      'updateCancel'             => __( 'Update canceled.' ),
1844                      'beforeunload'             => __( 'Updates may not complete if you navigate away from this page.' ),
1845                      'installNow'               => __( 'Install Now' ),
1846                      /* translators: %s: Plugin name. */
1847                      'pluginInstallNowLabel'    => _x( 'Install %s now', 'plugin' ),
1848                      'installing'               => __( 'Installing...' ),
1849                      'pluginInstalled'          => _x( 'Installed!', 'plugin' ),
1850                      'themeInstalled'           => _x( 'Installed!', 'theme' ),
1851                      'installFailedShort'       => __( 'Installation Failed!' ),
1852                      /* translators: %s: Error string for a failed installation. */
1853                      'installFailed'            => __( 'Installation failed: %s' ),
1854                      /* translators: %s: Plugin name and version. */
1855                      'pluginInstallingLabel'    => _x( 'Installing %s...', 'plugin' ), // no ellipsis
1856                      /* translators: %s: Theme name and version. */
1857                      'themeInstallingLabel'     => _x( 'Installing %s...', 'theme' ), // no ellipsis
1858                      /* translators: %s: Plugin name and version. */
1859                      'pluginInstalledLabel'     => _x( '%s installed!', 'plugin' ),
1860                      /* translators: %s: Theme name and version. */
1861                      'themeInstalledLabel'      => _x( '%s installed!', 'theme' ),
1862                      /* translators: %s: Plugin name and version. */
1863                      'pluginInstallFailedLabel' => _x( '%s installation failed', 'plugin' ),
1864                      /* translators: %s: Theme name and version. */
1865                      'themeInstallFailedLabel'  => _x( '%s installation failed', 'theme' ),
1866                      'installingMsg'            => __( 'Installing... please wait.' ),
1867                      'installedMsg'             => __( 'Installation completed successfully.' ),
1868                      /* translators: %s: Activation URL. */
1869                      'importerInstalledMsg'     => __( 'Importer installed successfully. <a href="%s">Run importer</a>' ),
1870                      /* translators: %s: Theme name. */
1871                      'aysDelete'                => __( 'Are you sure you want to delete %s?' ),
1872                      /* translators: %s: Plugin name. */
1873                      'aysDeleteUninstall'       => __( 'Are you sure you want to delete %s and its data?' ),
1874                      'aysBulkDelete'            => __( 'Are you sure you want to delete the selected plugins and their data?' ),
1875                      'aysBulkDeleteThemes'      => __( 'Caution: These themes may be active on other sites in the network. Are you sure you want to proceed?' ),
1876                      'deleting'                 => __( 'Deleting...' ),
1877                      /* translators: %s: Error string for a failed deletion. */
1878                      'deleteFailed'             => __( 'Deletion failed: %s' ),
1879                      'pluginDeleted'            => _x( 'Deleted!', 'plugin' ),
1880                      'themeDeleted'             => _x( 'Deleted!', 'theme' ),
1881                      'livePreview'              => __( 'Live Preview' ),
1882                      'activatePlugin'           => is_network_admin() ? __( 'Network Activate' ) : __( 'Activate' ),
1883                      'activateTheme'            => is_network_admin() ? __( 'Network Enable' ) : __( 'Activate' ),
1884                      /* translators: %s: Plugin name. */
1885                      'activatePluginLabel'      => is_network_admin() ? _x( 'Network Activate %s', 'plugin' ) : _x( 'Activate %s', 'plugin' ),
1886                      /* translators: %s: Theme name. */
1887                      'activateThemeLabel'       => is_network_admin() ? _x( 'Network Activate %s', 'theme' ) : _x( 'Activate %s', 'theme' ),
1888                      'activateImporter'         => __( 'Run Importer' ),
1889                      /* translators: %s: Importer name. */
1890                      'activateImporterLabel'    => __( 'Run %s' ),
1891                      'unknownError'             => __( 'Something went wrong.' ),
1892                      'connectionError'          => __( 'Connection lost or the server is busy. Please try again later.' ),
1893                      'nonceError'               => __( 'An error has occurred. Please reload the page and try again.' ),
1894                      /* translators: %s: Number of plugins. */
1895                      'pluginsFound'             => __( 'Number of plugins found: %d' ),
1896                      'noPluginsFound'           => __( 'No plugins found. Try a different search.' ),
1897                  ),
1898              )
1899          );
1900  
1901          $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array( 'jquery' ), '1.2' );
1902  
1903          $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.0.7', 1 );
1904          $scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 );
1905          did_action( 'init' ) && $scripts->localize(
1906              'wp-color-picker',
1907              'wpColorPickerL10n',
1908              array(
1909                  'clear'            => __( 'Clear' ),
1910                  'clearAriaLabel'   => __( 'Clear color' ),
1911                  'defaultString'    => __( 'Default' ),
1912                  'defaultAriaLabel' => __( 'Select default color' ),
1913                  'pick'             => __( 'Select Color' ),
1914                  'defaultLabel'     => __( 'Color value' ),
1915              )
1916          );
1917  
1918          $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y' ), false, 1 );
1919  
1920          $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" );
1921  
1922          $scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 );
1923          $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 );
1924          did_action( 'init' ) && $scripts->localize(
1925              'media',
1926              'attachMediaBoxL10n',
1927              array(
1928                  'error' => __( 'An error has occurred. Please reload the page and try again.' ),
1929              )
1930          );
1931  
1932          $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'json2', 'imgareaselect' ), false, 1 );
1933          did_action( 'init' ) && $scripts->localize(
1934              'image-edit',
1935              'imageEditL10n',
1936              array(
1937                  'error' => __( 'Could not load the preview image. Please reload the page and try again.' ),
1938              )
1939          );
1940  
1941          $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
1942          did_action( 'init' ) && $scripts->localize(
1943              'set-post-thumbnail',
1944              'setPostThumbnailL10n',
1945              array(
1946                  'setThumbnail' => __( 'Use as featured image' ),
1947                  'saving'       => __( 'Saving...' ), // no ellipsis
1948                  'error'        => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
1949                  'done'         => __( 'Done' ),
1950              )
1951          );
1952  
1953          /*
1954           * Navigation Menus: Adding underscore as a dependency to utilize _.debounce
1955           * see https://core.trac.wordpress.org/ticket/42321
1956           */
1957          $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' ) );
1958          did_action( 'init' ) && $scripts->localize(
1959              'nav-menu',
1960              'navMenuL10n',
1961              array(
1962                  'noResultsFound' => __( 'No results found.' ),
1963                  'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
1964                  'saveAlert'      => __( 'The changes you made will be lost if you navigate away from this page.' ),
1965                  'untitled'       => _x( '(no label)', 'missing menu item navigation label' ),
1966              )
1967          );
1968  
1969          $scripts->add( 'custom-header', '/wp-admin/js/custom-header.js', array( 'jquery-masonry' ), false, 1 );
1970          $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 );
1971          $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array( 'jquery' ), false, 1 );
1972  
1973          $scripts->add( 'svg-painter', '/wp-admin/js/svg-painter.js', array( 'jquery' ), false, 1 );
1974      }
1975  }
1976  
1977  /**
1978   * Assign default styles to $styles object.
1979   *
1980   * Nothing is returned, because the $styles parameter is passed by reference.
1981   * Meaning that whatever object is passed will be updated without having to
1982   * reassign the variable that was passed back to the same value. This saves
1983   * memory.
1984   *
1985   * Adding default styles is not the only task, it also assigns the base_url
1986   * property, the default version, and text direction for the object.
1987   *
1988   * @since 2.6.0
1989   *
1990   * @param WP_Styles $styles
1991   */
1992  function wp_default_styles( &$styles ) {
1993      include ( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
1994  
1995      if ( ! defined( 'SCRIPT_DEBUG' ) ) {
1996          define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) );
1997      }
1998  
1999      $guessurl = site_url();
2000  
2001      if ( ! $guessurl ) {
2002          $guessurl = wp_guess_url();
2003      }
2004  
2005      $styles->base_url        = $guessurl;
2006      $styles->content_url     = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : '';
2007      $styles->default_version = get_bloginfo( 'version' );
2008      $styles->text_direction  = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
2009      $styles->default_dirs    = array( '/wp-admin/', '/wp-includes/css/' );
2010  
2011      // Open Sans is no longer used by core, but may be relied upon by themes and plugins.
2012      $open_sans_font_url = '';
2013  
2014      /*
2015       * translators: If there are characters in your language that are not supported
2016       * by Open Sans, translate this to 'off'. Do not translate into your own language.
2017       */
2018      if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) {
2019          $subsets = 'latin,latin-ext';
2020  
2021          /*
2022           * translators: To add an additional Open Sans character subset specific to your language,
2023           * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language.
2024           */
2025          $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' );
2026  
2027          if ( 'cyrillic' === $subset ) {
2028              $subsets .= ',cyrillic,cyrillic-ext';
2029          } elseif ( 'greek' === $subset ) {
2030              $subsets .= ',greek,greek-ext';
2031          } elseif ( 'vietnamese' === $subset ) {
2032              $subsets .= ',vietnamese';
2033          }
2034  
2035          // Hotlink Open Sans, for now
2036          $open_sans_font_url = "https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets&display=fallback";
2037      }
2038  
2039      // Register a stylesheet for the selected admin color scheme.
2040      $styles->add( 'colors', true, array( 'wp-admin', 'buttons' ) );
2041  
2042      $suffix = SCRIPT_DEBUG ? '' : '.min';
2043  
2044      // Admin CSS
2045      $styles->add( 'common', "/wp-admin/css/common$suffix.css" );
2046      $styles->add( 'forms', "/wp-admin/css/forms$suffix.css" );
2047      $styles->add( 'admin-menu', "/wp-admin/css/admin-menu$suffix.css" );
2048      $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css" );
2049      $styles->add( 'list-tables', "/wp-admin/css/list-tables$suffix.css" );
2050      $styles->add( 'edit', "/wp-admin/css/edit$suffix.css" );
2051      $styles->add( 'revisions', "/wp-admin/css/revisions$suffix.css" );
2052      $styles->add( 'media', "/wp-admin/css/media$suffix.css" );
2053      $styles->add( 'themes', "/wp-admin/css/themes$suffix.css" );
2054      $styles->add( 'about', "/wp-admin/css/about$suffix.css" );
2055      $styles->add( 'nav-menus', "/wp-admin/css/nav-menus$suffix.css" );
2056      $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array( 'wp-pointer' ) );
2057      $styles->add( 'site-icon', "/wp-admin/css/site-icon$suffix.css" );
2058      $styles->add( 'l10n', "/wp-admin/css/l10n$suffix.css" );
2059      $styles->add( 'code-editor', "/wp-admin/css/code-editor$suffix.css", array( 'wp-codemirror' ) );
2060      $styles->add( 'site-health', "/wp-admin/css/site-health$suffix.css" );
2061  
2062      $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' ) );
2063  
2064      $styles->add( 'login', "/wp-admin/css/login$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) );
2065      $styles->add( 'install', "/wp-admin/css/install$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) );
2066      $styles->add( 'wp-color-picker', "/wp-admin/css/color-picker$suffix.css" );
2067      $styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie', 'imgareaselect' ) );
2068      $styles->add( 'customize-widgets', "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) );
2069      $styles->add( 'customize-nav-menus', "/wp-admin/css/customize-nav-menus$suffix.css", array( 'wp-admin', 'colors' ) );
2070  
2071      $styles->add( 'ie', "/wp-admin/css/ie$suffix.css" );
2072      $styles->add_data( 'ie', 'conditional', 'lte IE 7' );
2073  
2074      // Common dependencies
2075      $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" );
2076      $styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" );
2077  
2078      // Includes CSS
2079      $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array( 'dashicons' ) );
2080      $styles->add( 'wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) );
2081      $styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) );
2082      $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) );
2083      $styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) );
2084      $styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) );
2085      $styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" );
2086      $styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' );
2087  
2088      // External libraries and friends
2089      $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' );
2090      $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) );
2091      $styles->add( 'mediaelement', '/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css', array(), '4.2.13-9993131' );
2092      $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) );
2093      $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) );
2094      $styles->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.css', array(), '5.29.1-alpha-ee20357' );
2095  
2096      // Deprecated CSS
2097      $styles->add( 'deprecated-media', "/wp-admin/css/deprecated-media$suffix.css" );
2098      $styles->add( 'farbtastic', "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1' );
2099      $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.css', array(), '0.9.12' );
2100      $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle.
2101      $styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6
2102  
2103      // Packages styles
2104      $fonts_url = '';
2105  
2106      /*
2107       * translators: Use this to specify the proper Google Font name and variants
2108       * to load that is supported by your language. Do not translate.
2109       * Set to 'off' to disable loading.
2110       */
2111      $font_family = _x( 'Noto Serif:400,400i,700,700i', 'Google Font Name and Variants' );
2112      if ( 'off' !== $font_family ) {
2113          $fonts_url = 'https://fonts.googleapis.com/css?family=' . urlencode( $font_family );
2114      }
2115      $styles->add( 'wp-editor-font', $fonts_url );
2116  
2117      $styles->add( 'wp-block-library-theme', "/wp-includes/css/dist/block-library/theme$suffix.css" );
2118  
2119      $styles->add(
2120          'wp-edit-blocks',
2121          "/wp-includes/css/dist/block-library/editor$suffix.css",
2122          array(
2123              'wp-components',
2124              'wp-editor',
2125              'wp-block-library',
2126              // Always include visual styles so the editor never appears broken.
2127              'wp-block-library-theme',
2128          )
2129      );
2130  
2131      $package_styles = array(
2132          'block-editor'         => array(
2133              'wp-components',
2134              'wp-editor-font',
2135          ),
2136          'block-library'        => array(),
2137          'components'           => array(),
2138          'edit-post'            => array(
2139              'wp-components',
2140              'wp-block-editor',
2141              'wp-editor',
2142              'wp-edit-blocks',
2143              'wp-block-library',
2144              'wp-nux',
2145          ),
2146          'editor'               => array(
2147              'wp-components',
2148              'wp-block-editor',
2149              'wp-nux',
2150          ),
2151          'format-library'       => array(),
2152          'list-reusable-blocks' => array( 'wp-components' ),
2153          'nux'                  => array( 'wp-components' ),
2154      );
2155  
2156      foreach ( $package_styles as $package => $dependencies ) {
2157          $handle = 'wp-' . $package;
2158          $path   = "/wp-includes/css/dist/$package/style$suffix.css";
2159  
2160          $styles->add( $handle, $path, $dependencies );
2161      }
2162  
2163      // RTL CSS
2164      $rtl_styles = array(
2165          // Admin CSS
2166          'common',
2167          'forms',
2168          'admin-menu',
2169          'dashboard',
2170          'list-tables',
2171          'edit',
2172          'revisions',
2173          'media',
2174          'themes',
2175          'about',
2176          'nav-menus',
2177          'widgets',
2178          'site-icon',
2179          'l10n',
2180          'install',
2181          'wp-color-picker',
2182          'customize-controls',
2183          'customize-widgets',
2184          'customize-nav-menus',
2185          'customize-preview',
2186          'ie',
2187          'login',
2188          'site-health',
2189          // Includes CSS
2190          'buttons',
2191          'admin-bar',
2192          'wp-auth-check',
2193          'editor-buttons',
2194          'media-views',
2195          'wp-pointer',
2196          'wp-jquery-ui-dialog',
2197          // Package styles
2198          'wp-block-library-theme',
2199          'wp-edit-blocks',
2200          'wp-block-editor',
2201          'wp-block-library',
2202          'wp-components',
2203          'wp-edit-post',
2204          'wp-editor',
2205          'wp-format-library',
2206          'wp-list-reusable-blocks',
2207          'wp-nux',
2208          // Deprecated CSS
2209          'deprecated-media',
2210          'farbtastic',
2211      );
2212  
2213      foreach ( $rtl_styles as $rtl_style ) {
2214          $styles->add_data( $rtl_style, 'rtl', 'replace' );
2215          if ( $suffix ) {
2216              $styles->add_data( $rtl_style, 'suffix', $suffix );
2217          }
2218      }
2219  }
2220  
2221  /**
2222   * Reorder JavaScript scripts array to place prototype before jQuery.
2223   *
2224   * @since 2.3.1
2225   *
2226   * @param array $js_array JavaScript scripts array
2227   * @return array Reordered array, if needed.
2228   */
2229  function wp_prototype_before_jquery( $js_array ) {
2230      $prototype = array_search( 'prototype', $js_array, true );
2231  
2232      if ( false === $prototype ) {
2233          return $js_array;
2234      }
2235  
2236      $jquery = array_search( 'jquery', $js_array, true );
2237  
2238      if ( false === $jquery ) {
2239          return $js_array;
2240      }
2241  
2242      if ( $prototype < $jquery ) {
2243          return $js_array;
2244      }
2245  
2246      unset( $js_array[ $prototype ] );
2247  
2248      array_splice( $js_array, $jquery, 0, 'prototype' );
2249  
2250      return $js_array;
2251  }
2252  
2253  /**
2254   * Load localized data on print rather than initialization.
2255   *
2256   * These localizations require information that may not be loaded even by init.
2257   *
2258   * @since 2.5.0
2259   */
2260  function wp_just_in_time_script_localization() {
2261  
2262      wp_localize_script(
2263          'autosave',
2264          'autosaveL10n',
2265          array(
2266              'autosaveInterval' => AUTOSAVE_INTERVAL,
2267              'blog_id'          => get_current_blog_id(),
2268          )
2269      );
2270  
2271      wp_localize_script(
2272          'mce-view',
2273          'mceViewL10n',
2274          array(
2275              'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(),
2276          )
2277      );
2278  
2279      wp_localize_script(
2280          'word-count',
2281          'wordCountL10n',
2282          array(
2283              /*
2284               * translators: If your word count is based on single characters (e.g. East Asian characters),
2285               * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
2286               * Do not translate into your own language.
2287               */
2288              'type'       => _x( 'words', 'Word count type. Do not translate!' ),
2289              'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(),
2290          )
2291      );
2292  }
2293  
2294  /**
2295   * Localizes the jQuery UI datepicker.
2296   *
2297   * @since 4.6.0
2298   *
2299   * @link https://api.jqueryui.com/datepicker/#options
2300   *
2301   * @global WP_Locale $wp_locale WordPress date and time locale object.
2302   */
2303  function wp_localize_jquery_ui_datepicker() {
2304      global $wp_locale;
2305  
2306      if ( ! wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) {
2307          return;
2308      }
2309  
2310      // Convert the PHP date format into jQuery UI's format.
2311      $datepicker_date_format = str_replace(
2312          array(
2313              'd',
2314              'j',
2315              'l',
2316              'z', // Day.
2317              'F',
2318              'M',
2319              'n',
2320              'm', // Month.
2321              'Y',
2322              'y',            // Year.
2323          ),
2324          array(
2325              'dd',
2326              'd',
2327              'DD',
2328              'o',
2329              'MM',
2330              'M',
2331              'm',
2332              'mm',
2333              'yy',
2334              'y',
2335          ),
2336          get_option( 'date_format' )
2337      );
2338  
2339      $datepicker_defaults = wp_json_encode(
2340          array(
2341              'closeText'       => __( 'Close' ),
2342              'currentText'     => __( 'Today' ),
2343              'monthNames'      => array_values( $wp_locale->month ),
2344              'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
2345              'nextText'        => __( 'Next' ),
2346              'prevText'        => __( 'Previous' ),
2347              'dayNames'        => array_values( $wp_locale->weekday ),
2348              'dayNamesShort'   => array_values( $wp_locale->weekday_abbrev ),
2349              'dayNamesMin'     => array_values( $wp_locale->weekday_initial ),
2350              'dateFormat'      => $datepicker_date_format,
2351              'firstDay'        => absint( get_option( 'start_of_week' ) ),
2352              'isRTL'           => $wp_locale->is_rtl(),
2353          )
2354      );
2355  
2356      wp_add_inline_script( 'jquery-ui-datepicker', "jQuery(document).ready(function(jQuery){jQuery.datepicker.setDefaults({$datepicker_defaults});});" );
2357  }
2358  
2359  /**
2360   * Localizes community events data that needs to be passed to dashboard.js.
2361   *
2362   * @since 4.8.0
2363   */
2364  function wp_localize_community_events() {
2365      if ( ! wp_script_is( 'dashboard' ) ) {
2366          return;
2367      }
2368  
2369      require_once ( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' );
2370  
2371      $user_id            = get_current_user_id();
2372      $saved_location     = get_user_option( 'community-events-location', $user_id );
2373      $saved_ip_address   = isset( $saved_location['ip'] ) ? $saved_location['ip'] : false;
2374      $current_ip_address = WP_Community_Events::get_unsafe_client_ip();
2375  
2376      /*
2377       * If the user's location is based on their IP address, then update their
2378       * location when their IP address changes. This allows them to see events
2379       * in their current city when travelling. Otherwise, they would always be
2380       * shown events in the city where they were when they first loaded the
2381       * Dashboard, which could have been months or years ago.
2382       */
2383      if ( $saved_ip_address && $current_ip_address && $current_ip_address !== $saved_ip_address ) {
2384          $saved_location['ip'] = $current_ip_address;
2385          update_user_option( $user_id, 'community-events-location', $saved_location, true );
2386      }
2387  
2388      $events_client = new WP_Community_Events( $user_id, $saved_location );
2389  
2390      wp_localize_script(
2391          'dashboard',
2392          'communityEventsData',
2393          array(
2394              'nonce' => wp_create_nonce( 'community_events' ),
2395              'cache' => $events_client->get_cached_events(),
2396  
2397              'l10n'  => array(
2398                  'enter_closest_city'              => __( 'Enter your closest city to find nearby events.' ),
2399                  'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ),
2400                  'attend_event_near_generic'       => __( 'Attend an upcoming event near you.' ),
2401  
2402                  /*
2403                   * These specific examples were chosen to highlight the fact that a
2404                   * state is not needed, even for cities whose name is not unique.
2405                   * It would be too cumbersome to include that in the instructions
2406                   * to the user, so it's left as an implication.
2407                   */
2408                  /*
2409                   * translators: %s is the name of the city we couldn't locate.
2410                   * Replace the examples with cities related to your locale. Test that
2411                   * they match the expected location and have upcoming events before
2412                   * including them. If no cities related to your locale have events,
2413                   * then use cities related to your locale that would be recognizable
2414                   * to most users. Use only the city name itself, without any region
2415                   * or country. Use the endonym (native locale name) instead of the
2416                   * English name if possible.
2417                   */
2418                  'could_not_locate_city'           => __( 'We couldn&#8217;t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
2419  
2420                  // This one is only used with wp.a11y.speak(), so it can/should be more brief.
2421                  /* translators: %s: The name of a city. */
2422                  'city_updated'                    => __( 'City updated. Listing events near %s.' ),
2423              ),
2424          )
2425      );
2426  }
2427  
2428  /**
2429   * Administration Screen CSS for changing the styles.
2430   *
2431   * If installing the 'wp-admin/' directory will be replaced with './'.
2432   *
2433   * The $_wp_admin_css_colors global manages the Administration Screens CSS
2434   * stylesheet that is loaded. The option that is set is 'admin_color' and is the
2435   * color and key for the array. The value for the color key is an object with
2436   * a 'url' parameter that has the URL path to the CSS file.
2437   *
2438   * The query from $src parameter will be appended to the URL that is given from
2439   * the $_wp_admin_css_colors array value URL.
2440   *
2441   * @since 2.6.0
2442   * @global array $_wp_admin_css_colors
2443   *
2444   * @param string $src    Source URL.
2445   * @param string $handle Either 'colors' or 'colors-rtl'.
2446   * @return string|false URL path to CSS stylesheet for Administration Screens.
2447   */
2448  function wp_style_loader_src( $src, $handle ) {
2449      global $_wp_admin_css_colors;
2450  
2451      if ( wp_installing() ) {
2452          return preg_replace( '#^wp-admin/#', './', $src );
2453      }
2454  
2455      if ( 'colors' === $handle ) {
2456          $color = get_user_option( 'admin_color' );
2457  
2458          if ( empty( $color ) || ! isset( $_wp_admin_css_colors[ $color ] ) ) {
2459              $color = 'fresh';
2460          }
2461  
2462          $color = $_wp_admin_css_colors[ $color ];
2463          $url   = $color->url;
2464  
2465          if ( ! $url ) {
2466              return false;
2467          }
2468  
2469          $parsed = parse_url( $src );
2470          if ( isset( $parsed['query'] ) && $parsed['query'] ) {
2471              wp_parse_str( $parsed['query'], $qv );
2472              $url = add_query_arg( $qv, $url );
2473          }
2474  
2475          return $url;
2476      }
2477  
2478      return $src;
2479  }
2480  
2481  /**
2482   * Prints the script queue in the HTML head on admin pages.
2483   *
2484   * Postpones the scripts that were queued for the footer.
2485   * print_footer_scripts() is called in the footer to print these scripts.
2486   *
2487   * @since 2.8.0
2488   *
2489   * @see wp_print_scripts()
2490   *
2491   * @global bool $concatenate_scripts
2492   *
2493   * @return array
2494   */
2495  function print_head_scripts() {
2496      global $concatenate_scripts;
2497  
2498      if ( ! did_action( 'wp_print_scripts' ) ) {
2499          /** This action is documented in wp-includes/functions.wp-scripts.php */
2500          do_action( 'wp_print_scripts' );
2501      }
2502  
2503      $wp_scripts = wp_scripts();
2504  
2505      script_concat_settings();
2506      $wp_scripts->do_concat = $concatenate_scripts;
2507      $wp_scripts->do_head_items();
2508  
2509      /**
2510       * Filters whether to print the head scripts.
2511       *
2512       * @since 2.8.0
2513       *
2514       * @param bool $print Whether to print the head scripts. Default true.
2515       */
2516      if ( apply_filters( 'print_head_scripts', true ) ) {
2517          _print_scripts();
2518      }
2519  
2520      $wp_scripts->reset();
2521      return $wp_scripts->done;
2522  }
2523  
2524  /**
2525   * Prints the scripts that were queued for the footer or too late for the HTML head.
2526   *
2527   * @since 2.8.0
2528   *
2529   * @global WP_Scripts $wp_scripts
2530   * @global bool       $concatenate_scripts
2531   *
2532   * @return array
2533   */
2534  function print_footer_scripts() {
2535      global $wp_scripts, $concatenate_scripts;
2536  
2537      if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
2538          return array(); // No need to run if not instantiated.
2539      }
2540      script_concat_settings();
2541      $wp_scripts->do_concat = $concatenate_scripts;
2542      $wp_scripts->do_footer_items();
2543  
2544      /**
2545       * Filters whether to print the footer scripts.
2546       *
2547       * @since 2.8.0
2548       *
2549       * @param bool $print Whether to print the footer scripts. Default true.
2550       */
2551      if ( apply_filters( 'print_footer_scripts', true ) ) {
2552          _print_scripts();
2553      }
2554  
2555      $wp_scripts->reset();
2556      return $wp_scripts->done;
2557  }
2558  
2559  /**
2560   * Print scripts (internal use only)
2561   *
2562   * @ignore
2563   *
2564   * @global WP_Scripts $wp_scripts
2565   * @global bool       $compress_scripts
2566   */
2567  function _print_scripts() {
2568      global $wp_scripts, $compress_scripts;
2569  
2570      $zip = $compress_scripts ? 1 : 0;
2571      if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) {
2572          $zip = 'gzip';
2573      }
2574  
2575      $concat    = trim( $wp_scripts->concat, ', ' );
2576      $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : " type='text/javascript'";
2577  
2578      if ( $concat ) {
2579          if ( ! empty( $wp_scripts->print_code ) ) {
2580              echo "\n<script{$type_attr}>\n";
2581              echo "/* <![CDATA[ */\n"; // not needed in HTML 5
2582              echo $wp_scripts->print_code;
2583              echo "/* ]]> */\n";
2584              echo "</script>\n";
2585          }
2586  
2587          $concat       = str_split( $concat, 128 );
2588          $concatenated = '';
2589  
2590          foreach ( $concat as $key => $chunk ) {
2591              $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}";
2592          }
2593  
2594          $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version;
2595          echo "<script{$type_attr} src='" . esc_attr( $src ) . "'></script>\n";
2596      }
2597  
2598      if ( ! empty( $wp_scripts->print_html ) ) {
2599          echo $wp_scripts->print_html;
2600      }
2601  }
2602  
2603  /**
2604   * Prints the script queue in the HTML head on the front end.
2605   *
2606   * Postpones the scripts that were queued for the footer.
2607   * wp_print_footer_scripts() is called in the footer to print these scripts.
2608   *
2609   * @since 2.8.0
2610   *
2611   * @global WP_Scripts $wp_scripts
2612   *
2613   * @return array
2614   */
2615  function wp_print_head_scripts() {
2616      if ( ! did_action( 'wp_print_scripts' ) ) {
2617          /** This action is documented in wp-includes/functions.wp-scripts.php */
2618          do_action( 'wp_print_scripts' );
2619      }
2620  
2621      global $wp_scripts;
2622  
2623      if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
2624          return array(); // no need to run if nothing is queued
2625      }
2626      return print_head_scripts();
2627  }
2628  
2629  /**
2630   * Private, for use in *_footer_scripts hooks
2631   *
2632   * @since 3.3.0
2633   */
2634  function _wp_footer_scripts() {
2635      print_late_styles();
2636      print_footer_scripts();
2637  }
2638  
2639  /**
2640   * Hooks to print the scripts and styles in the footer.
2641   *
2642   * @since 2.8.0
2643   */
2644  function wp_print_footer_scripts() {
2645      /**
2646       * Fires when footer scripts are printed.
2647       *
2648       * @since 2.8.0
2649       */
2650      do_action( 'wp_print_footer_scripts' );
2651  }
2652  
2653  /**
2654   * Wrapper for do_action('wp_enqueue_scripts')
2655   *
2656   * Allows plugins to queue scripts for the front end using wp_enqueue_script().
2657   * Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.
2658   *
2659   * @since 2.8.0
2660   */
2661  function wp_enqueue_scripts() {
2662      /**
2663       * Fires when scripts and styles are enqueued.
2664       *
2665       * @since 2.8.0
2666       */
2667      do_action( 'wp_enqueue_scripts' );
2668  }
2669  
2670  /**
2671   * Prints the styles queue in the HTML head on admin pages.
2672   *
2673   * @since 2.8.0
2674   *
2675   * @global bool $concatenate_scripts
2676   *
2677   * @return array
2678   */
2679  function print_admin_styles() {
2680      global $concatenate_scripts;
2681  
2682      $wp_styles = wp_styles();
2683  
2684      script_concat_settings();
2685      $wp_styles->do_concat = $concatenate_scripts;
2686      $wp_styles->do_items( false );
2687  
2688      /**
2689       * Filters whether to print the admin styles.
2690       *
2691       * @since 2.8.0
2692       *
2693       * @param bool $print Whether to print the admin styles. Default true.
2694       */
2695      if ( apply_filters( 'print_admin_styles', true ) ) {
2696          _print_styles();
2697      }
2698  
2699      $wp_styles->reset();
2700      return $wp_styles->done;
2701  }
2702  
2703  /**
2704   * Prints the styles that were queued too late for the HTML head.
2705   *
2706   * @since 3.3.0
2707   *
2708   * @global WP_Styles $wp_styles
2709   * @global bool      $concatenate_scripts
2710   *
2711   * @return array|void
2712   */
2713  function print_late_styles() {
2714      global $wp_styles, $concatenate_scripts;
2715  
2716      if ( ! ( $wp_styles instanceof WP_Styles ) ) {
2717          return;
2718      }
2719  
2720      script_concat_settings();
2721      $wp_styles->do_concat = $concatenate_scripts;
2722      $wp_styles->do_footer_items();
2723  
2724      /**
2725       * Filters whether to print the styles queued too late for the HTML head.
2726       *
2727       * @since 3.3.0
2728       *
2729       * @param bool $print Whether to print the 'late' styles. Default true.
2730       */
2731      if ( apply_filters( 'print_late_styles', true ) ) {
2732          _print_styles();
2733      }
2734  
2735      $wp_styles->reset();
2736      return $wp_styles->done;
2737  }
2738  
2739  /**
2740   * Print styles (internal use only)
2741   *
2742   * @ignore
2743   * @since 3.3.0
2744   *
2745   * @global bool $compress_css
2746   */
2747  function _print_styles() {
2748      global $compress_css;
2749  
2750      $wp_styles = wp_styles();
2751  
2752      $zip = $compress_css ? 1 : 0;
2753      if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) {
2754          $zip = 'gzip';
2755      }
2756  
2757      $concat    = trim( $wp_styles->concat, ', ' );
2758      $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
2759  
2760      if ( $concat ) {
2761          $dir = $wp_styles->text_direction;
2762          $ver = $wp_styles->default_version;
2763  
2764          $concat       = str_split( $concat, 128 );
2765          $concatenated = '';
2766  
2767          foreach ( $concat as $key => $chunk ) {
2768              $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}";
2769          }
2770  
2771          $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}" . $concatenated . '&ver=' . $ver;
2772          echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "'{$type_attr} media='all' />\n";
2773  
2774          if ( ! empty( $wp_styles->print_code ) ) {
2775              echo "<style{$type_attr}>\n";
2776              echo $wp_styles->print_code;
2777              echo "\n</style>\n";
2778          }
2779      }
2780  
2781      if ( ! empty( $wp_styles->print_html ) ) {
2782          echo $wp_styles->print_html;
2783      }
2784  }
2785  
2786  /**
2787   * Determine the concatenation and compression settings for scripts and styles.
2788   *
2789   * @since 2.8.0
2790   *
2791   * @global bool $concatenate_scripts
2792   * @global bool $compress_scripts
2793   * @global bool $compress_css
2794   */
2795  function script_concat_settings() {
2796      global $concatenate_scripts, $compress_scripts, $compress_css;
2797  
2798      $compressed_output = ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) );
2799  
2800      if ( ! isset( $concatenate_scripts ) ) {
2801          $concatenate_scripts = defined( 'CONCATENATE_SCRIPTS' ) ? CONCATENATE_SCRIPTS : true;
2802          if ( ( ! is_admin() && ! did_action( 'login_init' ) ) || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) {
2803              $concatenate_scripts = false;
2804          }
2805      }
2806  
2807      if ( ! isset( $compress_scripts ) ) {
2808          $compress_scripts = defined( 'COMPRESS_SCRIPTS' ) ? COMPRESS_SCRIPTS : true;
2809          if ( $compress_scripts && ( ! get_site_option( 'can_compress_scripts' ) || $compressed_output ) ) {
2810              $compress_scripts = false;
2811          }
2812      }
2813  
2814      if ( ! isset( $compress_css ) ) {
2815          $compress_css = defined( 'COMPRESS_CSS' ) ? COMPRESS_CSS : true;
2816          if ( $compress_css && ( ! get_site_option( 'can_compress_scripts' ) || $compressed_output ) ) {
2817              $compress_css = false;
2818          }
2819      }
2820  }
2821  
2822  /**
2823   * Handles the enqueueing of block scripts and styles that are common to both
2824   * the editor and the front-end.
2825   *
2826   * @since 5.0.0
2827   *
2828   * @global WP_Screen $current_screen WordPress current screen object.
2829   */
2830  function wp_common_block_scripts_and_styles() {
2831      global $current_screen;
2832  
2833      if ( is_admin() && ( $current_screen instanceof WP_Screen ) && ! $current_screen->is_block_editor() ) {
2834          return;
2835      }
2836  
2837      wp_enqueue_style( 'wp-block-library' );
2838  
2839      if ( current_theme_supports( 'wp-block-styles' ) ) {
2840          wp_enqueue_style( 'wp-block-library-theme' );
2841      }
2842  
2843      /**
2844       * Fires after enqueuing block assets for both editor and front-end.
2845       *
2846       * Call `add_action` on any hook before 'wp_enqueue_scripts'.
2847       *
2848       * In the function call you supply, simply use `wp_enqueue_script` and
2849       * `wp_enqueue_style` to add your functionality to the Gutenberg editor.
2850       *
2851       * @since 5.0.0
2852       */
2853      do_action( 'enqueue_block_assets' );
2854  }
2855  
2856  /**
2857   * Enqueues registered block scripts and styles, depending on current rendered
2858   * context (only enqueuing editor scripts while in context of the editor).
2859   *
2860   * @since 5.0.0
2861   *
2862   * @global WP_Screen $current_screen WordPress current screen object.
2863   */
2864  function wp_enqueue_registered_block_scripts_and_styles() {
2865      global $current_screen;
2866  
2867      $is_editor = ( ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor() );
2868  
2869      $block_registry = WP_Block_Type_Registry::get_instance();
2870      foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {
2871          // Front-end styles.
2872          if ( ! empty( $block_type->style ) ) {
2873              wp_enqueue_style( $block_type->style );
2874          }
2875  
2876          // Front-end script.
2877          if ( ! empty( $block_type->script ) ) {
2878              wp_enqueue_script( $block_type->script );
2879          }
2880  
2881          // Editor styles.
2882          if ( $is_editor && ! empty( $block_type->editor_style ) ) {
2883              wp_enqueue_style( $block_type->editor_style );
2884          }
2885  
2886          // Editor script.
2887          if ( $is_editor && ! empty( $block_type->editor_script ) ) {
2888              wp_enqueue_script( $block_type->editor_script );
2889          }
2890      }
2891  }
2892  
2893  /**
2894   * Function responsible for enqueuing the styles required for block styles functionality on the editor and on the frontend.
2895   *
2896   * @since 5.3.0
2897   */
2898  function enqueue_block_styles_assets() {
2899      $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
2900  
2901      foreach ( $block_styles as $styles ) {
2902          foreach ( $styles as $style_properties ) {
2903              if ( isset( $style_properties['style_handle'] ) ) {
2904                  wp_enqueue_style( $style_properties['style_handle'] );
2905              }
2906              if ( isset( $style_properties['inline_style'] ) ) {
2907                  wp_add_inline_style( 'wp-block-library', $style_properties['inline_style'] );
2908              }
2909          }
2910      }
2911  }
2912  
2913  /**
2914   * Function responsible for enqueuing the assets required for block styles functionality on the editor.
2915   *
2916   * @since 5.3.0
2917   */
2918  function enqueue_editor_block_styles_assets() {
2919      $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
2920  
2921      $register_script_lines = array( '( function() {' );
2922      foreach ( $block_styles as $block_name => $styles ) {
2923          foreach ( $styles as $style_properties ) {
2924              $register_script_lines[] = sprintf(
2925                  '    wp.blocks.registerBlockStyle( \'%s\', %s );',
2926                  $block_name,
2927                  wp_json_encode(
2928                      array(
2929                          'name'  => $style_properties['name'],
2930                          'label' => $style_properties['label'],
2931                      )
2932                  )
2933              );
2934          }
2935      }
2936      $register_script_lines[] = '} )();';
2937      $inline_script           = implode( "\n", $register_script_lines );
2938  
2939      wp_register_script( 'wp-block-styles', false, array( 'wp-blocks' ), true, true );
2940      wp_add_inline_script( 'wp-block-styles', $inline_script );
2941      wp_enqueue_script( 'wp-block-styles' );
2942  }


Generated: Sat Nov 23 20:47:33 2019 Cross-referenced by PHPXref 0.7