spider-elements
Last commit date
assets
1 year ago
includes
1 year ago
languages
1 year ago
widgets
1 year ago
index.php
1 year ago
readme.txt
1 year ago
spider-elements.php
1 year ago
spider-elements.php
459 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: Spider Elements |
| 4 | * Requires Plugins: elementor |
| 5 | * Plugin URI: https://wordpress-plugins.spider-themes.net/spider-elements/ |
| 6 | * Description: Spider Elements is a hassle-free addon bundle with super useful widgets for building beautiful websites. Plug and play to create stunning designs effortlessly. |
| 7 | * Version: 1.6.0 |
| 8 | * Requires at least: 5.0 |
| 9 | * Tested up to: 6.5.4 |
| 10 | * Requires PHP: 7.4 |
| 11 | * Author: spider-themes |
| 12 | * Author URI: https://spider-themes.net/spider-elements |
| 13 | * Domain Path: /languages |
| 14 | * License: GPL2 or later |
| 15 | * License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 16 | * Text domain: spider-elements |
| 17 | * Elementor requires at least: 3.0.0 |
| 18 | * Elementor tested up to: 3.20.3 |
| 19 | */ |
| 20 | if ( ! defined( 'ABSPATH' ) ) { |
| 21 | exit; |
| 22 | } |
| 23 | |
| 24 | if ( function_exists( 'spel_fs' ) ) { |
| 25 | spel_fs()->set_basename( false, __FILE__ ); |
| 26 | } else { |
| 27 | |
| 28 | // DO NOT REMOVE THIS IF; IT IS ESSENTIAL FOR THE `function_exists` CALL ABOVE TO PROPERLY WORK. |
| 29 | if ( ! function_exists( 'spel_fs' ) ) { |
| 30 | // Create a helper function for easy SDK access. |
| 31 | function spel_fs() { |
| 32 | global $spel_fs; |
| 33 | |
| 34 | if ( ! isset( $spel_fs ) ) { |
| 35 | |
| 36 | // Include Freemius SDK. |
| 37 | require_once dirname(__FILE__) . '/includes/freemius/start.php'; |
| 38 | |
| 39 | $spel_fs = fs_dynamic_init( |
| 40 | [ |
| 41 | 'id' => '16034', |
| 42 | 'slug' => 'spider-elements', |
| 43 | 'premium_slug' => 'spider-elements-pro', |
| 44 | 'type' => 'plugin', |
| 45 | 'public_key' => 'pk_711f20dd503c8eb713171079ffeb5', |
| 46 | 'is_premium' => false, |
| 47 | 'premium_suffix' => 'Pro', |
| 48 | 'has_premium_version' => true, |
| 49 | 'has_paid_plans' => true, |
| 50 | 'trial' => [ |
| 51 | 'days' => 14, |
| 52 | 'is_require_payment'=> true, |
| 53 | ], |
| 54 | 'menu' => [ |
| 55 | 'slug' => 'spider_elements_settings', |
| 56 | 'contact' => true, |
| 57 | 'support' => false, |
| 58 | 'first-path' => 'admin.php?page=spider_elements_settings' |
| 59 | ], |
| 60 | ] |
| 61 | ); |
| 62 | } |
| 63 | |
| 64 | return $spel_fs; |
| 65 | } |
| 66 | |
| 67 | // Init Freemius. |
| 68 | spel_fs()->add_filter( 'deactivate_on_activation', '__return_false' ); |
| 69 | spel_fs()->add_filter( 'hide_freemius_powered_by', '__return_true' ); |
| 70 | |
| 71 | // Init Freemius. |
| 72 | spel_fs(); |
| 73 | |
| 74 | // Signal that SDK was initiated. |
| 75 | do_action( 'spel_fs_loaded' ); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | |
| 80 | /** |
| 81 | * SPEL class. |
| 82 | * |
| 83 | * The main class that initiates and runs the addon. |
| 84 | * |
| 85 | */ |
| 86 | if (!class_exists('SPEL')) { |
| 87 | |
| 88 | /** |
| 89 | * Class SPEL |
| 90 | */ |
| 91 | final class SPEL { |
| 92 | |
| 93 | /** |
| 94 | * Plugin Version |
| 95 | * |
| 96 | * Holds the version of the plugin. |
| 97 | * |
| 98 | * @var string The plugin version. |
| 99 | */ |
| 100 | const VERSION = '1.6.0'; |
| 101 | |
| 102 | |
| 103 | /** |
| 104 | * Instance |
| 105 | * |
| 106 | * Holds a single instance of the `SPEL` class. |
| 107 | * |
| 108 | * @access private |
| 109 | * @static |
| 110 | * |
| 111 | * @var SPEL A single instance of the class. |
| 112 | */ |
| 113 | private static $_instance = null; |
| 114 | |
| 115 | |
| 116 | /** |
| 117 | * Instance |
| 118 | * |
| 119 | * Ensures only one instance of the class is loaded or can be loaded. |
| 120 | * |
| 121 | * @return SPEL An instance of the class. |
| 122 | * @since 1.7.0 |
| 123 | * |
| 124 | * @access public |
| 125 | * @static |
| 126 | * |
| 127 | */ |
| 128 | public static function instance() { |
| 129 | if ( is_null( self::$_instance ) ) { |
| 130 | self::$_instance = new self(); |
| 131 | } |
| 132 | |
| 133 | return self::$_instance; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Constructor |
| 138 | * |
| 139 | * Initialize the Spider Elements plugins. |
| 140 | * |
| 141 | */ |
| 142 | public function __construct() { |
| 143 | |
| 144 | // Include Files |
| 145 | $this->core_includes(); |
| 146 | |
| 147 | // define constants |
| 148 | $this->define_constants(); |
| 149 | |
| 150 | // Init Plugin |
| 151 | add_action('plugins_loaded', array( $this, 'init_plugin' )); |
| 152 | |
| 153 | // Load text domain for localization |
| 154 | add_action('init', [ $this, 'i18n' ]); |
| 155 | |
| 156 | // Register Category |
| 157 | add_action('elementor/elements/categories_registered', [ $this, 'elements_register_category' ]); |
| 158 | |
| 159 | // Register widgets |
| 160 | add_action('elementor/widgets/register', [ $this, 'widgets_register' ], 99 ); |
| 161 | |
| 162 | // Register Icon |
| 163 | add_filter('elementor/icons_manager/additional_tabs', [ $this, 'elegant_icons' ]); |
| 164 | |
| 165 | } |
| 166 | |
| 167 | |
| 168 | /** |
| 169 | * Clone |
| 170 | * |
| 171 | * Disable class cloning. |
| 172 | * |
| 173 | * @return void |
| 174 | * @since 1.7.0 |
| 175 | * |
| 176 | * @access protected |
| 177 | * |
| 178 | */ |
| 179 | public function __clone() { |
| 180 | // Cloning instances of the class is forbidden |
| 181 | _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'spider-elements' ), self::VERSION ); |
| 182 | } |
| 183 | |
| 184 | |
| 185 | /** |
| 186 | * Wakeup |
| 187 | * |
| 188 | * Disable unserializing the class. |
| 189 | * |
| 190 | * @return void |
| 191 | * @since 1.7.0 |
| 192 | * |
| 193 | * @access protected |
| 194 | * |
| 195 | */ |
| 196 | public function __wakeup() { |
| 197 | // Un-serializing instances of the class is forbidden. |
| 198 | _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'spider-elements' ), '1.7.0' ); |
| 199 | } |
| 200 | |
| 201 | |
| 202 | /*** |
| 203 | * Added Custom Font Icon Integrated Elementor Icon Library |
| 204 | */ |
| 205 | public function elegant_icons( $custom_fonts ) { |
| 206 | |
| 207 | $css_data = plugins_url( 'assets/vendors/elegant-icon/style.css', __FILE__ ); |
| 208 | $json_data = plugins_url( 'assets/vendors/elegant-icon/elegant-icons.json', __FILE__ ); |
| 209 | |
| 210 | $custom_fonts[ 'elegant-icon' ] = [ |
| 211 | 'name' => 'elegant-icon', |
| 212 | 'label' => esc_html__( 'Elegant Icons', 'spider-elements' ), |
| 213 | 'url' => $css_data, |
| 214 | 'prefix' => '', |
| 215 | 'displayPrefix' => '', |
| 216 | 'labelIcon' => 'icon_star', |
| 217 | 'ver' => '', |
| 218 | 'fetchJson' => $json_data, |
| 219 | 'native' => true, |
| 220 | ]; |
| 221 | |
| 222 | return $custom_fonts; |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Load Textdomain |
| 227 | * |
| 228 | * Load plugin localization files. |
| 229 | */ |
| 230 | public function i18n(): void |
| 231 | { |
| 232 | load_plugin_textdomain( 'spider-elements', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
| 233 | } |
| 234 | |
| 235 | |
| 236 | /** |
| 237 | * Include Files |
| 238 | * |
| 239 | * Load core files required to run the plugin. |
| 240 | * |
| 241 | * @since 1.7.0 |
| 242 | * |
| 243 | * @access public |
| 244 | */ |
| 245 | public function core_includes(): void |
| 246 | { |
| 247 | |
| 248 | |
| 249 | // Extra functions |
| 250 | require_once __DIR__ . '/includes/functions.php'; |
| 251 | |
| 252 | //Action Filter |
| 253 | require_once __DIR__ . '/includes/filters.php'; |
| 254 | |
| 255 | require_once __DIR__ . '/includes/Admin/Module_Settings.php'; |
| 256 | |
| 257 | // Admin and Frontend Scripts Loaded |
| 258 | require_once __DIR__ . '/includes/Admin/Plugin_Installer.php'; |
| 259 | |
| 260 | $theme = wp_get_theme(); |
| 261 | if ( spel_is_premium() || in_array($theme->get('Name'), ['jobi', 'Jobi', 'jobi-child', 'Jobi Child']) ) { |
| 262 | require_once __DIR__ . '/includes/Admin/extension/Heading_Highlighted.php'; |
| 263 | require_once __DIR__ . '/includes/Admin/extension/Features_Badge.php'; |
| 264 | } |
| 265 | |
| 266 | // Admin UI |
| 267 | if ( is_admin() ) { |
| 268 | require_once __DIR__ . '/includes/Admin/Assets.php'; |
| 269 | require_once __DIR__ . '/includes/Admin/Dashboard.php'; |
| 270 | } |
| 271 | |
| 272 | // Frontend UI |
| 273 | require_once __DIR__ . '/includes/Frontend/Assets.php'; |
| 274 | |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * Initialize the plugin |
| 279 | * |
| 280 | * Validates that Elementor is already loaded. |
| 281 | * Checks for basic plugin requirements, if one check fail don't continue, |
| 282 | * if all checks have passed include the plugin class. |
| 283 | * |
| 284 | * Fired by `plugins_loaded` action hook. |
| 285 | * |
| 286 | * @access public |
| 287 | */ |
| 288 | public function init_plugin(): void |
| 289 | { |
| 290 | |
| 291 | $theme = wp_get_theme(); |
| 292 | $features_opt = get_option('spel_features_settings'); |
| 293 | |
| 294 | $is_premium_or_theme = spel_is_premium() || in_array($theme->get('Name'), ['jobi', 'Jobi', 'jobi-child', 'Jobi Child']); |
| 295 | |
| 296 | if ( $is_premium_or_theme ) { |
| 297 | |
| 298 | // Get the feature badge status |
| 299 | $heading_highlighted = $features_opt['spel_heading_highlighted'] ?? ''; |
| 300 | if ($heading_highlighted) { |
| 301 | new SPEL\includes\Admin\extension\Heading_Highlighted(); |
| 302 | } |
| 303 | |
| 304 | $badge = $features_opt['spel_badge'] ?? ''; |
| 305 | if ($badge) { |
| 306 | new SPEL\includes\Admin\extension\Features_Badge(); |
| 307 | } |
| 308 | |
| 309 | } |
| 310 | |
| 311 | // Admin UI |
| 312 | if ( is_admin() ) { |
| 313 | new SPEL\includes\Admin\Dashboard(); |
| 314 | new SPEL\includes\Admin\Assets(); |
| 315 | } |
| 316 | |
| 317 | // Frontend UI |
| 318 | new SPEL\includes\Admin\Plugin_Installer(); |
| 319 | new SPEL\includes\Frontend\Assets(); |
| 320 | |
| 321 | } |
| 322 | |
| 323 | |
| 324 | /** |
| 325 | * Add new Elementor Categories |
| 326 | * |
| 327 | * Register new widget categories for Spider Elements widgets. |
| 328 | */ |
| 329 | public function elements_register_category (): void |
| 330 | { |
| 331 | |
| 332 | \Elementor\Plugin::instance()->elements_manager->add_category('spider-elements', [ |
| 333 | 'title' => esc_html__('Spider Elements', 'spider-elements'), |
| 334 | ], 1); |
| 335 | |
| 336 | } |
| 337 | |
| 338 | /** |
| 339 | * Register New Widgets |
| 340 | * |
| 341 | * Include Spider Elements widgets files and register them in Elementor. |
| 342 | * |
| 343 | * @since 1.0.0 |
| 344 | * |
| 345 | * @access public |
| 346 | */ |
| 347 | public function widgets_register(): void |
| 348 | { |
| 349 | |
| 350 | // Register each widget class |
| 351 | $widgets_manager = \Elementor\Plugin::instance()->widgets_manager; |
| 352 | $elements_opt = get_option( 'spe_widget_settings' ); |
| 353 | |
| 354 | if ( isset( $elements_opt[ 'docy_tabs' ] ) && $elements_opt[ 'docy_tabs' ] == 'on' ) { |
| 355 | require_once( __DIR__ . '/widgets/Tabs.php' ); |
| 356 | $widgets_manager->register( new \SPEL\Widgets\Tabs() ); |
| 357 | } |
| 358 | if ( isset( $elements_opt[ 'docy_videos_playlist' ] ) && $elements_opt[ 'docy_videos_playlist' ] == 'on' ) { |
| 359 | require_once( __DIR__ . '/widgets/Video_Playlist.php' ); |
| 360 | $widgets_manager->register( new \SPEL\Widgets\Video_Playlist() ); |
| 361 | } |
| 362 | if ( isset( $elements_opt[ 'docly_alerts_box' ] ) && $elements_opt[ 'docly_alerts_box' ] == 'on' ) { |
| 363 | require_once( __DIR__ . '/widgets/Alerts_Box.php' ); |
| 364 | $widgets_manager->register( new \SPEL\Widgets\Alerts_Box() ); |
| 365 | } |
| 366 | if ( isset( $elements_opt[ 'spel_accordion' ] ) && $elements_opt[ 'spel_accordion' ] == 'on' ) { |
| 367 | require_once( __DIR__ . '/widgets/Accordion.php' ); |
| 368 | $widgets_manager->register( new \SPEL\Widgets\Accordion() ); |
| 369 | } |
| 370 | if ( isset( $elements_opt[ 'docy_testimonial' ] ) && $elements_opt[ 'docy_testimonial' ] == 'on' ) { |
| 371 | require_once( __DIR__ . '/widgets/Testimonial.php' ); |
| 372 | $widgets_manager->register( new \SPEL\Widgets\Testimonial() ); |
| 373 | } |
| 374 | if ( isset( $elements_opt[ 'docly_list_item' ] ) && $elements_opt[ 'docly_list_item' ] == 'on' ) { |
| 375 | require_once( __DIR__ . '/widgets/List_Item.php' ); |
| 376 | $widgets_manager->register( new \SPEL\Widgets\List_Item() ); |
| 377 | } |
| 378 | if ( isset( $elements_opt[ 'docly_cheatsheet' ] ) && $elements_opt[ 'docly_cheatsheet' ] == 'on' ) { |
| 379 | require_once( __DIR__ . '/widgets/Cheat_Sheet.php' ); |
| 380 | $widgets_manager->register( new \SPEL\Widgets\Cheat_Sheet() ); |
| 381 | } |
| 382 | if ( isset( $elements_opt[ 'docy_team_carousel' ] ) && $elements_opt[ 'docy_team_carousel' ] == 'on' ) { |
| 383 | require_once( __DIR__ . '/widgets/Team_Carousel.php' ); |
| 384 | $widgets_manager->register( new \SPEL\Widgets\Team_Carousel() ); |
| 385 | } |
| 386 | if ( isset( $elements_opt[ 'docy_integrations' ] ) && $elements_opt[ 'docy_integrations' ] == 'on' ) { |
| 387 | require_once( __DIR__ . '/widgets/Integrations.php' ); |
| 388 | $widgets_manager->register( new \SPEL\Widgets\Integrations() ); |
| 389 | } |
| 390 | if ( isset( $elements_opt[ 'spel_before_after' ] ) && $elements_opt[ 'spel_before_after' ] == 'on' ) { |
| 391 | require_once( __DIR__ . '/widgets/Before_after.php' ); |
| 392 | $widgets_manager->register( new \SPEL\Widgets\Before_After() ); |
| 393 | } |
| 394 | if ( isset( $elements_opt[ 'docy_video_popup' ] ) && $elements_opt[ 'docy_video_popup' ] == 'on' ) { |
| 395 | require_once( __DIR__ . '/widgets/Video_Popup.php' ); |
| 396 | $widgets_manager->register( new \SPEL\Widgets\Video_Popup() ); |
| 397 | } |
| 398 | if ( isset( $elements_opt[ 'docy_blog_grid' ] ) && $elements_opt[ 'docy_blog_grid' ] == 'on' ) { |
| 399 | require_once( __DIR__ . '/widgets/Blog_Grid.php' ); |
| 400 | $widgets_manager->register( new \SPEL\Widgets\Blog_Grid() ); |
| 401 | } |
| 402 | if ( isset( $elements_opt[ 'spe_timeline_widget' ] ) && $elements_opt[ 'spe_timeline_widget' ] == 'on' ) { |
| 403 | require_once( __DIR__ . '/widgets/Timeline.php' ); |
| 404 | $widgets_manager->register( new \SPEL\Widgets\Timeline() ); |
| 405 | } |
| 406 | if ( isset( $elements_opt[ 'spe_counter' ] ) && $elements_opt[ 'spe_counter' ] == 'on' ) { |
| 407 | require_once( __DIR__ . '/widgets/Counter.php' ); |
| 408 | $widgets_manager->register( new \SPEL\Widgets\Counter() ); |
| 409 | } |
| 410 | if ( isset( $elements_opt[ 'spel_icon_box' ] ) && $elements_opt[ 'spel_icon_box' ] == 'on' ) { |
| 411 | require_once( __DIR__ . '/widgets/Icon_Box.php' ); |
| 412 | $widgets_manager->register( new \SPEL\Widgets\Icon_Box() ); |
| 413 | } |
| 414 | |
| 415 | } |
| 416 | |
| 417 | |
| 418 | /** |
| 419 | * @return void |
| 420 | * @since 1.7.0 |
| 421 | * @access public |
| 422 | * @static |
| 423 | */ |
| 424 | public function define_constants(): void |
| 425 | { |
| 426 | |
| 427 | //SPEL(Short form - Spider Elements) |
| 428 | define('SPEL_VERSION', self::VERSION); |
| 429 | define('SPEL_FILE', __FILE__); |
| 430 | define('SPEL_PATH', __DIR__); |
| 431 | define('SPEL_URL', plugins_url('', SPEL_FILE)); |
| 432 | define('SPEL_ASSETS', SPEL_URL . '/assets'); |
| 433 | define('SPEL_CSS', SPEL_URL . '/assets/css'); |
| 434 | define('SPEL_JS', SPEL_URL . '/assets/js'); |
| 435 | define('SPEL_IMG', SPEL_URL . '/assets/images'); |
| 436 | define('SPEL_VEND', SPEL_URL . '/assets/vendors'); |
| 437 | |
| 438 | } |
| 439 | |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | |
| 444 | /** |
| 445 | * Initialize the main plugin class |
| 446 | * |
| 447 | * @return SPEL |
| 448 | * |
| 449 | */ |
| 450 | if (!function_exists('spel')) { |
| 451 | |
| 452 | function spel () |
| 453 | { |
| 454 | return SPEL::instance(); |
| 455 | } |
| 456 | |
| 457 | //kick-off the plugin |
| 458 | spel(); |
| 459 | } |