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