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


Generated : Sat Nov 28 08:20:01 2020 Cross-referenced by PHPXref