[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

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


Generated: Thu Sep 19 01:00:03 2019 Cross-referenced by PHPXref 0.7.1