elementskit-lite
Last commit date
compatibility
5 years ago
core
5 years ago
helpers
5 years ago
libs
5 years ago
modules
5 years ago
widgets
5 years ago
autoloader.php
6 years ago
core.php
5 years ago
elementskit-lite.php
5 years ago
handler.php
5 years ago
license.txt
5 years ago
readme.txt
5 years ago
core.php
394 lines
| 1 | <?php |
| 2 | |
| 3 | defined( 'ABSPATH' ) || exit; |
| 4 | |
| 5 | if(!class_exists('ElementsKit')): |
| 6 | final class ElementsKit{ |
| 7 | /** |
| 8 | * Plugin Version |
| 9 | * |
| 10 | * @since 1.0.0 |
| 11 | * @var string The plugin version. |
| 12 | */ |
| 13 | const VERSION = '1.5.7'; |
| 14 | |
| 15 | /** |
| 16 | * Package type |
| 17 | * |
| 18 | * @since 1.1.0 |
| 19 | * @var string The plugin purchase type [pro/ free]. |
| 20 | */ |
| 21 | const PACKAGE_TYPE = 'free'; |
| 22 | |
| 23 | /** |
| 24 | * Product ID |
| 25 | * |
| 26 | * @since 1.2.6 |
| 27 | * @var string The plugin ID in our server. |
| 28 | */ |
| 29 | const PRODUCT_ID = '9'; |
| 30 | |
| 31 | /** |
| 32 | * Minimum Elementor Version |
| 33 | * |
| 34 | * @since 1.0.0 |
| 35 | * @var string Minimum Elementor version required to run the plugin. |
| 36 | */ |
| 37 | |
| 38 | const MINIMUM_ELEMENTOR_VERSION = '2.4.0'; |
| 39 | |
| 40 | /** |
| 41 | * Minimum PHP Version |
| 42 | * |
| 43 | * @since 1.0.0 |
| 44 | * @var string Minimum PHP version required to run the plugin. |
| 45 | */ |
| 46 | const MINIMUM_PHP_VERSION = '5.6'; |
| 47 | |
| 48 | /** |
| 49 | * API url |
| 50 | * |
| 51 | * @since 1.0.0 |
| 52 | * @var string plugins's root url. |
| 53 | */ |
| 54 | static function api_url(){ |
| 55 | return 'https://api.wpmet.com/public/'; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Plugin url |
| 60 | * |
| 61 | * @since 1.0.0 |
| 62 | * @var string plugins's root url. |
| 63 | */ |
| 64 | static function plugin_url(){ |
| 65 | return trailingslashit(plugin_dir_url( __FILE__ )); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Plugin dir |
| 70 | * |
| 71 | * @since 1.0.0 |
| 72 | * @var string plugins's root directory. |
| 73 | */ |
| 74 | static function plugin_dir(){ |
| 75 | return trailingslashit(plugin_dir_path( __FILE__ )); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Plugin's widget directory. |
| 80 | * |
| 81 | * @since 1.0.0 |
| 82 | * @var string widget's root directory. |
| 83 | */ |
| 84 | static function widget_dir(){ |
| 85 | return self::plugin_dir() . 'widgets/'; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Plugin's widget url. |
| 90 | * |
| 91 | * @since 1.0.0 |
| 92 | * @var string widget's root url. |
| 93 | */ |
| 94 | static function widget_url(){ |
| 95 | return self::plugin_url() . 'widgets/'; |
| 96 | } |
| 97 | |
| 98 | |
| 99 | /** |
| 100 | * Plugin's widget image choose url. |
| 101 | * |
| 102 | * @since 1.0.0 |
| 103 | * @var string widget image choose's root url. |
| 104 | */ |
| 105 | |
| 106 | /** |
| 107 | * Plugin's module directory. |
| 108 | * |
| 109 | * @since 1.0.0 |
| 110 | * @var string module's root directory. |
| 111 | */ |
| 112 | static function module_dir(){ |
| 113 | return self::plugin_dir() . 'modules/'; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Plugin's module url. |
| 118 | * |
| 119 | * @since 1.0.0 |
| 120 | * @var string module's root url. |
| 121 | */ |
| 122 | static function module_url(){ |
| 123 | return self::plugin_url() . 'modules/'; |
| 124 | } |
| 125 | |
| 126 | |
| 127 | /** |
| 128 | * Plugin's lib directory. |
| 129 | * |
| 130 | * @since 1.0.0 |
| 131 | * @var string lib's root directory. |
| 132 | */ |
| 133 | static function lib_dir(){ |
| 134 | return self::plugin_dir() . 'libs/'; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Plugin's lib url. |
| 139 | * |
| 140 | * @since 1.0.0 |
| 141 | * @var string lib's root url. |
| 142 | */ |
| 143 | static function lib_url(){ |
| 144 | return self::plugin_url() . 'libs/'; |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Constructor |
| 149 | * |
| 150 | * @since 1.0.0 |
| 151 | * @access public |
| 152 | */ |
| 153 | public function __construct() { |
| 154 | // Load translation |
| 155 | add_action( 'init', array( $this, 'i18n' ) ); |
| 156 | // Init Plugin |
| 157 | $this->init(); |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Load Textdomain |
| 162 | * |
| 163 | * Load plugin localization files. |
| 164 | * Fired by `init` action hook. |
| 165 | * |
| 166 | * @since 1.0.0 |
| 167 | * @access public |
| 168 | */ |
| 169 | public function i18n() { |
| 170 | load_plugin_textdomain( 'elementskit', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Initialize the plugin |
| 175 | * |
| 176 | * Checks for basic plugin requirements, if one check fail don't continue, |
| 177 | * if all check have passed include the plugin class. |
| 178 | * |
| 179 | * Fired by `plugins_loaded` action hook. |
| 180 | * |
| 181 | * @since 1.0.0 |
| 182 | * @access public |
| 183 | */ |
| 184 | public function init() { |
| 185 | // Load the main static helper class. |
| 186 | require_once self::plugin_dir() . 'helpers/notice.php'; |
| 187 | require_once self::plugin_dir() . 'helpers/utils.php'; |
| 188 | |
| 189 | // Check if Elementor installed and activated. |
| 190 | if ( ! did_action( 'elementor/loaded' ) ) { |
| 191 | add_action( 'admin_notices', array( $this, 'missing_elementor' ) ); |
| 192 | return; |
| 193 | } |
| 194 | // Check for required Elementor version. |
| 195 | if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) { |
| 196 | add_action( 'admin_notices', array( $this, 'failed_elementor_version' ) ); |
| 197 | return; |
| 198 | } |
| 199 | // Check for required PHP version. |
| 200 | if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) { |
| 201 | add_action( 'admin_notices', array( $this, 'failed_php_version' ) ); |
| 202 | return; |
| 203 | } |
| 204 | // Once we get here, We have passed all validation checks so we can safely include our plugin. |
| 205 | |
| 206 | // Register ElementsKit widget category |
| 207 | add_action('elementor/init', [$this, 'elementor_widget_category']); |
| 208 | |
| 209 | add_action( 'elementor/init', function(){ |
| 210 | // Load the Handler class, it's the core class of ElementsKit. |
| 211 | require_once self::plugin_dir() . 'handler.php'; |
| 212 | }); |
| 213 | |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * Admin notice |
| 218 | * |
| 219 | * Warning when the site doesn't have required Elementor. |
| 220 | * |
| 221 | * @since 1.0.0 |
| 222 | * @access public |
| 223 | */ |
| 224 | public function missing_elementor() { |
| 225 | if ( isset( $_GET['activate'] ) ) { |
| 226 | unset( $_GET['activate'] ); |
| 227 | } |
| 228 | |
| 229 | if ( file_exists( WP_PLUGIN_DIR . '/elementor/elementor.php' ) ) { |
| 230 | $btn['label'] = esc_html__('Activate Elementor', 'elementskit'); |
| 231 | $btn['url'] = wp_nonce_url( 'plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php' ); |
| 232 | } else { |
| 233 | $btn['label'] = esc_html__('Install Elementor', 'elementskit'); |
| 234 | $btn['url'] = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' ); |
| 235 | } |
| 236 | |
| 237 | \ElementsKit\Notice::push( |
| 238 | [ |
| 239 | 'id' => 'unsupported-elementor-version', |
| 240 | 'type' => 'error', |
| 241 | 'dismissible' => true, |
| 242 | 'btn' => $btn, |
| 243 | 'message' => sprintf( esc_html__( 'ElementsKit requires Elementor version %1$s+, which is currently NOT RUNNING.', 'elementskit' ), self::MINIMUM_ELEMENTOR_VERSION ), |
| 244 | ] |
| 245 | ); |
| 246 | } |
| 247 | |
| 248 | |
| 249 | /** |
| 250 | * Admin notice |
| 251 | * |
| 252 | * Warning when the site doesn't have a minimum required PHP version. |
| 253 | * |
| 254 | * @since 1.0.0 |
| 255 | * @access public |
| 256 | */ |
| 257 | public function admin_notice_minimum_php_version() { |
| 258 | \ElementsKit\Notice::push( |
| 259 | [ |
| 260 | 'id' => 'unsupported-php-version', |
| 261 | 'type' => 'error', |
| 262 | 'dismissible' => true, |
| 263 | 'message' => sprintf( esc_html__( 'ElementsKit requires PHP version %1$s+, which is currently NOT RUNNING on this server.', 'elementskit' ), self::MINIMUM_PHP_VERSION ), |
| 264 | ] |
| 265 | ); |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * Add category. |
| 270 | * |
| 271 | * Register custom widget category in Elementor's editor |
| 272 | * |
| 273 | * @since 1.0.0 |
| 274 | * @access public |
| 275 | */ |
| 276 | public function elementor_widget_category($widgets_manager){ |
| 277 | \Elementor\Plugin::$instance->elements_manager->add_category( |
| 278 | 'elementskit', |
| 279 | [ |
| 280 | 'title' =>esc_html__( 'ElementsKit', 'elementskit' ), |
| 281 | 'icon' => 'fa fa-plug', |
| 282 | ], |
| 283 | 1 |
| 284 | ); |
| 285 | \Elementor\Plugin::$instance->elements_manager->add_category( |
| 286 | 'elementskit_headerfooter', |
| 287 | [ |
| 288 | 'title' =>esc_html__( 'ElementsKit Header Footer', 'elementskit' ), |
| 289 | 'icon' => 'fa fa-plug', |
| 290 | ], |
| 291 | 1 |
| 292 | ); |
| 293 | } |
| 294 | |
| 295 | |
| 296 | static function default_widgets($package = null){ |
| 297 | $package = ($package != null) ? $package : self::PACKAGE_TYPE; |
| 298 | |
| 299 | $default_list = [ |
| 300 | 'image-accordion', |
| 301 | 'accordion', |
| 302 | 'button', |
| 303 | 'heading', |
| 304 | 'blog-posts', |
| 305 | 'icon-box', |
| 306 | 'image-box', |
| 307 | 'countdown-timer', |
| 308 | 'client-logo', |
| 309 | 'faq', |
| 310 | 'funfact', |
| 311 | 'image-comparison', |
| 312 | 'lottie', |
| 313 | 'testimonial', |
| 314 | 'pricing', |
| 315 | 'team', |
| 316 | 'social', |
| 317 | 'progressbar', |
| 318 | 'category-list', |
| 319 | 'page-list', |
| 320 | 'post-grid', |
| 321 | 'post-list', |
| 322 | 'post-tab', |
| 323 | 'nav-menu', |
| 324 | 'mail-chimp', |
| 325 | 'header-info', |
| 326 | 'piechart', |
| 327 | 'header-search', |
| 328 | 'header-offcanvas', |
| 329 | 'tab', |
| 330 | 'contact-form7', |
| 331 | 'video', |
| 332 | 'business-hours', |
| 333 | 'drop-caps', |
| 334 | 'social-share', |
| 335 | 'dual-button', |
| 336 | 'caldera-forms', |
| 337 | 'we-forms', |
| 338 | 'wp-forms', |
| 339 | 'ninja-forms', |
| 340 | ]; |
| 341 | |
| 342 | $optional_list = [ |
| 343 | 'advanced-accordion', |
| 344 | 'advanced-tab', |
| 345 | 'hotspot', |
| 346 | 'motion-text', |
| 347 | 'twitter-feed', |
| 348 | 'facebook-feed', |
| 349 | 'instagram-feed', |
| 350 | 'gallery', |
| 351 | 'chart', |
| 352 | 'woo-category-list', |
| 353 | 'woo-mini-cart', |
| 354 | 'woo-product-carousel', |
| 355 | 'woo-product-list', |
| 356 | 'table', |
| 357 | 'timeline', |
| 358 | 'creative-button', |
| 359 | 'vertical-menu', |
| 360 | 'advanced-toggle' |
| 361 | ]; |
| 362 | |
| 363 | if(class_exists('\ElementsKit_Widget_Config')){ |
| 364 | $default_list = \ElementsKit_Widget_Config::instance()->get_default_widgets(); |
| 365 | $optional_list = \ElementsKit_Widget_Config::instance()->get_widgets(); |
| 366 | |
| 367 | return (array_merge($default_list, $optional_list)); |
| 368 | }else{ |
| 369 | return ($package == 'pro') ? array_merge($default_list, $optional_list) : $default_list; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | static function default_modules($package = null){ |
| 374 | $package = ($package != null) ? $package : self::PACKAGE_TYPE; |
| 375 | $default_list = [ |
| 376 | 'header-footer', |
| 377 | 'megamenu', |
| 378 | 'onepage-scroll', |
| 379 | 'widget-builder' |
| 380 | ]; |
| 381 | |
| 382 | $optional_list =[ |
| 383 | 'parallax', |
| 384 | 'sticky-content', |
| 385 | ]; |
| 386 | |
| 387 | return ($package == 'pro') ? array_merge($default_list, $optional_list) : $default_list; |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | new ElementsKit(); |
| 392 | |
| 393 | endif; |
| 394 |