bdthemes-element-pack-lite
Last commit date
admin
1 year ago
assets
1 year ago
base
1 year ago
dci
1 year ago
includes
1 year ago
languages
1 year ago
modules
1 year ago
traits
1 year ago
bdthemes-element-pack-lite.php
1 year ago
loader.php
1 year ago
readme.txt
1 year ago
loader.php
690 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ElementPack; |
| 4 | |
| 5 | use Elementor\Plugin; |
| 6 | use ElementPack\Includes\Element_Pack_WPML; |
| 7 | use Elementor\Core\Kits\Documents\Kit; |
| 8 | use ElementPack\Includes\ElementPack_FB_Access_Token_Generator_Control; |
| 9 | use ElementPack\Includes\ElementPack_JSON_File_Upload_Control; |
| 10 | use ElementPack\Includes\SVG_Support; |
| 11 | use ElementPack\Includes\Pro_Widget_Map; |
| 12 | |
| 13 | if (!defined('ABSPATH')) { |
| 14 | exit; |
| 15 | } // Exit if accessed directly |
| 16 | |
| 17 | /** |
| 18 | * Main class for element pack |
| 19 | */ |
| 20 | class Element_Pack_Loader { |
| 21 | |
| 22 | /** |
| 23 | * @var Element_Pack_Loader |
| 24 | */ |
| 25 | private static $_instance; |
| 26 | public $_modules_manager; |
| 27 | |
| 28 | public $elements_data = [ |
| 29 | 'sections' => [], |
| 30 | 'columns' => [], |
| 31 | 'widgets' => [], |
| 32 | ]; |
| 33 | |
| 34 | private function get_upload_dir() { |
| 35 | return trailingslashit(wp_upload_dir()['basedir']) . 'element-pack/minified/'; |
| 36 | } |
| 37 | |
| 38 | private function get_upload_url() { |
| 39 | return trailingslashit(wp_upload_dir()['baseurl']) . 'element-pack/minified/'; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @return string |
| 44 | * @deprecated |
| 45 | * |
| 46 | */ |
| 47 | public function get_version() { |
| 48 | return BDTEP_VER; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * return active theme |
| 53 | */ |
| 54 | public function get_theme() { |
| 55 | return wp_get_theme(); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Throw error on object clone |
| 60 | * |
| 61 | * The whole idea of the singleton design pattern is that there is a single |
| 62 | * object therefore, we don't want the object to be cloned. |
| 63 | * |
| 64 | * @return void |
| 65 | * @since 1.0.0 |
| 66 | */ |
| 67 | public function __clone() { |
| 68 | // Cloning instances of the class is forbidden |
| 69 | _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'bdthemes-element-pack'), '1.6.0'); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Disable unserializing of the class |
| 74 | * |
| 75 | * @return void |
| 76 | * @since 1.0.0 |
| 77 | */ |
| 78 | public function __wakeup() { |
| 79 | // Unserializing instances of the class is forbidden |
| 80 | _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'bdthemes-element-pack'), '1.6.0'); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * @return Plugin |
| 85 | */ |
| 86 | |
| 87 | public static function elementor() { |
| 88 | return Plugin::$instance; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * @return Element_Pack_Loader |
| 93 | */ |
| 94 | public static function instance() { |
| 95 | if (is_null(self::$_instance)) { |
| 96 | self::$_instance = new self(); |
| 97 | } |
| 98 | |
| 99 | return self::$_instance; |
| 100 | } |
| 101 | |
| 102 | |
| 103 | /** |
| 104 | * we loaded module manager + admin php from here |
| 105 | * @return [type] [description] |
| 106 | */ |
| 107 | private function _includes() { |
| 108 | |
| 109 | $live_copy = element_pack_option('live-copy', 'element_pack_other_settings', 'off'); |
| 110 | $template_library = element_pack_option('template-library', 'element_pack_other_settings', 'off'); |
| 111 | $duplicator = element_pack_option('duplicator', 'element_pack_other_settings', 'off'); |
| 112 | |
| 113 | // Admin settings controller |
| 114 | require_once BDTEP_ADMIN_PATH . 'module-settings.php'; |
| 115 | //Assets Manager |
| 116 | require_once 'admin/optimizer/asset-minifier-manager.php'; |
| 117 | |
| 118 | // Dynamic Select control |
| 119 | require_once BDTEP_INC_PATH . 'controls/select-input/dynamic-select-input-module.php'; |
| 120 | require_once BDTEP_INC_PATH . 'controls/select-input/dynamic-select.php'; |
| 121 | |
| 122 | // Global Controls |
| 123 | require_once BDTEP_PATH . 'traits/global-widget-controls.php'; |
| 124 | require_once BDTEP_PATH . 'traits/global-swiper-controls.php'; |
| 125 | require_once BDTEP_PATH . 'traits/global-mask-controls.php'; |
| 126 | |
| 127 | // json upload support for wordpress |
| 128 | require_once BDTEP_INC_PATH . 'class-json-file-upload-control.php'; |
| 129 | // svg support for full wordpress site |
| 130 | require_once BDTEP_INC_PATH . 'class-svg-support.php'; |
| 131 | // All modules loading from here |
| 132 | require_once BDTEP_INC_PATH . 'modules-manager.php'; |
| 133 | // wpml compatibility class for wpml support |
| 134 | require_once BDTEP_INC_PATH . 'class-elements-wpml-compatibility.php'; |
| 135 | // For changelog file parse |
| 136 | require_once BDTEP_INC_PATH . 'class-parsedown.php'; |
| 137 | |
| 138 | // Live copy paste from demo website |
| 139 | if ($live_copy == 'on') { |
| 140 | require_once BDTEP_INC_PATH . 'live-copy/class-live-copy.php'; |
| 141 | } |
| 142 | |
| 143 | // register the elementor template loading widget in widgets |
| 144 | require_once BDTEP_INC_PATH . 'widgets/elementor-template.php'; |
| 145 | |
| 146 | // Facebook access token generator control for editor |
| 147 | require_once BDTEP_INC_PATH . 'class-fb-access-token-generator-control.php'; |
| 148 | |
| 149 | require_once BDTEP_INC_PATH . 'class-google-recaptcha.php'; |
| 150 | |
| 151 | if ($duplicator == 'on') { |
| 152 | require_once BDTEP_INC_PATH . 'class-duplicator.php'; |
| 153 | } |
| 154 | |
| 155 | // Rooten theme header footer compatibility |
| 156 | if ('Rooten' === $this->get_theme()->name or 'Rooten' === $this->get_theme()->parent_theme) { |
| 157 | if (!class_exists('RootenCustomTemplate')) { |
| 158 | require_once BDTEP_INC_PATH . 'class-rooten-theme-compatibility.php'; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | // editor template library |
| 163 | if (!defined('BDTEP_CH') and $template_library == 'on') { |
| 164 | require_once(BDTEP_INC_PATH . 'template-library/editor/init.php'); |
| 165 | } |
| 166 | |
| 167 | if (is_admin()) { |
| 168 | if (!defined('BDTEP_CH')) { |
| 169 | require_once BDTEP_ADMIN_PATH . 'admin.php'; |
| 170 | |
| 171 | if (!defined('BDTEP_CH') and $template_library == 'on') { |
| 172 | require_once(BDTEP_INC_PATH . 'template-library/template-library-base.php'); |
| 173 | require_once(BDTEP_INC_PATH . 'template-library/editor/manager/api.php'); |
| 174 | } |
| 175 | |
| 176 | // Load admin class for admin related content process |
| 177 | new Admin(); |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Autoloader function for all classes files |
| 184 | * |
| 185 | * @param [type] class [description] |
| 186 | * |
| 187 | * @return [type] [description] |
| 188 | */ |
| 189 | public function autoload($class) { |
| 190 | if (0 !== strpos($class, __NAMESPACE__)) { |
| 191 | return; |
| 192 | } |
| 193 | |
| 194 | |
| 195 | $class_to_load = $class; |
| 196 | |
| 197 | if (!class_exists($class_to_load)) { |
| 198 | $filename = strtolower( |
| 199 | preg_replace( |
| 200 | ['/^' . __NAMESPACE__ . '\\\/', '/([a-z])([A-Z0-9])/', '/_/', '/\\\/'], |
| 201 | ['', '$1-$2', '-', DIRECTORY_SEPARATOR], |
| 202 | $class_to_load |
| 203 | ) |
| 204 | ); |
| 205 | |
| 206 | $filename = BDTEP_PATH . $filename . '.php'; |
| 207 | |
| 208 | if (is_readable($filename)) { |
| 209 | include($filename); |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Register all script that need for any specific widget on call basis. |
| 216 | * @return [type] [description] |
| 217 | */ |
| 218 | public function register_site_scripts() { |
| 219 | |
| 220 | $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
| 221 | $api_settings = get_option('element_pack_api_settings'); |
| 222 | |
| 223 | if (element_pack_is_widget_enabled('progress-pie')) { |
| 224 | wp_register_script('aspieprogress', BDTEP_ASSETS_URL . 'vendor/js/jquery-asPieProgress.min.js', ['jquery'], '0.4.7', true); |
| 225 | } |
| 226 | if (element_pack_is_widget_enabled('cookie-consent')) { |
| 227 | wp_register_script('cookieconsent', BDTEP_ASSETS_URL . 'vendor/js/cookieconsent.min.js', ['jquery'], '3.1.0', true); |
| 228 | } |
| 229 | if (element_pack_is_widget_enabled('static-grid-tab')) { |
| 230 | wp_register_script('gridtab', BDTEP_ASSETS_URL . 'vendor/js/gridtab.min.js', ['jquery'], '2.1.1', true); |
| 231 | } |
| 232 | if (element_pack_is_widget_enabled('user-register') or element_pack_is_widget_enabled('contact-form')) { |
| 233 | wp_register_script('recaptcha', 'https://www.google.com/recaptcha/api.js', ['jquery'], null, true); |
| 234 | } |
| 235 | if (element_pack_is_widget_enabled('open-street-map')) { |
| 236 | wp_register_script('leaflet', BDTEP_ASSETS_URL . 'vendor/js/leaflet.min.js', ['jquery'], '', true); |
| 237 | } |
| 238 | if (element_pack_is_widget_enabled('panel-slider')) { |
| 239 | wp_register_script('bdt-parallax', BDTEP_ASSETS_URL . 'vendor/js/parallax.min.js', ['jquery'], null, true); |
| 240 | } |
| 241 | if (element_pack_is_widget_enabled('image-magnifier')) { |
| 242 | wp_register_script('imagezoom', BDTEP_ASSETS_URL . 'vendor/js/jquery.imagezoom.min.js', ['jquery'], null, true); |
| 243 | } |
| 244 | if (element_pack_is_widget_enabled('logo-grid')) { |
| 245 | wp_register_script('popper', BDTEP_ASSETS_URL . 'vendor/js/popper.min.js', ['jquery'], null, true); |
| 246 | wp_register_script('tippyjs', BDTEP_ASSETS_URL . 'vendor/js/tippy.all.min.js', ['jquery'], null, true); |
| 247 | } |
| 248 | //advanced-image-gallery |
| 249 | if (element_pack_is_widget_enabled('custom-gallery') or element_pack_is_widget_enabled('tutor-lms-course-grid')) { |
| 250 | wp_register_script('tilt', BDTEP_ASSETS_URL . 'vendor/js/vanilla-tilt.min.js', ['jquery'], null, true); |
| 251 | } |
| 252 | if (element_pack_is_widget_enabled('reading-progress')) { |
| 253 | wp_register_script('progressHorizontal', BDTEP_ASSETS_URL . 'vendor/js/jquery.progressHorizontal.min.js', ['jquery'], '2.0.2', true); |
| 254 | // wp_register_script('progressScroll', BDTEP_ASSETS_URL . 'vendor/js/jquery.progressScroll.min.js', ['jquery'], '2.0.2', true); |
| 255 | } |
| 256 | if (element_pack_is_widget_enabled('image-compare')) { |
| 257 | wp_register_script('image-compare-viewer', BDTEP_ASSETS_URL . 'vendor/js/image-compare-viewer.min.js', ['jquery'], '0.0.1', true); |
| 258 | } |
| 259 | if (element_pack_is_widget_enabled('calendly')) { |
| 260 | wp_register_script('calendly', BDTEP_ASSETS_URL . 'vendor/js/calendly.min.js', ['jquery'], '0.0.1', true); |
| 261 | } |
| 262 | if (element_pack_is_widget_enabled('dark-mode')) { |
| 263 | wp_register_script('darkmode', BDTEP_ASSETS_URL . 'vendor/js/darkmode.min.js', ['jquery'], '1.1.1', true); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | public function register_site_styles() { |
| 268 | $direction_suffix = is_rtl() ? '.rtl' : ''; |
| 269 | |
| 270 | // third party widget css |
| 271 | if (element_pack_is_widget_enabled('image-magnifier')) { |
| 272 | wp_register_style('imagezoom', BDTEP_ASSETS_URL . 'css/imagezoom' . $direction_suffix . '.css', [], BDTEP_VER); |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * ?TODO: Need to separate wc widget css |
| 277 | */ |
| 278 | wp_register_style('ep-tutor-lms', BDTEP_ASSETS_URL . 'css/ep-tutor-lms' . $direction_suffix . '.css', [], BDTEP_VER); |
| 279 | // Vendor style register |
| 280 | wp_register_style('tippy', BDTEP_ASSETS_URL . 'css/tippy' . $direction_suffix . '.css', [], BDTEP_VER); |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * Loading site related style from here. |
| 285 | * @return [type] [description] |
| 286 | */ |
| 287 | public function enqueue_site_styles() { |
| 288 | |
| 289 | $direction_suffix = is_rtl() ? '.rtl' : ''; |
| 290 | |
| 291 | wp_register_style('bdt-uikit', BDTEP_ASSETS_URL . 'css/bdt-uikit' . $direction_suffix . '.css', [], '3.21.7'); |
| 292 | wp_register_style('ep-helper', BDTEP_ASSETS_URL . 'css/ep-helper' . $direction_suffix . '.css', [], BDTEP_VER); |
| 293 | |
| 294 | wp_enqueue_style( 'bdt-uikit' ); |
| 295 | wp_enqueue_style( 'ep-helper' ); |
| 296 | } |
| 297 | |
| 298 | |
| 299 | /** |
| 300 | * Loading site related script that needs all time such as uikit. |
| 301 | * @return [type] [description]mn |
| 302 | */ |
| 303 | public function enqueue_site_scripts() { |
| 304 | |
| 305 | $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
| 306 | |
| 307 | wp_register_script('bdt-uikit', BDTEP_ASSETS_URL . 'js/bdt-uikit' . $suffix . '.js', ['jquery'], '3.21.7', true); |
| 308 | |
| 309 | wp_enqueue_script( 'bdt-uikit' ); |
| 310 | |
| 311 | if (!element_pack_is_asset_optimization_enabled()) { |
| 312 | wp_register_script('element-pack-helper', BDTEP_ASSETS_URL . 'js/common/helper' . $suffix . '.js', ['jquery', 'elementor-frontend'], BDTEP_VER, true); |
| 313 | wp_enqueue_script('element-pack-helper'); |
| 314 | } |
| 315 | |
| 316 | |
| 317 | $script_config = [ |
| 318 | 'ajaxurl' => admin_url('admin-ajax.php'), |
| 319 | 'nonce' => wp_create_nonce('element-pack-site'), |
| 320 | 'data_table' => [ |
| 321 | 'language' => [ |
| 322 | 'lengthMenu' => sprintf(esc_html_x('Show %1s Entries', 'DataTable String', 'bdthemes-element-pack'), '_MENU_'), |
| 323 | 'info' => sprintf(esc_html_x('Showing %1s to %2s of %3s entries', 'DataTable String', 'bdthemes-element-pack'), '_START_', '_END_', '_TOTAL_'), |
| 324 | 'search' => esc_html_x('Search :', 'DataTable String', 'bdthemes-element-pack'), |
| 325 | 'paginate' => [ |
| 326 | 'previous' => esc_html_x('Previous', 'DataTable String', 'bdthemes-element-pack'), |
| 327 | 'next' => esc_html_x('Next', 'DataTable String', 'bdthemes-element-pack'), |
| 328 | ], |
| 329 | ], |
| 330 | ], |
| 331 | 'contact_form' => [ |
| 332 | 'sending_msg' => esc_html_x('Sending message please wait...', 'Contact Form String', 'bdthemes-element-pack'), |
| 333 | 'captcha_nd' => esc_html_x('Invisible captcha not defined!', 'Contact Form String', 'bdthemes-element-pack'), |
| 334 | 'captcha_nr' => esc_html_x('Could not get invisible captcha response!', 'Contact Form String', 'bdthemes-element-pack'), |
| 335 | |
| 336 | ], |
| 337 | 'mailchimp' => [ |
| 338 | 'subscribing' => esc_html_x('Subscribing you please wait...', 'Mailchimp String', 'bdthemes-element-pack'), |
| 339 | ], |
| 340 | 'search' => [ |
| 341 | 'more_result' => esc_html_x( 'More Results', 'Search Widget String', 'bdthemes-element-pack' ), |
| 342 | 'search_result' => esc_html_x( 'SEARCH RESULT', 'Search Widget String', 'bdthemes-element-pack' ), |
| 343 | 'not_found' => esc_html_x( 'not found', 'Search Widget String', 'bdthemes-element-pack' ), |
| 344 | ], |
| 345 | 'elements_data' => $this->elements_data, |
| 346 | ]; |
| 347 | |
| 348 | |
| 349 | // localize for user login widget ajax login script |
| 350 | |
| 351 | // if (!defined('ICL_LANGUAGE_CODE')) { |
| 352 | // define('ICL_LANGUAGE_CODE', null); |
| 353 | // } |
| 354 | // ICL_LANGUAGE_CODE = ''; |
| 355 | // TODO Language dynamic for ajax call |
| 356 | |
| 357 | wp_localize_script( |
| 358 | 'bdt-uikit', |
| 359 | 'element_pack_ajax_login_config', |
| 360 | array( |
| 361 | 'ajaxurl' => admin_url('admin-ajax.php'), |
| 362 | 'language' => substr(get_locale(), 0, 2), |
| 363 | 'loadingmessage' => esc_html_x('Sending user info, please wait...', 'User Login and Register', 'bdthemes-element-pack'), |
| 364 | 'unknownerror' => esc_html_x('Unknown error, make sure access is correct!', 'User Login and Register', 'bdthemes-element-pack'), |
| 365 | ) |
| 366 | ); |
| 367 | |
| 368 | $script_config = apply_filters('element_pack/frontend/localize_settings', $script_config); |
| 369 | |
| 370 | // TODO for editor script |
| 371 | wp_localize_script('bdt-uikit', 'ElementPackConfig', $script_config); |
| 372 | } |
| 373 | |
| 374 | public function enqueue_editor_scripts() { |
| 375 | |
| 376 | $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
| 377 | |
| 378 | wp_register_script( |
| 379 | 'element-pack', |
| 380 | BDTEP_ASSETS_URL . 'js/ep-editor' . $suffix . '.js', |
| 381 | [ |
| 382 | 'backbone-marionette', |
| 383 | 'elementor-common-modules', |
| 384 | 'elementor-editor-modules', |
| 385 | ], |
| 386 | BDTEP_VER, |
| 387 | true |
| 388 | ); |
| 389 | |
| 390 | wp_enqueue_script( 'element-pack' ); |
| 391 | |
| 392 | $localize_data = [ |
| 393 | 'pro_installed' => element_pack_pro_installed(), |
| 394 | 'promotional_widgets' => [], |
| 395 | ]; |
| 396 | |
| 397 | if (!element_pack_pro_installed()) { |
| 398 | $pro_widget_map = new Pro_Widget_Map(); |
| 399 | $localize_data['promotional_widgets'] = $pro_widget_map->get_pro_widget_map(); |
| 400 | } |
| 401 | |
| 402 | wp_localize_script( |
| 403 | 'element-pack', |
| 404 | 'ElementPackConfig', |
| 405 | $localize_data |
| 406 | ); |
| 407 | |
| 408 | // $locale_settings = [ |
| 409 | // 'i18n' => [], |
| 410 | // 'urls' => [ |
| 411 | // 'modules' => BDTEP_MODULES_URL, |
| 412 | // ], |
| 413 | // ]; |
| 414 | |
| 415 | // $locale_settings = apply_filters( 'element_pack/editor/localize_settings', $locale_settings ); |
| 416 | |
| 417 | // wp_localize_script( |
| 418 | // 'element-pack', |
| 419 | // 'ElementPackConfig', |
| 420 | // $locale_settings |
| 421 | // );f |
| 422 | } |
| 423 | |
| 424 | /** |
| 425 | * Load editor editor related style from here |
| 426 | * @return [type] [description] |
| 427 | */ |
| 428 | public function enqueue_preview_styles() { |
| 429 | $direction_suffix = is_rtl() ? '.rtl' : ''; |
| 430 | |
| 431 | wp_enqueue_style('ep-preview', BDTEP_ASSETS_URL . 'css/ep-preview' . $direction_suffix . '.css', '', BDTEP_VER); |
| 432 | } |
| 433 | |
| 434 | |
| 435 | public function enqueue_editor_styles() { |
| 436 | $direction_suffix = is_rtl() ? '.rtl' : ''; |
| 437 | |
| 438 | wp_register_style('ep-editor', BDTEP_ASSETS_URL . 'css/ep-editor' . $direction_suffix . '.css', '', BDTEP_VER); |
| 439 | wp_enqueue_style('ep-editor'); |
| 440 | } |
| 441 | |
| 442 | |
| 443 | public function enqueue_minified_css() { |
| 444 | $direction_suffix = is_rtl() ? '.rtl' : ''; |
| 445 | |
| 446 | $upload_dir = $this->get_upload_dir() . 'css/ep-styles.css'; |
| 447 | $version = get_option('element-pack-minified-asset-manager-version'); |
| 448 | |
| 449 | if (element_pack_is_asset_optimization_enabled() && file_exists($upload_dir)) { |
| 450 | $upload_url = $this->get_upload_url() . 'css/ep-styles.css'; |
| 451 | wp_register_style('ep-styles', $upload_url, [], $version); |
| 452 | } else { |
| 453 | wp_register_style('ep-styles', BDTEP_URL . 'assets/css/ep-styles' . $direction_suffix . '.css', [], BDTEP_VER); |
| 454 | wp_register_style('ep-font', BDTEP_ASSETS_URL . 'css/ep-font' . $direction_suffix . '.css', [], BDTEP_VER); |
| 455 | } |
| 456 | |
| 457 | if (element_pack_is_asset_optimization_enabled()) { |
| 458 | wp_enqueue_style('ep-styles'); |
| 459 | } |
| 460 | |
| 461 | /** |
| 462 | * Must load into Editor for Extension Support |
| 463 | * |
| 464 | * by U-011 |
| 465 | */ |
| 466 | if ( Element_Pack_Loader::elementor()->preview->is_preview_mode() || Element_Pack_Loader::elementor()->editor->is_edit_mode() ) { |
| 467 | wp_enqueue_style( 'ep-styles' ); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | public function enqueue_minified_js() { |
| 472 | $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
| 473 | |
| 474 | $upload_dir = $this->get_upload_dir() . 'js/ep-scripts.js'; |
| 475 | $version = get_option('element-pack-minified-asset-manager-version'); |
| 476 | |
| 477 | if (element_pack_is_asset_optimization_enabled() && file_exists($upload_dir)) { |
| 478 | $upload_url = $this->get_upload_url() . 'js/ep-scripts.js'; |
| 479 | |
| 480 | wp_register_script('ep-scripts', $upload_url, ['elementor-frontend'], $version, true); |
| 481 | } else { |
| 482 | wp_register_script('ep-scripts', BDTEP_URL . 'assets/js/ep-scripts' . $suffix . '.js', ['elementor-frontend'], BDTEP_VER, true); |
| 483 | } |
| 484 | |
| 485 | if (element_pack_is_asset_optimization_enabled()) { |
| 486 | wp_enqueue_script('ep-scripts'); |
| 487 | } |
| 488 | /** |
| 489 | * Must load into Editor for Extension Support |
| 490 | * |
| 491 | * by U-011 |
| 492 | */ |
| 493 | if ( Element_Pack_Loader::elementor()->preview->is_preview_mode() || Element_Pack_Loader::elementor()->editor->is_edit_mode() ) { |
| 494 | wp_enqueue_script( 'ep-scripts' ); |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | /** |
| 499 | * To load notice JS file |
| 500 | */ |
| 501 | |
| 502 | public function enqueue_admin_scripts() { |
| 503 | wp_enqueue_style( 'ep-notice-css', BDTEP_ADMIN_URL . 'assets/css/ep-notice.css', [], BDTEP_VER, 'all' ); |
| 504 | wp_enqueue_script( 'ep-notice-js', BDTEP_ADMIN_URL . 'assets/js/ep-notice.js', [ 'jquery' ], BDTEP_VER, true ); |
| 505 | |
| 506 | $script_config = [ |
| 507 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 508 | 'nonce' => wp_create_nonce( 'element-pack' ), |
| 509 | ]; |
| 510 | wp_localize_script( 'ep-notice-js', 'ElementPackNoticeConfig', $script_config ); |
| 511 | } |
| 512 | |
| 513 | /** |
| 514 | * Callback to shortcodes template |
| 515 | * @param array $atts attributes for shortcode. |
| 516 | */ |
| 517 | public function shortcode_template($atts) { |
| 518 | |
| 519 | $atts = shortcode_atts( |
| 520 | array( |
| 521 | 'id' => '', |
| 522 | ), |
| 523 | $atts, |
| 524 | 'rooten_custom_template' |
| 525 | ); |
| 526 | |
| 527 | $id = !empty($atts['id']) ? intval($atts['id']) : ''; |
| 528 | |
| 529 | if (empty($id)) { |
| 530 | return ''; |
| 531 | } |
| 532 | |
| 533 | return self::elementor()->frontend->get_builder_content_for_display($id); |
| 534 | } |
| 535 | |
| 536 | |
| 537 | /** |
| 538 | * Add element_pack_ajax_login() function with wp_ajax_nopriv_ function |
| 539 | * @return [type] [description] |
| 540 | */ |
| 541 | public function element_pack_ajax_login_init() { |
| 542 | // Enable the user with no privileges to run element_pack_ajax_login() in AJAX |
| 543 | add_action('wp_ajax_nopriv_element_pack_ajax_login', [$this, "element_pack_ajax_login"]); |
| 544 | } |
| 545 | |
| 546 | /** |
| 547 | * For ajax login |
| 548 | * @return [type] [description] |
| 549 | */ |
| 550 | public function element_pack_ajax_login() { |
| 551 | // First check the nonce, if it fails the function will break |
| 552 | check_ajax_referer('ajax-login-nonce', 'bdt-user-login-sc'); |
| 553 | |
| 554 | // Nonce is checked, get the POST data and sign user on |
| 555 | $access_info = []; |
| 556 | $access_info['user_login'] = !empty($_POST['user_login']) ? $_POST['user_login'] : ""; |
| 557 | $access_info['user_password'] = !empty($_POST['user_password']) ? $_POST['user_password'] : ""; |
| 558 | $access_info['remember'] = !empty($_POST['rememberme']) ? true : false; |
| 559 | $user_signon = wp_signon($access_info, false); |
| 560 | |
| 561 | if (!is_wp_error($user_signon)) { |
| 562 | echo wp_json_encode( |
| 563 | [ |
| 564 | 'loggedin' => true, |
| 565 | 'message' => esc_html_x('Login successful, Redirecting...', 'User Login and Register', 'bdthemes-element-pack') |
| 566 | ] |
| 567 | ); |
| 568 | } else { |
| 569 | echo wp_json_encode( |
| 570 | [ |
| 571 | 'loggedin' => false, |
| 572 | 'message' => esc_html_x('Oops! Wrong username or password!', 'User Login and Register', 'bdthemes-element-pack') |
| 573 | ] |
| 574 | ); |
| 575 | } |
| 576 | |
| 577 | die(); |
| 578 | } |
| 579 | |
| 580 | |
| 581 | |
| 582 | // Load WPML compatibility instance |
| 583 | public function wpml_compatiblity() { |
| 584 | return Element_Pack_WPML::get_instance(); |
| 585 | } |
| 586 | |
| 587 | |
| 588 | /** |
| 589 | * initialize the category |
| 590 | * @return void |
| 591 | */ |
| 592 | public function element_pack_init() { |
| 593 | |
| 594 | $this->_modules_manager = new Manager(); |
| 595 | |
| 596 | do_action('bdthemes_element_pack/init'); |
| 597 | } |
| 598 | |
| 599 | function ElementPack_Json_File_Import_register_controls() { |
| 600 | $controls_manager = Plugin::$instance->controls_manager; |
| 601 | $controls_manager->register(new ElementPack_JSON_File_Upload_Control()); |
| 602 | } |
| 603 | |
| 604 | |
| 605 | |
| 606 | function ElementPack_FB_Token_Register_Controls() { |
| 607 | |
| 608 | $controls_manager = Plugin::$instance->controls_manager; |
| 609 | $controls_manager->register(new ElementPack_FB_Access_Token_Generator_Control()); |
| 610 | } |
| 611 | |
| 612 | /** |
| 613 | * initialize the category |
| 614 | * @return [type] [description] |
| 615 | */ |
| 616 | public function element_pack_category_register() { |
| 617 | |
| 618 | $elementor = Plugin::$instance; |
| 619 | |
| 620 | // Add element category in panel |
| 621 | $elementor->elements_manager->add_category(BDTEP_SLUG, ['title' => BDTEP_TITLE, 'icon' => 'font']); |
| 622 | } |
| 623 | |
| 624 | public function element_pack_svg_support() { |
| 625 | |
| 626 | return SVG_Support::get_instance(); |
| 627 | } |
| 628 | |
| 629 | private function setup_hooks() { |
| 630 | |
| 631 | add_action('elementor/controls/register', [$this, 'ElementPack_Json_File_Import_register_controls']); |
| 632 | add_action('elementor/controls/register', [$this, 'ElementPack_FB_Token_Register_Controls']); |
| 633 | add_action('elementor/elements/categories_registered', [$this, 'element_pack_category_register']); |
| 634 | add_action('elementor/init', [$this, 'element_pack_init']); |
| 635 | |
| 636 | add_action('elementor/editor/after_enqueue_styles', [$this, 'enqueue_editor_styles']); |
| 637 | |
| 638 | add_action('wp_enqueue_scripts', [$this, 'register_site_styles'], 99999); |
| 639 | add_action('wp_enqueue_scripts', [$this, 'register_site_scripts'], 99999); |
| 640 | add_action('wp_enqueue_scripts', [$this, 'enqueue_site_styles'], 99999); |
| 641 | add_action('wp_enqueue_scripts', [$this, 'enqueue_site_scripts'], 99999); |
| 642 | |
| 643 | add_action('elementor/preview/enqueue_styles', [$this, 'enqueue_preview_styles']); |
| 644 | add_action('elementor/editor/after_enqueue_scripts', [$this, 'enqueue_editor_scripts']); |
| 645 | |
| 646 | |
| 647 | // For frontend css load |
| 648 | add_action('elementor/frontend/after_enqueue_styles', [$this, 'enqueue_minified_css']); |
| 649 | add_action('elementor/frontend/after_enqueue_scripts', [$this, 'enqueue_minified_js']); |
| 650 | |
| 651 | |
| 652 | add_shortcode('rooten_custom_template', [$this, 'shortcode_template']); |
| 653 | |
| 654 | |
| 655 | // When user not login add this action |
| 656 | if (!is_user_logged_in()) { |
| 657 | add_action('elementor/init', [$this, 'element_pack_ajax_login_init']); |
| 658 | } |
| 659 | |
| 660 | // load WordPress dashboard scripts |
| 661 | add_action('admin_init', [$this, 'enqueue_admin_scripts']); |
| 662 | } |
| 663 | |
| 664 | /** |
| 665 | * Element_Pack_Loader constructor. |
| 666 | */ |
| 667 | private function __construct() { |
| 668 | // Register class automatically |
| 669 | spl_autoload_register([$this, 'autoload']); |
| 670 | // Include some backend files |
| 671 | $this->_includes(); |
| 672 | |
| 673 | // Finally hooked up all things here |
| 674 | $this->setup_hooks(); |
| 675 | |
| 676 | $this->element_pack_svg_support()->init(); |
| 677 | |
| 678 | $this->wpml_compatiblity()->init(); |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | if (!defined('BDTEP_TESTS')) { |
| 683 | // In tests we run the instance manually. |
| 684 | Element_Pack_Loader::instance(); |
| 685 | } |
| 686 | // handy function for push data |
| 687 | function element_pack_config() { |
| 688 | return Element_Pack_Loader::instance(); |
| 689 | } |
| 690 |