PluginProbe
Gutenberg / 14.5.2
Gutenberg v14.5.2
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / compat / wordpress-6.2 / script-loader.php

script-loader.php in Gutenberg 14.5.2, at lib/compat/wordpress-6.2/script-loader.php

66 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Updates the script-loader.php file
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * Registers vendor JavaScript files to be used as dependencies of the editor
10 * and plugins.
11 *
12 * This function is called from a script during the plugin build process, so it
13 * should not call any WordPress PHP functions.
14 *
15 * @since 13.0
16 *
17 * @param WP_Scripts $scripts WP_Scripts instance.
18 */
19 function gutenberg_register_vendor_scripts_62( $scripts ) {
20 $extension = SCRIPT_DEBUG ? '.js' : '.min.js';
21
22 $script = $scripts->query( 'wp-inert-polyfill', 'registered' );
23 if ( ! $script ) {
24 $scripts->add( 'wp-inert-polyfill', gutenberg_url( 'build/vendors/inert-polyfill' . $extension ), array() );
25 }
26
27 $script = $scripts->query( 'wp-polyfill', 'registered' );
28 $script->deps = array_merge( $script->deps, array( 'wp-inert-polyfill' ) );
29 }
30 add_action( 'wp_default_scripts', 'gutenberg_register_vendor_scripts_62' );
31
32 /**
33 * This function takes care of adding inline styles
34 * in the proper place, depending on the theme in use.
35 *
36 * This method was added to core in 5.9.1, but with a single param ($style). The second param ($priority) was
37 * added post 6.0, so the 6.1 release needs to have wp_enqueue_block_support_styles updated to include this param.
38 *
39 * For block themes, it's loaded in the head.
40 * For classic ones, it's loaded in the body
41 * because the wp_head action happens before
42 * the render_block.
43 *
44 * @link https://core.trac.wordpress.org/ticket/53494.
45 *
46 * @deprecated 6.2 Block supports styles are now stored for enqueuing via the style engine API. See: packages/style-engine/README.md.
47 *
48 * @param string $style String containing the CSS styles to be added.
49 * @param int $priority To set the priority for the add_action.
50 */
51 function gutenberg_enqueue_block_support_styles( $style, $priority = 10 ) {
52 _deprecated_function( __FUNCTION__, '6.2' );
53
54 $action_hook_name = 'wp_footer';
55 if ( wp_is_block_theme() ) {
56 $action_hook_name = 'wp_head';
57 }
58 add_action(
59 $action_hook_name,
60 static function () use ( $style ) {
61 echo "<style>$style</style>\n";
62 },
63 $priority
64 );
65 }
66