bdthemes-prime-slider-lite
Last commit date
admin
2 months ago
assets
2 months ago
base
2 months ago
includes
2 months ago
languages
2 months ago
modules
2 months ago
traits
2 months ago
.buildignore
2 months ago
bdthemes-prime-slider.php
2 months ago
loader.php
2 months ago
readme.txt
2 months ago
loader.php
395 lines
| 1 | <?php |
| 2 | |
| 3 | namespace PrimeSlider; |
| 4 | |
| 5 | use Elementor\Plugin; |
| 6 | use PrimeSlider\Includes\PrimeSlider_WPML; |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; // Exit if accessed directly |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Main class for element pack |
| 14 | */ |
| 15 | class Prime_Slider_Loader { |
| 16 | |
| 17 | /** |
| 18 | * @var Prime_Slider_Loader |
| 19 | */ |
| 20 | private static $_instance; |
| 21 | |
| 22 | /** |
| 23 | * @var Manager |
| 24 | */ |
| 25 | private $_modules_manager; |
| 26 | |
| 27 | private $classes_aliases = [ |
| 28 | 'PrimeSlider\Modules\PanelPostsControl\Module' => 'PrimeSlider\Modules\QueryControl\Module', |
| 29 | 'PrimeSlider\Modules\PanelPostsControl\Controls\Group_Control_Posts' => 'PrimeSlider\Modules\QueryControl\Controls\Group_Control_Posts', |
| 30 | 'PrimeSlider\Modules\PanelPostsControl\Controls\Query' => 'PrimeSlider\Modules\QueryControl\Controls\Query', |
| 31 | ]; |
| 32 | |
| 33 | public $elements_data = [ |
| 34 | 'sections' => [], |
| 35 | 'columns' => [], |
| 36 | 'widgets' => [], |
| 37 | ]; |
| 38 | |
| 39 | /** |
| 40 | * @deprecated |
| 41 | * |
| 42 | * @return string |
| 43 | */ |
| 44 | public function get_version() { |
| 45 | return BDTPS_CORE_VER; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Throw error on object clone |
| 50 | * |
| 51 | * The whole idea of the singleton design pattern is that there is a single |
| 52 | * object therefore, we don't want the object to be cloned. |
| 53 | * |
| 54 | * @since 1.0.0 |
| 55 | * @return void |
| 56 | */ |
| 57 | public function __clone() { |
| 58 | // Cloning instances of the class is forbidden |
| 59 | _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'bdthemes-prime-slider' ), '1.6.0' ); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Disable unserializing of the class |
| 64 | * |
| 65 | * @since 1.0.0 |
| 66 | * @return void |
| 67 | */ |
| 68 | public function __wakeup() { |
| 69 | // Unserializing instances of the class is forbidden |
| 70 | _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'bdthemes-prime-slider' ), '1.6.0' ); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @return Plugin |
| 75 | */ |
| 76 | |
| 77 | public static function elementor() { |
| 78 | return Plugin::$instance; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @return Prime_Slider_Loader |
| 83 | */ |
| 84 | public static function instance() { |
| 85 | if ( is_null( self::$_instance ) ) { |
| 86 | self::$_instance = new self(); |
| 87 | } |
| 88 | |
| 89 | do_action( 'bdthemes_prime_slider_lite/init' ); |
| 90 | |
| 91 | return self::$_instance; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * we loaded module manager + admin php from here |
| 96 | * @return [type] [description] |
| 97 | */ |
| 98 | private function _includes() { |
| 99 | $duplicator = prime_slider_option( 'duplicator', 'prime_slider_other_settings', 'off' ); |
| 100 | $live_copy = prime_slider_option( 'live-copy', 'prime_slider_other_settings', 'off' ); |
| 101 | |
| 102 | // Admin settings controller |
| 103 | require_once BDTPS_CORE_ADMIN_PATH . 'module-settings.php'; |
| 104 | //Assets Manager |
| 105 | // require_once 'admin/optimizer/asset-minifier-manager.php'; |
| 106 | |
| 107 | // Dynamic Select control |
| 108 | require BDTPS_CORE_PATH . 'traits/query-controls/select-input/dynamic-select-input-module.php'; |
| 109 | require BDTPS_CORE_PATH . 'traits/query-controls/select-input/dynamic-select.php'; |
| 110 | // Global Controls |
| 111 | require_once BDTPS_CORE_PATH . 'traits/global-widget-controls.php'; |
| 112 | //require_once BDTPS_CORE_PATH . 'traits/global-swiper-controls.php'; |
| 113 | //require_once BDTPS_CORE_PATH . 'traits/global-mask-controls.php'; |
| 114 | |
| 115 | // wpml compatibility class for wpml support |
| 116 | require_once BDTPS_CORE_PATH . 'includes/class-elements-wpml-compatibility.php'; |
| 117 | |
| 118 | require BDTPS_CORE_PATH . 'includes/modules-manager.php'; |
| 119 | |
| 120 | if ( ! class_exists( 'BdThemes_Duplicator' ) ) { |
| 121 | if ( $duplicator == 'on' ) { |
| 122 | require BDTPS_CORE_PATH . 'includes/class-duplicator.php'; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | if ( ! class_exists( 'BdThemes_Live_Copy' ) ) { |
| 127 | if ( ( $live_copy == 'on' ) && ( ! is_plugin_active( 'live-copy-paste/live-copy-paste.php' ) ) ) { |
| 128 | require_once BDTPS_CORE_PATH . 'includes/live-copy/class-live-copy.php'; |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | // Load WPML compatibility instance |
| 134 | public function wpml_compatiblity() { |
| 135 | return PrimeSlider_WPML::get_instance(); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Autoloader function for all classes files |
| 140 | * @param [type] $class [description] |
| 141 | * @return [type] [description] |
| 142 | */ |
| 143 | public function autoload( $class ) { |
| 144 | if ( 0 !== strpos( $class, __NAMESPACE__ ) ) { |
| 145 | return; |
| 146 | } |
| 147 | |
| 148 | $has_class_alias = isset( $this->classes_aliases[ $class ] ); |
| 149 | |
| 150 | // Backward Compatibility: Save old class name for set an alias after the new class is loaded |
| 151 | if ( $has_class_alias ) { |
| 152 | $class_alias_name = $this->classes_aliases[ $class ]; |
| 153 | $class_to_load = $class_alias_name; |
| 154 | } else { |
| 155 | $class_to_load = $class; |
| 156 | } |
| 157 | |
| 158 | if ( ! class_exists( $class_to_load ) ) { |
| 159 | $filename = strtolower( |
| 160 | preg_replace( |
| 161 | [ '/^' . __NAMESPACE__ . '\\\/', '/([a-z])([A-Z])/', '/_/', '/\\\/' ], |
| 162 | [ '', '$1-$2', '-', DIRECTORY_SEPARATOR ], |
| 163 | $class_to_load |
| 164 | ) |
| 165 | ); |
| 166 | $filename = BDTPS_CORE_PATH . $filename . '.php'; |
| 167 | |
| 168 | if ( is_readable( $filename ) ) { |
| 169 | include( $filename ); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | if ( $has_class_alias ) { |
| 174 | class_alias( $class_alias_name, $class ); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Register all script that need for any specific widget on call basis. |
| 180 | * @return [type] [description] |
| 181 | */ |
| 182 | public function register_site_scripts() { |
| 183 | |
| 184 | //TODO more attractive animation |
| 185 | //Thirdparty widgets |
| 186 | if ( prime_slider_is_widget_enabled( 'multiscroll' ) ) { |
| 187 | wp_register_script( 'jquery-multiscroll', BDTPS_CORE_ASSETS_URL . 'vendor/js/jquery.multiscroll.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 188 | wp_register_script( 'easings', BDTPS_CORE_ASSETS_URL . 'vendor/js/jquery.easings.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 189 | } |
| 190 | if ( prime_slider_is_widget_enabled( 'pagepiling' ) ) { |
| 191 | wp_register_script( 'jquery-pagepiling', BDTPS_CORE_ASSETS_URL . 'vendor/js/jquery.pagepiling.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 192 | } |
| 193 | if ( prime_slider_is_widget_enabled( 'knily' ) or prime_slider_is_third_party_enabled( 'woolamp' ) ) { |
| 194 | wp_register_script( 'bdt-goodshare', BDTPS_CORE_ASSETS_URL . 'vendor/js/goodshare.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 195 | } |
| 196 | |
| 197 | if ( prime_slider_is_third_party_enabled( 'woocircle' ) ) { |
| 198 | wp_register_script( 'classie', BDTPS_CORE_ASSETS_URL . 'vendor/js/classie.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 199 | wp_register_script( 'dynamics', BDTPS_CORE_ASSETS_URL . 'vendor/js/dynamics.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 200 | } |
| 201 | if ( prime_slider_is_widget_enabled( 'pieces' ) ) { |
| 202 | wp_register_script( 'pieces', BDTPS_CORE_ASSETS_URL . 'vendor/js/pieces.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 203 | } |
| 204 | if ( prime_slider_is_widget_enabled( 'fortune' ) or prime_slider_is_widget_enabled( 'knily' ) or prime_slider_is_widget_enabled( 'storker' ) or prime_slider_is_widget_enabled( 'omatic' ) or prime_slider_is_widget_enabled( 'sniper' ) or prime_slider_is_widget_enabled( 'mercury' ) or prime_slider_is_widget_enabled( 'coddle' ) or prime_slider_is_widget_enabled( 'escape' ) or prime_slider_is_widget_enabled( 'titanic' ) or prime_slider_is_widget_enabled( 'woohotspot' ) ) { |
| 205 | wp_register_script( 'shutters', BDTPS_CORE_ASSETS_URL . 'vendor/js/effect-shutters.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 206 | wp_register_script( 'gl', BDTPS_CORE_ASSETS_URL . 'vendor/js/swiper-gl.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 207 | wp_register_script( 'slicer', BDTPS_CORE_ASSETS_URL . 'vendor/js/effect-slicer.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 208 | wp_register_script( 'tinder', BDTPS_CORE_ASSETS_URL . 'vendor/js/effect-tinder.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 209 | } |
| 210 | if ( prime_slider_is_widget_enabled( 'fluent' ) or prime_slider_is_widget_enabled( 'flogia' ) ) { |
| 211 | wp_register_script( 'mThumbnailScroller', BDTPS_CORE_ASSETS_URL . 'vendor/js/jquery.mThumbnailScroller.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 212 | } |
| 213 | |
| 214 | wp_register_script( 'bdt-parallax', BDTPS_CORE_ASSETS_URL . 'vendor/js/parallax.min.js', [ 'jquery' ], null, true ); |
| 215 | |
| 216 | if ( prime_slider_is_widget_enabled( 'blog' ) |
| 217 | || prime_slider_is_widget_enabled( 'dragon' ) |
| 218 | || prime_slider_is_widget_enabled( 'flogia' ) |
| 219 | || prime_slider_is_widget_enabled( 'general' ) |
| 220 | || prime_slider_is_widget_enabled( 'isolate' ) |
| 221 | || prime_slider_is_widget_enabled( 'mount' ) |
| 222 | || prime_slider_is_widget_enabled( 'sequester' ) |
| 223 | || prime_slider_is_widget_enabled( 'woocommerce' ) |
| 224 | || prime_slider_is_widget_enabled( 'woolamp' ) |
| 225 | || prime_slider_is_widget_enabled( 'fluent' ) // Pro widget |
| 226 | ) { |
| 227 | wp_register_script( 'ps-animation-helper', BDTPS_CORE_ASSETS_URL . 'js/ps-animation-helper.min.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 228 | } |
| 229 | |
| 230 | } |
| 231 | |
| 232 | public function register_site_styles() { |
| 233 | $direction_suffix = is_rtl() ? '.rtl' : ''; |
| 234 | |
| 235 | wp_register_style( 'prime-slider-font', BDTPS_CORE_ASSETS_URL . 'css/prime-slider-font' . $direction_suffix . '.css', [], BDTPS_CORE_VER ); |
| 236 | |
| 237 | } |
| 238 | |
| 239 | /** |
| 240 | * Loading site related style from here. |
| 241 | * @return [type] [description] |
| 242 | */ |
| 243 | public function enqueue_site_styles() { |
| 244 | |
| 245 | $direction_suffix = is_rtl() ? '.rtl' : ''; |
| 246 | |
| 247 | wp_register_style( 'bdt-uikit', BDTPS_CORE_ASSETS_URL . 'css/bdt-uikit' . $direction_suffix . '.css', [], '3.21.7' ); |
| 248 | wp_register_style( 'prime-slider-site', BDTPS_CORE_ASSETS_URL . 'css/prime-slider-site' . $direction_suffix . '.css', [], BDTPS_CORE_VER ); |
| 249 | wp_register_style( 'splitting', BDTPS_CORE_ASSETS_URL . 'vendor/css/splitting' . $direction_suffix . '.css', [], BDTPS_CORE_VER ); |
| 250 | |
| 251 | wp_enqueue_style( 'bdt-uikit' ); |
| 252 | wp_enqueue_style( 'prime-slider-site' ); |
| 253 | } |
| 254 | |
| 255 | |
| 256 | /** |
| 257 | * Loading site related script that needs all time such as uikit. |
| 258 | * @return [type] [description] |
| 259 | */ |
| 260 | public function enqueue_site_scripts() { |
| 261 | |
| 262 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.min' : '.min'; |
| 263 | |
| 264 | wp_register_script( 'bdt-uikit', BDTPS_CORE_ASSETS_URL . 'js/bdt-uikit.min.js', [ 'jquery' ], '3.21.7' ); |
| 265 | wp_register_script( 'prime-slider-site', BDTPS_CORE_ASSETS_URL . 'js/prime-slider-site' . $suffix . '.js', [ 'jquery' ], BDTPS_CORE_VER, true ); |
| 266 | |
| 267 | wp_enqueue_script( 'bdt-uikit' ); |
| 268 | wp_enqueue_script( 'prime-slider-site' ); |
| 269 | } |
| 270 | |
| 271 | public function enqueue_editor_scripts() { |
| 272 | |
| 273 | wp_register_script( 'ps-editor', BDTPS_CORE_ASSETS_URL . 'js/prime-slider-editor.min.js', [ |
| 274 | 'backbone-marionette', |
| 275 | 'elementor-common-modules', |
| 276 | 'elementor-editor-modules', |
| 277 | ], BDTPS_CORE_VER, true ); |
| 278 | |
| 279 | wp_enqueue_script( 'ps-editor' ); |
| 280 | |
| 281 | $_is_ps_pro_activated = false; |
| 282 | if ( function_exists( 'ps_license_validation' ) && true === ps_license_validation() ) { |
| 283 | $_is_ps_pro_activated = true; |
| 284 | } |
| 285 | |
| 286 | $localize_data = [ |
| 287 | 'pro_installed' => _is_ps_pro_activated(), |
| 288 | 'pro_license_activated' => $_is_ps_pro_activated, |
| 289 | 'promotional_widgets' => [], |
| 290 | ]; |
| 291 | |
| 292 | if ( ! $_is_ps_pro_activated ) { |
| 293 | $pro_widget_map = new \PrimeSlider\Includes\Pro_Widget_Map(); |
| 294 | $localize_data['promotional_widgets'] = $pro_widget_map->get_pro_widget_map(); |
| 295 | } |
| 296 | |
| 297 | wp_localize_script( 'ps-editor', 'PrimeSliderConfigEditor', $localize_data ); |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Load editor editor related style from here |
| 302 | * @return [type] [description] |
| 303 | */ |
| 304 | public function enqueue_preview_styles() { |
| 305 | $direction_suffix = is_rtl() ? '.rtl' : ''; |
| 306 | |
| 307 | wp_register_style( 'prime-slider-preview', BDTPS_CORE_ASSETS_URL . 'css/prime-slider-preview' . $direction_suffix . '.css', array(), BDTPS_CORE_VER ); |
| 308 | |
| 309 | wp_enqueue_style( 'prime-slider-preview' ); |
| 310 | } |
| 311 | |
| 312 | |
| 313 | public function enqueue_editor_styles() { |
| 314 | $direction_suffix = is_rtl() ? '-rtl' : ''; |
| 315 | |
| 316 | wp_register_style( 'prime-slider-editor', BDTPS_CORE_ASSETS_URL . 'css/prime-slider-editor' . $direction_suffix . '.css', array(), BDTPS_CORE_VER ); |
| 317 | wp_register_style( 'prime-slider-font', BDTPS_CORE_ASSETS_URL . 'css/prime-slider-font' . $direction_suffix . '.css', [], BDTPS_CORE_VER ); |
| 318 | |
| 319 | wp_enqueue_style( 'prime-slider-editor' ); |
| 320 | wp_enqueue_style( 'prime-slider-font' ); |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * initialize the category |
| 325 | * @return [type] [description] |
| 326 | */ |
| 327 | public function prime_slider_init() { |
| 328 | $this->_modules_manager = new Manager(); |
| 329 | do_action( 'bdthemes_prime_slider/init' ); |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * initialize the category |
| 334 | */ |
| 335 | public function category_register() { |
| 336 | $elementor = Plugin::$instance; |
| 337 | |
| 338 | // Add element category in panel |
| 339 | $elementor->elements_manager->add_category( BDTPS_CORE_SLUG, [ 'title' => BDTPS_CORE_TITLE, 'icon' => 'font' ] ); |
| 340 | } |
| 341 | |
| 342 | private function setup_hooks() { |
| 343 | add_action( 'elementor/elements/categories_registered', [ $this, 'category_register' ] ); |
| 344 | add_action( 'elementor/init', [ $this, 'prime_slider_init' ] ); |
| 345 | add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_editor_styles' ] ); |
| 346 | |
| 347 | add_action( 'wp_enqueue_scripts', [ $this, 'register_site_styles' ], 99999 ); |
| 348 | add_action( 'wp_enqueue_scripts', [ $this, 'register_site_scripts' ], 99999 ); |
| 349 | add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_site_styles' ], 99999 ); |
| 350 | add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_site_scripts' ], 99999 ); |
| 351 | |
| 352 | add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_preview_styles' ] ); |
| 353 | add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'enqueue_editor_scripts' ] ); |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * Load files on init |
| 358 | */ |
| 359 | public function init() { |
| 360 | if ( is_admin() && ps_is_dashboard_enabled() ) { |
| 361 | require_once BDTPS_CORE_ADMIN_PATH . 'admin-biggopti.php'; |
| 362 | require_once BDTPS_CORE_ADMIN_PATH . 'admin-api-biggopti.php'; |
| 363 | require_once BDTPS_CORE_ADMIN_PATH . 'admin.php'; |
| 364 | new Admin(); |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | /** |
| 369 | * Prime_Slider_Loader constructor. |
| 370 | * @throws \Exception |
| 371 | */ |
| 372 | private function __construct() { |
| 373 | // Register class automatically |
| 374 | spl_autoload_register( [ $this, 'autoload' ] ); |
| 375 | // Include some backend files |
| 376 | $this->_includes(); |
| 377 | // Finally hooked up all things here |
| 378 | $this->setup_hooks(); |
| 379 | |
| 380 | $this->wpml_compatiblity()->init(); |
| 381 | |
| 382 | add_action( 'init', [ $this, 'init' ] ); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | if ( ! defined( 'BDTPS_CORE_TESTS' ) ) { |
| 387 | // In tests we run the instance manually. |
| 388 | Prime_Slider_Loader::instance(); |
| 389 | } |
| 390 | |
| 391 | // handy function for push data |
| 392 | function prime_slider_config() { |
| 393 | return Prime_Slider_Loader::instance(); |
| 394 | } |
| 395 |