PluginProbe
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 2.2.2
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v2.2.2
4.0.5 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 All 184 releases
elementskit-lite / plugin.php

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

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