diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-includes/script-loader.php
--- a/wp/wp-includes/script-loader.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/script-loader.php Tue Dec 15 13:49:49 2020 +0100
@@ -17,31 +17,32 @@
*/
/** WordPress Dependency Class */
-require( ABSPATH . WPINC . '/class-wp-dependency.php' );
+require ABSPATH . WPINC . '/class-wp-dependency.php';
/** WordPress Dependencies Class */
-require( ABSPATH . WPINC . '/class.wp-dependencies.php' );
+require ABSPATH . WPINC . '/class.wp-dependencies.php';
/** WordPress Scripts Class */
-require( ABSPATH . WPINC . '/class.wp-scripts.php' );
+require ABSPATH . WPINC . '/class.wp-scripts.php';
/** WordPress Scripts Functions */
-require( ABSPATH . WPINC . '/functions.wp-scripts.php' );
+require ABSPATH . WPINC . '/functions.wp-scripts.php';
/** WordPress Styles Class */
-require( ABSPATH . WPINC . '/class.wp-styles.php' );
+require ABSPATH . WPINC . '/class.wp-styles.php';
/** WordPress Styles Functions */
-require( ABSPATH . WPINC . '/functions.wp-styles.php' );
+require ABSPATH . WPINC . '/functions.wp-styles.php';
/**
* Registers TinyMCE scripts.
*
* @since 5.0.0
*
- * @param WP_Scripts $scripts WP_Scripts object.
+ * @param WP_Scripts $scripts WP_Scripts object.
+ * @param bool $force_uncompressed Whether to forcibly prevent gzip compression. Default false.
*/
-function wp_register_tinymce_scripts( &$scripts, $force_uncompressed = false ) {
+function wp_register_tinymce_scripts( $scripts, $force_uncompressed = false ) {
global $tinymce_version, $concatenate_scripts, $compress_scripts;
$suffix = wp_scripts_get_suffix();
$dev_suffix = wp_scripts_get_suffix( 'dev' );
@@ -49,10 +50,10 @@
script_concat_settings();
$compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] )
- && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed;
+ && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed;
- // Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production) or
- // tinymce.min.js (when SCRIPT_DEBUG is true).
+ // Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production)
+ // or tinymce.min.js (when SCRIPT_DEBUG is true).
if ( $compressed ) {
$scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version );
} else {
@@ -73,7 +74,7 @@
*
* @param WP_Scripts $scripts WP_Scripts object.
*/
-function wp_default_packages_vendor( &$scripts ) {
+function wp_default_packages_vendor( $scripts ) {
global $wp_locale;
$suffix = wp_scripts_get_suffix();
@@ -86,20 +87,24 @@
'wp-polyfill-fetch',
'wp-polyfill-formdata',
'wp-polyfill-node-contains',
+ 'wp-polyfill-url',
+ 'wp-polyfill-dom-rect',
'wp-polyfill-element-closest',
'wp-polyfill',
);
$vendor_scripts_versions = array(
- 'react' => '16.8.4',
- 'react-dom' => '16.8.4',
- 'moment' => '2.22.2',
- 'lodash' => '4.17.11',
+ 'react' => '16.9.0',
+ 'react-dom' => '16.9.0',
+ 'moment' => '2.26.0',
+ 'lodash' => '4.17.15',
'wp-polyfill-fetch' => '3.0.0',
'wp-polyfill-formdata' => '3.0.12',
- 'wp-polyfill-node-contains' => '3.26.0-0',
+ 'wp-polyfill-node-contains' => '3.42.0',
+ 'wp-polyfill-url' => '3.6.4',
+ 'wp-polyfill-dom-rect' => '3.42.0',
'wp-polyfill-element-closest' => '2.0.2',
- 'wp-polyfill' => '7.0.0',
+ 'wp-polyfill' => '7.4.4',
);
foreach ( $vendor_scripts as $handle => $dependencies ) {
@@ -122,6 +127,8 @@
array(
'\'fetch\' in window' => 'wp-polyfill-fetch',
'document.contains' => 'wp-polyfill-node-contains',
+ 'window.DOMRect' => 'wp-polyfill-dom-rect',
+ 'window.URL && window.URL.prototype && window.URLSearchParams' => 'wp-polyfill-url',
'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata',
'Element.prototype.matches && Element.prototype.closest' => 'wp-polyfill-element-closest',
)
@@ -133,7 +140,7 @@
did_action( 'init' ) && $scripts->add_inline_script(
'moment',
sprintf(
- "moment.locale( '%s', %s );",
+ "moment.updateLocale( '%s', %s );",
get_user_locale(),
wp_json_encode(
array(
@@ -170,7 +177,7 @@
* @param array $tests Features to detect.
* @return string Conditional polyfill inline script.
*/
-function wp_get_script_polyfill( &$scripts, $tests ) {
+function wp_get_script_polyfill( $scripts, $tests ) {
$polyfill = '';
foreach ( $tests as $test => $handle ) {
if ( ! array_key_exists( $handle, $scripts->registered ) ) {
@@ -198,9 +205,11 @@
$polyfill .= (
// Test presence of feature...
'( ' . $test . ' ) || ' .
- // ...appending polyfill on any failures. Cautious viewers may balk
- // at the `document.write`. Its caveat of synchronous mid-stream
- // blocking write is exactly the behavior we need though.
+ /*
+ * ...appending polyfill on any failures. Cautious viewers may balk
+ * at the `document.write`. Its caveat of synchronous mid-stream
+ * blocking write is exactly the behavior we need though.
+ */
'document.write( \'\n";
}
- $concat = str_split( $concat, 128 );
- $concat = 'load%5B%5D=' . implode( '&load%5B%5D=', $concat );
+ $concat = str_split( $concat, 128 );
+ $concatenated = '';
- $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&" . $concat . '&ver=' . $wp_scripts->default_version;
- echo "\n";
+ foreach ( $concat as $key => $chunk ) {
+ $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}";
+ }
+
+ $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version;
+ echo "\n";
}
if ( ! empty( $wp_scripts->print_html ) ) {
@@ -2491,7 +1953,7 @@
global $wp_scripts;
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
- return array(); // no need to run if nothing is queued
+ return array(); // No need to run if nothing is queued.
}
return print_head_scripts();
}
@@ -2521,7 +1983,7 @@
}
/**
- * Wrapper for do_action('wp_enqueue_scripts')
+ * Wrapper for do_action( 'wp_enqueue_scripts' ).
*
* Allows plugins to queue scripts for the front end using wp_enqueue_script().
* Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.
@@ -2624,18 +2086,25 @@
$zip = 'gzip';
}
- if ( $concat = trim( $wp_styles->concat, ', ' ) ) {
+ $concat = trim( $wp_styles->concat, ', ' );
+ $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
+
+ if ( $concat ) {
$dir = $wp_styles->text_direction;
$ver = $wp_styles->default_version;
- $concat = str_split( $concat, 128 );
- $concat = 'load%5B%5D=' . implode( '&load%5B%5D=', $concat );
+ $concat = str_split( $concat, 128 );
+ $concatenated = '';
- $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&" . $concat . '&ver=' . $ver;
- echo "\n";
+ foreach ( $concat as $key => $chunk ) {
+ $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}";
+ }
+
+ $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}" . $concatenated . '&ver=' . $ver;
+ echo "\n";
if ( ! empty( $wp_styles->print_code ) ) {
- echo "\n";
}
@@ -2658,7 +2127,7 @@
function script_concat_settings() {
global $concatenate_scripts, $compress_scripts, $compress_css;
- $compressed_output = ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' == ini_get( 'output_handler' ) );
+ $compressed_output = ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) );
if ( ! isset( $concatenate_scripts ) ) {
$concatenate_scripts = defined( 'CONCATENATE_SCRIPTS' ) ? CONCATENATE_SCRIPTS : true;
@@ -2688,7 +2157,7 @@
*
* @since 5.0.0
*
- * @global WP_Screen $current_screen
+ * @global WP_Screen $current_screen WordPress current screen object.
*/
function wp_common_block_scripts_and_styles() {
global $current_screen;
@@ -2713,7 +2182,7 @@
*
* @since 5.0.0
*/
- do_action( 'enqueue_block_assets' );
+ do_action( 'enqueue_block_assets' );
}
/**
@@ -2722,7 +2191,7 @@
*
* @since 5.0.0
*
- * @global WP_Screen $current_screen
+ * @global WP_Screen $current_screen WordPress current screen object.
*/
function wp_enqueue_registered_block_scripts_and_styles() {
global $current_screen;
@@ -2752,3 +2221,64 @@
}
}
}
+
+/**
+ * Function responsible for enqueuing the styles required for block styles functionality on the editor and on the frontend.
+ *
+ * @since 5.3.0
+ */
+function enqueue_block_styles_assets() {
+ $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
+
+ foreach ( $block_styles as $styles ) {
+ foreach ( $styles as $style_properties ) {
+ if ( isset( $style_properties['style_handle'] ) ) {
+ wp_enqueue_style( $style_properties['style_handle'] );
+ }
+ if ( isset( $style_properties['inline_style'] ) ) {
+ wp_add_inline_style( 'wp-block-library', $style_properties['inline_style'] );
+ }
+ }
+ }
+}
+
+/**
+ * Function responsible for enqueuing the assets required for block styles functionality on the editor.
+ *
+ * @since 5.3.0
+ */
+function enqueue_editor_block_styles_assets() {
+ $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
+
+ $register_script_lines = array( '( function() {' );
+ foreach ( $block_styles as $block_name => $styles ) {
+ foreach ( $styles as $style_properties ) {
+ $register_script_lines[] = sprintf(
+ ' wp.blocks.registerBlockStyle( \'%s\', %s );',
+ $block_name,
+ wp_json_encode(
+ array(
+ 'name' => $style_properties['name'],
+ 'label' => $style_properties['label'],
+ )
+ )
+ );
+ }
+ }
+ $register_script_lines[] = '} )();';
+ $inline_script = implode( "\n", $register_script_lines );
+
+ wp_register_script( 'wp-block-styles', false, array( 'wp-blocks' ), true, true );
+ wp_add_inline_script( 'wp-block-styles', $inline_script );
+ wp_enqueue_script( 'wp-block-styles' );
+}
+
+/**
+ * Enqueues the assets required for the block directory within the block editor.
+ *
+ * @since 5.5.0
+ */
+function wp_enqueue_editor_block_directory_assets() {
+ wp_enqueue_script( 'wp-block-directory' );
+ wp_enqueue_style( 'wp-block-directory' );
+}