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

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