PluginProbe
GutSlider – All in One Slider and Carousel Blocks for Gutenberg / 2.5.1
GutSlider – All in One Slider and Carousel Blocks for Gutenberg v2.5.1
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.5.1, at includes/classes/class-enqueue-assets.php

125 lines 4.7 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' ], 1 );
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 // modules
49 if( file_exists( trailingslashit( GUTSLIDER_DIR_PATH ) . './build/modules/modules.asset.php' ) ) {
50 $modules_dependency_file = include_once trailingslashit( GUTSLIDER_DIR_PATH ) . './build/modules/modules.asset.php';
51 }
52
53 if( is_array( $modules_dependency_file ) && ! empty( $modules_dependency_file ) ) {
54 wp_enqueue_script(
55 'gutslider-blocks-modules-script',
56 trailingslashit( GUTSLIDER_URL ) . './build/modules/modules.js',
57 isset( $modules_dependency_file['dependencies'] ) ? $modules_dependency_file['dependencies'] : [],
58 isset( $modules_dependency_file['version'] ) ? $modules_dependency_file['version'] : GUTSLIDER_VERSION,
59 false
60 );
61 }
62 }
63
64 /**
65 * Enqueue Block Assets [ Editor + Frontend ]
66 * return void
67 */
68 public function enqueue_assets() {
69
70 if( is_admin() ) {
71 // swiper style
72 wp_enqueue_style(
73 'swiper-style',
74 trailingslashit( GUTSLIDER_URL ) . 'assets/css/swiper-bundle.min.css',
75 [],
76 GUTSLIDER_VERSION
77 );
78
79 // swiper script
80 wp_enqueue_script(
81 'swiper-script',
82 trailingslashit( GUTSLIDER_URL ) . 'assets/js/swiper-bundle.min.js',
83 [],
84 GUTSLIDER_VERSION,
85 true
86 );
87 }
88
89 // enqueue frontend scripts
90 $swiper_scripts = get_option( 'swiper_scripts', true );
91 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' ) || has_block( 'gutsliders/logo-carousel' ) )) {
92 // swiper style
93 wp_enqueue_style(
94 'swiper-style',
95 trailingslashit( GUTSLIDER_URL ) . 'assets/css/swiper-bundle.min.css',
96 [],
97 GUTSLIDER_VERSION
98 );
99
100 // swiper script
101 wp_enqueue_script(
102 'swiper-script',
103 trailingslashit( GUTSLIDER_URL ) . 'assets/js/swiper-bundle.min.js',
104 [],
105 GUTSLIDER_VERSION,
106 true
107 );
108 }
109 if( ! is_admin() && ( has_block( 'gutsliders/photo-carousel' ) )) {
110 // lightbox
111 wp_enqueue_script(
112 'gutslider-fslightbox',
113 trailingslashit( GUTSLIDER_URL ) . 'assets/js/fslightbox.js',
114 [],
115 GUTSLIDER_VERSION,
116 true
117 );
118 }
119 }
120
121 }
122
123 }
124
125 new GutSlider_Assets(); // Initialize the class