PluginProbe
GutSlider – All in One Slider and Carousel Blocks for Gutenberg / 2.4.0
GutSlider – All in One Slider and Carousel Blocks for Gutenberg v2.4.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 2.6.1 All 56 releases
slider-blocks / includes / classes / class-enqueue-assets.php

class-enqueue-assets.php in GutSlider – All in One Slider and Carousel Blocks for Gutenberg 2.4.0, at includes/classes/class-enqueue-assets.php

110 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Enqueue Assets
4 * @package GutSliderBlocks
5 */
6
7 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
8
9 if( ! class_exists( 'GutSlider_Assets' ) ) {
10
11 class GutSlider_Assets {
12
13 /**
14 * Constructor
15 * return void
16 */
17 public function __construct() {
18 add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_editor_assets' ] );
19 add_action( 'enqueue_block_assets', [ $this, 'enqueue_assets' ] );
20 }
21
22 /**
23 * Enqueue Block Assets [ Editor Only ]
24 * return void
25 */
26 public function enqueue_editor_assets(){
27 if( file_exists( trailingslashit( GUTSLIDER_DIR_PATH ) . './build/global/global.asset.php' ) ){
28 $dependency_file = include_once trailingslashit( GUTSLIDER_DIR_PATH ) . './build/global/global.asset.php';
29 }
30
31 if( is_array( $dependency_file ) && ! empty( $dependency_file ) ) {
32 wp_enqueue_script(
33 'gutslider-blocks-global-script',
34 trailingslashit( GUTSLIDER_URL ) . './build/global/global.js',
35 isset( $dependency_file['dependencies'] ) ? $dependency_file['dependencies'] : [],
36 isset( $dependency_file['version'] ) ? $dependency_file['version'] : GUTSLIDER_VERSION,
37 true
38 );
39 }
40
41 wp_enqueue_style(
42 'gutslider-blocks-global-style',
43 trailingslashit( GUTSLIDER_URL ) . './build/global/global.css',
44 [],
45 GUTSLIDER_VERSION
46 );
47 }
48
49 /**
50 * Enqueue Block Assets [ Editor + Frontend ]
51 * return void
52 */
53 public function enqueue_assets() {
54
55 if( is_admin() ) {
56 // swiper style
57 wp_enqueue_style(
58 'swiper-style',
59 trailingslashit( GUTSLIDER_URL ) . 'assets/css/swiper-bundle.min.css',
60 [],
61 GUTSLIDER_VERSION
62 );
63
64 // swiper script
65 wp_enqueue_script(
66 'swiper-script',
67 trailingslashit( GUTSLIDER_URL ) . 'assets/js/swiper-bundle.min.js',
68 [],
69 GUTSLIDER_VERSION,
70 true
71 );
72 }
73
74 // enqueue frontend scripts
75 $swiper_scripts = get_option( 'swiper_scripts', true );
76 if( ! is_admin() && $swiper_scripts && ( has_block( 'gutsliders/content-slider' ) || has_block( 'gutsliders/any-content' ) || has_block( 'gutsliders/testimonial-slider' ) || has_block( 'gutsliders/post-slider' ) || has_block( 'gutsliders/photo-carousel' ) )) {
77 // swiper style
78 wp_enqueue_style(
79 'swiper-style',
80 trailingslashit( GUTSLIDER_URL ) . 'assets/css/swiper-bundle.min.css',
81 [],
82 GUTSLIDER_VERSION
83 );
84
85 // swiper script
86 wp_enqueue_script(
87 'swiper-script',
88 trailingslashit( GUTSLIDER_URL ) . 'assets/js/swiper-bundle.min.js',
89 [],
90 GUTSLIDER_VERSION,
91 true
92 );
93 }
94 if( ! is_admin() && ( has_block( 'gutsliders/photo-carousel' ) )) {
95 // lightbox
96 wp_enqueue_script(
97 'gutslider-fslightbox',
98 trailingslashit( GUTSLIDER_URL ) . 'assets/js/fslightbox.js',
99 [],
100 GUTSLIDER_VERSION,
101 true
102 );
103 }
104 }
105
106 }
107
108 }
109
110 new GutSlider_Assets(); // Initialize the class