PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.2.7
Easy Elements for Elementor – Addons & Website Templates v1.2.7
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / includes / Template_Library / Easyel_Templates_Library.php

Easyel_Templates_Library.php in Easy Elements for Elementor – Addons & Website Templates 1.2.7, at includes/Template_Library/Easyel_Templates_Library.php

121 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Easyel\EasyElements\Template_Library;
3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
5 class Easyel_Templates_Library {
6
7 private $assets_url;
8 private $rest_url;
9
10 const SITE_URL = 'https://wpeasyelements.com/demotemplate/';
11
12 protected static $instance = null;
13
14 public function __construct() {
15
16 // get current module's url.
17 $this->assets_url = EASYELEMENTS_DIR_URL . 'includes/Template_Library/assets/';
18
19 // get current module's url.
20 $this->rest_url = self::SITE_URL . '/wp-json/rtTemplates/v1/templates';
21
22 // print variables on footer.
23 add_action( 'elementor/editor/footer', array( $this, 'easy_editor_footer_script' ) );
24
25 // enqueue editor js for elementor.
26 add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'easy_editor_scripts' ), 1 );
27
28 // enqueue editor css.
29 add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'easy_editor_styles' ) );
30
31 // enqueue modal's preview css.
32 add_action( 'elementor/preview/enqueue_styles', array( $this, 'easy_preview_styles' ) );
33
34 }
35
36 /**
37 * Get instance
38 */
39 public static function get_instance() {
40 if ( null === self::$instance ) {
41 self::$instance = new self();
42 }
43 return self::$instance;
44 }
45
46 public function easy_editor_scripts() {
47 wp_enqueue_script( 'easy-elements-template-library-script', $this->assets_url . 'js/easy-template-library.js', array( 'jquery', 'wp-element' ), EASYELEMENTS_VER, true );
48
49 wp_localize_script('easy-elements-template-library-script', 'rtElementsTemplatesajax', [
50 'previewBaseUrl' => "https://wpeasyelements.com/demotemplate/",
51 'ajaxUrl' => admin_url('admin-ajax.php'),
52 ]);
53
54 wp_enqueue_script( 'easy-elements-template-library-isotope-script', $this->assets_url . 'js/isotope.pkgd.min.js', array( 'jquery', 'wp-element' ), EASYELEMENTS_VER, true );
55 }
56
57 public function easy_editor_styles() {
58 wp_enqueue_style( 'easy-elements-template-library-style', $this->assets_url . 'css/easy-elements-template-library.min.css', array(), EASYELEMENTS_VER );
59 }
60
61 public function easy_preview_styles() {
62 wp_enqueue_style( 'easy-elements-template-library-preview-style', $this->assets_url . 'css/preview.css', array(), EASYELEMENTS_VER );
63 }
64
65 public function easy_editor_footer_script() {
66
67 $license_status = 'invalid';
68
69 $pro_version = easyel_get_pro_clean_version();
70
71 if (
72 $pro_version &&
73 version_compare( $pro_version, '1.0.8', '>=' )
74 ) {
75
76 if (
77 did_action( 'plugins_loaded' ) &&
78 class_exists( '\EasyElements_Elementor\Pro\Licenses\EasyelLicense' )
79 ) {
80 $manager = \EasyElements_Elementor\Pro\Licenses\EasyelLicense::get_instance();
81
82 if ( method_exists( $manager, 'check_license_validity' ) ) {
83 $license_status = $manager->check_license_validity();
84 }
85 }
86
87 } else {
88 if ( did_action( 'plugins_loaded' ) && class_exists( '\Easyel_License_Manager' ) ) {
89 $license_manager = new \Easyel_License_Manager();
90
91 if ( $license_manager && method_exists( $license_manager, 'check_license_validity' ) ) {
92 $license_status = $license_manager->check_license_validity();
93 }
94 }
95 }
96
97 $is_pro = class_exists('Easy_Elements_Pro');
98 $license_page_url = admin_url('admin.php?page=easy-elements-license');
99
100 ?>
101 <script type="text/javascript">
102
103 var rtElementsTemplatesManager = {
104 "activeTab": "sections",
105 "nonce": "<?php echo esc_attr(wp_create_nonce( 'wp_rest' )); ?>",
106 "buttonIcon": "<?php echo esc_url( $this->assets_url . 'img/easy-template-logo.png' ); ?>",
107 "logoUrl": "<?php echo esc_url( $this->assets_url . 'img/easy-template-logo-sm2.webp' ); ?>",
108 "headerLogoUrl": "<?php echo esc_url( $this->assets_url . 'img/easy-template-logo.png' ); ?>",
109 "bannerAdUrl": "<?php echo esc_url( $this->assets_url . 'img/easy-templates-banner-ad2.webp' ); ?>",
110 "apiUrl": "<?php echo esc_url( $this->rest_url); ?>",
111 "thumbnailPlaceholderUrl": "<?php echo esc_url( $this->assets_url . 'img/about-img.jpg' ); ?>",
112 "templatesContainer": document.querySelector('#rtElementsTemplatesLibrary #elementor-template-library-templates-container'),
113 "licenseStatus": "<?php echo esc_js($license_status); ?>",
114 "proActive": "<?php echo $is_pro ? true : false; ?>",
115 "licensePageUrl": "<?php echo esc_url($license_page_url); ?>"
116 };
117
118 </script>
119 <?php
120 }
121 }