PageRenderTime 58ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/wp-includes/script-loader.php

https://gitlab.com/VTTE/sitios-vtte
PHP | 1141 lines | 826 code | 129 blank | 186 comment | 59 complexity | 4585b4db320a3979d44be3aeea84c4b4 MD5 | raw file
  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. /** WordPress Dependency Class */
  19. require ABSPATH . WPINC . '/class-wp-dependency.php';
  20. /** WordPress Dependencies Class */
  21. require ABSPATH . WPINC . '/class.wp-dependencies.php';
  22. /** WordPress Scripts Class */
  23. require ABSPATH . WPINC . '/class.wp-scripts.php';
  24. /** WordPress Scripts Functions */
  25. require ABSPATH . WPINC . '/functions.wp-scripts.php';
  26. /** WordPress Styles Class */
  27. require ABSPATH . WPINC . '/class.wp-styles.php';
  28. /** WordPress Styles Functions */
  29. require ABSPATH . WPINC . '/functions.wp-styles.php';
  30. /**
  31. * Registers TinyMCE scripts.
  32. *
  33. * @since 5.0.0
  34. *
  35. * @param WP_Scripts $scripts WP_Scripts object.
  36. */
  37. function wp_register_tinymce_scripts( $scripts, $force_uncompressed = false ) {
  38. global $tinymce_version, $concatenate_scripts, $compress_scripts;
  39. $suffix = wp_scripts_get_suffix();
  40. $dev_suffix = wp_scripts_get_suffix( 'dev' );
  41. script_concat_settings();
  42. $compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] )
  43. && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed;
  44. // Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production)
  45. // or tinymce.min.js (when SCRIPT_DEBUG is true).
  46. if ( $compressed ) {
  47. $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version );
  48. } else {
  49. $scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$dev_suffix.js", array(), $tinymce_version );
  50. $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$dev_suffix.js", array( 'wp-tinymce-root' ), $tinymce_version );
  51. }
  52. $scripts->add( 'wp-tinymce-lists', includes_url( "js/tinymce/plugins/lists/plugin$suffix.js" ), array( 'wp-tinymce' ), $tinymce_version );
  53. }
  54. /**
  55. * Registers all the WordPress vendor scripts that are in the standardized
  56. * `js/dist/vendor/` location.
  57. *
  58. * For the order of `$scripts->add` see `wp_default_scripts`.
  59. *
  60. * @since 5.0.0
  61. *
  62. * @param WP_Scripts $scripts WP_Scripts object.
  63. */
  64. function wp_default_packages_vendor( $scripts ) {
  65. global $wp_locale;
  66. $suffix = wp_scripts_get_suffix();
  67. $vendor_scripts = array(
  68. 'react' => array( 'wp-polyfill' ),
  69. 'react-dom' => array( 'react' ),
  70. 'moment',
  71. 'lodash',
  72. 'wp-polyfill-fetch',
  73. 'wp-polyfill-formdata',
  74. 'wp-polyfill-node-contains',
  75. 'wp-polyfill-url',
  76. 'wp-polyfill-dom-rect',
  77. 'wp-polyfill-element-closest',
  78. 'wp-polyfill',
  79. );
  80. $vendor_scripts_versions = array(
  81. 'react' => '16.9.0',
  82. 'react-dom' => '16.9.0',
  83. 'moment' => '2.22.2',
  84. 'lodash' => '4.17.15',
  85. 'wp-polyfill-fetch' => '3.0.0',
  86. 'wp-polyfill-formdata' => '3.0.12',
  87. 'wp-polyfill-node-contains' => '3.42.0',
  88. 'wp-polyfill-url' => '3.6.4',
  89. 'wp-polyfill-dom-rect' => '3.42.0',
  90. 'wp-polyfill-element-closest' => '2.0.2',
  91. 'wp-polyfill' => '7.4.4',
  92. );
  93. foreach ( $vendor_scripts as $handle => $dependencies ) {
  94. if ( is_string( $dependencies ) ) {
  95. $handle = $dependencies;
  96. $dependencies = array();
  97. }
  98. $path = "/wp-includes/js/dist/vendor/$handle$suffix.js";
  99. $version = $vendor_scripts_versions[ $handle ];
  100. $scripts->add( $handle, $path, $dependencies, $version, 1 );
  101. }
  102. $scripts->add( 'wp-polyfill', null, array( 'wp-polyfill' ) );
  103. did_action( 'init' ) && $scripts->add_inline_script(
  104. 'wp-polyfill',
  105. wp_get_script_polyfill(
  106. $scripts,
  107. array(
  108. '\'fetch\' in window' => 'wp-polyfill-fetch',
  109. 'document.contains' => 'wp-polyfill-node-contains',
  110. 'window.DOMRect' => 'wp-polyfill-dom-rect',
  111. 'window.URL && window.URL.prototype && window.URLSearchParams' => 'wp-polyfill-url',
  112. 'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata',
  113. 'Element.prototype.matches && Element.prototype.closest' => 'wp-polyfill-element-closest',
  114. )
  115. )
  116. );
  117. did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
  118. did_action( 'init' ) && $scripts->add_inline_script(
  119. 'moment',
  120. sprintf(
  121. "moment.locale( '%s', %s );",
  122. get_user_locale(),
  123. wp_json_encode(
  124. array(
  125. 'months' => array_values( $wp_locale->month ),
  126. 'monthsShort' => array_values( $wp_locale->month_abbrev ),
  127. 'weekdays' => array_values( $wp_locale->weekday ),
  128. 'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
  129. 'week' => array(
  130. 'dow' => (int) get_option( 'start_of_week', 0 ),
  131. ),
  132. 'longDateFormat' => array(
  133. 'LT' => get_option( 'time_format', __( 'g:i a', 'default' ) ),
  134. 'LTS' => null,
  135. 'L' => null,
  136. 'LL' => get_option( 'date_format', __( 'F j, Y', 'default' ) ),
  137. 'LLL' => __( 'F j, Y g:i a', 'default' ),
  138. 'LLLL' => null,
  139. ),
  140. )
  141. )
  142. ),
  143. 'after'
  144. );
  145. }
  146. /**
  147. * Returns contents of an inline script used in appending polyfill scripts for
  148. * browsers which fail the provided tests. The provided array is a mapping from
  149. * a condition to verify feature support to its polyfill script handle.
  150. *
  151. * @since 5.0.0
  152. *
  153. * @param WP_Scripts $scripts WP_Scripts object.
  154. * @param array $tests Features to detect.
  155. * @return string Conditional polyfill inline script.
  156. */
  157. function wp_get_script_polyfill( $scripts, $tests ) {
  158. $polyfill = '';
  159. foreach ( $tests as $test => $handle ) {
  160. if ( ! array_key_exists( $handle, $scripts->registered ) ) {
  161. continue;
  162. }
  163. $src = $scripts->registered[ $handle ]->src;
  164. $ver = $scripts->registered[ $handle ]->ver;
  165. if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $scripts->content_url && 0 === strpos( $src, $scripts->content_url ) ) ) {
  166. $src = $scripts->base_url . $src;
  167. }
  168. if ( ! empty( $ver ) ) {
  169. $src = add_query_arg( 'ver', $ver, $src );
  170. }
  171. /** This filter is documented in wp-includes/class.wp-scripts.php */
  172. $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
  173. if ( ! $src ) {
  174. continue;
  175. }
  176. $polyfill .= (
  177. // Test presence of feature...
  178. '( ' . $test . ' ) || ' .
  179. /*
  180. * ...appending polyfill on any failures. Cautious viewers may balk
  181. * at the `document.write`. Its caveat of synchronous mid-stream
  182. * blocking write is exactly the behavior we need though.
  183. */
  184. 'document.write( \'<script src="' .
  185. $src .
  186. '"></scr\' + \'ipt>\' );'
  187. );
  188. }
  189. return $polyfill;
  190. }
  191. /**
  192. * Registers all the WordPress packages scripts that are in the standardized
  193. * `js/dist/` location.
  194. *
  195. * For the order of `$scripts->add` see `wp_default_scripts`.
  196. *
  197. * @since 5.0.0
  198. *
  199. * @param WP_Scripts $scripts WP_Scripts object.
  200. */
  201. function wp_default_packages_scripts( $scripts ) {
  202. $suffix = wp_scripts_get_suffix();
  203. // Expects multidimensional array like:
  204. // 'a11y.js' => array('dependencies' => array(...), 'version' => '...'),
  205. // 'annotations.js' => array('dependencies' => array(...), 'version' => '...'),
  206. // 'api-fetch.js' => array(...
  207. $assets = include ABSPATH . WPINC . '/assets/script-loader-packages.php';
  208. foreach ( $assets as $package_name => $package_data ) {
  209. $basename = basename( $package_name, '.js' );
  210. $handle = 'wp-' . $basename;
  211. $path = "/wp-includes/js/dist/{$basename}{$suffix}.js";
  212. if ( ! empty( $package_data['dependencies'] ) ) {
  213. $dependencies = $package_data['dependencies'];
  214. } else {
  215. $dependencies = array();
  216. }
  217. // Add dependencies that cannot be detected and generated by build tools.
  218. switch ( $handle ) {
  219. case 'wp-block-library':
  220. array_push( $dependencies, 'editor' );
  221. break;
  222. case 'wp-edit-post':
  223. array_push( $dependencies, 'media-models', 'media-views', 'postbox', 'wp-dom-ready' );
  224. break;
  225. }
  226. $scripts->add( $handle, $path, $dependencies, $package_data['version'], 1 );
  227. if ( in_array( 'wp-i18n', $dependencies, true ) ) {
  228. $scripts->set_translations( $handle );
  229. }
  230. }
  231. }
  232. /**
  233. * Adds inline scripts required for the WordPress JavaScript packages.
  234. *
  235. * @since 5.0.0
  236. *
  237. * @param WP_Scripts $scripts WP_Scripts object.
  238. */
  239. function wp_default_packages_inline_scripts( $scripts ) {
  240. global $wp_locale;
  241. if ( isset( $scripts->registered['wp-api-fetch'] ) ) {
  242. $scripts->registered['wp-api-fetch']->deps[] = 'wp-hooks';
  243. }
  244. $scripts->add_inline_script(
  245. 'wp-api-fetch',
  246. sprintf(
  247. 'wp.apiFetch.use( wp.apiFetch.createRootURLMiddleware( "%s" ) );',
  248. esc_url_raw( get_rest_url() )
  249. ),
  250. 'after'
  251. );
  252. $scripts->add_inline_script(
  253. 'wp-api-fetch',
  254. implode(
  255. "\n",
  256. array(
  257. sprintf(
  258. 'wp.apiFetch.nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );',
  259. ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' )
  260. ),
  261. 'wp.apiFetch.use( wp.apiFetch.nonceMiddleware );',
  262. 'wp.apiFetch.use( wp.apiFetch.mediaUploadMiddleware );',
  263. sprintf(
  264. 'wp.apiFetch.nonceEndpoint = "%s";',
  265. admin_url( 'admin-ajax.php?action=rest-nonce' )
  266. ),
  267. )
  268. ),
  269. 'after'
  270. );
  271. $scripts->add_inline_script(
  272. 'wp-data',
  273. implode(
  274. "\n",
  275. array(
  276. '( function() {',
  277. ' var userId = ' . get_current_user_ID() . ';',
  278. ' var storageKey = "WP_DATA_USER_" + userId;',
  279. ' wp.data',
  280. ' .use( wp.data.plugins.persistence, { storageKey: storageKey } );',
  281. ' wp.data.plugins.persistence.__unstableMigrate( { storageKey: storageKey } );',
  282. '} )();',
  283. )
  284. )
  285. );
  286. $scripts->add_inline_script(
  287. 'wp-date',
  288. sprintf(
  289. 'wp.date.setSettings( %s );',
  290. wp_json_encode(
  291. array(
  292. 'l10n' => array(
  293. 'locale' => get_user_locale(),
  294. 'months' => array_values( $wp_locale->month ),
  295. 'monthsShort' => array_values( $wp_locale->month_abbrev ),
  296. 'weekdays' => array_values( $wp_locale->weekday ),
  297. 'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
  298. 'meridiem' => (object) $wp_locale->meridiem,
  299. 'relative' => array(
  300. /* translators: %s: Duration. */
  301. 'future' => __( '%s from now' ),
  302. /* translators: %s: Duration. */
  303. 'past' => __( '%s ago' ),
  304. ),
  305. ),
  306. 'formats' => array(
  307. /* translators: Time format, see https://www.php.net/date */
  308. 'time' => get_option( 'time_format', __( 'g:i a' ) ),
  309. /* translators: Date format, see https://www.php.net/date */
  310. 'date' => get_option( 'date_format', __( 'F j, Y' ) ),
  311. /* translators: Date/Time format, see https://www.php.net/date */
  312. 'datetime' => __( 'F j, Y g:i a' ),
  313. /* translators: Abbreviated date/time format, see https://www.php.net/date */
  314. 'datetimeAbbreviated' => __( 'M j, Y g:i a' ),
  315. ),
  316. 'timezone' => array(
  317. 'offset' => get_option( 'gmt_offset', 0 ),
  318. 'string' => get_option( 'timezone_string', 'UTC' ),
  319. ),
  320. )
  321. )
  322. ),
  323. 'after'
  324. );
  325. // Loading the old editor and its config to ensure the classic block works as expected.
  326. $scripts->add_inline_script(
  327. 'editor',
  328. 'window.wp.oldEditor = window.wp.editor;',
  329. 'after'
  330. );
  331. }
  332. /**
  333. * Adds inline scripts required for the TinyMCE in the block editor.
  334. *
  335. * These TinyMCE init settings are used to extend and override the default settings
  336. * from `_WP_Editors::default_settings()` for the Classic block.
  337. *
  338. * @since 5.0.0
  339. *
  340. * @global WP_Scripts $wp_scripts
  341. */
  342. function wp_tinymce_inline_scripts() {
  343. global $wp_scripts;
  344. /** This filter is documented in wp-includes/class-wp-editor.php */
  345. $editor_settings = apply_filters( 'wp_editor_settings', array( 'tinymce' => true ), 'classic-block' );
  346. $tinymce_plugins = array(
  347. 'charmap',
  348. 'colorpicker',
  349. 'hr',
  350. 'lists',
  351. 'media',
  352. 'paste',
  353. 'tabfocus',
  354. 'textcolor',
  355. 'fullscreen',
  356. 'wordpress',
  357. 'wpautoresize',
  358. 'wpeditimage',
  359. 'wpemoji',
  360. 'wpgallery',
  361. 'wplink',
  362. 'wpdialogs',
  363. 'wptextpattern',
  364. 'wpview',
  365. );
  366. /** This filter is documented in wp-includes/class-wp-editor.php */
  367. $tinymce_plugins = apply_filters( 'tiny_mce_plugins', $tinymce_plugins, 'classic-block' );
  368. $tinymce_plugins = array_unique( $tinymce_plugins );
  369. $disable_captions = false;
  370. // Runs after `tiny_mce_plugins` but before `mce_buttons`.
  371. /** This filter is documented in wp-admin/includes/media.php */
  372. if ( apply_filters( 'disable_captions', '' ) ) {
  373. $disable_captions = true;
  374. }
  375. $toolbar1 = array(
  376. 'formatselect',
  377. 'bold',
  378. 'italic',
  379. 'bullist',
  380. 'numlist',
  381. 'blockquote',
  382. 'alignleft',
  383. 'aligncenter',
  384. 'alignright',
  385. 'link',
  386. 'unlink',
  387. 'wp_more',
  388. 'spellchecker',
  389. 'wp_add_media',
  390. 'wp_adv',
  391. );
  392. /** This filter is documented in wp-includes/class-wp-editor.php */
  393. $toolbar1 = apply_filters( 'mce_buttons', $toolbar1, 'classic-block' );
  394. $toolbar2 = array(
  395. 'strikethrough',
  396. 'hr',
  397. 'forecolor',
  398. 'pastetext',
  399. 'removeformat',
  400. 'charmap',
  401. 'outdent',
  402. 'indent',
  403. 'undo',
  404. 'redo',
  405. 'wp_help',
  406. );
  407. /** This filter is documented in wp-includes/class-wp-editor.php */
  408. $toolbar2 = apply_filters( 'mce_buttons_2', $toolbar2, 'classic-block' );
  409. /** This filter is documented in wp-includes/class-wp-editor.php */
  410. $toolbar3 = apply_filters( 'mce_buttons_3', array(), 'classic-block' );
  411. /** This filter is documented in wp-includes/class-wp-editor.php */
  412. $toolbar4 = apply_filters( 'mce_buttons_4', array(), 'classic-block' );
  413. /** This filter is documented in wp-includes/class-wp-editor.php */
  414. $external_plugins = apply_filters( 'mce_external_plugins', array(), 'classic-block' );
  415. $tinymce_settings = array(
  416. 'plugins' => implode( ',', $tinymce_plugins ),
  417. 'toolbar1' => implode( ',', $toolbar1 ),
  418. 'toolbar2' => implode( ',', $toolbar2 ),
  419. 'toolbar3' => implode( ',', $toolbar3 ),
  420. 'toolbar4' => implode( ',', $toolbar4 ),
  421. 'external_plugins' => wp_json_encode( $external_plugins ),
  422. 'classic_block_editor' => true,
  423. );
  424. if ( $disable_captions ) {
  425. $tinymce_settings['wpeditimage_disable_captions'] = true;
  426. }
  427. if ( ! empty( $editor_settings['tinymce'] ) && is_array( $editor_settings['tinymce'] ) ) {
  428. array_merge( $tinymce_settings, $editor_settings['tinymce'] );
  429. }
  430. /** This filter is documented in wp-includes/class-wp-editor.php */
  431. $tinymce_settings = apply_filters( 'tiny_mce_before_init', $tinymce_settings, 'classic-block' );
  432. // Do "by hand" translation from PHP array to js object.
  433. // Prevents breakage in some custom settings.
  434. $init_obj = '';
  435. foreach ( $tinymce_settings as $key => $value ) {
  436. if ( is_bool( $value ) ) {
  437. $val = $value ? 'true' : 'false';
  438. $init_obj .= $key . ':' . $val . ',';
  439. continue;
  440. } elseif ( ! empty( $value ) && is_string( $value ) && (
  441. ( '{' === $value[0] && '}' === $value[ strlen( $value ) - 1 ] ) ||
  442. ( '[' === $value[0] && ']' === $value[ strlen( $value ) - 1 ] ) ||
  443. preg_match( '/^\(?function ?\(/', $value ) ) ) {
  444. $init_obj .= $key . ':' . $value . ',';
  445. continue;
  446. }
  447. $init_obj .= $key . ':"' . $value . '",';
  448. }
  449. $init_obj = '{' . trim( $init_obj, ' ,' ) . '}';
  450. $script = 'window.wpEditorL10n = {
  451. tinymce: {
  452. baseURL: ' . wp_json_encode( includes_url( 'js/tinymce' ) ) . ',
  453. suffix: ' . ( SCRIPT_DEBUG ? '""' : '".min"' ) . ',
  454. settings: ' . $init_obj . ',
  455. }
  456. }';
  457. $wp_scripts->add_inline_script( 'wp-block-library', $script, 'before' );
  458. }
  459. /**
  460. * Registers all the WordPress packages scripts.
  461. *
  462. * @since 5.0.0
  463. *
  464. * @param WP_Scripts $scripts WP_Scripts object.
  465. */
  466. function wp_default_packages( $scripts ) {
  467. wp_default_packages_vendor( $scripts );
  468. wp_register_tinymce_scripts( $scripts );
  469. wp_default_packages_scripts( $scripts );
  470. if ( did_action( 'init' ) ) {
  471. wp_default_packages_inline_scripts( $scripts );
  472. }
  473. }
  474. /**
  475. * Returns the suffix that can be used for the scripts.
  476. *
  477. * There are two suffix types, the normal one and the dev suffix.
  478. *
  479. * @since 5.0.0
  480. *
  481. * @param string $type The type of suffix to retrieve.
  482. * @return string The script suffix.
  483. */
  484. function wp_scripts_get_suffix( $type = '' ) {
  485. static $suffixes;
  486. if ( null === $suffixes ) {
  487. // Include an unmodified $wp_version.
  488. require ABSPATH . WPINC . '/version.php';
  489. $develop_src = false !== strpos( $wp_version, '-src' );
  490. if ( ! defined( 'SCRIPT_DEBUG' ) ) {
  491. define( 'SCRIPT_DEBUG', $develop_src );
  492. }
  493. $suffix = SCRIPT_DEBUG ? '' : '.min';
  494. $dev_suffix = $develop_src ? '' : '.min';
  495. $suffixes = array(
  496. 'suffix' => $suffix,
  497. 'dev_suffix' => $dev_suffix,
  498. );
  499. }
  500. if ( 'dev' === $type ) {
  501. return $suffixes['dev_suffix'];
  502. }
  503. return $suffixes['suffix'];
  504. }
  505. /**
  506. * Register all WordPress scripts.
  507. *
  508. * Localizes some of them.
  509. * args order: `$scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 );`
  510. * when last arg === 1 queues the script for the footer
  511. *
  512. * @since 2.6.0
  513. *
  514. * @param WP_Scripts $scripts WP_Scripts object.
  515. */
  516. function wp_default_scripts( $scripts ) {
  517. $suffix = wp_scripts_get_suffix();
  518. $dev_suffix = wp_scripts_get_suffix( 'dev' );
  519. $guessurl = site_url();
  520. if ( ! $guessurl ) {
  521. $guessed_url = true;
  522. $guessurl = wp_guess_url();
  523. }
  524. $scripts->base_url = $guessurl;
  525. $scripts->content_url = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : '';
  526. $scripts->default_version = get_bloginfo( 'version' );
  527. $scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' );
  528. $scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" );
  529. did_action( 'init' ) && $scripts->localize(
  530. 'utils',
  531. 'userSettings',
  532. array(
  533. 'url' => (string) SITECOOKIEPATH,
  534. 'uid' => (string) get_current_user_id(),
  535. 'time' => (string) time(),
  536. 'secure' => (string) ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ),
  537. )
  538. );
  539. $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hoverIntent', 'utils' ), false, 1 );
  540. did_action( 'init' ) && $scripts->localize(
  541. 'common',
  542. 'commonL10n',
  543. array(
  544. 'warnDelete' => __( "You are about to permanently delete these items from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
  545. 'dismiss' => __( 'Dismiss this notice.' ),
  546. 'collapseMenu' => __( 'Collapse Main menu' ),
  547. 'expandMenu' => __( 'Expand Main menu' ),
  548. )
  549. );
  550. $scripts->add( 'wp-sanitize', "/wp-includes/js/wp-sanitize$suffix.js", array(), false, 1 );
  551. $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 );
  552. $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 );
  553. did_action( 'init' ) && $scripts->localize(
  554. 'quicktags',
  555. 'quicktagsL10n',
  556. array(
  557. 'closeAllOpenTags' => __( 'Close all open tags' ),
  558. 'closeTags' => __( 'close tags' ),
  559. 'enterURL' => __( 'Enter the URL' ),
  560. 'enterImageURL' => __( 'Enter the URL of the image' ),
  561. 'enterImageDescription' => __( 'Enter a description of the image' ),
  562. 'textdirection' => __( 'text direction' ),
  563. 'toggleTextdirection' => __( 'Toggle Editor Text Direction' ),
  564. 'dfw' => __( 'Distraction-free writing mode' ),
  565. 'strong' => __( 'Bold' ),
  566. 'strongClose' => __( 'Close bold tag' ),
  567. 'em' => __( 'Italic' ),
  568. 'emClose' => __( 'Close italic tag' ),
  569. 'link' => __( 'Insert link' ),
  570. 'blockquote' => __( 'Blockquote' ),
  571. 'blockquoteClose' => __( 'Close blockquote tag' ),
  572. 'del' => __( 'Deleted text (strikethrough)' ),
  573. 'delClose' => __( 'Close deleted text tag' ),
  574. 'ins' => __( 'Inserted text' ),
  575. 'insClose' => __( 'Close inserted text tag' ),
  576. 'image' => __( 'Insert image' ),
  577. 'ul' => __( 'Bulleted list' ),
  578. 'ulClose' => __( 'Close bulleted list tag' ),
  579. 'ol' => __( 'Numbered list' ),
  580. 'olClose' => __( 'Close numbered list tag' ),
  581. 'li' => __( 'List item' ),
  582. 'liClose' => __( 'Close list item tag' ),
  583. 'code' => __( 'Code' ),
  584. 'codeClose' => __( 'Close code tag' ),
  585. 'more' => __( 'Insert Read More tag' ),
  586. )
  587. );
  588. $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array( 'prototype' ), '3517m' );
  589. $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array( 'utils', 'jquery' ), false, 1 );
  590. $scripts->add( 'clipboard', "/wp-includes/js/clipboard$suffix.js", array(), false, 1 );
  591. $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array( 'jquery' ), false, 1 );
  592. did_action( 'init' ) && $scripts->localize(
  593. 'wp-ajax-response',
  594. 'wpAjax',
  595. array(
  596. 'noPerm' => __( 'Sorry, you are not allowed to do that.' ),
  597. 'broken' => __( 'Something went wrong.' ),
  598. )
  599. );
  600. $scripts->add( 'wp-api-request', "/wp-includes/js/api-request$suffix.js", array( 'jquery' ), false, 1 );
  601. // `wpApiSettings` is also used by `wp-api`, which depends on this script.
  602. did_action( 'init' ) && $scripts->localize(
  603. 'wp-api-request',
  604. 'wpApiSettings',
  605. array(
  606. 'root' => esc_url_raw( get_rest_url() ),
  607. 'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ),
  608. 'versionString' => 'wp/v2/',
  609. )
  610. );
  611. $scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), '20111129a', 1 );
  612. did_action( 'init' ) && $scripts->localize(
  613. 'wp-pointer',
  614. 'wpPointerL10n',
  615. array(
  616. 'dismiss' => __( 'Dismiss' ),
  617. )
  618. );
  619. $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array( 'heartbeat' ), false, 1 );
  620. $scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array( 'jquery', 'wp-hooks' ), false, 1 );
  621. did_action( 'init' ) && $scripts->localize(
  622. 'heartbeat',
  623. 'heartbeatSettings',
  624. /**
  625. * Filters the Heartbeat settings.
  626. *
  627. * @since 3.6.0
  628. *
  629. * @param array $settings Heartbeat settings array.
  630. */
  631. apply_filters( 'heartbeat_settings', array() )
  632. );
  633. $scripts->add( 'wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array( 'heartbeat' ), false, 1 );
  634. did_action( 'init' ) && $scripts->localize(
  635. 'wp-auth-check',
  636. 'authcheckL10n',
  637. array(
  638. 'beforeunload' => __( 'Your session has expired. You can log in again from this page or go to the login page.' ),
  639. /**
  640. * Filters the authentication check interval.
  641. *
  642. * @since 3.6.0
  643. *
  644. * @param int $interval The interval in which to check a user's authentication.
  645. * Default 3 minutes in seconds, or 180.
  646. */
  647. 'interval' => apply_filters( 'wp_auth_check_interval', 3 * MINUTE_IN_SECONDS ),
  648. )
  649. );
  650. $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 );
  651. // WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source.
  652. $scripts->add( 'prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1' );
  653. $scripts->add( 'scriptaculous-root', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array( 'prototype' ), '1.9.0' );
  654. $scripts->add( 'scriptaculous-builder', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array( 'scriptaculous-root' ), '1.9.0' );
  655. $scripts->add( 'scriptaculous-dragdrop', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array( 'scriptaculous-builder', 'scriptaculous-effects' ), '1.9.0' );
  656. $scripts->add( 'scriptaculous-effects', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array( 'scriptaculous-root' ), '1.9.0' );
  657. $scripts->add( 'scriptaculous-slider', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array( 'scriptaculous-effects' ), '1.9.0' );
  658. $scripts->add( 'scriptaculous-sound', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' );
  659. $scripts->add( 'scriptaculous-controls', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array( 'scriptaculous-root' ), '1.9.0' );
  660. $scripts->add( 'scriptaculous', false, array( 'scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls' ) );
  661. // Not used in core, replaced by Jcrop.js.
  662. $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array( 'scriptaculous-dragdrop' ) );
  663. // jQuery.
  664. $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.12.4-wp' );
  665. $scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.12.4-wp' );
  666. $scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.4.1' );
  667. // Full jQuery UI.
  668. $scripts->add( 'jquery-ui-core', "/wp-includes/js/jquery/ui/core$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
  669. $scripts->add( 'jquery-effects-core', "/wp-includes/js/jquery/ui/effect$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
  670. $scripts->add( 'jquery-effects-blind', "/wp-includes/js/jquery/ui/effect-blind$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  671. $scripts->add( 'jquery-effects-bounce', "/wp-includes/js/jquery/ui/effect-bounce$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  672. $scripts->add( 'jquery-effects-clip', "/wp-includes/js/jquery/ui/effect-clip$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  673. $scripts->add( 'jquery-effects-drop', "/wp-includes/js/jquery/ui/effect-drop$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  674. $scripts->add( 'jquery-effects-explode', "/wp-includes/js/jquery/ui/effect-explode$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  675. $scripts->add( 'jquery-effects-fade', "/wp-includes/js/jquery/ui/effect-fade$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  676. $scripts->add( 'jquery-effects-fold', "/wp-includes/js/jquery/ui/effect-fold$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  677. $scripts->add( 'jquery-effects-highlight', "/wp-includes/js/jquery/ui/effect-highlight$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  678. $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 );
  679. $scripts->add( 'jquery-effects-pulsate', "/wp-includes/js/jquery/ui/effect-pulsate$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  680. $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 );
  681. $scripts->add( 'jquery-effects-shake', "/wp-includes/js/jquery/ui/effect-shake$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  682. $scripts->add( 'jquery-effects-size', "/wp-includes/js/jquery/ui/effect-size$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  683. $scripts->add( 'jquery-effects-slide', "/wp-includes/js/jquery/ui/effect-slide$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  684. $scripts->add( 'jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  685. $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 );
  686. $scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$dev_suffix.js", array( 'jquery-ui-menu', 'wp-a11y' ), '1.11.4', 1 );
  687. $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 );
  688. $scripts->add( 'jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$dev_suffix.js", array( 'jquery-ui-core' ), '1.11.4', 1 );
  689. $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 );
  690. $scripts->add( 'jquery-ui-draggable', "/wp-includes/js/jquery/ui/draggable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
  691. $scripts->add( 'jquery-ui-droppable', "/wp-includes/js/jquery/ui/droppable$dev_suffix.js", array( 'jquery-ui-draggable' ), '1.11.4', 1 );
  692. $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 );
  693. $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 );
  694. $scripts->add( 'jquery-ui-position', "/wp-includes/js/jquery/ui/position$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
  695. $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 );
  696. $scripts->add( 'jquery-ui-resizable', "/wp-includes/js/jquery/ui/resizable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
  697. $scripts->add( 'jquery-ui-selectable', "/wp-includes/js/jquery/ui/selectable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
  698. $scripts->add( 'jquery-ui-selectmenu', "/wp-includes/js/jquery/ui/selectmenu$dev_suffix.js", array( 'jquery-ui-menu' ), '1.11.4', 1 );
  699. $scripts->add( 'jquery-ui-slider', "/wp-includes/js/jquery/ui/slider$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
  700. $scripts->add( 'jquery-ui-sortable', "/wp-includes/js/jquery/ui/sortable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
  701. $scripts->add( 'jquery-ui-spinner', "/wp-includes/js/jquery/ui/spinner$dev_suffix.js", array( 'jquery-ui-button' ), '1.11.4', 1 );
  702. $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 );
  703. $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 );
  704. $scripts->add( 'jquery-ui-widget', "/wp-includes/js/jquery/ui/widget$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
  705. // Strings for 'jquery-ui-autocomplete' live region messages.
  706. did_action( 'init' ) && $scripts->localize(
  707. 'jquery-ui-autocomplete',
  708. 'uiAutocompleteL10n',
  709. array(
  710. 'noResults' => __( 'No results found.' ),
  711. /* translators: Number of results found when using jQuery UI Autocomplete. */
  712. 'oneResult' => __( '1 result found. Use up and down arrow keys to navigate.' ),
  713. /* translators: %d: Number of results found when using jQuery UI Autocomplete. */
  714. 'manyResults' => __( '%d results found. Use up and down arrow keys to navigate.' ),
  715. 'itemSelected' => __( 'Item selected.' ),
  716. )
  717. );
  718. // Deprecated, not used in core, most functionality is included in jQuery 1.3.
  719. $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array( 'jquery' ), '4.2.1', 1 );
  720. // jQuery plugins.
  721. $scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.min.js', array( 'jquery' ), '2.1.2', 1 );
  722. $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array( 'jquery' ), '20m', 1 );
  723. $scripts->add( 'jquery-query', '/wp-includes/js/jquery/jquery.query.js', array( 'jquery' ), '2.1.7', 1 );
  724. $scripts->add( 'jquery-serialize-object', '/wp-includes/js/jquery/jquery.serialize-object.js', array( 'jquery' ), '0.2', 1 );
  725. $scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array( 'jquery' ), '0.0.2m', 1 );
  726. $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array( 'jquery', 'jquery-hotkeys' ), false, 1 );
  727. $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 );
  728. // Not used any more, registered for backward compatibility.
  729. $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array( 'jquery' ), '1.1-20110113', 1 );
  730. // Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv.
  731. // It sets jQuery as a dependency, as the theme may have been implicitly loading it this way.
  732. $scripts->add( 'imagesloaded', '/wp-includes/js/imagesloaded.min.js', array(), '3.2.0', 1 );
  733. $scripts->add( 'masonry', '/wp-includes/js/masonry.min.js', array( 'imagesloaded' ), '3.3.2', 1 );
  734. $scripts->add( 'jquery-masonry', "/wp-includes/js/jquery/jquery.masonry$dev_suffix.js", array( 'jquery', 'masonry' ), '3.1.2b', 1 );
  735. $scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array( 'jquery' ), '3.1-20121105', 1 );
  736. did_action( 'init' ) && $scripts->localize(
  737. 'thickbox',
  738. 'thickboxL10n',
  739. array(
  740. 'next' => __( 'Next &gt;' ),
  741. 'prev' => __( '&lt; Prev' ),
  742. 'image' => __( 'Image' ),
  743. 'of' => __( 'of' ),
  744. 'close' => __( 'Close' ),
  745. 'noiframes' => __( 'This feature requires inline frames. You have iframes disabled or your browser does not support them.' ),
  746. 'loadingAnimation' => includes_url( 'js/thickbox/loadingAnimation.gif' ),
  747. )
  748. );
  749. $scripts->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.js', array( 'jquery' ), '0.9.12' );
  750. $scripts->add( 'swfobject', '/wp-includes/js/swfobject.js', array(), '2.2-20120417' );
  751. // Error messages for Plupload.
  752. $uploader_l10n = array(
  753. 'queue_limit_exceeded' => __( 'You have attempted to queue too many files.' ),
  754. /* translators: %s: File name. */
  755. 'file_exceeds_size_limit' => __( '%s exceeds the maximum upload size for this site.' ),
  756. 'zero_byte_file' => __( 'This file is empty. Please try another.' ),
  757. 'invalid_filetype' => __( 'Sorry, this file type is not permitted for security reasons.' ),
  758. 'not_an_image' => __( 'This file is not an image. Please try another.' ),
  759. 'image_memory_exceeded' => __( 'Memory exceeded. Please try another smaller file.' ),
  760. 'image_dimensions_exceeded' => __( 'This is larger than the maximum size. Please try another.' ),
  761. 'default_error' => __( 'An error occurred in the upload. Please try again later.' ),
  762. 'missing_upload_url' => __( 'There was a configuration error. Please contact the server administrator.' ),
  763. 'upload_limit_exceeded' => __( 'You may only upload 1 file.' ),
  764. 'http_error' => __( 'Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.' ),
  765. 'http_error_image' => __( 'Post-processing of the image failed likely because the server is busy or does not have enough resources. Uploading a smaller image may help. Suggested maximum size is 2500 pixels.' ),
  766. 'upload_failed' => __( 'Upload failed.' ),
  767. /* translators: 1: Opening link tag, 2: Closing link tag. */
  768. 'big_upload_failed' => __( 'Please try uploading this file with the %1$sbrowser uploader%2$s.' ),
  769. /* translators: %s: File name. */
  770. 'big_upload_queued' => __( '%s exceeds the maximum upload size for the multi-file uploader when used in your browser.' ),
  771. 'io_error' => __( 'IO error.' ),
  772. 'security_error' => __( 'Security error.' ),
  773. 'file_cancelled' => __( 'File canceled.' ),
  774. 'upload_stopped' => __( 'Upload stopped.' ),
  775. 'dismiss' => __( 'Dismiss' ),
  776. 'crunching' => __( 'Crunching&hellip;' ),
  777. 'deleted' => __( 'moved to the Trash.' ),
  778. /* translators: %s: File name. */
  779. 'error_uploading' => __( '&#8220;%s&#8221; has failed to upload.' ),
  780. );
  781. $scripts->add( 'moxiejs', "/wp-includes/js/plupload/moxie$suffix.js", array(), '1.3.5' );
  782. $scripts->add( 'plupload', "/wp-includes/js/plupload/plupload$suffix.js", array( 'moxiejs' ), '2.1.9' );
  783. // Back compat handles:
  784. foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) {
  785. $scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' );
  786. }
  787. $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'plupload', 'jquery' ) );
  788. did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
  789. $scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 );
  790. did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n );
  791. // Keep 'swfupload' for back-compat.
  792. $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', array(), '2201-20110113' );
  793. $scripts->add( 'swfupload-all', false, array( 'swfupload' ), '2201' );
  794. $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array( 'swfupload-all', 'jquery' ), '2201-20110524' );
  795. did_action( 'init' ) && $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', $uploader_l10n );
  796. $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 );
  797. $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' );
  798. did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' );
  799. $scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.8.3', 1 );
  800. $scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.4.0', 1 );
  801. $scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array( 'underscore', 'jquery' ), false, 1 );
  802. did_action( 'init' ) && $scripts->localize(
  803. 'wp-util',
  804. '_wpUtilSettings',
  805. array(
  806. 'ajax' => array(
  807. 'url' => admin_url( 'admin-ajax.php', 'relative' ),
  808. ),
  809. )
  810. );
  811. $scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array( 'backbone', 'wp-util' ), false, 1 );
  812. $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverIntent' ), false, 1 );
  813. $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array( 'jquery' ), false, 1 );
  814. $scripts->add( 'mediaelement', false, array( 'jquery', 'mediaelement-core', 'mediaelement-migrate' ), '4.2.13-9993131', 1 );
  815. $scripts->add( 'mediaelement-core', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array(), '4.2.13-9993131', 1 );
  816. $scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1 );
  817. did_action( 'init' ) && $scripts->add_inline_script(
  818. 'mediaelement-core',
  819. sprintf(
  820. 'var mejsL10n = %s;',
  821. wp_json_encode(
  822. array(
  823. 'language' => strtolower( strtok( determine_locale(), '_-' ) ),
  824. 'strings' => array(
  825. 'mejs.download-file' => __( 'Download File' ),
  826. '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/' ),
  827. 'mejs.fullscreen' => __( 'Fullscreen' ),
  828. 'mejs.play' => __( 'Play' ),
  829. 'mejs.pause' => __( 'Pause' ),
  830. 'mejs.time-slider' => __( 'Time Slider' ),
  831. 'mejs.time-help-text' => __( 'Use Left/Right Arrow keys to advance one second, Up/Down arrows to advance ten seconds.' ),
  832. 'mejs.live-broadcast' => __( 'Live Broadcast' ),
  833. 'mejs.volume-help-text' => __( 'Use Up/Down Arrow keys to increase or decrease volume.' ),
  834. 'mejs.unmute' => __( 'Unmute' ),
  835. 'mejs.mute' => __( 'Mute' ),
  836. 'mejs.volume-slider' => __( 'Volume Slider' ),
  837. 'mejs.video-player' => __( 'Video Player' ),
  838. 'mejs.audio-player' => __( 'Audio Player' ),
  839. 'mejs.captions-subtitles' => __( 'Captions/Subtitles' ),
  840. 'mejs.captions-chapters' => __( 'Chapters' ),
  841. 'mejs.none' => __( 'None' ),
  842. 'mejs.afrikaans' => __( 'Afrikaans' ),
  843. 'mejs.albanian' => __( 'Albanian' ),
  844. 'mejs.arabic' => __( 'Arabic' ),
  845. 'mejs.belarusian' => __( 'Belarusian' ),
  846. 'mejs.bulgarian' => __( 'Bulgarian' ),
  847. 'mejs.catalan' => __( 'Catalan' ),
  848. 'mejs.chinese' => __( 'Chinese' ),
  849. 'mejs.chinese-simplified' => __( 'Chinese (Simplified)' ),
  850. 'mejs.chinese-traditional' => __( 'Chinese (Traditional)' ),
  851. 'mejs.croatian' => __( 'Croatian' ),
  852. 'mejs.czech' => __( 'Czech' ),
  853. 'mejs.danish' => __( 'Danish' ),
  854. 'mejs.dutch' => __( 'Dutch' ),
  855. 'mejs.english' => __( 'English' ),
  856. 'mejs.estonian' => __( 'Estonian' ),
  857. 'mejs.filipino' => __( 'Filipino' ),
  858. 'mejs.finnish' => __( 'Finnish' ),
  859. 'mejs.french' => __( 'French' ),
  860. 'mejs.galician' => __( 'Galician' ),
  861. 'mejs.german' => __( 'German' ),
  862. 'mejs.greek' => __( 'Greek' ),
  863. 'mejs.haitian-creole' => __( 'Haitian Creole' ),
  864. 'mejs.hebrew' => __( 'Hebrew' ),
  865. 'mejs.hindi' => __( 'Hindi' ),
  866. 'mejs.hungarian' => __( 'Hungarian' ),
  867. 'mejs.icelandic' => __( 'Icelandic' ),
  868. 'mejs.indonesian' => __( 'Indonesian' ),
  869. 'mejs.irish' => __( 'Irish' ),
  870. 'mejs.italian' => __( 'Italian' ),
  871. 'mejs.japanese' => __( 'Japanese' ),
  872. 'mejs.korean' => __( 'Korean' ),
  873. 'mejs.latvian' => __( 'Latvian' ),
  874. 'mejs.lithuanian' => __( 'Lithuanian' ),
  875. 'mejs.macedonian' => __( 'Macedonian' ),
  876. 'mejs.malay' => __( 'Malay' ),
  877. 'mejs.maltese' => __( 'Maltese' ),
  878. 'mejs.norwegian' => __( 'Norwegian' ),
  879. 'mejs.persian' => __( 'Persian' ),
  880. 'mejs.polish' => __( 'Polish' ),
  881. 'mejs.portuguese' => __( 'Portuguese' ),
  882. 'mejs.romanian' => __( 'Romanian' ),
  883. 'mejs.russian' => __( 'Russian' ),
  884. 'mejs.serbian' => __( 'Serbian' ),
  885. 'mejs.slovak' => __( 'Slovak' ),
  886. 'mejs.slovenian' => __( 'Slovenian' ),
  887. 'mejs.spanish' => __( 'Spanish' ),
  888. 'mejs.swahili' => __( 'Swahili' ),
  889. 'mejs.swedish' => __( 'Swedish' ),
  890. 'mejs.tagalog' => __( 'Tagalog' ),
  891. 'mejs.thai' => __( 'Thai' ),
  892. 'mejs.turkish' => __( 'Turkish' ),
  893. 'mejs.ukrainian' => __( 'Ukrainian' ),
  894. 'mejs.vietnamese' => __( 'Vietnamese' ),
  895. 'mejs.welsh' => __( 'Welsh' ),
  896. 'mejs.yiddish' => __( 'Yiddish' ),
  897. ),
  898. )
  899. )
  900. ),
  901. 'before'
  902. );
  903. $scripts->add( 'mediaelement-vimeo', '/wp-includes/js/mediaelement/renderers/vimeo.min.js', array( 'mediaelement' ), '4.2.13-9993131', 1 );
  904. $scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.js", array( 'mediaelement' ), false, 1 );
  905. $mejs_settings = array(
  906. 'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ),
  907. 'classPrefix' => 'mejs-',
  908. 'stretching' => 'responsive',
  909. );
  910. did_action( 'init' ) && $scripts->localize(
  911. 'mediaelement',
  912. '_wpmejsSettings',
  913. /**
  914. * Filters the MediaElement configuration settings.
  915. *
  916. * @since 4.4.0
  917. *
  918. * @param array $mejs_settings MediaElement settings array.
  919. */
  920. apply_filters( 'mejs_settings', $mejs_settings )
  921. );
  922. $scripts->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.js', array(), '5.29.1-alpha-ee20357' );
  923. $scripts->add( 'csslint', '/wp-includes/js/codemirror/csslint.js', array(), '1.0.5' );
  924. $scripts->add( 'esprima', '/wp-includes/js/codemirror/esprima.js', array(), '4.0.0' );
  925. $scripts->add( 'jshint', '/wp-includes/js/codemirror/fakejshint.js', array( 'esprima' ), '2.9.5' );
  926. $scripts->add( 'jsonlint', '/wp-includes/js/codemirror/jsonlint.js', array(), '1.6.2' );
  927. $scripts->add( 'htmlhint', '/wp-includes/js/codemirror/htmlhint.js', array(), '0.9.14-xwp' );
  928. $scripts->add( 'htmlhint-kses', '/wp-includes/js/codemirror/htmlhint-kses.js', array( 'htmlhint' ) );
  929. $scripts->add( 'code-editor', "/wp-admin/js/code-editor$suffix.js", array( 'jquery', 'wp-codemirror', 'underscore' ) );
  930. $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' ) );
  931. did_action( 'init' ) && $scripts->add_inline_script(
  932. 'wp-theme-plugin-editor',
  933. sprintf(
  934. 'wp.themePluginEditor.l10n = %s;',
  935. wp_json_encode(
  936. array(
  937. 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
  938. '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.' ),
  939. 'lintError' => array(
  940. /* translators: %d: Error count. */
  941. '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 ),
  942. /* translators: %d: Error count. */
  943. '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 ),
  944. // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
  945. ),
  946. )
  947. )
  948. )
  949. );
  950. $scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist$suffix.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 );
  951. $scripts->add( 'zxcvbn-async', "/wp-includes/js/zxcvbn-async$suffix.js", array(), '1.0' );
  952. did_action( 'init' ) && $scripts->localize(
  953. 'zxcvbn-async',
  954. '_zxcvbnSettings',
  955. array(
  956. 'src' => empty( $guessed_url ) ? includes_url( '/js/zxcvbn.min.js' ) : $scripts->base_url . '/wp-includes/js/zxcvbn.min.js',
  957. )
  958. );
  959. $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 );
  960. did_action( 'init' ) && $scripts->localize(
  961. 'password-strength-meter',
  962. 'pwsL10n',
  963. array(
  964. 'unknown' => _x( 'Password strength unknown', 'password strength' ),
  965. 'short' => _x( 'Very weak', 'password strength' ),
  966. 'bad' => _x( 'Weak', 'password strength' ),
  967. 'good' => _x( 'Medium', 'password strength' ),
  968. 'strong' => _x( 'Strong', 'password strength' ),
  969. 'mismatch' => _x( 'Mismatch', 'password mismatch' ),
  970. )
  971. );
  972. $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 );
  973. did_action( 'init' ) && $scripts->localize(
  974. 'user-profile',
  975. 'userProfileL10n',
  976. array(
  977. 'warn' => __( 'Your new password has not been saved.' ),
  978. 'warnWeak' => __( 'Confirm use of weak password' ),
  979. 'show' => __( 'Show' ),
  980. 'hide' => __( 'Hide' ),
  981. 'cancel' => __( 'Cancel' ),
  982. 'ariaShow' => esc_attr__( 'Show password' ),
  983. 'ariaHide' => esc_attr__( 'Hide password' ),
  984. )
  985. );
  986. $scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 );
  987. $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
  988. $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array( 'hoverintent-js' ), false, 1 );
  989. $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
  990. did_action( 'init' ) && $scripts->localize(
  991. 'wplink',
  992. 'wpLinkL10n',
  993. array(
  994. 'title' => __( 'Insert/edit link' ),
  995. 'update' => __( 'Update' ),
  996. 'save' => __( 'Add Link' ),
  997. 'noTitle' => __( '(no title)' ),
  998. 'noMatchesFound' => __( 'No results found.' ),
  999. 'linkSelected' => __( 'Link selected.' ),
  1000. 'linkInserted' => __( 'Link inserted.' ),
  1001. /* translators: Minimum input length in characters to start searching posts in the "Insert/edit link" modal. */
  1002. 'minInputLength' => (int) _x( '3', 'minimum input length for searching post links' ),
  1003. )
  1004. );
  1005. $scripts->add( 'wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 );
  1006. $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 );
  1007. $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 );
  1008. $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array( 'jquery' ), '1.8.1', 1 );
  1009. // JS-only version of hoverintent (no dependencies).
  1010. $scripts->add( 'hoverintent-js', '/wp-includes/js/hoverintent-js.min.js', array(), '2.2.1', 1 );
  1011. $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 );
  1012. $scrip