wp/wp-includes/script-loader.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    78 	global $wp_locale;
    78 	global $wp_locale;
    79 
    79 
    80 	$suffix = wp_scripts_get_suffix();
    80 	$suffix = wp_scripts_get_suffix();
    81 
    81 
    82 	$vendor_scripts = array(
    82 	$vendor_scripts = array(
    83 		'react'     => array( 'wp-polyfill' ),
    83 		'react'       => array( 'wp-polyfill' ),
    84 		'react-dom' => array( 'react' ),
    84 		'react-dom'   => array( 'react' ),
       
    85 		'regenerator-runtime',
    85 		'moment',
    86 		'moment',
    86 		'lodash',
    87 		'lodash',
    87 		'wp-polyfill-fetch',
    88 		'wp-polyfill-fetch',
    88 		'wp-polyfill-formdata',
    89 		'wp-polyfill-formdata',
    89 		'wp-polyfill-node-contains',
    90 		'wp-polyfill-node-contains',
    90 		'wp-polyfill-url',
    91 		'wp-polyfill-url',
    91 		'wp-polyfill-dom-rect',
    92 		'wp-polyfill-dom-rect',
    92 		'wp-polyfill-element-closest',
    93 		'wp-polyfill-element-closest',
    93 		'wp-polyfill',
    94 		'wp-polyfill-object-fit',
       
    95 		'wp-polyfill' => array( 'regenerator-runtime' ),
    94 	);
    96 	);
    95 
    97 
    96 	$vendor_scripts_versions = array(
    98 	$vendor_scripts_versions = array(
    97 		'react'                       => '16.9.0',
    99 		'react'                       => '16.13.1',
    98 		'react-dom'                   => '16.9.0',
   100 		'react-dom'                   => '16.13.1',
    99 		'moment'                      => '2.26.0',
   101 		'regenerator-runtime'         => '0.13.7',
   100 		'lodash'                      => '4.17.15',
   102 		'moment'                      => '2.29.1',
       
   103 		'lodash'                      => '4.17.19',
   101 		'wp-polyfill-fetch'           => '3.0.0',
   104 		'wp-polyfill-fetch'           => '3.0.0',
   102 		'wp-polyfill-formdata'        => '3.0.12',
   105 		'wp-polyfill-formdata'        => '4.0.0',
   103 		'wp-polyfill-node-contains'   => '3.42.0',
   106 		'wp-polyfill-node-contains'   => '3.105.0',
   104 		'wp-polyfill-url'             => '3.6.4',
   107 		'wp-polyfill-url'             => '3.6.4',
   105 		'wp-polyfill-dom-rect'        => '3.42.0',
   108 		'wp-polyfill-dom-rect'        => '3.104.0',
   106 		'wp-polyfill-element-closest' => '2.0.2',
   109 		'wp-polyfill-element-closest' => '2.0.2',
   107 		'wp-polyfill'                 => '7.4.4',
   110 		'wp-polyfill-object-fit'      => '2.3.5',
       
   111 		'wp-polyfill'                 => '3.15.0',
   108 	);
   112 	);
   109 
   113 
   110 	foreach ( $vendor_scripts as $handle => $dependencies ) {
   114 	foreach ( $vendor_scripts as $handle => $dependencies ) {
   111 		if ( is_string( $dependencies ) ) {
   115 		if ( is_string( $dependencies ) ) {
   112 			$handle       = $dependencies;
   116 			$handle       = $dependencies;
   116 		$path    = "/wp-includes/js/dist/vendor/$handle$suffix.js";
   120 		$path    = "/wp-includes/js/dist/vendor/$handle$suffix.js";
   117 		$version = $vendor_scripts_versions[ $handle ];
   121 		$version = $vendor_scripts_versions[ $handle ];
   118 
   122 
   119 		$scripts->add( $handle, $path, $dependencies, $version, 1 );
   123 		$scripts->add( $handle, $path, $dependencies, $version, 1 );
   120 	}
   124 	}
   121 
       
   122 	$scripts->add( 'wp-polyfill', null, array( 'wp-polyfill' ) );
       
   123 	did_action( 'init' ) && $scripts->add_inline_script(
       
   124 		'wp-polyfill',
       
   125 		wp_get_script_polyfill(
       
   126 			$scripts,
       
   127 			array(
       
   128 				'\'fetch\' in window' => 'wp-polyfill-fetch',
       
   129 				'document.contains'   => 'wp-polyfill-node-contains',
       
   130 				'window.DOMRect'      => 'wp-polyfill-dom-rect',
       
   131 				'window.URL && window.URL.prototype && window.URLSearchParams' => 'wp-polyfill-url',
       
   132 				'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata',
       
   133 				'Element.prototype.matches && Element.prototype.closest' => 'wp-polyfill-element-closest',
       
   134 			)
       
   135 		)
       
   136 	);
       
   137 
   125 
   138 	did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
   126 	did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
   139 
   127 
   140 	did_action( 'init' ) && $scripts->add_inline_script(
   128 	did_action( 'init' ) && $scripts->add_inline_script(
   141 		'moment',
   129 		'moment',
   150 					'weekdaysShort'  => array_values( $wp_locale->weekday_abbrev ),
   138 					'weekdaysShort'  => array_values( $wp_locale->weekday_abbrev ),
   151 					'week'           => array(
   139 					'week'           => array(
   152 						'dow' => (int) get_option( 'start_of_week', 0 ),
   140 						'dow' => (int) get_option( 'start_of_week', 0 ),
   153 					),
   141 					),
   154 					'longDateFormat' => array(
   142 					'longDateFormat' => array(
   155 						'LT'   => get_option( 'time_format', __( 'g:i a', 'default' ) ),
   143 						'LT'   => get_option( 'time_format', __( 'g:i a' ) ),
   156 						'LTS'  => null,
   144 						'LTS'  => null,
   157 						'L'    => null,
   145 						'L'    => null,
   158 						'LL'   => get_option( 'date_format', __( 'F j, Y', 'default' ) ),
   146 						'LL'   => get_option( 'date_format', __( 'F j, Y' ) ),
   159 						'LLL'  => __( 'F j, Y g:i a', 'default' ),
   147 						'LLL'  => __( 'F j, Y g:i a' ),
   160 						'LLLL' => null,
   148 						'LLLL' => null,
   161 					),
   149 					),
   162 				)
   150 				)
   163 			)
   151 			)
   164 		),
   152 		),
   261 
   249 
   262 		$scripts->add( $handle, $path, $dependencies, $package_data['version'], 1 );
   250 		$scripts->add( $handle, $path, $dependencies, $package_data['version'], 1 );
   263 
   251 
   264 		if ( in_array( 'wp-i18n', $dependencies, true ) ) {
   252 		if ( in_array( 'wp-i18n', $dependencies, true ) ) {
   265 			$scripts->set_translations( $handle );
   253 			$scripts->set_translations( $handle );
       
   254 		}
       
   255 
       
   256 		/*
       
   257 		 * Manually set the text direction localization after wp-i18n is printed.
       
   258 		 * This ensures that wp.i18n.isRTL() returns true in RTL languages.
       
   259 		 * We cannot use $scripts->set_translations( 'wp-i18n' ) to do this
       
   260 		 * because WordPress prints a script's translations *before* the script,
       
   261 		 * which means, in the case of wp-i18n, that wp.i18n.setLocaleData()
       
   262 		 * is called before wp.i18n is defined.
       
   263 		 */
       
   264 		if ( 'wp-i18n' === $handle ) {
       
   265 			$ltr    = _x( 'ltr', 'text direction' );
       
   266 			$script = sprintf( "wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ '%s' ] } );", $ltr );
       
   267 			$scripts->add_inline_script( $handle, $script, 'after' );
   266 		}
   268 		}
   267 	}
   269 	}
   268 }
   270 }
   269 
   271 
   270 /**
   272 /**
   320 				'	wp.data.plugins.persistence.__unstableMigrate( { storageKey: storageKey } );',
   322 				'	wp.data.plugins.persistence.__unstableMigrate( { storageKey: storageKey } );',
   321 				'} )();',
   323 				'} )();',
   322 			)
   324 			)
   323 		)
   325 		)
   324 	);
   326 	);
       
   327 
       
   328 	// Calculate the timezone abbr (EDT, PST) if possible.
       
   329 	$timezone_string = get_option( 'timezone_string', 'UTC' );
       
   330 	$timezone_abbr   = '';
       
   331 
       
   332 	if ( ! empty( $timezone_string ) ) {
       
   333 		$timezone_date = new DateTime( null, new DateTimeZone( $timezone_string ) );
       
   334 		$timezone_abbr = $timezone_date->format( 'T' );
       
   335 	}
   325 
   336 
   326 	$scripts->add_inline_script(
   337 	$scripts->add_inline_script(
   327 		'wp-date',
   338 		'wp-date',
   328 		sprintf(
   339 		sprintf(
   329 			'wp.date.setSettings( %s );',
   340 			'wp.date.setSettings( %s );',
   342 							/* translators: %s: Duration. */
   353 							/* translators: %s: Duration. */
   343 							'past'   => __( '%s ago' ),
   354 							'past'   => __( '%s ago' ),
   344 						),
   355 						),
   345 					),
   356 					),
   346 					'formats'  => array(
   357 					'formats'  => array(
   347 						/* translators: Time format, see https://www.php.net/date */
   358 						/* translators: Time format, see https://www.php.net/manual/datetime.format.php */
   348 						'time'                => get_option( 'time_format', __( 'g:i a' ) ),
   359 						'time'                => get_option( 'time_format', __( 'g:i a' ) ),
   349 						/* translators: Date format, see https://www.php.net/date */
   360 						/* translators: Date format, see https://www.php.net/manual/datetime.format.php */
   350 						'date'                => get_option( 'date_format', __( 'F j, Y' ) ),
   361 						'date'                => get_option( 'date_format', __( 'F j, Y' ) ),
   351 						/* translators: Date/Time format, see https://www.php.net/date */
   362 						/* translators: Date/Time format, see https://www.php.net/manual/datetime.format.php */
   352 						'datetime'            => __( 'F j, Y g:i a' ),
   363 						'datetime'            => __( 'F j, Y g:i a' ),
   353 						/* translators: Abbreviated date/time format, see https://www.php.net/date */
   364 						/* translators: Abbreviated date/time format, see https://www.php.net/manual/datetime.format.php */
   354 						'datetimeAbbreviated' => __( 'M j, Y g:i a' ),
   365 						'datetimeAbbreviated' => __( 'M j, Y g:i a' ),
   355 					),
   366 					),
   356 					'timezone' => array(
   367 					'timezone' => array(
   357 						'offset' => get_option( 'gmt_offset', 0 ),
   368 						'offset' => get_option( 'gmt_offset', 0 ),
   358 						'string' => get_option( 'timezone_string', 'UTC' ),
   369 						'string' => $timezone_string,
       
   370 						'abbr'   => $timezone_abbr,
   359 					),
   371 					),
   360 				)
   372 				)
   361 			)
   373 			)
   362 		),
   374 		),
   363 		'after'
   375 		'after'
   365 
   377 
   366 	// Loading the old editor and its config to ensure the classic block works as expected.
   378 	// Loading the old editor and its config to ensure the classic block works as expected.
   367 	$scripts->add_inline_script(
   379 	$scripts->add_inline_script(
   368 		'editor',
   380 		'editor',
   369 		'window.wp.oldEditor = window.wp.editor;',
   381 		'window.wp.oldEditor = window.wp.editor;',
       
   382 		'after'
       
   383 	);
       
   384 
       
   385 	/*
       
   386 	 * wp-editor module is exposed as window.wp.editor.
       
   387 	 * Problem: there is quite some code expecting window.wp.oldEditor object available under window.wp.editor.
       
   388 	 * Solution: fuse the two objects together to maintain backward compatibility.
       
   389 	 * For more context, see https://github.com/WordPress/gutenberg/issues/33203.
       
   390 	 */
       
   391 	$scripts->add_inline_script(
       
   392 		'wp-editor',
       
   393 		'Object.assign( window.wp.editor, window.wp.oldEditor );',
   370 		'after'
   394 		'after'
   371 	);
   395 	);
   372 }
   396 }
   373 
   397 
   374 /**
   398 /**
   678 			'nonce'         => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ),
   702 			'nonce'         => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ),
   679 			'versionString' => 'wp/v2/',
   703 			'versionString' => 'wp/v2/',
   680 		)
   704 		)
   681 	);
   705 	);
   682 
   706 
   683 	$scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), false, 1 );
   707 	$scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-core' ), false, 1 );
   684 	$scripts->set_translations( 'wp-pointer' );
   708 	$scripts->set_translations( 'wp-pointer' );
   685 
   709 
   686 	$scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array( 'heartbeat' ), false, 1 );
   710 	$scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array( 'heartbeat' ), false, 1 );
   687 
   711 
   688 	$scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array( 'jquery', 'wp-hooks' ), false, 1 );
   712 	$scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array( 'jquery', 'wp-hooks' ), false, 1 );
   717 
   741 
   718 	// Not used in core, replaced by Jcrop.js.
   742 	// Not used in core, replaced by Jcrop.js.
   719 	$scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array( 'scriptaculous-dragdrop' ) );
   743 	$scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array( 'scriptaculous-dragdrop' ) );
   720 
   744 
   721 	// jQuery.
   745 	// jQuery.
   722 	$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.12.4-wp' );
   746 	// The unminified jquery.js and jquery-migrate.js are included to facilitate debugging.
   723 	$scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.12.4-wp' );
   747 	$scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '3.6.0' );
   724 	$scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.4.1' );
   748 	$scripts->add( 'jquery-core', "/wp-includes/js/jquery/jquery$suffix.js", array(), '3.6.0' );
       
   749 	$scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '3.3.2' );
   725 
   750 
   726 	// Full jQuery UI.
   751 	// Full jQuery UI.
   727 	$scripts->add( 'jquery-ui-core', "/wp-includes/js/jquery/ui/core$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
   752 	// The build process in 1.12.1 has changed significantly.
   728 	$scripts->add( 'jquery-effects-core', "/wp-includes/js/jquery/ui/effect$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
   753 	// In order to keep backwards compatibility, and to keep the optimized loading,
   729 
   754 	// the source files were flattened and included with some modifications for AMD loading.
   730 	$scripts->add( 'jquery-effects-blind', "/wp-includes/js/jquery/ui/effect-blind$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   755 	// A notable change is that 'jquery-ui-core' now contains 'jquery-ui-position' and 'jquery-ui-widget'.
   731 	$scripts->add( 'jquery-effects-bounce', "/wp-includes/js/jquery/ui/effect-bounce$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   756 	$scripts->add( 'jquery-ui-core', "/wp-includes/js/jquery/ui/core$suffix.js", array( 'jquery' ), '1.12.1', 1 );
   732 	$scripts->add( 'jquery-effects-clip', "/wp-includes/js/jquery/ui/effect-clip$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   757 	$scripts->add( 'jquery-effects-core', "/wp-includes/js/jquery/ui/effect$suffix.js", array( 'jquery' ), '1.12.1', 1 );
   733 	$scripts->add( 'jquery-effects-drop', "/wp-includes/js/jquery/ui/effect-drop$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   758 
   734 	$scripts->add( 'jquery-effects-explode', "/wp-includes/js/jquery/ui/effect-explode$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   759 	$scripts->add( 'jquery-effects-blind', "/wp-includes/js/jquery/ui/effect-blind$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   735 	$scripts->add( 'jquery-effects-fade', "/wp-includes/js/jquery/ui/effect-fade$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   760 	$scripts->add( 'jquery-effects-bounce', "/wp-includes/js/jquery/ui/effect-bounce$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   736 	$scripts->add( 'jquery-effects-fold', "/wp-includes/js/jquery/ui/effect-fold$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   761 	$scripts->add( 'jquery-effects-clip', "/wp-includes/js/jquery/ui/effect-clip$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   737 	$scripts->add( 'jquery-effects-highlight', "/wp-includes/js/jquery/ui/effect-highlight$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   762 	$scripts->add( 'jquery-effects-drop', "/wp-includes/js/jquery/ui/effect-drop$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   738 	$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 );
   763 	$scripts->add( 'jquery-effects-explode', "/wp-includes/js/jquery/ui/effect-explode$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   739 	$scripts->add( 'jquery-effects-pulsate', "/wp-includes/js/jquery/ui/effect-pulsate$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   764 	$scripts->add( 'jquery-effects-fade', "/wp-includes/js/jquery/ui/effect-fade$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   740 	$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 );
   765 	$scripts->add( 'jquery-effects-fold', "/wp-includes/js/jquery/ui/effect-fold$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   741 	$scripts->add( 'jquery-effects-shake', "/wp-includes/js/jquery/ui/effect-shake$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   766 	$scripts->add( 'jquery-effects-highlight', "/wp-includes/js/jquery/ui/effect-highlight$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   742 	$scripts->add( 'jquery-effects-size', "/wp-includes/js/jquery/ui/effect-size$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   767 	$scripts->add( 'jquery-effects-puff', "/wp-includes/js/jquery/ui/effect-puff$suffix.js", array( 'jquery-effects-core', 'jquery-effects-scale' ), '1.12.1', 1 );
   743 	$scripts->add( 'jquery-effects-slide', "/wp-includes/js/jquery/ui/effect-slide$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   768 	$scripts->add( 'jquery-effects-pulsate', "/wp-includes/js/jquery/ui/effect-pulsate$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   744 	$scripts->add( 'jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
   769 	$scripts->add( 'jquery-effects-scale', "/wp-includes/js/jquery/ui/effect-scale$suffix.js", array( 'jquery-effects-core', 'jquery-effects-size' ), '1.12.1', 1 );
   745 
   770 	$scripts->add( 'jquery-effects-shake', "/wp-includes/js/jquery/ui/effect-shake$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   746 	$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 );
   771 	$scripts->add( 'jquery-effects-size', "/wp-includes/js/jquery/ui/effect-size$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   747 	$scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$dev_suffix.js", array( 'jquery-ui-menu', 'wp-a11y' ), '1.11.4', 1 );
   772 	$scripts->add( 'jquery-effects-slide', "/wp-includes/js/jquery/ui/effect-slide$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   748 	$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 );
   773 	$scripts->add( 'jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$suffix.js", array( 'jquery-effects-core' ), '1.12.1', 1 );
   749 	$scripts->add( 'jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$dev_suffix.js", array( 'jquery-ui-core' ), '1.11.4', 1 );
   774 
   750 	$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 );
   775 	// Widgets
   751 	$scripts->add( 'jquery-ui-draggable', "/wp-includes/js/jquery/ui/draggable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
   776 	$scripts->add( 'jquery-ui-accordion', "/wp-includes/js/jquery/ui/accordion$suffix.js", array( 'jquery-ui-core' ), '1.12.1', 1 );
   752 	$scripts->add( 'jquery-ui-droppable', "/wp-includes/js/jquery/ui/droppable$dev_suffix.js", array( 'jquery-ui-draggable' ), '1.11.4', 1 );
   777 	$scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$suffix.js", array( 'jquery-ui-menu', 'wp-a11y' ), '1.12.1', 1 );
   753 	$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 );
   778 	$scripts->add( 'jquery-ui-button', "/wp-includes/js/jquery/ui/button$suffix.js", array( 'jquery-ui-core', 'jquery-ui-controlgroup', 'jquery-ui-checkboxradio' ), '1.12.1', 1 );
   754 	$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 );
   779 	$scripts->add( 'jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$suffix.js", array( 'jquery-ui-core' ), '1.12.1', 1 );
   755 	$scripts->add( 'jquery-ui-position', "/wp-includes/js/jquery/ui/position$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
   780 	$scripts->add( 'jquery-ui-dialog', "/wp-includes/js/jquery/ui/dialog$suffix.js", array( 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button' ), '1.12.1', 1 );
   756 	$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 );
   781 	$scripts->add( 'jquery-ui-menu', "/wp-includes/js/jquery/ui/menu$suffix.js", array( 'jquery-ui-core' ), '1.12.1', 1 );
   757 	$scripts->add( 'jquery-ui-resizable', "/wp-includes/js/jquery/ui/resizable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
   782 	$scripts->add( 'jquery-ui-mouse', "/wp-includes/js/jquery/ui/mouse$suffix.js", array( 'jquery-ui-core' ), '1.12.1', 1 );
   758 	$scripts->add( 'jquery-ui-selectable', "/wp-includes/js/jquery/ui/selectable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
   783 	$scripts->add( 'jquery-ui-progressbar', "/wp-includes/js/jquery/ui/progressbar$suffix.js", array( 'jquery-ui-core' ), '1.12.1', 1 );
   759 	$scripts->add( 'jquery-ui-selectmenu', "/wp-includes/js/jquery/ui/selectmenu$dev_suffix.js", array( 'jquery-ui-menu' ), '1.11.4', 1 );
   784 	$scripts->add( 'jquery-ui-selectmenu', "/wp-includes/js/jquery/ui/selectmenu$suffix.js", array( 'jquery-ui-menu' ), '1.12.1', 1 );
   760 	$scripts->add( 'jquery-ui-slider', "/wp-includes/js/jquery/ui/slider$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
   785 	$scripts->add( 'jquery-ui-slider', "/wp-includes/js/jquery/ui/slider$suffix.js", array( 'jquery-ui-mouse' ), '1.12.1', 1 );
   761 	$scripts->add( 'jquery-ui-sortable', "/wp-includes/js/jquery/ui/sortable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
   786 	$scripts->add( 'jquery-ui-spinner', "/wp-includes/js/jquery/ui/spinner$suffix.js", array( 'jquery-ui-button' ), '1.12.1', 1 );
   762 	$scripts->add( 'jquery-ui-spinner', "/wp-includes/js/jquery/ui/spinner$dev_suffix.js", array( 'jquery-ui-button' ), '1.11.4', 1 );
   787 	$scripts->add( 'jquery-ui-tabs', "/wp-includes/js/jquery/ui/tabs$suffix.js", array( 'jquery-ui-core' ), '1.12.1', 1 );
   763 	$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 );
   788 	$scripts->add( 'jquery-ui-tooltip', "/wp-includes/js/jquery/ui/tooltip$suffix.js", array( 'jquery-ui-core' ), '1.12.1', 1 );
   764 	$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 );
   789 
   765 	$scripts->add( 'jquery-ui-widget', "/wp-includes/js/jquery/ui/widget$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
   790 	// New in 1.12.1
       
   791 	$scripts->add( 'jquery-ui-checkboxradio', "/wp-includes/js/jquery/ui/checkboxradio$suffix.js", array( 'jquery-ui-core' ), '1.12.1', 1 );
       
   792 	$scripts->add( 'jquery-ui-controlgroup', "/wp-includes/js/jquery/ui/controlgroup$suffix.js", array( 'jquery-ui-core' ), '1.12.1', 1 );
       
   793 
       
   794 	// Interactions
       
   795 	$scripts->add( 'jquery-ui-draggable', "/wp-includes/js/jquery/ui/draggable$suffix.js", array( 'jquery-ui-mouse' ), '1.12.1', 1 );
       
   796 	$scripts->add( 'jquery-ui-droppable', "/wp-includes/js/jquery/ui/droppable$suffix.js", array( 'jquery-ui-draggable' ), '1.12.1', 1 );
       
   797 	$scripts->add( 'jquery-ui-resizable', "/wp-includes/js/jquery/ui/resizable$suffix.js", array( 'jquery-ui-mouse' ), '1.12.1', 1 );
       
   798 	$scripts->add( 'jquery-ui-selectable', "/wp-includes/js/jquery/ui/selectable$suffix.js", array( 'jquery-ui-mouse' ), '1.12.1', 1 );
       
   799 	$scripts->add( 'jquery-ui-sortable', "/wp-includes/js/jquery/ui/sortable$suffix.js", array( 'jquery-ui-mouse' ), '1.12.1', 1 );
       
   800 
       
   801 	// As of 1.12.1 `jquery-ui-position` and `jquery-ui-widget` are part of `jquery-ui-core`.
       
   802 	// Listed here for back-compat.
       
   803 	$scripts->add( 'jquery-ui-position', false, array( 'jquery-ui-core' ), '1.12.1', 1 );
       
   804 	$scripts->add( 'jquery-ui-widget', false, array( 'jquery-ui-core' ), '1.12.1', 1 );
   766 
   805 
   767 	// Strings for 'jquery-ui-autocomplete' live region messages.
   806 	// Strings for 'jquery-ui-autocomplete' live region messages.
   768 	did_action( 'init' ) && $scripts->localize(
   807 	did_action( 'init' ) && $scripts->localize(
   769 		'jquery-ui-autocomplete',
   808 		'jquery-ui-autocomplete',
   770 		'uiAutocompleteL10n',
   809 		'uiAutocompleteL10n',
   777 			'itemSelected' => __( 'Item selected.' ),
   816 			'itemSelected' => __( 'Item selected.' ),
   778 		)
   817 		)
   779 	);
   818 	);
   780 
   819 
   781 	// Deprecated, not used in core, most functionality is included in jQuery 1.3.
   820 	// Deprecated, not used in core, most functionality is included in jQuery 1.3.
   782 	$scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array( 'jquery' ), '4.2.1', 1 );
   821 	$scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array( 'jquery' ), '4.3.0', 1 );
   783 
   822 
   784 	// jQuery plugins.
   823 	// jQuery plugins.
   785 	$scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.min.js', array( 'jquery' ), '2.1.2', 1 );
   824 	$scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.min.js', array( 'jquery' ), '2.1.2', 1 );
   786 	$scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array( 'jquery' ), '20m', 1 );
   825 	$scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array( 'jquery' ), '20m', 1 );
   787 	$scripts->add( 'jquery-query', '/wp-includes/js/jquery/jquery.query.js', array( 'jquery' ), '2.1.7', 1 );
   826 	$scripts->add( 'jquery-query', '/wp-includes/js/jquery/jquery.query.js', array( 'jquery' ), '2.1.7', 1 );
   788 	$scripts->add( 'jquery-serialize-object', '/wp-includes/js/jquery/jquery.serialize-object.js', array( 'jquery' ), '0.2', 1 );
   827 	$scripts->add( 'jquery-serialize-object', '/wp-includes/js/jquery/jquery.serialize-object.js', array( 'jquery' ), '0.2-wp', 1 );
   789 	$scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array( 'jquery' ), '0.0.2m', 1 );
   828 	$scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array( 'jquery' ), '0.0.2m', 1 );
   790 	$scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array( 'jquery', 'jquery-hotkeys' ), false, 1 );
   829 	$scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array( 'jquery', 'jquery-hotkeys' ), false, 1 );
   791 	$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 );
   830 	$scripts->add( 'jquery-touch-punch', '/wp-includes/js/jquery/jquery.ui.touch-punch.js', array( 'jquery-ui-core', 'jquery-ui-mouse' ), '0.2.2', 1 );
   792 
   831 
   793 	// Not used any more, registered for backward compatibility.
   832 	// Not used any more, registered for backward compatibility.
   794 	$scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array( 'jquery' ), '1.1-20110113', 1 );
   833 	$scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array( 'jquery' ), '1.1-20110113', 1 );
   795 
   834 
   796 	// Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv.
   835 	// Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv.
   797 	// It sets jQuery as a dependency, as the theme may have been implicitly loading it this way.
   836 	// It sets jQuery as a dependency, as the theme may have been implicitly loading it this way.
   798 	$scripts->add( 'imagesloaded', '/wp-includes/js/imagesloaded.min.js', array(), '4.1.4', 1 );
   837 	$scripts->add( 'imagesloaded', '/wp-includes/js/imagesloaded.min.js', array(), '4.1.4', 1 );
   799 	$scripts->add( 'masonry', '/wp-includes/js/masonry.min.js', array( 'imagesloaded' ), '4.2.2', 1 );
   838 	$scripts->add( 'masonry', '/wp-includes/js/masonry.min.js', array( 'imagesloaded' ), '4.2.2', 1 );
   800 	$scripts->add( 'jquery-masonry', "/wp-includes/js/jquery/jquery.masonry$dev_suffix.js", array( 'jquery', 'masonry' ), '3.1.2b', 1 );
   839 	$scripts->add( 'jquery-masonry', '/wp-includes/js/jquery/jquery.masonry.min.js', array( 'jquery', 'masonry' ), '3.1.2b', 1 );
   801 
   840 
   802 	$scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array( 'jquery' ), '3.1-20121105', 1 );
   841 	$scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array( 'jquery' ), '3.1-20121105', 1 );
   803 	did_action( 'init' ) && $scripts->localize(
   842 	did_action( 'init' ) && $scripts->localize(
   804 		'thickbox',
   843 		'thickbox',
   805 		'thickboxL10n',
   844 		'thickboxL10n',
   846 		'crunching'                 => __( 'Crunching…' ),
   885 		'crunching'                 => __( 'Crunching…' ),
   847 		'deleted'                   => __( 'moved to the Trash.' ),
   886 		'deleted'                   => __( 'moved to the Trash.' ),
   848 		/* translators: %s: File name. */
   887 		/* translators: %s: File name. */
   849 		'error_uploading'           => __( '“%s” has failed to upload.' ),
   888 		'error_uploading'           => __( '“%s” has failed to upload.' ),
   850 		'unsupported_image'         => __( 'This image cannot be displayed in a web browser. For best results convert it to JPEG before uploading.' ),
   889 		'unsupported_image'         => __( 'This image cannot be displayed in a web browser. For best results convert it to JPEG before uploading.' ),
       
   890 		'noneditable_image'         => __( 'This image cannot be processed by the web server. Convert it to JPEG or PNG before uploading.' ),
       
   891 		'file_url_copied'           => __( 'The file URL has been copied to your clipboard' ),
   851 	);
   892 	);
   852 
   893 
   853 	$scripts->add( 'moxiejs', "/wp-includes/js/plupload/moxie$suffix.js", array(), '1.3.5' );
   894 	$scripts->add( 'moxiejs', "/wp-includes/js/plupload/moxie$suffix.js", array(), '1.3.5' );
   854 	$scripts->add( 'plupload', "/wp-includes/js/plupload/plupload$suffix.js", array( 'moxiejs' ), '2.1.9' );
   895 	$scripts->add( 'plupload', "/wp-includes/js/plupload/plupload$suffix.js", array( 'moxiejs' ), '2.1.9' );
   855 	// Back compat handles:
   896 	// Back compat handles:
   856 	foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) {
   897 	foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) {
   857 		$scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' );
   898 		$scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' );
   858 	}
   899 	}
   859 
   900 
   860 	$scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'plupload', 'jquery' ) );
   901 	$scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'clipboard', 'jquery', 'plupload', 'underscore', 'wp-a11y', 'wp-i18n' ) );
   861 	did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
   902 	did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
   862 
   903 
   863 	$scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 );
   904 	$scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 );
   864 	did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n );
   905 	did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n );
   865 
   906 
   872 	$scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 );
   913 	$scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 );
   873 
   914 
   874 	$scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' );
   915 	$scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' );
   875 	did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' );
   916 	did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' );
   876 
   917 
   877 	$scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.8.3', 1 );
   918 	$scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.13.1', 1 );
   878 	$scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.4.0', 1 );
   919 	$scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.4.0', 1 );
   879 
   920 
   880 	$scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array( 'underscore', 'jquery' ), false, 1 );
   921 	$scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array( 'underscore', 'jquery' ), false, 1 );
   881 	did_action( 'init' ) && $scripts->localize(
   922 	did_action( 'init' ) && $scripts->localize(
   882 		'wp-util',
   923 		'wp-util',
   892 
   933 
   893 	$scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverIntent' ), false, 1 );
   934 	$scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverIntent' ), false, 1 );
   894 
   935 
   895 	$scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array( 'jquery' ), false, 1 );
   936 	$scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array( 'jquery' ), false, 1 );
   896 
   937 
   897 	$scripts->add( 'mediaelement', false, array( 'jquery', 'mediaelement-core', 'mediaelement-migrate' ), '4.2.13-9993131', 1 );
   938 	$scripts->add( 'mediaelement', false, array( 'jquery', 'mediaelement-core', 'mediaelement-migrate' ), '4.2.16', 1 );
   898 	$scripts->add( 'mediaelement-core', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array(), '4.2.13-9993131', 1 );
   939 	$scripts->add( 'mediaelement-core', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array(), '4.2.16', 1 );
   899 	$scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1 );
   940 	$scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1 );
   900 
   941 
   901 	did_action( 'init' ) && $scripts->add_inline_script(
   942 	did_action( 'init' ) && $scripts->add_inline_script(
   902 		'mediaelement-core',
   943 		'mediaelement-core',
   903 		sprintf(
   944 		sprintf(
   983 			)
  1024 			)
   984 		),
  1025 		),
   985 		'before'
  1026 		'before'
   986 	);
  1027 	);
   987 
  1028 
   988 	$scripts->add( 'mediaelement-vimeo', '/wp-includes/js/mediaelement/renderers/vimeo.min.js', array( 'mediaelement' ), '4.2.13-9993131', 1 );
  1029 	$scripts->add( 'mediaelement-vimeo', '/wp-includes/js/mediaelement/renderers/vimeo.min.js', array( 'mediaelement' ), '4.2.16', 1 );
   989 	$scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.js", array( 'mediaelement' ), false, 1 );
  1030 	$scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.js", array( 'mediaelement' ), false, 1 );
   990 	$mejs_settings = array(
  1031 	$mejs_settings = array(
   991 		'pluginPath'  => includes_url( 'js/mediaelement/', 'relative' ),
  1032 		'pluginPath'  => includes_url( 'js/mediaelement/', 'relative' ),
   992 		'classPrefix' => 'mejs-',
  1033 		'classPrefix' => 'mejs-',
   993 		'stretching'  => 'responsive',
  1034 		'stretching'  => 'responsive',
  1040 			'mismatch' => _x( 'Mismatch', 'password mismatch' ),
  1081 			'mismatch' => _x( 'Mismatch', 'password mismatch' ),
  1041 		)
  1082 		)
  1042 	);
  1083 	);
  1043 	$scripts->set_translations( 'password-strength-meter' );
  1084 	$scripts->set_translations( 'password-strength-meter' );
  1044 
  1085 
       
  1086 	$scripts->add( 'application-passwords', "/wp-admin/js/application-passwords$suffix.js", array( 'jquery', 'wp-util', 'wp-api-request', 'wp-date', 'wp-i18n', 'wp-hooks' ), false, 1 );
       
  1087 	$scripts->set_translations( 'application-passwords' );
       
  1088 
       
  1089 	$scripts->add( 'auth-app', "/wp-admin/js/auth-app$suffix.js", array( 'jquery', 'wp-api-request', 'wp-i18n', 'wp-hooks' ), false, 1 );
       
  1090 	$scripts->set_translations( 'auth-app' );
       
  1091 
  1045 	$scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 );
  1092 	$scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 );
  1046 	$scripts->set_translations( 'user-profile' );
  1093 	$scripts->set_translations( 'user-profile' );
       
  1094 	$user_id = isset( $_GET['user_id'] ) ? (int) $_GET['user_id'] : 0;
       
  1095 	did_action( 'init' ) && $scripts->localize(
       
  1096 		'user-profile',
       
  1097 		'userProfileL10n',
       
  1098 		array(
       
  1099 			'user_id' => $user_id,
       
  1100 			'nonce'   => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'reset-password-for-' . $user_id ),
       
  1101 		)
       
  1102 	);
  1047 
  1103 
  1048 	$scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 );
  1104 	$scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 );
  1049 
  1105 
  1050 	$scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
  1106 	$scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
  1051 
  1107 
  1072 
  1128 
  1073 	$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 );
  1129 	$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 );
  1074 
  1130 
  1075 	$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 );
  1131 	$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 );
  1076 
  1132 
  1077 	$scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array( 'jquery' ), '1.8.1', 1 );
  1133 	$scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array( 'jquery' ), '1.10.1', 1 );
  1078 
  1134 
  1079 	// JS-only version of hoverintent (no dependencies).
  1135 	// JS-only version of hoverintent (no dependencies).
  1080 	$scripts->add( 'hoverintent-js', '/wp-includes/js/hoverintent-js.min.js', array(), '2.2.1', 1 );
  1136 	$scripts->add( 'hoverintent-js', '/wp-includes/js/hoverintent-js.min.js', array(), '2.2.1', 1 );
  1081 
  1137 
  1082 	$scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 );
  1138 	$scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 );
  1253 		$scripts->set_translations( 'inline-edit-tax' );
  1309 		$scripts->set_translations( 'inline-edit-tax' );
  1254 
  1310 
  1255 		$scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 );
  1311 		$scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 );
  1256 		$scripts->set_translations( 'plugin-install' );
  1312 		$scripts->set_translations( 'plugin-install' );
  1257 
  1313 
  1258 		$scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
  1314 		$scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-api-request', 'wp-url', 'wp-i18n', 'wp-hooks' ), false, 1 );
  1259 		$scripts->set_translations( 'site-health' );
  1315 		$scripts->set_translations( 'site-health' );
  1260 
  1316 
  1261 		$scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
  1317 		$scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
  1262 		$scripts->set_translations( 'privacy-tools' );
  1318 		$scripts->set_translations( 'privacy-tools' );
  1263 
  1319 
  1275 
  1331 
  1276 		$scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.0.7', 1 );
  1332 		$scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.0.7', 1 );
  1277 		$scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 );
  1333 		$scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 );
  1278 		$scripts->set_translations( 'wp-color-picker' );
  1334 		$scripts->set_translations( 'wp-color-picker' );
  1279 
  1335 
  1280 		$scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y' ), false, 1 );
  1336 		$scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y', 'wp-date' ), false, 1 );
       
  1337 		$scripts->set_translations( 'dashboard' );
  1281 
  1338 
  1282 		$scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" );
  1339 		$scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" );
  1283 
  1340 
  1284 		$scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 );
  1341 		$scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 );
  1285 		$scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 );
  1342 		$scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 );
  1416 	$styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' );
  1473 	$styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' );
  1417 
  1474 
  1418 	// External libraries and friends.
  1475 	// External libraries and friends.
  1419 	$styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' );
  1476 	$styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' );
  1420 	$styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) );
  1477 	$styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) );
  1421 	$styles->add( 'mediaelement', '/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css', array(), '4.2.13-9993131' );
  1478 	$styles->add( 'mediaelement', '/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css', array(), '4.2.16' );
  1422 	$styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) );
  1479 	$styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) );
  1423 	$styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) );
  1480 	$styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) );
  1424 	$styles->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.css', array(), '5.29.1-alpha-ee20357' );
  1481 	$styles->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.css', array(), '5.29.1-alpha-ee20357' );
  1425 
  1482 
  1426 	// Deprecated CSS.
  1483 	// Deprecated CSS.
  1428 	$styles->add( 'farbtastic', "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1' );
  1485 	$styles->add( 'farbtastic', "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1' );
  1429 	$styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.css', array(), '0.9.12' );
  1486 	$styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.css', array(), '0.9.12' );
  1430 	$styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle.
  1487 	$styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle.
  1431 	$styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6.
  1488 	$styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6.
  1432 
  1489 
  1433 	// Packages styles.
  1490 	// Noto Serif is no longer used by core, but may be relied upon by themes and plugins.
  1434 	$fonts_url = '';
  1491 	$fonts_url = '';
  1435 
  1492 
  1436 	/*
  1493 	/*
  1437 	 * translators: Use this to specify the proper Google Font name and variants
  1494 	 * translators: Use this to specify the proper Google Font name and variants
  1438 	 * to load that is supported by your language. Do not translate.
  1495 	 * to load that is supported by your language. Do not translate.
  1440 	 */
  1497 	 */
  1441 	$font_family = _x( 'Noto Serif:400,400i,700,700i', 'Google Font Name and Variants' );
  1498 	$font_family = _x( 'Noto Serif:400,400i,700,700i', 'Google Font Name and Variants' );
  1442 	if ( 'off' !== $font_family ) {
  1499 	if ( 'off' !== $font_family ) {
  1443 		$fonts_url = 'https://fonts.googleapis.com/css?family=' . urlencode( $font_family );
  1500 		$fonts_url = 'https://fonts.googleapis.com/css?family=' . urlencode( $font_family );
  1444 	}
  1501 	}
  1445 	$styles->add( 'wp-editor-font', $fonts_url );
  1502 	$styles->add( 'wp-editor-font', $fonts_url ); // No longer used in core as of 5.7.
  1446 
  1503 	$block_library_theme_path = WPINC . "/css/dist/block-library/theme$suffix.css";
  1447 	$styles->add( 'wp-block-library-theme', "/wp-includes/css/dist/block-library/theme$suffix.css" );
  1504 	$styles->add( 'wp-block-library-theme', "/$block_library_theme_path" );
       
  1505 	$styles->add_data( 'wp-block-library-theme', 'path', ABSPATH . $block_library_theme_path );
       
  1506 
       
  1507 	$styles->add(
       
  1508 		'wp-reset-editor-styles',
       
  1509 		"/wp-includes/css/dist/block-library/reset$suffix.css",
       
  1510 		array( 'common', 'forms' ) // Make sure the reset is loaded after the default WP Admin styles.
       
  1511 	);
       
  1512 
       
  1513 	$styles->add(
       
  1514 		'wp-editor-classic-layout-styles',
       
  1515 		"/wp-includes/css/dist/edit-post/classic$suffix.css",
       
  1516 		array()
       
  1517 	);
       
  1518 
       
  1519 	$wp_edit_blocks_dependencies = array(
       
  1520 		'wp-components',
       
  1521 		'wp-editor',
       
  1522 		// This need to be added before the block library styles,
       
  1523 		// The block library styles override the "reset" styles.
       
  1524 		'wp-reset-editor-styles',
       
  1525 		'wp-block-library',
       
  1526 		'wp-reusable-blocks',
       
  1527 	);
       
  1528 
       
  1529 	// Only load the default layout and margin styles for themes without theme.json file.
       
  1530 	if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) {
       
  1531 		$wp_edit_blocks_dependencies[] = 'wp-editor-classic-layout-styles';
       
  1532 	}
       
  1533 
       
  1534 	global $editor_styles;
       
  1535 	if ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) {
       
  1536 		// Include opinionated block styles if no $editor_styles are declared, so the editor never appears broken.
       
  1537 		$wp_edit_blocks_dependencies[] = 'wp-block-library-theme';
       
  1538 	}
  1448 
  1539 
  1449 	$styles->add(
  1540 	$styles->add(
  1450 		'wp-edit-blocks',
  1541 		'wp-edit-blocks',
  1451 		"/wp-includes/css/dist/block-library/editor$suffix.css",
  1542 		"/wp-includes/css/dist/block-library/editor$suffix.css",
  1452 		array(
  1543 		$wp_edit_blocks_dependencies
  1453 			'wp-components',
       
  1454 			'wp-editor',
       
  1455 			'wp-block-library',
       
  1456 			// Always include visual styles so the editor never appears broken.
       
  1457 			'wp-block-library-theme',
       
  1458 		)
       
  1459 	);
  1544 	);
  1460 
  1545 
  1461 	$package_styles = array(
  1546 	$package_styles = array(
  1462 		'block-editor'         => array(
  1547 		'block-editor'         => array( 'wp-components' ),
  1463 			'wp-components',
       
  1464 			'wp-editor-font',
       
  1465 		),
       
  1466 		'block-library'        => array(),
  1548 		'block-library'        => array(),
  1467 		'block-directory'      => array(),
  1549 		'block-directory'      => array(),
  1468 		'components'           => array(),
  1550 		'components'           => array(),
  1469 		'edit-post'            => array(
  1551 		'edit-post'            => array(
  1470 			'wp-components',
  1552 			'wp-components',
  1476 		),
  1558 		),
  1477 		'editor'               => array(
  1559 		'editor'               => array(
  1478 			'wp-components',
  1560 			'wp-components',
  1479 			'wp-block-editor',
  1561 			'wp-block-editor',
  1480 			'wp-nux',
  1562 			'wp-nux',
       
  1563 			'wp-reusable-blocks',
  1481 		),
  1564 		),
  1482 		'format-library'       => array(),
  1565 		'format-library'       => array(),
  1483 		'list-reusable-blocks' => array( 'wp-components' ),
  1566 		'list-reusable-blocks' => array( 'wp-components' ),
       
  1567 		'reusable-blocks'      => array( 'wp-components' ),
  1484 		'nux'                  => array( 'wp-components' ),
  1568 		'nux'                  => array( 'wp-components' ),
       
  1569 		'widgets'              => array(
       
  1570 			'wp-components',
       
  1571 		),
       
  1572 		'edit-widgets'         => array(
       
  1573 			'wp-widgets',
       
  1574 			'wp-block-editor',
       
  1575 			'wp-edit-blocks',
       
  1576 			'wp-block-library',
       
  1577 			'wp-reusable-blocks',
       
  1578 		),
       
  1579 		'customize-widgets'    => array(
       
  1580 			'wp-widgets',
       
  1581 			'wp-block-editor',
       
  1582 			'wp-edit-blocks',
       
  1583 			'wp-block-library',
       
  1584 			'wp-reusable-blocks',
       
  1585 		),
  1485 	);
  1586 	);
  1486 
  1587 
  1487 	foreach ( $package_styles as $package => $dependencies ) {
  1588 	foreach ( $package_styles as $package => $dependencies ) {
  1488 		$handle = 'wp-' . $package;
  1589 		$handle = 'wp-' . $package;
  1489 		$path   = "/wp-includes/css/dist/$package/style$suffix.css";
  1590 		$path   = "/wp-includes/css/dist/$package/style$suffix.css";
  1490 
  1591 
       
  1592 		if ( 'block-library' === $package && wp_should_load_separate_core_block_assets() ) {
       
  1593 			$path = "/wp-includes/css/dist/$package/common$suffix.css";
       
  1594 		}
  1491 		$styles->add( $handle, $path, $dependencies );
  1595 		$styles->add( $handle, $path, $dependencies );
       
  1596 		$styles->add_data( $handle, 'path', ABSPATH . $path );
  1492 	}
  1597 	}
  1493 
  1598 
  1494 	// RTL CSS.
  1599 	// RTL CSS.
  1495 	$rtl_styles = array(
  1600 	$rtl_styles = array(
  1496 		// Admin CSS.
  1601 		// Admin CSS.
  1523 		'editor-buttons',
  1628 		'editor-buttons',
  1524 		'media-views',
  1629 		'media-views',
  1525 		'wp-pointer',
  1630 		'wp-pointer',
  1526 		'wp-jquery-ui-dialog',
  1631 		'wp-jquery-ui-dialog',
  1527 		// Package styles.
  1632 		// Package styles.
       
  1633 		'wp-reset-editor-styles',
       
  1634 		'wp-editor-classic-layout-styles',
  1528 		'wp-block-library-theme',
  1635 		'wp-block-library-theme',
  1529 		'wp-edit-blocks',
  1636 		'wp-edit-blocks',
  1530 		'wp-block-editor',
  1637 		'wp-block-editor',
  1531 		'wp-block-library',
  1638 		'wp-block-library',
  1532 		'wp-block-directory',
  1639 		'wp-block-directory',
  1533 		'wp-components',
  1640 		'wp-components',
       
  1641 		'wp-customize-widgets',
  1534 		'wp-edit-post',
  1642 		'wp-edit-post',
       
  1643 		'wp-edit-widgets',
  1535 		'wp-editor',
  1644 		'wp-editor',
  1536 		'wp-format-library',
  1645 		'wp-format-library',
  1537 		'wp-list-reusable-blocks',
  1646 		'wp-list-reusable-blocks',
       
  1647 		'wp-reusable-blocks',
  1538 		'wp-nux',
  1648 		'wp-nux',
       
  1649 		'wp-widgets',
  1539 		// Deprecated CSS.
  1650 		// Deprecated CSS.
  1540 		'deprecated-media',
  1651 		'deprecated-media',
  1541 		'farbtastic',
  1652 		'farbtastic',
  1542 	);
  1653 	);
  1543 
  1654 
  1711 	 * shown events in the city where they were when they first loaded the
  1822 	 * shown events in the city where they were when they first loaded the
  1712 	 * Dashboard, which could have been months or years ago.
  1823 	 * Dashboard, which could have been months or years ago.
  1713 	 */
  1824 	 */
  1714 	if ( $saved_ip_address && $current_ip_address && $current_ip_address !== $saved_ip_address ) {
  1825 	if ( $saved_ip_address && $current_ip_address && $current_ip_address !== $saved_ip_address ) {
  1715 		$saved_location['ip'] = $current_ip_address;
  1826 		$saved_location['ip'] = $current_ip_address;
  1716 		update_user_option( $user_id, 'community-events-location', $saved_location, true );
  1827 		update_user_meta( $user_id, 'community-events-location', $saved_location );
  1717 	}
  1828 	}
  1718 
  1829 
  1719 	$events_client = new WP_Community_Events( $user_id, $saved_location );
  1830 	$events_client = new WP_Community_Events( $user_id, $saved_location );
  1720 
  1831 
  1721 	wp_localize_script(
  1832 	wp_localize_script(
  1722 		'dashboard',
  1833 		'dashboard',
  1723 		'communityEventsData',
  1834 		'communityEventsData',
  1724 		array(
  1835 		array(
  1725 			'nonce' => wp_create_nonce( 'community_events' ),
  1836 			'nonce'       => wp_create_nonce( 'community_events' ),
  1726 			'cache' => $events_client->get_cached_events(),
  1837 			'cache'       => $events_client->get_cached_events(),
  1727 
  1838 			'time_format' => get_option( 'time_format' ),
  1728 			'l10n'  => array(
       
  1729 				'enter_closest_city'              => __( 'Enter your closest city to find nearby events.' ),
       
  1730 				'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ),
       
  1731 				'attend_event_near_generic'       => __( 'Attend an upcoming event near you.' ),
       
  1732 
       
  1733 				/*
       
  1734 				 * These specific examples were chosen to highlight the fact that a
       
  1735 				 * state is not needed, even for cities whose name is not unique.
       
  1736 				 * It would be too cumbersome to include that in the instructions
       
  1737 				 * to the user, so it's left as an implication.
       
  1738 				 */
       
  1739 				/*
       
  1740 				 * translators: %s is the name of the city we couldn't locate.
       
  1741 				 * Replace the examples with cities related to your locale. Test that
       
  1742 				 * they match the expected location and have upcoming events before
       
  1743 				 * including them. If no cities related to your locale have events,
       
  1744 				 * then use cities related to your locale that would be recognizable
       
  1745 				 * to most users. Use only the city name itself, without any region
       
  1746 				 * or country. Use the endonym (native locale name) instead of the
       
  1747 				 * English name if possible.
       
  1748 				 */
       
  1749 				'could_not_locate_city'           => __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
       
  1750 
       
  1751 				// This one is only used with wp.a11y.speak(), so it can/should be more brief.
       
  1752 				/* translators: %s: The name of a city. */
       
  1753 				'city_updated'                    => __( 'City updated. Listing events near %s.' ),
       
  1754 			),
       
  1755 		)
  1839 		)
  1756 	);
  1840 	);
  1757 }
  1841 }
  1758 
  1842 
  1759 /**
  1843 /**
  2158  * @since 5.0.0
  2242  * @since 5.0.0
  2159  *
  2243  *
  2160  * @global WP_Screen $current_screen WordPress current screen object.
  2244  * @global WP_Screen $current_screen WordPress current screen object.
  2161  */
  2245  */
  2162 function wp_common_block_scripts_and_styles() {
  2246 function wp_common_block_scripts_and_styles() {
  2163 	global $current_screen;
  2247 	if ( is_admin() && ! wp_should_load_block_editor_scripts_and_styles() ) {
  2164 
       
  2165 	if ( is_admin() && ( $current_screen instanceof WP_Screen ) && ! $current_screen->is_block_editor() ) {
       
  2166 		return;
  2248 		return;
  2167 	}
  2249 	}
  2168 
  2250 
  2169 	wp_enqueue_style( 'wp-block-library' );
  2251 	wp_enqueue_style( 'wp-block-library' );
  2170 
  2252 
  2184 	 */
  2266 	 */
  2185 	do_action( 'enqueue_block_assets' );
  2267 	do_action( 'enqueue_block_assets' );
  2186 }
  2268 }
  2187 
  2269 
  2188 /**
  2270 /**
       
  2271  * Enqueues the global styles defined via theme.json.
       
  2272  *
       
  2273  * @since 5.8.0
       
  2274  */
       
  2275 function wp_enqueue_global_styles() {
       
  2276 	if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) {
       
  2277 		return;
       
  2278 	}
       
  2279 
       
  2280 	$separate_assets = wp_should_load_separate_core_block_assets();
       
  2281 
       
  2282 	/*
       
  2283 	 * Global styles should be printed in the head when loading all styles combined.
       
  2284 	 * The footer should only be used to print global styles for classic themes with separate core assets enabled.
       
  2285 	 *
       
  2286 	 * See https://core.trac.wordpress.org/ticket/53494.
       
  2287 	 */
       
  2288 	if ( ( ! $separate_assets && doing_action( 'wp_footer' ) ) || ( $separate_assets && doing_action( 'wp_enqueue_scripts' ) ) ) {
       
  2289 		return;
       
  2290 	}
       
  2291 
       
  2292 	$can_use_cache = (
       
  2293 		( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) &&
       
  2294 		( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) &&
       
  2295 		( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) &&
       
  2296 		! is_admin()
       
  2297 	);
       
  2298 
       
  2299 	$stylesheet = null;
       
  2300 	if ( $can_use_cache ) {
       
  2301 		$cache = get_transient( 'global_styles' );
       
  2302 		if ( $cache ) {
       
  2303 			$stylesheet = $cache;
       
  2304 		}
       
  2305 	}
       
  2306 
       
  2307 	if ( null === $stylesheet ) {
       
  2308 		$settings   = get_default_block_editor_settings();
       
  2309 		$theme_json = WP_Theme_JSON_Resolver::get_merged_data( $settings );
       
  2310 		$stylesheet = $theme_json->get_stylesheet();
       
  2311 
       
  2312 		if ( $can_use_cache ) {
       
  2313 			set_transient( 'global_styles', $stylesheet, MINUTE_IN_SECONDS );
       
  2314 		}
       
  2315 	}
       
  2316 
       
  2317 	if ( empty( $stylesheet ) ) {
       
  2318 		return;
       
  2319 	}
       
  2320 
       
  2321 	wp_register_style( 'global-styles', false, array(), true, true );
       
  2322 	wp_add_inline_style( 'global-styles', $stylesheet );
       
  2323 	wp_enqueue_style( 'global-styles' );
       
  2324 }
       
  2325 
       
  2326 /**
       
  2327  * Checks if the editor scripts and styles for all registered block types
       
  2328  * should be enqueued on the current screen.
       
  2329  *
       
  2330  * @since 5.6.0
       
  2331  *
       
  2332  * @return bool Whether scripts and styles should be enqueued.
       
  2333  */
       
  2334 function wp_should_load_block_editor_scripts_and_styles() {
       
  2335 	global $current_screen;
       
  2336 
       
  2337 	$is_block_editor_screen = ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor();
       
  2338 
       
  2339 	/**
       
  2340 	 * Filters the flag that decides whether or not block editor scripts and styles
       
  2341 	 * are going to be enqueued on the current screen.
       
  2342 	 *
       
  2343 	 * @since 5.6.0
       
  2344 	 *
       
  2345 	 * @param bool $is_block_editor_screen Current value of the flag.
       
  2346 	 */
       
  2347 	return apply_filters( 'should_load_block_editor_scripts_and_styles', $is_block_editor_screen );
       
  2348 }
       
  2349 
       
  2350 /**
       
  2351  * Checks whether separate styles should be loaded for core blocks on-render.
       
  2352  *
       
  2353  * When this function returns true, other functions ensure that core blocks
       
  2354  * only load their assets on-render, and each block loads its own, individual
       
  2355  * assets. Third-party blocks only load their assets when rendered.
       
  2356  *
       
  2357  * When this function returns false, all core block assets are loaded regardless
       
  2358  * of whether they are rendered in a page or not, because they are all part of
       
  2359  * the `block-library/style.css` file. Assets for third-party blocks are always
       
  2360  * enqueued regardless of whether they are rendered or not.
       
  2361  *
       
  2362  * This only affects front end and not the block editor screens.
       
  2363  *
       
  2364  * @see wp_enqueue_registered_block_scripts_and_styles()
       
  2365  * @see register_block_style_handle()
       
  2366  *
       
  2367  * @since 5.8.0
       
  2368  *
       
  2369  * @return bool Whether separate assets will be loaded.
       
  2370  */
       
  2371 function wp_should_load_separate_core_block_assets() {
       
  2372 	if ( is_admin() || is_feed() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) {
       
  2373 		return false;
       
  2374 	}
       
  2375 
       
  2376 	/**
       
  2377 	 * Filters whether block styles should be loaded separately.
       
  2378 	 *
       
  2379 	 * Returning false loads all core block assets, regardless of whether they are rendered
       
  2380 	 * in a page or not. Returning true loads core block assets only when they are rendered.
       
  2381 	 *
       
  2382 	 * @since 5.8.0
       
  2383 	 *
       
  2384 	 * @param bool $load_separate_assets Whether separate assets will be loaded.
       
  2385 	 *                                   Default false (all block assets are loaded, even when not used).
       
  2386 	 */
       
  2387 	return apply_filters( 'should_load_separate_core_block_assets', false );
       
  2388 }
       
  2389 
       
  2390 /**
  2189  * Enqueues registered block scripts and styles, depending on current rendered
  2391  * Enqueues registered block scripts and styles, depending on current rendered
  2190  * context (only enqueuing editor scripts while in context of the editor).
  2392  * context (only enqueuing editor scripts while in context of the editor).
  2191  *
  2393  *
  2192  * @since 5.0.0
  2394  * @since 5.0.0
  2193  *
  2395  *
  2194  * @global WP_Screen $current_screen WordPress current screen object.
  2396  * @global WP_Screen $current_screen WordPress current screen object.
  2195  */
  2397  */
  2196 function wp_enqueue_registered_block_scripts_and_styles() {
  2398 function wp_enqueue_registered_block_scripts_and_styles() {
  2197 	global $current_screen;
  2399 	global $current_screen;
  2198 
  2400 
  2199 	$is_editor = ( ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor() );
  2401 	if ( wp_should_load_separate_core_block_assets() ) {
       
  2402 		return;
       
  2403 	}
       
  2404 
       
  2405 	$load_editor_scripts = is_admin() && wp_should_load_block_editor_scripts_and_styles();
  2200 
  2406 
  2201 	$block_registry = WP_Block_Type_Registry::get_instance();
  2407 	$block_registry = WP_Block_Type_Registry::get_instance();
  2202 	foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {
  2408 	foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {
  2203 		// Front-end styles.
  2409 		// Front-end styles.
  2204 		if ( ! empty( $block_type->style ) ) {
  2410 		if ( ! empty( $block_type->style ) ) {
  2209 		if ( ! empty( $block_type->script ) ) {
  2415 		if ( ! empty( $block_type->script ) ) {
  2210 			wp_enqueue_script( $block_type->script );
  2416 			wp_enqueue_script( $block_type->script );
  2211 		}
  2417 		}
  2212 
  2418 
  2213 		// Editor styles.
  2419 		// Editor styles.
  2214 		if ( $is_editor && ! empty( $block_type->editor_style ) ) {
  2420 		if ( $load_editor_scripts && ! empty( $block_type->editor_style ) ) {
  2215 			wp_enqueue_style( $block_type->editor_style );
  2421 			wp_enqueue_style( $block_type->editor_style );
  2216 		}
  2422 		}
  2217 
  2423 
  2218 		// Editor script.
  2424 		// Editor script.
  2219 		if ( $is_editor && ! empty( $block_type->editor_script ) ) {
  2425 		if ( $load_editor_scripts && ! empty( $block_type->editor_script ) ) {
  2220 			wp_enqueue_script( $block_type->editor_script );
  2426 			wp_enqueue_script( $block_type->editor_script );
  2221 		}
  2427 		}
  2222 	}
  2428 	}
  2223 }
  2429 }
  2224 
  2430 
  2228  * @since 5.3.0
  2434  * @since 5.3.0
  2229  */
  2435  */
  2230 function enqueue_block_styles_assets() {
  2436 function enqueue_block_styles_assets() {
  2231 	$block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
  2437 	$block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
  2232 
  2438 
  2233 	foreach ( $block_styles as $styles ) {
  2439 	foreach ( $block_styles as $block_name => $styles ) {
  2234 		foreach ( $styles as $style_properties ) {
  2440 		foreach ( $styles as $style_properties ) {
  2235 			if ( isset( $style_properties['style_handle'] ) ) {
  2441 			if ( isset( $style_properties['style_handle'] ) ) {
  2236 				wp_enqueue_style( $style_properties['style_handle'] );
  2442 
       
  2443 				// If the site loads separate styles per-block, enqueue the stylesheet on render.
       
  2444 				if ( wp_should_load_separate_core_block_assets() ) {
       
  2445 					add_filter(
       
  2446 						'render_block',
       
  2447 						function( $html, $block ) use ( $style_properties ) {
       
  2448 							wp_enqueue_style( $style_properties['style_handle'] );
       
  2449 							return $html;
       
  2450 						}
       
  2451 					);
       
  2452 				} else {
       
  2453 					wp_enqueue_style( $style_properties['style_handle'] );
       
  2454 				}
  2237 			}
  2455 			}
  2238 			if ( isset( $style_properties['inline_style'] ) ) {
  2456 			if ( isset( $style_properties['inline_style'] ) ) {
  2239 				wp_add_inline_style( 'wp-block-library', $style_properties['inline_style'] );
  2457 
       
  2458 				// Default to "wp-block-library".
       
  2459 				$handle = 'wp-block-library';
       
  2460 
       
  2461 				// If the site loads separate styles per-block, check if the block has a stylesheet registered.
       
  2462 				if ( wp_should_load_separate_core_block_assets() ) {
       
  2463 					$block_stylesheet_handle = generate_block_asset_handle( $block_name, 'style' );
       
  2464 					global $wp_styles;
       
  2465 					if ( isset( $wp_styles->registered[ $block_stylesheet_handle ] ) ) {
       
  2466 						$handle = $block_stylesheet_handle;
       
  2467 					}
       
  2468 				}
       
  2469 
       
  2470 				// Add inline styles to the calculated handle.
       
  2471 				wp_add_inline_style( $handle, $style_properties['inline_style'] );
  2240 			}
  2472 			}
  2241 		}
  2473 		}
  2242 	}
  2474 	}
  2243 }
  2475 }
  2244 
  2476 
  2251 	$block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
  2483 	$block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
  2252 
  2484 
  2253 	$register_script_lines = array( '( function() {' );
  2485 	$register_script_lines = array( '( function() {' );
  2254 	foreach ( $block_styles as $block_name => $styles ) {
  2486 	foreach ( $block_styles as $block_name => $styles ) {
  2255 		foreach ( $styles as $style_properties ) {
  2487 		foreach ( $styles as $style_properties ) {
       
  2488 			$block_style = array(
       
  2489 				'name'  => $style_properties['name'],
       
  2490 				'label' => $style_properties['label'],
       
  2491 			);
       
  2492 			if ( isset( $style_properties['is_default'] ) ) {
       
  2493 				$block_style['isDefault'] = $style_properties['is_default'];
       
  2494 			}
  2256 			$register_script_lines[] = sprintf(
  2495 			$register_script_lines[] = sprintf(
  2257 				'	wp.blocks.registerBlockStyle( \'%s\', %s );',
  2496 				'	wp.blocks.registerBlockStyle( \'%s\', %s );',
  2258 				$block_name,
  2497 				$block_name,
  2259 				wp_json_encode(
  2498 				wp_json_encode( $block_style )
  2260 					array(
       
  2261 						'name'  => $style_properties['name'],
       
  2262 						'label' => $style_properties['label'],
       
  2263 					)
       
  2264 				)
       
  2265 			);
  2499 			);
  2266 		}
  2500 		}
  2267 	}
  2501 	}
  2268 	$register_script_lines[] = '} )();';
  2502 	$register_script_lines[] = '} )();';
  2269 	$inline_script           = implode( "\n", $register_script_lines );
  2503 	$inline_script           = implode( "\n", $register_script_lines );
  2280  */
  2514  */
  2281 function wp_enqueue_editor_block_directory_assets() {
  2515 function wp_enqueue_editor_block_directory_assets() {
  2282 	wp_enqueue_script( 'wp-block-directory' );
  2516 	wp_enqueue_script( 'wp-block-directory' );
  2283 	wp_enqueue_style( 'wp-block-directory' );
  2517 	wp_enqueue_style( 'wp-block-directory' );
  2284 }
  2518 }
       
  2519 
       
  2520 /**
       
  2521  * Enqueues the assets required for the format library within the block editor.
       
  2522  *
       
  2523  * @since 5.8.0
       
  2524  */
       
  2525 function wp_enqueue_editor_format_library_assets() {
       
  2526 	wp_enqueue_script( 'wp-format-library' );
       
  2527 	wp_enqueue_style( 'wp-format-library' );
       
  2528 }
       
  2529 
       
  2530 /**
       
  2531  * Sanitizes an attributes array into an attributes string to be placed inside a `<script>` tag.
       
  2532  *
       
  2533  * Automatically injects type attribute if needed.
       
  2534  * Used by {@see wp_get_script_tag()} and {@see wp_get_inline_script_tag()}.
       
  2535  *
       
  2536  * @since 5.7.0
       
  2537  *
       
  2538  * @param array $attributes Key-value pairs representing `<script>` tag attributes.
       
  2539  * @return string String made of sanitized `<script>` tag attributes.
       
  2540  */
       
  2541 function wp_sanitize_script_attributes( $attributes ) {
       
  2542 	$html5_script_support = ! is_admin() && ! current_theme_supports( 'html5', 'script' );
       
  2543 	$attributes_string    = '';
       
  2544 
       
  2545 	// If HTML5 script tag is supported, only the attribute name is added
       
  2546 	// to $attributes_string for entries with a boolean value, and that are true.
       
  2547 	foreach ( $attributes as $attribute_name => $attribute_value ) {
       
  2548 		if ( is_bool( $attribute_value ) ) {
       
  2549 			if ( $attribute_value ) {
       
  2550 				$attributes_string .= $html5_script_support ? sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_name ) ) : ' ' . esc_attr( $attribute_name );
       
  2551 			}
       
  2552 		} else {
       
  2553 			$attributes_string .= sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) );
       
  2554 		}
       
  2555 	}
       
  2556 
       
  2557 	return $attributes_string;
       
  2558 }
       
  2559 
       
  2560 /**
       
  2561  * Formats `<script>` loader tags.
       
  2562  *
       
  2563  * It is possible to inject attributes in the `<script>` tag via the {@see 'wp_script_attributes'} filter.
       
  2564  * Automatically injects type attribute if needed.
       
  2565  *
       
  2566  * @since 5.7.0
       
  2567  *
       
  2568  * @param array $attributes Key-value pairs representing `<script>` tag attributes.
       
  2569  * @return string String containing `<script>` opening and closing tags.
       
  2570  */
       
  2571 function wp_get_script_tag( $attributes ) {
       
  2572 	if ( ! isset( $attributes['type'] ) && ! is_admin() && ! current_theme_supports( 'html5', 'script' ) ) {
       
  2573 		$attributes['type'] = 'text/javascript';
       
  2574 	}
       
  2575 	/**
       
  2576 	 * Filters attributes to be added to a script tag.
       
  2577 	 *
       
  2578 	 * @since 5.7.0
       
  2579 	 *
       
  2580 	 * @param array $attributes Key-value pairs representing `<script>` tag attributes.
       
  2581 	 *                          Only the attribute name is added to the `<script>` tag for
       
  2582 	 *                          entries with a boolean value, and that are true.
       
  2583 	 */
       
  2584 	$attributes = apply_filters( 'wp_script_attributes', $attributes );
       
  2585 
       
  2586 	return sprintf( "<script%s></script>\n", wp_sanitize_script_attributes( $attributes ) );
       
  2587 }
       
  2588 
       
  2589 /**
       
  2590  * Prints formatted `<script>` loader tag.
       
  2591  *
       
  2592  * It is possible to inject attributes in the `<script>` tag via the  {@see 'wp_script_attributes'}  filter.
       
  2593  * Automatically injects type attribute if needed.
       
  2594  *
       
  2595  * @since 5.7.0
       
  2596  *
       
  2597  * @param array $attributes Key-value pairs representing `<script>` tag attributes.
       
  2598  */
       
  2599 function wp_print_script_tag( $attributes ) {
       
  2600 	echo wp_get_script_tag( $attributes );
       
  2601 }
       
  2602 
       
  2603 /**
       
  2604  * Wraps inline JavaScript in `<script>` tag.
       
  2605  *
       
  2606  * It is possible to inject attributes in the `<script>` tag via the  {@see 'wp_script_attributes'}  filter.
       
  2607  * Automatically injects type attribute if needed.
       
  2608  *
       
  2609  * @since 5.7.0
       
  2610  *
       
  2611  * @param string $javascript Inline JavaScript code.
       
  2612  * @param array  $attributes  Optional. Key-value pairs representing `<script>` tag attributes.
       
  2613  * @return string String containing inline JavaScript code wrapped around `<script>` tag.
       
  2614  */
       
  2615 function wp_get_inline_script_tag( $javascript, $attributes = array() ) {
       
  2616 	if ( ! isset( $attributes['type'] ) && ! is_admin() && ! current_theme_supports( 'html5', 'script' ) ) {
       
  2617 		$attributes['type'] = 'text/javascript';
       
  2618 	}
       
  2619 	/**
       
  2620 	 * Filters attributes to be added to a script tag.
       
  2621 	 *
       
  2622 	 * @since 5.7.0
       
  2623 	 *
       
  2624 	 * @param array $attributes Key-value pairs representing `<script>` tag attributes.
       
  2625 	 *                          Only the attribute name is added to the `<script>` tag for
       
  2626 	 *                          entries with a boolean value, and that are true.
       
  2627 	 */
       
  2628 	$attributes = apply_filters( 'wp_inline_script_attributes', $attributes, $javascript );
       
  2629 
       
  2630 	$javascript = "\n" . trim( $javascript, "\n\r " ) . "\n";
       
  2631 
       
  2632 	return sprintf( "<script%s>%s</script>\n", wp_sanitize_script_attributes( $attributes ), $javascript );
       
  2633 }
       
  2634 
       
  2635 /**
       
  2636  * Prints inline JavaScript wrapped in `<script>` tag.
       
  2637  *
       
  2638  * It is possible to inject attributes in the `<script>` tag via the  {@see 'wp_script_attributes'}  filter.
       
  2639  * Automatically injects type attribute if needed.
       
  2640  *
       
  2641  * @since 5.7.0
       
  2642  *
       
  2643  * @param string $javascript Inline JavaScript code.
       
  2644  * @param array  $attributes Optional. Key-value pairs representing `<script>` tag attributes.
       
  2645  */
       
  2646 function wp_print_inline_script_tag( $javascript, $attributes = array() ) {
       
  2647 	echo wp_get_inline_script_tag( $javascript, $attributes );
       
  2648 }
       
  2649 
       
  2650 /**
       
  2651  * Allows small styles to be inlined.
       
  2652  *
       
  2653  * This improves performance and sustainability, and is opt-in. Stylesheets can opt in
       
  2654  * by adding `path` data using `wp_style_add_data`, and defining the file's absolute path:
       
  2655  *
       
  2656  *     wp_style_add_data( $style_handle, 'path', $file_path );
       
  2657  *
       
  2658  * @since 5.8.0
       
  2659  *
       
  2660  * @global WP_Styles $wp_styles
       
  2661  */
       
  2662 function wp_maybe_inline_styles() {
       
  2663 	global $wp_styles;
       
  2664 
       
  2665 	$total_inline_limit = 20000;
       
  2666 	/**
       
  2667 	 * The maximum size of inlined styles in bytes.
       
  2668 	 *
       
  2669 	 * @since 5.8.0
       
  2670 	 *
       
  2671 	 * @param int $total_inline_limit The file-size threshold, in bytes. Default 20000.
       
  2672 	 */
       
  2673 	$total_inline_limit = apply_filters( 'styles_inline_size_limit', $total_inline_limit );
       
  2674 
       
  2675 	$styles = array();
       
  2676 
       
  2677 	// Build an array of styles that have a path defined.
       
  2678 	foreach ( $wp_styles->queue as $handle ) {
       
  2679 		if ( wp_styles()->get_data( $handle, 'path' ) && file_exists( $wp_styles->registered[ $handle ]->extra['path'] ) ) {
       
  2680 			$styles[] = array(
       
  2681 				'handle' => $handle,
       
  2682 				'path'   => $wp_styles->registered[ $handle ]->extra['path'],
       
  2683 				'size'   => filesize( $wp_styles->registered[ $handle ]->extra['path'] ),
       
  2684 			);
       
  2685 		}
       
  2686 	}
       
  2687 
       
  2688 	if ( ! empty( $styles ) ) {
       
  2689 		// Reorder styles array based on size.
       
  2690 		usort(
       
  2691 			$styles,
       
  2692 			function( $a, $b ) {
       
  2693 				return ( $a['size'] <= $b['size'] ) ? -1 : 1;
       
  2694 			}
       
  2695 		);
       
  2696 
       
  2697 		/*
       
  2698 		 * The total inlined size.
       
  2699 		 *
       
  2700 		 * On each iteration of the loop, if a style gets added inline the value of this var increases
       
  2701 		 * to reflect the total size of inlined styles.
       
  2702 		 */
       
  2703 		$total_inline_size = 0;
       
  2704 
       
  2705 		// Loop styles.
       
  2706 		foreach ( $styles as $style ) {
       
  2707 
       
  2708 			// Size check. Since styles are ordered by size, we can break the loop.
       
  2709 			if ( $total_inline_size + $style['size'] > $total_inline_limit ) {
       
  2710 				break;
       
  2711 			}
       
  2712 
       
  2713 			// Get the styles if we don't already have them.
       
  2714 			$style['css'] = file_get_contents( $style['path'] );
       
  2715 
       
  2716 			// Set `src` to `false` and add styles inline.
       
  2717 			$wp_styles->registered[ $style['handle'] ]->src = false;
       
  2718 			if ( empty( $wp_styles->registered[ $style['handle'] ]->extra['after'] ) ) {
       
  2719 				$wp_styles->registered[ $style['handle'] ]->extra['after'] = array();
       
  2720 			}
       
  2721 			array_unshift( $wp_styles->registered[ $style['handle'] ]->extra['after'], $style['css'] );
       
  2722 
       
  2723 			// Add the styles size to the $total_inline_size var.
       
  2724 			$total_inline_size += (int) $style['size'];
       
  2725 		}
       
  2726 	}
       
  2727 }
       
  2728 
       
  2729 /**
       
  2730  * Inject the block editor assets that need to be loaded into the editor's iframe as an inline script.
       
  2731  *
       
  2732  * @since 5.8.0
       
  2733  */
       
  2734 function wp_add_iframed_editor_assets_html() {
       
  2735 	if ( ! wp_should_load_block_editor_scripts_and_styles() ) {
       
  2736 		return;
       
  2737 	}
       
  2738 
       
  2739 	$script_handles = array();
       
  2740 	$style_handles  = array(
       
  2741 		'wp-block-editor',
       
  2742 		'wp-block-library',
       
  2743 		'wp-block-library-theme',
       
  2744 		'wp-edit-blocks',
       
  2745 	);
       
  2746 
       
  2747 	$block_registry = WP_Block_Type_Registry::get_instance();
       
  2748 
       
  2749 	foreach ( $block_registry->get_all_registered() as $block_type ) {
       
  2750 		if ( ! empty( $block_type->style ) ) {
       
  2751 			$style_handles[] = $block_type->style;
       
  2752 		}
       
  2753 
       
  2754 		if ( ! empty( $block_type->editor_style ) ) {
       
  2755 			$style_handles[] = $block_type->editor_style;
       
  2756 		}
       
  2757 
       
  2758 		if ( ! empty( $block_type->script ) ) {
       
  2759 			$script_handles[] = $block_type->script;
       
  2760 		}
       
  2761 	}
       
  2762 
       
  2763 	$style_handles = array_unique( $style_handles );
       
  2764 	$done          = wp_styles()->done;
       
  2765 
       
  2766 	ob_start();
       
  2767 
       
  2768 	wp_styles()->done = array();
       
  2769 	wp_styles()->do_items( $style_handles );
       
  2770 	wp_styles()->done = $done;
       
  2771 
       
  2772 	$styles = ob_get_clean();
       
  2773 
       
  2774 	$script_handles = array_unique( $script_handles );
       
  2775 	$done           = wp_scripts()->done;
       
  2776 
       
  2777 	ob_start();
       
  2778 
       
  2779 	wp_scripts()->done = array();
       
  2780 	wp_scripts()->do_items( $script_handles );
       
  2781 	wp_scripts()->done = $done;
       
  2782 
       
  2783 	$scripts = ob_get_clean();
       
  2784 
       
  2785 	$editor_assets = wp_json_encode(
       
  2786 		array(
       
  2787 			'styles'  => $styles,
       
  2788 			'scripts' => $scripts,
       
  2789 		)
       
  2790 	);
       
  2791 
       
  2792 	echo "<script>window.__editorAssets = $editor_assets</script>";
       
  2793 }