PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.0.9
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.0.9
4.5.4 4.2.1 4.2.2 4.2.3 4.5.0 4.5.2 4.5.3 4.2.0 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 All 146 releases
ultimate-post-kit / loader.php

loader.php in Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets 4.0.9, at loader.php

365 lines 10.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UltimatePostKit;
4
5 use Elementor\Plugin;
6 use UltimatePostKit\Admin;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 } // Exit if accessed directly
11
12 /**
13 * Main class for element pack
14 */
15 class Ultimate_Post_Kit_Loader {
16
17 /**
18 * @var Ultimate_Post_Kit_Loader
19 */
20 private static $_instance;
21
22 /**
23 * @var Manager
24 */
25 private $_modules_manager;
26
27 private $classes_aliases;
28
29 public $elements_data = [
30 'sections' => [],
31 'columns' => [],
32 'widgets' => [],
33 ];
34
35 /**
36 * @return string
37 * @deprecated
38 *
39 */
40 public function get_version() {
41 return BDTUPK_VER;
42 }
43
44 /**
45 * return active theme
46 */
47 public function get_theme() {
48 return wp_get_theme();
49 }
50
51 /**
52 * Throw error on object clone
53 *
54 * The whole idea of the singleton design pattern is that there is a single
55 * object therefore, we don't want the object to be cloned.
56 *
57 * @return void
58 * @since 1.0.0
59 */
60 public function __clone() {
61 // Cloning instances of the class is forbidden
62 _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'ultimate-post-kit' ), '1.6.0' );
63 }
64
65 /**
66 * Disable unserializing of the class
67 *
68 * @return void
69 * @since 1.0.0
70 */
71 public function __wakeup() {
72 // Unserializing instances of the class is forbidden
73 _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'ultimate-post-kit' ), '1.6.0' );
74 }
75
76 /**
77 * @return Plugin
78 */
79
80 public static function elementor() {
81 return Plugin::$instance;
82 }
83
84 /**
85 * @return Ultimate_Post_Kit_Loader
86 */
87 public static function instance() {
88 if ( is_null( self::$_instance ) ) {
89 self::$_instance = new self();
90 }
91 do_action( 'bdthemes_ultimate_post_kit/init' );
92 return self::$_instance;
93 }
94
95
96 /**
97 * we loaded module manager + admin php from here
98 * @return [type] [description]
99 */
100 private function _includes() {
101 $category_image = ultimate_post_kit_option( 'category_image', 'ultimate_post_kit_other_settings', 'off' );
102 $duplicator = ultimate_post_kit_option( 'duplicator', 'ultimate_post_kit_other_settings', 'off' );
103 $live_copy = ultimate_post_kit_option( 'live-copy', 'ultimate_post_kit_other_settings', 'off' );
104
105
106 // Admin settings controller
107 require_once BDTUPK_ADMIN_PATH . 'module-settings.php';
108
109 // Dynamic Select control
110 require BDTUPK_INC_PATH . 'controls/select-input/dynamic-select-input-module.php';
111 require BDTUPK_INC_PATH . 'controls/select-input/dynamic-select.php';
112
113 //require BDTUPK_PATH . 'base/ultimate-post-kit-base.php';
114
115 // all widgets control from here
116 require_once BDTUPK_PATH . 'traits/global-widget-controls.php';
117 require_once BDTUPK_PATH . 'traits/global-swiper-functions.php';
118 require_once BDTUPK_INC_PATH . 'modules-manager.php';
119
120 if ( $category_image == 'on' ) {
121 require BDTUPK_INC_PATH . 'ultimate-post-kit-category-image.php';
122 }
123 // if ($category_image == 'on') {
124 require BDTUPK_INC_PATH . 'ultimate-post-kit-metabox.php';
125 // }
126
127 if ( ! class_exists( 'BdThemes_Duplicator' ) ) {
128 if ( $duplicator == 'on' ) {
129 require BDTUPK_PATH . 'includes/class-duplicator.php';
130 }
131 }
132
133 if ( ! class_exists( 'BdThemes_Live_Copy' ) ) {
134 if ( ( $live_copy == 'on' ) && ( ! is_plugin_active( 'live-copy-paste/live-copy-paste.php' ) ) ) {
135 require_once BDTUPK_PATH . 'includes/live-copy/class-live-copy.php';
136 }
137 }
138 }
139
140 /**
141 * Autoloader function for all classes files
142 *
143 * @param [type] class [description]
144 *
145 * @return [type] [description]
146 */
147 public function autoload( $class ) {
148 if ( 0 !== strpos( $class, __NAMESPACE__ ) ) {
149 return;
150 }
151
152 $class_to_load = $class;
153
154 if ( ! class_exists( $class_to_load ) ) {
155 $filename = strtolower(
156 preg_replace(
157 [ '/^' . __NAMESPACE__ . '\\\/', '/([a-z])([A-Z])/', '/_/', '/\\\/' ],
158 [ '', '$1-$2', '-', DIRECTORY_SEPARATOR ],
159 $class_to_load
160 )
161 );
162 $filename = BDTUPK_PATH . $filename . '.php';
163
164 if ( is_readable( $filename ) ) {
165 include( $filename );
166 }
167 }
168 }
169
170 public function register_site_styles() {
171 $direction_suffix = is_rtl() ? '.rtl' : '';
172
173 wp_register_style( 'upk-all-styles', BDTUPK_ASSETS_URL . 'css/upk-all-styles' . $direction_suffix . '.css', [], BDTUPK_VER );
174 wp_register_style( 'upk-font', BDTUPK_ASSETS_URL . 'css/upk-font' . $direction_suffix . '.css', [], BDTUPK_VER );
175 }
176
177 public function register_site_scripts() {
178
179 // $suffix = '.min';
180
181 wp_register_script( 'goodshare', BDTUPK_ASSETS_URL . 'vendor/js/goodshare.min.js', [ 'jquery' ], '4.1.2', true );
182 wp_register_script( 'scrolline', BDTUPK_ASSETS_URL . 'vendor/js/jquery.scrolline.min.js', [ 'jquery' ], '4.1.2', true );
183 wp_register_script( 'news-ticker-js', BDTUPK_ASSETS_URL . 'vendor/js/newsticker.min.js', [ 'jquery' ], '', true );
184 wp_register_script( 'fslightbox', BDTUPK_ASSETS_URL . 'vendor/js/fslightbox.min.js', [], '3.4.1', true );
185 wp_register_script( 'upk-animations', BDTUPK_ASSETS_URL . 'js/extensions/upk-animations.min.js', [ 'jquery' ], '', true );
186
187 wp_register_script( 'upk-ajax-loadmore', BDTUPK_ASSETS_URL . 'js/extensions/upk-ajax-loadmore.min.js', [ 'jquery' ], '', true );
188
189 wp_register_script( 'upk-all-scripts', BDTUPK_ASSETS_URL . 'js/upk-all-scripts.min.js', [
190 'jquery',
191 'scrolline'
192 ], BDTUPK_VER, true );
193 }
194
195
196 /**
197 * Loading site related style from here.
198 * @return [type] [description]
199 */
200 public function enqueue_site_styles() {
201
202 $direction_suffix = is_rtl() ? '.rtl' : '';
203
204 wp_register_style( 'upk-site', BDTUPK_ASSETS_URL . 'css/upk-site' . $direction_suffix . '.css', [], BDTUPK_VER );
205 wp_enqueue_style( 'upk-site' );
206 }
207
208
209 /**
210 * Loading site related script that needs all time such as uikit.
211 * @return [type] [description]
212 */
213 public function enqueue_site_scripts() {
214
215 // $suffix = '.min';
216
217
218 wp_register_script( 'upk-site', BDTUPK_ASSETS_URL . 'js/upk-site.min.js', [
219 'jquery'
220 ], BDTUPK_VER, true ); // tooltip file should be separate
221
222 wp_enqueue_script( 'upk-site' );
223
224 $script_config = [
225 'ajaxurl' => admin_url( 'admin-ajax.php' ),
226 'nonce' => wp_create_nonce( 'upk-site' ),
227 'mailchimp' => [
228 'subscribing' => esc_html_x( 'Subscribing you please wait...', 'Mailchimp String', 'ultimate-post-kit' ),
229 ],
230 'elements_data' => $this->elements_data,
231 ];
232
233
234 $script_config = apply_filters( 'ultimate_post_kit/frontend/localize_settings', $script_config );
235
236 // TODO for editor script
237 wp_localize_script( 'upk-site', 'UltimatePostKitConfig', $script_config );
238 }
239
240 public function enqueue_editor_scripts() {
241
242 // $suffix = '.min';
243
244 wp_register_script( 'upk-editor', BDTUPK_ASSETS_URL . 'js/upk-editor.min.js', [
245 'backbone-marionette',
246 'elementor-common-modules',
247 'elementor-editor-modules',
248 ], BDTUPK_VER, true );
249
250 wp_enqueue_script( 'upk-editor' );
251
252 $_is_upk_pro_activated = false;
253 if ( function_exists( 'upk_license_validation' ) && true === upk_license_validation() ) {
254 $_is_upk_pro_activated = true;
255 }
256
257 $localize_data = [
258 'pro_installed' => _is_upk_pro_activated(),
259 'pro_license_activated' => $_is_upk_pro_activated,
260 'promotional_widgets' => [],
261 ];
262
263 if ( ! $_is_upk_pro_activated ) {
264 $pro_widget_map = new \UltimatePostKit\Includes\Pro_Widget_Map();
265 $localize_data['promotional_widgets'] = $pro_widget_map->get_pro_widget_map();
266 }
267
268 wp_localize_script( 'upk-editor', 'UltimatePostKitConfigEditor', $localize_data );
269 }
270
271 /**
272 * Load editor editor related style from here
273 * @return [type] [description]
274 */
275 public function enqueue_preview_styles() {
276 $direction_suffix = is_rtl() ? '.rtl' : '';
277
278 wp_register_style( 'upk-preview', BDTUPK_ASSETS_URL . 'css/upk-preview' . $direction_suffix . '.css', '', BDTUPK_VER );
279 wp_enqueue_style( 'upk-preview' );
280 }
281
282
283 public function enqueue_editor_styles() {
284 $direction_suffix = is_rtl() ? '.rtl' : '';
285
286 wp_register_style( 'upk-editor', BDTUPK_ASSETS_URL . 'css/upk-editor' . $direction_suffix . '.css', '', BDTUPK_VER );
287 wp_register_style( 'upk-font', BDTUPK_URL . 'assets/css/upk-font' . $direction_suffix . '.css', [], BDTUPK_VER );
288
289 wp_enqueue_style( 'upk-editor' );
290 wp_enqueue_style( 'upk-font' );
291 }
292
293 /**
294 * initialize the category
295 * @return [type] [description]
296 */
297 public function ultimate_post_kit_init() {
298 $this->_modules_manager = new Manager();
299 }
300
301 /**
302 * initialize the category
303 * @return [type] [description]
304 */
305 public function ultimate_post_kit_category_register() {
306
307 $elementor = Plugin::$instance;
308
309 // Add element category in panel
310 $elementor->elements_manager->add_category( BDTUPK_SLUG, [ 'title' => BDTUPK_TITLE, 'icon' => 'font' ] );
311 }
312
313
314 private function setup_hooks() {
315 add_action( 'elementor/elements/categories_registered', [ $this, 'ultimate_post_kit_category_register' ] );
316 add_action( 'elementor/init', [ $this, 'ultimate_post_kit_init' ] );
317
318 add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_editor_styles' ] );
319 add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'enqueue_editor_scripts' ] );
320
321 add_action( 'wp_enqueue_scripts', [ $this, 'register_site_styles' ], 99999 );
322 add_action( 'wp_enqueue_scripts', [ $this, 'register_site_scripts' ], 99999 );
323 add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_site_styles' ], 99999 );
324 add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_site_scripts' ], 99999 );
325
326 add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_preview_styles' ] );
327 }
328
329 public function init(){
330 if ( ! defined( 'BDTUPK_CH' ) && is_admin() ) {
331 // Notice class
332 require_once BDTUPK_ADMIN_PATH . 'admin-biggopti.php';
333 require_once BDTUPK_ADMIN_PATH . 'admin.php';
334
335 // Load admin class for admin related content process
336 new Admin();
337 }
338 }
339
340 /**
341 * Ultimate_Post_Kit_Loader constructor.
342 */
343 private function __construct() {
344 // Register class automatically
345 spl_autoload_register( [ $this, 'autoload' ] );
346 // Include some backend files
347 $this->_includes();
348
349 // Finally hooked up all things here
350 $this->setup_hooks();
351
352 add_action( 'init', [ $this, 'init' ] );
353 }
354 }
355
356 if ( ! defined( 'BDTUPK_TESTS' ) ) {
357 // In tests we run the instance manually.
358 Ultimate_Post_Kit_Loader::instance();
359 }
360
361 // handy fundtion for push data
362 function ultimate_post_kit_config() {
363 return Ultimate_Post_Kit_Loader::instance();
364 }
365