[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

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


Generated : Fri Mar 5 08:20:02 2021 Cross-referenced by PHPXref