PluginProbe
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 2.0.9.2
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v2.0.9.2
4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 All 183 releases
elementskit-lite / plugin.php

plugin.php in ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor 2.0.9.2, at plugin.php

260 lines 8.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ElementsKit_Lite;
3
4 defined( 'ABSPATH' ) || exit;
5
6
7 /**
8 * ElementsKit - the God class.
9 * Initiate all necessary classes, hooks, configs.
10 *
11 * @since 1.0.0
12 */
13 class Plugin{
14
15
16 /**
17 * The plugin instance.
18 *
19 * @since 1.0.0
20 * @access public
21 * @static
22 *
23 * @var Plugin
24 */
25 public static $instance = null;
26
27 /**
28 * Construct the plugin object.
29 *
30 * @since 1.0.0
31 * @access public
32 */
33 public function __construct() {
34
35 // Enqueue frontend scripts.
36 add_action( 'wp_enqueue_scripts', [$this, 'enqueue_frontend'] );
37
38 // Enqueue admin scripts.
39 add_action( 'admin_enqueue_scripts', [$this, 'enqueue_admin'] );
40
41 // Enqueue inline scripts
42 Core\Build_Inline_Scripts::instance();
43
44 // Register plugin settings pages
45 Libs\Framework\Attr::instance();
46
47 // Register default widgets
48 Core\Build_Widgets::instance();
49
50 // Register default modules
51 Core\Build_Modules::instance();
52
53 // Register ElementsKit supported widgets to Elementor from 3rd party plugins.
54 add_action( 'elementor/widgets/widgets_registered', [$this, 'register_widgets'], 1050);
55
56 // Register wpml compability module
57 Compatibility\Wpml\Init::instance();
58 Compatibility\Conflicts\Init::instance();
59
60 // Register data migration class
61 //Compatibility\Data_Migration\Translate_File::instance()->init();
62 //Libs\Xs_Migration\Initiator::instance()->init();
63
64 add_action('wp_head', [$this, 'add_meta_for_search_excluded']);
65
66 // Add banner class
67 add_action('admin_head', function() {
68
69 $filter_string = ''; // elementskit,metform-pro
70 $filter_string .= ((!in_array('elementskit/elementskit.php', apply_filters('active_plugins', get_option('active_plugins')))) ? '' : ',elementskit');
71 $filter_string .= (!class_exists('\MetForm\Plugin') ? '' : ',metform');
72 $filter_string .= (!class_exists('\MetForm_Pro\Plugin') ? '' : ',metform-pro');
73
74 \Wpmet\Libs\Banner\Init::instance()
75 ->set_text_domain('elementskit-lite')
76 // ->is_test(true)
77 ->set_filter(ltrim($filter_string, ','))
78 ->set_api_url('https://api.wpmet.com/public/jhanda/index.php')
79 ->set_plugin_screens('edit-elementskit_template')
80 ->set_plugin_screens('toplevel_page_elementskit')
81 ->call();
82 });
83
84 // Adding pro lebel
85 if(\ElementsKit_Lite::package_type() == 'free'){
86 new Libs\Pro_Label\Init();
87 }
88
89 }
90
91 /**
92 * Check the admin screen and show the rating notice if eligible
93 *
94 * @access private
95 * @return boolean
96 */
97 private function should_show_rating_notice() {
98
99 if(\ElementsKit_Lite::package_type() == 'free'){
100 return true;
101 }
102
103 if( !function_exists('get_current_screen') ) {
104 return false;
105 }
106
107 $current_screen = (get_current_screen())->base;
108 $current_post_type = (get_current_screen())->post_type;
109 $eligible_post_type = ['elementskit_template'];
110 $eligible_screens = ['plugins', 'dashboard', 'elementskit', 'themes'];
111
112 if (in_array($current_post_type, $eligible_post_type)){
113 return true;
114 }
115
116
117 if (in_array($current_screen, $eligible_screens)){
118 return true;
119 }
120
121
122 return false;
123 }
124
125 /**
126 * Enqueue scripts
127 *
128 * Enqueue js and css to frontend.
129 *
130 * @since 1.0.0
131 * @access public
132 */
133 public function enqueue_frontend(){
134 wp_enqueue_style( 'elementor-icons-ekiticons', \ElementsKit_Lite::module_url() . 'controls/assets/css/ekiticons.css', \ElementsKit_Lite::version() );
135 wp_enqueue_script( 'elementskit-framework-js-frontend', \ElementsKit_Lite::lib_url() . 'framework/assets/js/frontend-script.js', ['jquery'], \ElementsKit_Lite::version(), true );
136 }
137
138 /**
139 * Enqueue scripts
140 *
141 * Enqueue js and css to admin.
142 *
143 * @since 1.0.0
144 * @access public
145 */
146 public function enqueue_admin(){
147 $screen = get_current_screen();
148
149 if(!in_array($screen->id, ['nav-menus', 'toplevel_page_elementskit', 'edit-elementskit_template', 'elementskit_page_elementskit-license'])){
150 return;
151 }
152
153 wp_register_style( 'fontawesome', \ElementsKit_Lite::widget_url() . 'init/assets/css/font-awesome.min.css', \ElementsKit_Lite::version() );
154 wp_register_style( 'elementskit-font-css-admin', \ElementsKit_Lite::module_url() . 'controls/assets/css/ekiticons.css', \ElementsKit_Lite::version() );
155 wp_register_style( 'elementskit-lib-css-admin', \ElementsKit_Lite::lib_url() . 'framework/assets/css/framework.css', \ElementsKit_Lite::version() );
156 wp_register_style( 'elementskit-init-css-admin', \ElementsKit_Lite::lib_url() . 'framework/assets/css/admin-style.css', \ElementsKit_Lite::version() );
157 wp_register_style( 'elementskit-init-css-admin-ems', \ElementsKit_Lite::lib_url() . 'framework/assets/css/admin-style-ems-dev.css', \ElementsKit_Lite::version() );
158
159 wp_enqueue_style( 'fontawesome' );
160 wp_enqueue_style( 'elementskit-font-css-admin' );
161 wp_enqueue_style( 'elementskit-lib-css-admin' );
162 wp_enqueue_style( 'elementskit-lib-css-admin' );
163 wp_enqueue_style( 'elementskit-init-css-admin' );
164 wp_enqueue_style( 'elementskit-init-css-admin-ems' );
165
166 wp_enqueue_script( 'ekit-admin-core', \ElementsKit_Lite::lib_url() . 'framework/assets/js/ekit-admin-core.js', ['jquery'], \ElementsKit_Lite::version(), true );
167
168 $data['rest_url'] = get_rest_url();
169 $data['nonce'] = wp_create_nonce('wp_rest');
170
171 wp_localize_script('ekit-admin-core', 'rest_config', $data);
172 }
173
174 /**
175 * Control registrar.
176 *
177 * Register the custom controls for Elementor
178 * using `elementskit/widgets/widgets_registered` action.
179 *
180 * @since 1.0.0
181 * @access public
182 */
183 public function register_control($widgets_manager){
184 do_action('elementskit/widgets/widgets_registered', $widgets_manager);
185 }
186
187
188 /**
189 * Widget registrar.
190 *
191 * Retrieve all the registered widgets
192 * using `elementor/widgets/widgets_registered` action.
193 *
194 * @since 1.0.0
195 * @access public
196 */
197 public function register_widgets($widgets_manager){
198 do_action('elementskit/widgets/widgets_registered', $widgets_manager);
199 }
200
201 /**
202 * Excluding ElementsKit template and megamenu content from search engine.
203 * See - https://wordpress.org/support/topic/google-is-indexing-elementskit-content-as-separate-pages/
204 *
205 * @since 1.4.5
206 * @access public
207 */
208 public function add_meta_for_search_excluded(){
209 if ( in_array(get_post_type(),
210 ['elementskit_widget', 'elementskit_template', 'elementskit_content'])
211 ){
212 echo '<meta name="robots" content="noindex,nofollow" />', "\n";
213 }
214 }
215
216 /**
217 * Autoloader.
218 *
219 * ElementsKit autoloader loads all the classes needed to run the plugin.
220 *
221 * @since 1.0.0
222 * @access private
223 */
224 private static function registrar_autoloader() {
225 require_once \ElementsKit_Lite::plugin_dir() . '/autoloader.php';
226 Autoloader::run();
227 }
228
229 /**
230 * Instance.
231 *
232 * Ensures only one instance of the plugin class is loaded or can be loaded.
233 *
234 * @since 1.0.0
235 * @access public
236 * @static
237 *
238 * @return Plugin An instance of the class.
239 */
240 public static function instance() {
241 if ( is_null( self::$instance ) ) {
242 // Call the method for ElementsKit lite autoloader.
243 self::registrar_autoloader();
244
245 do_action( 'elementskit_lite/before_loaded' );
246
247 // Fire when ElementsKit instance.
248 self::$instance = new self();
249
250 do_action( 'elementskit/loaded' ); // legacy support
251 do_action( 'elementskit_lite/after_loaded' );
252 }
253
254 return self::$instance;
255 }
256 }
257
258 // Run the instance.
259 Plugin::instance();
260