PluginProbe
Ultimate Post Kit / 4.1.2
Ultimate Post Kit v4.1.2
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 4.1.5 All 145 releases
ultimate-post-kit / loader.php

loader.php in Ultimate Post Kit 4.1.2, at loader.php

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