PluginProbe
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 2.2.4
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v2.2.4
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.2.4, at plugin.php

337 lines 11.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
5
6 defined( 'ABSPATH' ) || exit;
7
8
9 /**
10 * ElementsKit - the God class.
11 * Initiate all necessary classes, hooks, configs.
12 *
13 * @since 1.0.0
14 */
15 class Plugin{
16
17
18 /**
19 * The plugin instance.
20 *
21 * @since 1.0.0
22 * @access public
23 * @static
24 *
25 * @var Plugin
26 */
27 public static $instance = null;
28
29 /**
30 * Construct the plugin object.
31 *
32 * @since 1.0.0
33 * @access public
34 */
35 public function __construct() {
36
37 // Enqueue frontend scripts.
38 add_action( 'wp_enqueue_scripts', [$this, 'enqueue_frontend'] );
39
40 // migrate old settings db to new format
41 new Compatibility\Data_Migration\Settings_Db();
42
43 // Enqueue admin scripts.
44 add_action( 'admin_enqueue_scripts', [$this, 'enqueue_admin'] );
45
46 // Enqueue inline scripts
47 Core\Build_Inline_Scripts::instance();
48
49 // Register plugin settings pages
50 Libs\Framework\Attr::instance();
51
52 // Register default widgets
53 Core\Build_Widgets::instance();
54
55 // Register default modules
56 Core\Build_Modules::instance();
57
58 add_action('wp_head', [$this, 'add_meta_for_search_excluded']);
59
60 // Register ElementsKit supported widgets to Elementor from 3rd party plugins.
61 add_action( 'elementor/widgets/widgets_registered', [$this, 'register_widgets'], 1050);
62
63 // Register wpml compability module
64 Compatibility\Wpml\Init::instance();
65 Compatibility\Conflicts\Init::instance();
66
67 $is_pro_active = in_array('elementskit/elementskit.php', apply_filters('active_plugins', get_option('active_plugins')));
68
69 $filter_string = ''; // elementskit,metform-pro
70 $filter_string .= ((!$is_pro_active) ? '' : ',elementskit');
71 $filter_string .= (!class_exists('\MetForm\Plugin') ? '' : ',metform');
72 $filter_string .= (!class_exists('\MetForm_Pro\Plugin') ? '' : ',metform-pro');
73
74
75 if(Libs\Framework\Classes\Utils::instance()->get_settings('ekit_user_consent_for_banner', 'yes') == 'yes'){
76 /**
77 * Show WPMET stories widget in dashboard
78 */
79 \Wpmet\Libs\Stories::instance('elementskit-lite')
80 // ->is_test(true)
81 ->set_filter($filter_string)
82 ->set_plugin('ElementsKit', 'https://wpmet.com/plugin/elementskit/')
83 ->set_api_url('https://api.wpmet.com/public/stories/')
84 ->call();
85
86
87 /**
88 * Show WPMET banner (codename: jhanda)
89 */
90 \Wpmet\Libs\Banner::instance('elementskit-lite')
91 // ->is_test(true)
92 ->set_filter(ltrim($filter_string, ','))
93 ->set_api_url('https://api.wpmet.com/public/jhanda')
94 ->set_plugin_screens('edit-elementskit_template')
95 ->set_plugin_screens('toplevel_page_elementskit')
96 ->call();
97
98
99 /**
100 * Ask for rating
101 * A rating notice will appear depends on
102 * @set_first_appear_day methods
103 */
104 \Wpmet\Libs\Rating::instance('elementskit-lite')
105 ->set_plugin('ElementsKit', 'https://wpmet.com/wordpress.org/rating/elementskit')
106 ->set_plugin_logo('https://ps.w.org/elementskit-lite/assets/icon-128x128.png','width:150px !important')
107 ->set_allowed_screens('edit-elementskit_template')
108 ->set_allowed_screens('toplevel_page_elementskit')
109 ->set_allowed_screens('elementskit_page_elementskit-lite_get_help')
110 ->set_priority(10)
111 ->set_first_appear_day(7)
112 ->set_condition(true)
113 ->call();
114
115 }
116
117
118 /**
119 * Show go Premium menu
120 */
121 \Wpmet\Libs\Pro_Awareness::instance('elementskit-lite')
122 ->set_parent_menu_slug('elementskit')
123 ->set_plugin_file('elementskit-lite/elementskit-lite.php')
124 ->set_pro_link(
125 ((\ElementsKit_Lite::package_type() != 'free') ? '' : 'https://wpmet.com/elementskit-pricing')
126 )
127 ->set_default_grid_thumbnail(\ElementsKit_Lite::lib_url() . 'pro-awareness/assets/support.png')
128
129 ->set_page_grid([
130 'url' => 'https://wpmet.com/fb-group',
131 'title' => 'Join the Community',
132 'thumbnail' => \ElementsKit_Lite::lib_url() . 'pro-awareness/assets/community.png',
133 ])
134 ->set_page_grid([
135 'url' => 'https://www.youtube.com/playlist?list=PL3t2OjZ6gY8MVnyA4OLB6qXb77-roJOuY',
136 'title' => 'Video Tutorials',
137 'thumbnail' => \ElementsKit_Lite::lib_url() . 'pro-awareness/assets/videos.png',
138 ])
139 ->set_page_grid([
140 'url' => 'https://wpmet.com/plugin/elementskit/roadmaps#ideas',
141 'title' => 'Request a feature',
142 'thumbnail' => \ElementsKit_Lite::lib_url() . 'pro-awareness/assets/request.png',
143 ])
144 ->set_plugin_row_meta('Documentation','https://wpmet.com/elementskit-docs', ['target'=>'_blank'])
145 ->set_plugin_row_meta('Facebook Community','https://wpmet.com/fb-group', ['target'=>'_blank'])
146 ->set_plugin_row_meta('Rate the plugin �
147
148
149
150
151 ','https://wordpress.org/support/plugin/elementskit-lite/reviews/#new-post', ['target'=>'_blank'])
152 ->set_plugin_action_link('Settings',admin_url() . 'admin.php?page=elementskit')
153 ->set_plugin_action_link(($is_pro_active ? '' : 'Go Premium'),'https://wpmet.com/plugin/elementskit', ['target'=>'_blank', 'style' => 'color: #FCB214; font-weight: bold;'])
154 ->call();
155
156
157
158 // Adding pro lebel
159 if(\ElementsKit_Lite::package_type() == 'free'){
160 new Libs\Pro_Label\Init();
161 }
162
163 }
164
165 /**
166 * Check the admin screen and show the rating notice if eligible
167 *
168 * @access private
169 * @return boolean
170 */
171 private function should_show_rating_notice() {
172
173 if(\ElementsKit_Lite::package_type() == 'free'){
174 return true;
175 }
176
177 if( !function_exists('get_current_screen') ) {
178 return false;
179 }
180
181 $current_screen = (get_current_screen())->base;
182 $current_post_type = (get_current_screen())->post_type;
183 $eligible_post_type = ['elementskit_template'];
184 $eligible_screens = ['plugins', 'dashboard', 'elementskit', 'themes'];
185
186 if (in_array($current_post_type, $eligible_post_type)){
187 return true;
188 }
189
190
191 if (in_array($current_screen, $eligible_screens)){
192 return true;
193 }
194
195
196 return false;
197 }
198
199 /**
200 * Enqueue scripts
201 *
202 * Enqueue js and css to frontend.
203 *
204 * @since 1.0.0
205 * @access public
206 */
207 public function enqueue_frontend(){
208 wp_enqueue_script( 'elementskit-framework-js-frontend', \ElementsKit_Lite::lib_url() . 'framework/assets/js/frontend-script.js', ['jquery'], \ElementsKit_Lite::version(), true );
209 }
210
211 /**
212 * Enqueue scripts
213 *
214 * Enqueue js and css to admin.
215 *
216 * @since 1.0.0
217 * @access public
218 */
219 public function enqueue_admin(){
220 $screen = get_current_screen();
221
222 if(!in_array($screen->id, ['nav-menus', 'toplevel_page_elementskit', 'edit-elementskit_template', 'elementskit_page_elementskit-license'])){
223 return;
224 }
225
226 wp_register_style( 'fontawesome', \ElementsKit_Lite::widget_url() . 'init/assets/css/font-awesome.min.css', \ElementsKit_Lite::version() );
227 wp_register_style( 'elementskit-font-css-admin', \ElementsKit_Lite::module_url() . 'elementskit-icon-pack/assets/css/ekiticons.css', \ElementsKit_Lite::version() );
228 wp_register_style( 'elementskit-lib-css-admin', \ElementsKit_Lite::lib_url() . 'framework/assets/css/framework.css', \ElementsKit_Lite::version() );
229 wp_register_style( 'elementskit-init-css-admin', \ElementsKit_Lite::lib_url() . 'framework/assets/css/admin-style.css', \ElementsKit_Lite::version() );
230 wp_register_style( 'elementskit-init-css-admin-ems', \ElementsKit_Lite::lib_url() . 'framework/assets/css/admin-style-ems-dev.css', \ElementsKit_Lite::version() );
231
232 wp_enqueue_style( 'fontawesome' );
233 wp_enqueue_style( 'elementskit-font-css-admin' );
234 wp_enqueue_style( 'elementskit-lib-css-admin' );
235 wp_enqueue_style( 'elementskit-lib-css-admin' );
236 wp_enqueue_style( 'elementskit-init-css-admin' );
237 wp_enqueue_style( 'elementskit-init-css-admin-ems' );
238
239 wp_enqueue_script( 'ekit-admin-core', \ElementsKit_Lite::lib_url() . 'framework/assets/js/ekit-admin-core.js', ['jquery'], \ElementsKit_Lite::version(), true );
240
241 $data['rest_url'] = get_rest_url();
242 $data['nonce'] = wp_create_nonce('wp_rest');
243
244 wp_localize_script('ekit-admin-core', 'rest_config', $data);
245
246 wp_localize_script('ekit-admin-core', 'ekit_ajax_var', array(
247 'nonce' => wp_create_nonce('ajax-nonce')
248 ));
249 }
250
251 /**
252 * Control registrar.
253 *
254 * Register the custom controls for Elementor
255 * using `elementskit/widgets/widgets_registered` action.
256 *
257 * @since 1.0.0
258 * @access public
259 */
260 public function register_control($widgets_manager){
261 do_action('elementskit/widgets/widgets_registered', $widgets_manager);
262 }
263
264
265 /**
266 * Widget registrar.
267 *
268 * Retrieve all the registered widgets
269 * using `elementor/widgets/widgets_registered` action.
270 *
271 * @since 1.0.0
272 * @access public
273 */
274 public function register_widgets($widgets_manager){
275 do_action('elementskit/widgets/widgets_registered', $widgets_manager);
276 }
277
278 /**
279 * Excluding ElementsKit template and megamenu content from search engine.
280 * See - https://wordpress.org/support/topic/google-is-indexing-elementskit-content-as-separate-pages/
281 *
282 * @since 1.4.5
283 * @access public
284 */
285 public function add_meta_for_search_excluded(){
286 if ( in_array(get_post_type(),
287 ['elementskit_widget', 'elementskit_template', 'elementskit_content'])
288 ){
289 echo '<meta name="robots" content="noindex,nofollow" />', "\n";
290 }
291 }
292
293 /**
294 * Autoloader.
295 *
296 * ElementsKit autoloader loads all the classes needed to run the plugin.
297 *
298 * @since 1.0.0
299 * @access private
300 */
301 private static function registrar_autoloader() {
302 require_once \ElementsKit_Lite::plugin_dir() . '/autoloader.php';
303 Autoloader::run();
304 }
305
306 /**
307 * Instance.
308 *
309 * Ensures only one instance of the plugin class is loaded or can be loaded.
310 *
311 * @since 1.0.0
312 * @access public
313 * @static
314 *
315 * @return Plugin An instance of the class.
316 */
317 public static function instance() {
318 if ( is_null( self::$instance ) ) {
319 // Call the method for ElementsKit lite autoloader.
320 self::registrar_autoloader();
321
322 do_action( 'elementskit_lite/before_loaded' );
323
324 // Fire when ElementsKit instance.
325 self::$instance = new self();
326
327 do_action( 'elementskit/loaded' ); // legacy support
328 do_action( 'elementskit_lite/after_loaded' );
329 }
330
331 return self::$instance;
332 }
333 }
334
335 // Run the instance.
336 Plugin::instance();
337