[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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


Generated : Wed Apr 8 08:20:02 2020 Cross-referenced by PHPXref