[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

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


Generated: Thu Jul 9 01:00:03 2020 Cross-referenced by PHPXref 0.7.1