PluginProbe ʕ •ᴥ•ʔ
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets / 4.0.7
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets v4.0.7
4.2.5 4.2.4 trunk 3.7.10 3.7.11 3.7.12 3.7.13 3.7.14 3.7.2 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8 3.8.1 3.8.10 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.8.9.1 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.5.1 4.0.6 4.0.6.1 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.2.0 4.2.1 4.2.2 4.2.3
widget-options / includes / widgets / gutenberg / lib / script-loader.php
widget-options / includes / widgets / gutenberg / lib Last commit date
block-supports 1 year ago compat 1 year ago experimental 1 year ago README.md 1 year ago block-editor-settings.php 1 year ago blocks.php 1 year ago class-wp-duotone-gutenberg.php 1 year ago class-wp-theme-json-data-gutenberg.php 1 year ago class-wp-theme-json-gutenberg.php 1 year ago class-wp-theme-json-resolver-gutenberg.php 1 year ago client-assets.php 1 year ago demo.php 1 year ago experiments-page.php 1 year ago global-styles-and-settings.php 1 year ago init.php 1 year ago load.php 1 year ago script-loader.php 1 year ago theme-i18n.json 1 year ago theme.json 1 year ago upgrade.php 1 year ago
script-loader.php
95 lines
1 <?php
2 /**
3 * Overrides the script-loader.php file.
4 *
5 * @package gutenberg
6 */
7
8 // Remove core actions to override.
9 remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
10 remove_action( 'wp_footer', 'wp_enqueue_global_styles', 1 );
11
12 /**
13 * Enqueues the global styles defined via theme.json.
14 *
15 * Copy of the core `wp_enqueue_global_styles`. Uses helper methods bundled with the plugin.
16 *
17 * @return void
18 */
19 function gutenberg_enqueue_global_styles() {
20 $separate_assets = wp_should_load_separate_core_block_assets();
21 $is_block_theme = wp_is_block_theme();
22 $is_classic_theme = ! $is_block_theme;
23
24 /*
25 * Global styles should be printed in the head when loading all styles combined.
26 * The footer should only be used to print global styles for classic themes with separate core assets enabled.
27 *
28 * See https://core.trac.wordpress.org/ticket/53494.
29 */
30 if (
31 ( $is_block_theme && doing_action( 'wp_footer' ) ) ||
32 ( $is_classic_theme && doing_action( 'wp_footer' ) && ! $separate_assets ) ||
33 ( $is_classic_theme && doing_action( 'wp_enqueue_scripts' ) && $separate_assets )
34 ) {
35 return;
36 }
37
38 /*
39 * If loading the CSS for each block separately, then load the theme.json CSS conditionally.
40 * This removes the CSS from the global-styles stylesheet and adds it to the inline CSS for each block.
41 * This filter must be registered before calling wp_get_global_stylesheet();
42 */
43 add_filter( 'wp_theme_json_get_style_nodes', 'wp_filter_out_block_nodes' );
44
45 $stylesheet = gutenberg_get_global_stylesheet();
46 if ( empty( $stylesheet ) ) {
47 return;
48 }
49
50 wp_register_style( 'global-styles', false );
51 wp_add_inline_style( 'global-styles', $stylesheet );
52 wp_enqueue_style( 'global-styles' );
53
54 // Add each block as an inline css.
55 gutenberg_add_global_styles_for_blocks();
56 }
57 add_action( 'wp_enqueue_scripts', 'gutenberg_enqueue_global_styles' );
58 add_action( 'wp_footer', 'gutenberg_enqueue_global_styles', 1 );
59
60 /**
61 * Enqueues the global styles custom css.
62 *
63 * @since 6.2.0
64 */
65 function gutenberg_enqueue_global_styles_custom_css() {
66 if ( ! wp_is_block_theme() ) {
67 return;
68 }
69
70 // Don't enqueue Customizer's custom CSS separately.
71 remove_action( 'wp_head', 'wp_custom_css_cb', 101 );
72
73 $custom_css = wp_get_custom_css();
74 $custom_css .= gutenberg_get_global_styles_custom_css();
75
76 if ( ! empty( $custom_css ) ) {
77 wp_add_inline_style( 'global-styles', $custom_css );
78 }
79 }
80 remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles_custom_css' );
81 add_action( 'wp_enqueue_scripts', 'gutenberg_enqueue_global_styles_custom_css' );
82
83 /**
84 * Function that enqueues the CSS Custom Properties coming from theme.json.
85 *
86 * @since 5.9.0
87 */
88 function gutenberg_enqueue_global_styles_css_custom_properties() {
89 wp_register_style( 'global-styles-css-custom-properties', false );
90 wp_add_inline_style( 'global-styles-css-custom-properties', gutenberg_get_global_stylesheet( array( 'variables' ) ) );
91 wp_enqueue_style( 'global-styles-css-custom-properties' );
92 }
93 remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_global_styles_css_custom_properties' );
94 add_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_global_styles_css_custom_properties' );
95