PluginProbe
GutSlider – All in One Slider and Carousel Blocks for Gutenberg / 3.2.0
GutSlider – All in One Slider and Carousel Blocks for Gutenberg v3.2.0
3.2.0 3.1.0 3.0.0 2.13.2 2.13.1 2.13.0 trunk 1.0.0 2.1.0 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.12.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.1 2.5.3 2.5.4 2.5.5 All 57 releases
← All changes | includes/Assets/EnqueueAssets.php +40 -2 2.11.1 → 3.2.0 View file →
@@ -42,9 +42,9 @@
42 42 * @since 3.0.0
43 43 */
44 44 public function __construct() {
45 45 add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_assets' ), 2 );
46 - add_action( 'enqueue_block_assets', array( $this, 'enqueue_assets' ) );
46 + add_action( 'enqueue_block_assets', array( $this, 'enqueue_both_assets' ) );
47 47 }
48 48
49 49 /**
50 50 * Enqueue editor-specific assets.
@@ -59,11 +59,41 @@
59 59 public function enqueue_editor_assets(): void {
60 60 $this->enqueue_asset( 'global', true, true );
61 61 $this->enqueue_asset( 'modules', false );
62 62 $this->localize_preview_images();
63 + $this->localize_editor_settings();
63 64 }
64 65
65 66 /**
67 + * Expose editor-facing settings to the global editor bundle.
68 + *
69 + * Printed as an inline script rather than via wp_localize_script so the
70 + * values keep their real types — wp_localize_script casts top level
71 + * scalars to strings, which would turn `false` into a truthy "".
72 + *
73 + * @since 3.0.0
74 + *
75 + * @return void
76 + */
77 + private function localize_editor_settings(): void {
78 + $settings = get_option( 'gutslider_settings', array() );
79 +
80 + $pattern_library = ! is_array( $settings ) || ! array_key_exists( 'pattern_library', $settings )
81 + ? true
82 + : (bool) $settings['pattern_library'];
83 +
84 + wp_add_inline_script(
85 + 'gutslider-blocks-global-script',
86 + 'window.gutsliderEditor = ' . wp_json_encode(
87 + array(
88 + 'patternLibrary' => $pattern_library,
89 + )
90 + ) . ';',
91 + 'before'
92 + );
93 + }
94 +
95 + /**
66 96 * Enqueue front-end and shared assets.
67 97 *
68 98 * Registers Swiper library assets and the lightbox script
69 99 * for use by individual blocks on the front-end.
@@ -71,9 +101,9 @@
71 101 * @since 3.0.0
72 102 *
73 103 * @return void
74 104 */
75 - public function enqueue_assets(): void {
105 + public function enqueue_both_assets(): void {
76 106 wp_register_style(
77 107 'gutslider-swiper-style',
78 108 GUTSLIDER_URL . 'assets/css/swiper-bundle.min.css',
79 109 array(),
@@ -169,8 +199,16 @@
169 199 $preview_urls[ $key ] = esc_url( GUTSLIDER_URL . "assets/images/{$image}" );
170 200 }
171 201
172 202 $preview_urls['is_pro'] = defined( 'GUTSLIDER_PRO_VERSION' );
203 +
204 + wp_localize_script(
205 + 'gutslider-blocks-modules-script',
206 + 'gutsliderData',
207 + array(
208 + 'hasPro' => defined( 'GUTSLIDER_PRO_VERSION' ),
209 + )
210 + );
173 211
174 212 wp_localize_script(
175 213 'gutslider-blocks-modules-script',
176 214 'gutslider_preview',