Assets.php
146 lines
| 1 | <?php |
| 2 | namespace SPEL\includes\Frontend; |
| 3 | |
| 4 | // Exit if accessed directly |
| 5 | if (!defined('ABSPATH')) { |
| 6 | exit; |
| 7 | } |
| 8 | |
| 9 | /** |
| 10 | * Assets Class |
| 11 | */ |
| 12 | class Assets |
| 13 | { |
| 14 | public function __construct() |
| 15 | { |
| 16 | // Register Widget Style's |
| 17 | add_action('elementor/frontend/after_enqueue_styles', [$this, 'register_widget_styles']); |
| 18 | |
| 19 | // Register Widget Script's |
| 20 | add_action('elementor/editor/after_enqueue_scripts', [$this, 'register_widget_scripts']); |
| 21 | add_action('elementor/frontend/after_register_scripts', [$this, 'register_widget_scripts']); |
| 22 | |
| 23 | // Register Elementor Preview Editor Script's |
| 24 | add_action('elementor/editor/after_enqueue_scripts', [$this, 'register_editor_scripts']); |
| 25 | add_action('elementor/frontend/after_enqueue_scripts', [$this, 'register_editor_scripts']); |
| 26 | |
| 27 | |
| 28 | // Register Elementor Preview Editor Style's |
| 29 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'elementor_editor_scripts' ] ); |
| 30 | } |
| 31 | |
| 32 | |
| 33 | /** |
| 34 | * Register Widget Scripts |
| 35 | * |
| 36 | * Register custom style required to run Spider Elements. |
| 37 | * |
| 38 | * @access public |
| 39 | */ |
| 40 | function register_widget_styles(): void |
| 41 | { |
| 42 | $elements_opt = get_option( 'spel_features_settings' ); |
| 43 | |
| 44 | if ( isset($elements_opt['spel_smooth_animation']) && $elements_opt[ 'spel_smooth_animation' ] == 'on' ) { |
| 45 | |
| 46 | // Define all the handlers in one string, separated by commas |
| 47 | $handlers = [ |
| 48 | 'e-animations', |
| 49 | 'e-animation-fadeIn', |
| 50 | 'e-animation-fadeInUp', |
| 51 | 'e-animation-fadeInRight', |
| 52 | 'e-animation-fadeInDown', |
| 53 | 'e-animation-fadeInLeft', |
| 54 | 'e-animation-zoomIn', |
| 55 | ]; |
| 56 | |
| 57 | // Deregister all styles for the handlers |
| 58 | foreach ($handlers as $handler) { |
| 59 | wp_deregister_style($handler); |
| 60 | } |
| 61 | |
| 62 | // Enqueue all handlers pointing to the same file |
| 63 | foreach ($handlers as $handler) { |
| 64 | wp_enqueue_style($handler, SPEL_VEND . '/animation/animate.css', [], SPEL_VERSION ); |
| 65 | } |
| 66 | |
| 67 | } |
| 68 | |
| 69 | wp_register_style('ionicons', SPEL_VEND . '/ionicons/ionicons.min.css', [], '2.0.1'); |
| 70 | wp_register_style('slick-theme', SPEL_VEND . '/slick/slick-theme.css', [], SPEL_VERSION); |
| 71 | wp_register_style('slick', SPEL_VEND . '/slick/slick.css', [], SPEL_VERSION); |
| 72 | wp_register_style('swiper', SPEL_VEND . '/swiper/swiper-bundle.min.css', [], '7.2.0'); |
| 73 | wp_register_style('video-js', SPEL_VEND . '/video/videojs.min.css', [], SPEL_VERSION); |
| 74 | wp_register_style('video-js-theaterMode', SPEL_VEND . '/video/videojs.theaterMode.css', [], SPEL_VERSION); |
| 75 | wp_register_style('elegant-icon', SPEL_VEND . '/elegant-icon/style.css', [], SPEL_VERSION); |
| 76 | wp_register_style('fancybox', SPEL_VEND . '/fancybox/css/jquery.fancybox.min.css', [], SPEL_VERSION); |
| 77 | wp_register_style('spel-main', SPEL_CSS . '/main.css', [], SPEL_VERSION); |
| 78 | |
| 79 | if ( is_rtl() ) { |
| 80 | wp_enqueue_style( 'spel-rtl', SPEL_CSS . '/rtl.css' ); |
| 81 | } |
| 82 | |
| 83 | wp_enqueue_style('spel-extension', SPEL_CSS . '/extension.css'); |
| 84 | |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Register Widget Scripts |
| 89 | * |
| 90 | * Register custom scripts required to run Spider Elements. |
| 91 | * |
| 92 | * @access public |
| 93 | */ |
| 94 | function register_widget_scripts() |
| 95 | { |
| 96 | |
| 97 | wp_register_script('ionicons', 'https://unpkg.com/ionicons@latest/dist/ionicons.js', '', SPEL_VERSION, true); |
| 98 | wp_register_script('slick', SPEL_VEND . '/slick/slick.min.js', array('jquery'), SPEL_VERSION, true); |
| 99 | wp_register_script('swiper', SPEL_VEND . '/swiper/swiper-bundle.min.js', array('jquery'), SPEL_VERSION, true); |
| 100 | wp_register_script('text-type', SPEL_VEND . '/text-type/text-type.js', array('jquery'), SPEL_VERSION, true); |
| 101 | wp_register_script('counterup', SPEL_VEND . '/counterup/jquery.counterup.min.js', array('jquery'), SPEL_VERSION, true); |
| 102 | wp_register_script('waypoint', SPEL_VEND . '/waypoint/jquery.waypoints.min.js', array('jquery'), SPEL_VERSION, true); |
| 103 | wp_register_script('wow', SPEL_VEND . '/wow/wow.min.js', array('jquery'), '1.1.3', true); |
| 104 | wp_register_script('artplayer', SPEL_VEND . '/video/artplayer.js', array('jquery'), '3.5.26', true); |
| 105 | wp_register_script('video-js-nuevo', SPEL_VEND . '/video/nuevo.min.js', array('jquery'), '7.6.0', true); |
| 106 | wp_register_script('video-js', SPEL_VEND . '/video/video.min.js', array('jquery'), '7.6.0', true); |
| 107 | wp_register_script('scroll-parallax', SPEL_VEND . '/scroll-parallax/jquery.parallax-scroll.js', array('jquery'), SPEL_VERSION, true); |
| 108 | wp_register_script('fancybox', SPEL_VEND . '/fancybox/js/jquery.fancybox.min.js', array('jquery'), '3.5.7', true); |
| 109 | wp_register_script('ajax-chimp', SPEL_JS . '/ajax-chimp.js', 'jquery', SPEL_VERSION, true); |
| 110 | wp_register_script('charming', SPEL_VEND . '/diagonal/charming.min.js', array('jquery'), SPEL_VERSION, true); |
| 111 | wp_register_script('tweenmax', SPEL_VEND . '/diagonal/TweenMax.min.js', array('jquery'), '1.18.0', true); |
| 112 | wp_register_script('beforeafter', SPEL_VEND . '/before/beforeafter.jquery-1.0.0.min.js', array('jquery'), '1.0.0', true); |
| 113 | wp_register_script('spel-script', SPEL_JS . '/scripts.js', array('jquery'), SPEL_VERSION, true); |
| 114 | } |
| 115 | |
| 116 | |
| 117 | /** |
| 118 | * Register Widget Styles |
| 119 | * |
| 120 | * Register custom styles required to run Spider Elements. |
| 121 | * |
| 122 | * @access public |
| 123 | */ |
| 124 | function register_editor_scripts(): void |
| 125 | { |
| 126 | wp_register_script('spel-el-widgets', SPEL_JS . '/elementor-widgets.js', [ |
| 127 | 'jquery', |
| 128 | 'elementor-frontend' |
| 129 | ], SPEL_VERSION, true); |
| 130 | } |
| 131 | |
| 132 | |
| 133 | /** |
| 134 | * Register Widget Styles |
| 135 | * |
| 136 | * Register custom styles required to run Spider Elements. |
| 137 | * |
| 138 | * @access public |
| 139 | */ |
| 140 | public function elementor_editor_scripts(): void |
| 141 | { |
| 142 | wp_enqueue_style( 'spel-elementor-editor', SPEL_CSS . '/elementor-editor.css', [], SPEL_VERSION ); |
| 143 | } |
| 144 | |
| 145 | |
| 146 | } |