controls
3 years ago
modules
6 months ago
widgets
6 months ago
class-auxin-elementor-core-elements.php
1 year ago
class-auxin-elementor-core-elements.php
865 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor; |
| 3 | |
| 4 | |
| 5 | /** |
| 6 | * Auxin Elementor Elements |
| 7 | * |
| 8 | * Custom Elementor extension. |
| 9 | * |
| 10 | * |
| 11 | * @package Auxin |
| 12 | * @license LICENSE.txt |
| 13 | * @author averta |
| 14 | * @link http://phlox.pro/ |
| 15 | * @copyright (c) 2010-2025 averta |
| 16 | */ |
| 17 | |
| 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 19 | exit; // Exit if accessed directly. |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Main Auxin Elementor Elements Class |
| 24 | * |
| 25 | * The main class that initiates and runs the plugin. |
| 26 | * |
| 27 | * @since 1.0.0 |
| 28 | */ |
| 29 | final class Elements { |
| 30 | |
| 31 | /** |
| 32 | * Plugin Version |
| 33 | * |
| 34 | * @since 1.0.0 |
| 35 | * |
| 36 | * @var string The plugin version. |
| 37 | */ |
| 38 | const VERSION = '1.0.0'; |
| 39 | |
| 40 | /** |
| 41 | * Minimum Elementor Version |
| 42 | * |
| 43 | * @since 1.0.0 |
| 44 | * |
| 45 | * @var string Minimum Elementor version required to run the plugin. |
| 46 | */ |
| 47 | const MINIMUM_ELEMENTOR_VERSION = '2.0.0'; |
| 48 | |
| 49 | /** |
| 50 | * Minimum PHP Version |
| 51 | * |
| 52 | * @since 1.0.0 |
| 53 | * |
| 54 | * @var string Minimum PHP version required to run the plugin. |
| 55 | */ |
| 56 | const MINIMUM_PHP_VERSION = '5.4.0'; |
| 57 | |
| 58 | /** |
| 59 | * Default elementor dir path |
| 60 | * |
| 61 | * @since 1.0.0 |
| 62 | * |
| 63 | * @var string The defualt path to elementor dir on this plugin. |
| 64 | */ |
| 65 | private $dir_path = ''; |
| 66 | |
| 67 | /** |
| 68 | * Instance |
| 69 | * |
| 70 | * @since 1.0.0 |
| 71 | * |
| 72 | * @access private |
| 73 | * @static |
| 74 | * |
| 75 | * @var Auxin_Elementor_Core_Elements The single instance of the class. |
| 76 | */ |
| 77 | private static $_instance = null; |
| 78 | |
| 79 | /** |
| 80 | * Instance |
| 81 | * |
| 82 | * Ensures only one instance of the class is loaded or can be loaded. |
| 83 | * |
| 84 | * @since 1.0.0 |
| 85 | * |
| 86 | * @access public |
| 87 | * @static |
| 88 | * |
| 89 | * @return Auxin_Elementor_Core_Elements An instance of the class. |
| 90 | */ |
| 91 | public static function instance() { |
| 92 | if ( is_null( self::$_instance ) ) { |
| 93 | self::$_instance = new self(); |
| 94 | } |
| 95 | return self::$_instance; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Constructor |
| 100 | * |
| 101 | * @since 1.0.0 |
| 102 | * |
| 103 | * @access public |
| 104 | */ |
| 105 | public function __construct() { |
| 106 | add_action( 'plugins_loaded', array( $this, 'init' ) ); |
| 107 | |
| 108 | if ( ! empty( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] && is_admin() ) { |
| 109 | add_action( 'init', [ $this, 'register_wc_hooks' ], 5 ); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | public function register_wc_hooks() { |
| 114 | if ( !class_exists('WooCommerce') ) { |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | wc()->frontend_includes(); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Initialize the plugin |
| 123 | * |
| 124 | * Load the plugin only after Elementor (and other plugins) are loaded. |
| 125 | * |
| 126 | * Fired by `plugins_loaded` action hook. |
| 127 | * |
| 128 | * @since 1.0.0 |
| 129 | * |
| 130 | * @access public |
| 131 | */ |
| 132 | public function init() { |
| 133 | |
| 134 | // Check if Elementor installed and activated |
| 135 | if ( ! did_action( 'elementor/loaded' ) ) { |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | // Check for required Elementor version |
| 140 | if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) { |
| 141 | add_action( 'admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ) ); |
| 142 | return; |
| 143 | } |
| 144 | |
| 145 | // Check for required PHP version |
| 146 | if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) { |
| 147 | add_action( 'admin_notices', array( $this, 'admin_notice_minimum_php_version' ) ); |
| 148 | return; |
| 149 | } |
| 150 | |
| 151 | // Define elementor dir path |
| 152 | $this->dir_path = AUXELS_INC_DIR . '/elementor'; |
| 153 | |
| 154 | // Include core files |
| 155 | $this->includes(); |
| 156 | |
| 157 | // Add required hooks |
| 158 | $this->hooks(); |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Include Files |
| 163 | * |
| 164 | * Load required core files. |
| 165 | * |
| 166 | * @since 1.0.0 |
| 167 | * |
| 168 | * @access public |
| 169 | */ |
| 170 | public function includes() { |
| 171 | $this->load_modules(); |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Add hooks |
| 176 | * |
| 177 | * Add required hooks for extending the Elementor. |
| 178 | * |
| 179 | * @since 1.0.0 |
| 180 | * |
| 181 | * @access public |
| 182 | */ |
| 183 | public function hooks() { |
| 184 | |
| 185 | // Register controls, widgets, and categories |
| 186 | add_action( 'elementor/elements/categories_registered' , [ $this, 'register_categories' ] ); |
| 187 | |
| 188 | if ( version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) { |
| 189 | add_action( 'elementor/widgets/register' , [ $this, 'register_widgets' ] ); |
| 190 | add_action( 'elementor/controls/register' , [ $this, 'register_controls' ] ); |
| 191 | } else { |
| 192 | add_action( 'elementor/widgets/widgets_registered' , [ $this, 'register_widgets' ] ); |
| 193 | add_action( 'elementor/controls/controls_registered' , [ $this, 'register_controls' ] ); |
| 194 | } |
| 195 | |
| 196 | // Register Widget Styles |
| 197 | add_action( 'elementor/frontend/after_enqueue_styles' , [ $this, 'widget_styles' ] ); |
| 198 | |
| 199 | // Register Widget Scripts |
| 200 | add_action( 'elementor/frontend/after_register_scripts', [ $this, 'widget_scripts' ] ); |
| 201 | |
| 202 | // Register Admin Scripts |
| 203 | add_action( 'elementor/editor/before_enqueue_scripts' , [ $this, 'editor_scripts' ] ); |
| 204 | add_action( 'elementor/editor/after_enqueue_scripts' , [ $this, 'editor_after_enqueue_scripts' ] ); |
| 205 | |
| 206 | |
| 207 | // Register additional font icons |
| 208 | add_filter('elementor/icons_manager/additional_tabs' , [ $this, 'add_auxin_font_icons' ] ); |
| 209 | |
| 210 | // Change options on auxin load |
| 211 | add_action( 'auxin_admin_loaded' , [ $this, 'auxin_admin_loaded' ] ); |
| 212 | |
| 213 | // Flush CSS cache on auxin theme or plugin update |
| 214 | add_action( 'auxin_updated' , [ $this, 'clear_cache' ] ); |
| 215 | |
| 216 | // Add additional fonts to elementor fonts |
| 217 | add_filter( 'elementor/fonts/additional_fonts', [ $this, 'additional_fonts' ], 1, 1 ); |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Register widgets |
| 222 | * |
| 223 | * Register all auxin widgets which are in widgets list. |
| 224 | * |
| 225 | * @access public |
| 226 | */ |
| 227 | public function register_widgets( $widgets_manager ) { |
| 228 | |
| 229 | $widgets = [ |
| 230 | |
| 231 | /* Dynamic Elements |
| 232 | /*-------------------------------------*/ |
| 233 | '10' => [ |
| 234 | 'file' => $this->dir_path . '/widgets/recent-posts-grid-carousel.php', |
| 235 | 'class' => 'Elements\RecentPostsGridCarousel' |
| 236 | ], |
| 237 | '20' => [ |
| 238 | 'file' => $this->dir_path . '/widgets/recent-posts-masonry.php', |
| 239 | 'class' => 'Elements\RecentPostsMasonry' |
| 240 | ], |
| 241 | '30' => [ |
| 242 | 'file' => $this->dir_path . '/widgets/recent-posts-land-style.php', |
| 243 | 'class' => 'Elements\RecentPostsLand' |
| 244 | ], |
| 245 | '40' => [ |
| 246 | 'file' => $this->dir_path . '/widgets/recent-posts-timeline.php', |
| 247 | 'class' => 'Elements\RecentPostsTimeline' |
| 248 | ], |
| 249 | '50' => [ |
| 250 | 'file' => $this->dir_path . '/widgets/recent-posts-tiles.php', |
| 251 | 'class' => 'Elements\RecentPostsTiles' |
| 252 | ], |
| 253 | '60' => [ |
| 254 | 'file' => $this->dir_path . '/widgets/recent-posts-tiles-carousel.php', |
| 255 | 'class' => 'Elements\RecentPostsTilesCarousel' |
| 256 | ], |
| 257 | '70' => [ |
| 258 | 'file' => $this->dir_path . '/widgets/recent-products.php', |
| 259 | 'class' => 'Elements\RecentProducts' |
| 260 | ], |
| 261 | '75' => [ |
| 262 | 'file' => $this->dir_path . '/widgets/products-grid.php', |
| 263 | 'class' => 'Elements\ProductsGrid' |
| 264 | ], |
| 265 | '80' => [ |
| 266 | 'file' => $this->dir_path . '/widgets/recent-comments.php', |
| 267 | 'class' => 'Elements\RecentComments' |
| 268 | ], |
| 269 | |
| 270 | /* General Elements |
| 271 | /*-------------------------------------*/ |
| 272 | '88' => [ |
| 273 | 'file' => $this->dir_path . '/widgets/heading-modern.php', |
| 274 | 'class' => 'Elements\ModernHeading' |
| 275 | ], |
| 276 | '89' => [ |
| 277 | 'file' => $this->dir_path . '/widgets/icon.php', |
| 278 | 'class' => 'Elements\Icon' |
| 279 | ], |
| 280 | '90' => [ |
| 281 | 'file' => $this->dir_path . '/widgets/image.php', |
| 282 | 'class' => 'Elements\Image' |
| 283 | ], |
| 284 | '100' => [ |
| 285 | 'file' => $this->dir_path . '/widgets/gallery.php', |
| 286 | 'class' => 'Elements\Gallery' |
| 287 | ], |
| 288 | '101' => [ |
| 289 | 'file' => $this->dir_path . '/widgets/circle-chart.php', |
| 290 | 'class' => 'Elements\CircleChart' |
| 291 | ], |
| 292 | '105' => [ |
| 293 | 'file' => $this->dir_path . '/widgets/text.php', |
| 294 | 'class' => 'Elements\Text' |
| 295 | ], |
| 296 | '110' => [ |
| 297 | 'file' => $this->dir_path . '/widgets/divider.php', |
| 298 | 'class' => 'Elements\Divider' |
| 299 | ], |
| 300 | '115' => [ |
| 301 | 'file' => $this->dir_path . '/widgets/button.php', |
| 302 | 'class' => 'Elements\Button' |
| 303 | ], |
| 304 | '120' => [ |
| 305 | 'file' => $this->dir_path . '/widgets/accordion.php', |
| 306 | 'class' => 'Elements\Accordion' |
| 307 | ], |
| 308 | '125' => [ |
| 309 | 'file' => $this->dir_path . '/widgets/tabs.php', |
| 310 | 'class' => 'Elements\Tabs' |
| 311 | ], |
| 312 | '130' => [ |
| 313 | 'file' => $this->dir_path . '/widgets/audio.php', |
| 314 | 'class' => 'Elements\Audio' |
| 315 | ], |
| 316 | '140' => [ |
| 317 | 'file' => $this->dir_path . '/widgets/video.php', |
| 318 | 'class' => 'Elements\Video' |
| 319 | ], |
| 320 | '145' => [ |
| 321 | 'file' => $this->dir_path . '/widgets/quote.php', |
| 322 | 'class' => 'Elements\Quote' |
| 323 | ], |
| 324 | '150' => [ |
| 325 | 'file' => $this->dir_path . '/widgets/testimonial.php', |
| 326 | 'class' => 'Elements\Testimonial' |
| 327 | ], |
| 328 | '155' => [ |
| 329 | 'file' => $this->dir_path . '/widgets/contact-form.php', |
| 330 | 'class' => 'Elements\ContactForm' |
| 331 | ], |
| 332 | '160' => [ |
| 333 | 'file' => $this->dir_path . '/widgets/contact-box.php', |
| 334 | 'class' => 'Elements\ContactBox' |
| 335 | ], |
| 336 | '165' => [ |
| 337 | 'file' => $this->dir_path . '/widgets/touch-slider.php', |
| 338 | 'class' => 'Elements\TouchSlider' |
| 339 | ], |
| 340 | '170' => [ |
| 341 | 'file' => $this->dir_path . '/widgets/before-after.php', |
| 342 | 'class' => 'Elements\BeforeAfter' |
| 343 | ], |
| 344 | '175' => [ |
| 345 | 'file' => $this->dir_path . '/widgets/staff.php', |
| 346 | 'class' => 'Elements\Staff' |
| 347 | ], |
| 348 | '180' => [ |
| 349 | 'file' => $this->dir_path . '/widgets/gmap.php', |
| 350 | 'class' => 'Elements\Gmap' |
| 351 | ], |
| 352 | '185' => [ |
| 353 | 'file' => $this->dir_path . '/widgets/custom-list.php', |
| 354 | 'class' => 'Elements\CustomList' |
| 355 | ], |
| 356 | '190' => [ |
| 357 | 'file' => $this->dir_path . '/widgets/mailchimp.php', |
| 358 | 'class' => 'Elements\MailChimp' |
| 359 | ], |
| 360 | '200' => [ |
| 361 | 'file' => $this->dir_path . '/widgets/theme-elements/current-time.php', |
| 362 | 'class' => 'Elements\Theme_Elements\Current_Time' |
| 363 | ], |
| 364 | '205' => [ |
| 365 | 'file' => $this->dir_path . '/widgets/theme-elements/search.php', |
| 366 | 'class' => 'Elements\Theme_Elements\SearchBox' |
| 367 | ], |
| 368 | '210' => [ |
| 369 | 'file' => $this->dir_path . '/widgets/theme-elements/site-title.php', |
| 370 | 'class' => 'Elements\Theme_Elements\SiteTitle' |
| 371 | ], |
| 372 | '215' => [ |
| 373 | 'file' => $this->dir_path . '/widgets/theme-elements/menu.php', |
| 374 | 'class' => 'Elements\Theme_Elements\MenuBox' |
| 375 | ], |
| 376 | '220' => [ |
| 377 | 'file' => $this->dir_path . '/widgets/theme-elements/logo.php', |
| 378 | 'class' => 'Elements\Theme_Elements\Logo' |
| 379 | ], |
| 380 | '225' => [ |
| 381 | 'file' => $this->dir_path . '/widgets/carousel-navigation.php', |
| 382 | 'class' => 'Elements\CarouselNavigation' |
| 383 | ], |
| 384 | '230' => [ |
| 385 | 'file' => $this->dir_path . '/widgets/theme-elements/copyright.php', |
| 386 | 'class' => 'Elements\Theme_Elements\Copyright' |
| 387 | ], |
| 388 | '235' => [ |
| 389 | 'file' => $this->dir_path . '/widgets/svg.php', |
| 390 | 'class' => 'Elements\Simple__SVG' |
| 391 | ], |
| 392 | '240' => [ |
| 393 | 'file' => $this->dir_path . '/widgets/theme-elements/modern-search.php', |
| 394 | 'class' => 'Elements\Theme_Elements\ModernSearch' |
| 395 | ], |
| 396 | '245' => [ |
| 397 | 'file' => $this->dir_path . '/widgets/theme-elements/breadcrumbs.php', |
| 398 | 'class' => 'Elements\Theme_Elements\Breadcrumbs' |
| 399 | ], |
| 400 | '250' => [ |
| 401 | 'file' => $this->dir_path . '/widgets/modern-button.php', |
| 402 | 'class' => 'Elements\ModernButton' |
| 403 | ], |
| 404 | '255' => [ |
| 405 | 'file' => $this->dir_path . '/widgets/responsive-table.php', |
| 406 | 'class' => 'Elements\ResponsiveTable' |
| 407 | ], |
| 408 | '260' => [ |
| 409 | 'file' => $this->dir_path . '/widgets/theme-elements/select.php', |
| 410 | 'class' => 'Elements\Theme_Elements\Select' |
| 411 | ] |
| 412 | ]; |
| 413 | |
| 414 | if ( class_exists('WooCommerce') ) { |
| 415 | $widgets['195'] = [ |
| 416 | 'file' => $this->dir_path . '/widgets/theme-elements/shopping-cart.php', |
| 417 | 'class' => 'Elements\Theme_Elements\Shopping_Cart' |
| 418 | ]; |
| 419 | } |
| 420 | |
| 421 | // sort the widgets by priority number |
| 422 | ksort( $widgets ); |
| 423 | |
| 424 | // making the list of widgets filterable |
| 425 | $widgets = apply_filters( 'auxin/core_elements/elementor/widgets_list', $widgets, $widgets_manager ); |
| 426 | |
| 427 | foreach ( $widgets as $widget ) { |
| 428 | if( ! empty( $widget['file'] ) && ! empty( $widget['class'] ) ){ |
| 429 | include_once( $widget['file'] ); |
| 430 | if( class_exists( $widget['class'] ) ){ |
| 431 | $class_name = $widget['class']; |
| 432 | } elseif( class_exists( __NAMESPACE__ . '\\' . $widget['class'] ) ){ |
| 433 | $class_name = __NAMESPACE__ . '\\' . $widget['class']; |
| 434 | } else { |
| 435 | auxin_error( sprintf( __('Element class "%s" not found.', 'auxin-elements' ), $class_name ) ); |
| 436 | continue; |
| 437 | } |
| 438 | |
| 439 | if ( version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) { |
| 440 | $widgets_manager->register( new $class_name() ); |
| 441 | } else { |
| 442 | $widgets_manager->register_widget_type( new $class_name() ); |
| 443 | } |
| 444 | } |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | /** |
| 449 | * Load Modules |
| 450 | * |
| 451 | * Load all auxin elementor modules. |
| 452 | * |
| 453 | * @since 1.0.0 |
| 454 | * |
| 455 | * @access public |
| 456 | */ |
| 457 | private function load_modules() { |
| 458 | |
| 459 | $modules = array( |
| 460 | array( |
| 461 | 'file' => $this->dir_path . '/modules/theme-builder/classes/locations-manager.php', |
| 462 | 'class' => 'Modules\ThemeBuilder\Classes\Locations_Manager', |
| 463 | 'instance' => false |
| 464 | ), |
| 465 | array( |
| 466 | 'file' => $this->dir_path . '/modules/theme-builder/classes/preview-manager.php', |
| 467 | 'class' => 'Modules\ThemeBuilder\Classes\Preview_Manager', |
| 468 | 'instance' => false |
| 469 | ), |
| 470 | array( |
| 471 | 'file' => $this->dir_path . '/modules/theme-builder/module.php', |
| 472 | 'class' => 'Modules\ThemeBuilder\Module' |
| 473 | ), |
| 474 | array( |
| 475 | 'file' => $this->dir_path . '/modules/theme-builder/theme-page-document.php', |
| 476 | 'class' => 'Modules\ThemeBuilder\Theme_Document', |
| 477 | 'instance' => false |
| 478 | ), |
| 479 | array( |
| 480 | 'file' => $this->dir_path . '/modules/query-control/module.php', |
| 481 | 'class' => 'Modules\QueryControl\Module' |
| 482 | ), |
| 483 | array( |
| 484 | 'file' => $this->dir_path . '/modules/common.php', |
| 485 | 'class' => 'Modules\Common' |
| 486 | ), |
| 487 | array( |
| 488 | 'file' => $this->dir_path . '/modules/section.php', |
| 489 | 'class' => 'Modules\Section' |
| 490 | ), |
| 491 | array( |
| 492 | 'file' => $this->dir_path . '/modules/column.php', |
| 493 | 'class' => 'Modules\Column' |
| 494 | ), |
| 495 | array( |
| 496 | 'file' => $this->dir_path . '/modules/container.php', |
| 497 | 'class' => 'Modules\Container' |
| 498 | ), |
| 499 | array( |
| 500 | 'file' => $this->dir_path . '/modules/documents/header.php', |
| 501 | 'class' => 'Modules\Documents\Header' |
| 502 | ), |
| 503 | array( |
| 504 | 'file' => $this->dir_path . '/modules/documents/footer.php', |
| 505 | 'class' => 'Modules\Documents\Footer' |
| 506 | ), |
| 507 | array( |
| 508 | 'file' => $this->dir_path . '/modules/templates-types-manager.php', |
| 509 | 'class' => 'Modules\Templates_Types_Manager' |
| 510 | ) |
| 511 | ); |
| 512 | |
| 513 | if( is_admin() ){ |
| 514 | $modules[] = [ |
| 515 | 'file' => $this->dir_path . '/modules/settings/base/manager.php', |
| 516 | 'class' => 'Settings\Base\Manager', |
| 517 | 'instance' => false |
| 518 | ]; |
| 519 | $modules[] = [ |
| 520 | 'file' => $this->dir_path . '/modules/settings/general/manager.php', |
| 521 | 'class' => 'Settings\General\Manager' |
| 522 | ]; |
| 523 | $modules[] = [ |
| 524 | 'file' => $this->dir_path . '/modules/settings/page/manager.php', |
| 525 | 'class' => 'Settings\Page\Manager' |
| 526 | ]; |
| 527 | } |
| 528 | |
| 529 | foreach ( $modules as $module ) { |
| 530 | if( ! empty( $module['file'] ) && ! empty( $module['class'] ) ){ |
| 531 | include_once( $module['file'] ); |
| 532 | |
| 533 | if( isset( $module['instance'] ) ) { |
| 534 | continue; |
| 535 | } |
| 536 | |
| 537 | if( class_exists( __NAMESPACE__ . '\\' . $module['class'] ) ){ |
| 538 | $class_name = __NAMESPACE__ . '\\' . $module['class']; |
| 539 | } else { |
| 540 | auxin_error( sprintf( __('Module class "%s" not found.', 'auxin-elements' ), $class_name ) ); |
| 541 | continue; |
| 542 | } |
| 543 | new $class_name(); |
| 544 | } |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | |
| 549 | /** |
| 550 | * Register controls |
| 551 | * |
| 552 | * @since 1.0.0 |
| 553 | * |
| 554 | * @access public |
| 555 | */ |
| 556 | public function register_controls( $controls_manager ) { |
| 557 | |
| 558 | $controls = array( |
| 559 | 'aux-visual-select' => array( |
| 560 | 'file' => $this->dir_path . '/controls/visual-select.php', |
| 561 | 'class' => 'Controls\Control_Visual_Select', |
| 562 | 'type' => 'single' |
| 563 | ), |
| 564 | 'aux-media' => array( |
| 565 | 'file' => $this->dir_path . '/controls/media-select.php', |
| 566 | 'class' => 'Controls\Control_Media_Select', |
| 567 | 'type' => 'single' |
| 568 | ), |
| 569 | 'aux-icon' => array( |
| 570 | 'file' => $this->dir_path . '/controls/icon-select.php', |
| 571 | 'class' => 'Controls\Control_Icon_Select', |
| 572 | 'type' => 'single' |
| 573 | ), |
| 574 | 'aux-featured-color' => array( |
| 575 | 'file' => $this->dir_path . '/controls/featured-color.php', |
| 576 | 'class' => 'Controls\Control_Featured_Color', |
| 577 | 'type' => 'single' |
| 578 | ) |
| 579 | ); |
| 580 | |
| 581 | foreach ( $controls as $control_type => $control_info ) { |
| 582 | if( ! empty( $control_info['file'] ) && ! empty( $control_info['class'] ) ){ |
| 583 | include_once( $control_info['file'] ); |
| 584 | |
| 585 | if( class_exists( $control_info['class'] ) ){ |
| 586 | $class_name = $control_info['class']; |
| 587 | } elseif( class_exists( __NAMESPACE__ . '\\' . $control_info['class'] ) ){ |
| 588 | $class_name = __NAMESPACE__ . '\\' . $control_info['class']; |
| 589 | } |
| 590 | |
| 591 | if( $control_info['type'] === 'group' ){ |
| 592 | $controls_manager->add_group_control( $control_type, new $class_name() ); |
| 593 | } else { |
| 594 | |
| 595 | if ( version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) { |
| 596 | $controls_manager->register( new $class_name() ); |
| 597 | } else { |
| 598 | $controls_manager->register_control( $control_type, new $class_name() ); |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | /** |
| 607 | * Register categories |
| 608 | * |
| 609 | * @since 1.0.0 |
| 610 | * |
| 611 | * @access public |
| 612 | */ |
| 613 | public function register_categories( $categories_manager ) { |
| 614 | |
| 615 | $categories_manager->add_category( |
| 616 | 'auxin-core', |
| 617 | array( |
| 618 | 'title' => sprintf( __( '%s - General', 'auxin-elements' ), '<strong>'. THEME_NAME_I18N .'</strong>' ), |
| 619 | 'icon' => 'eicon-font', |
| 620 | ) |
| 621 | ); |
| 622 | |
| 623 | $categories_manager->add_category( |
| 624 | 'auxin-pro', |
| 625 | array( |
| 626 | 'title' => sprintf( __( '%s - Featured', 'auxin-elements' ), '<strong>'. THEME_NAME_I18N .'</strong>' ), |
| 627 | 'icon' => 'eicon-font', |
| 628 | ) |
| 629 | ); |
| 630 | |
| 631 | $categories_manager->add_category( |
| 632 | 'auxin-dynamic', |
| 633 | array( |
| 634 | 'title' => sprintf( __( '%s - Posts', 'auxin-elements' ), '<strong>'. THEME_NAME_I18N .'</strong>' ), |
| 635 | 'icon' => 'eicon-font', |
| 636 | ) |
| 637 | ); |
| 638 | |
| 639 | $categories_manager->add_category( |
| 640 | 'auxin-portfolio', |
| 641 | array( |
| 642 | 'title' => sprintf( __( '%s - Portfolio', 'auxin-elements' ), '<strong>'. THEME_NAME_I18N .'</strong>' ), |
| 643 | 'icon' => 'eicon-font', |
| 644 | ) |
| 645 | ); |
| 646 | |
| 647 | } |
| 648 | |
| 649 | /** |
| 650 | * Enqueue styles. |
| 651 | * |
| 652 | * Enqueue all the frontend styles. |
| 653 | * |
| 654 | * @since 1.0.0 |
| 655 | * |
| 656 | * @access public |
| 657 | */ |
| 658 | public function widget_styles() { |
| 659 | // Add auxin custom styles |
| 660 | wp_enqueue_style( 'auxin-elementor-widgets' , AUXELS_ADMIN_URL . '/assets/css/elementor-widgets.css', [], AUXELS_VERSION ); |
| 661 | wp_enqueue_style( 'wp-mediaelement' ); |
| 662 | |
| 663 | } |
| 664 | |
| 665 | /** |
| 666 | * Enqueue scripts. |
| 667 | * |
| 668 | * Enqueue all the frontend scripts. |
| 669 | * |
| 670 | * @since 1.0.0 |
| 671 | * |
| 672 | * @access public |
| 673 | */ |
| 674 | public function widget_scripts() { |
| 675 | $dependencies = array('jquery', 'auxin-plugins', 'auxin-scripts'); |
| 676 | |
| 677 | if( defined('MSWP_AVERTA_VERSION') ){ |
| 678 | $dependencies[] = 'masterslider-core'; |
| 679 | } |
| 680 | wp_enqueue_script( 'auxin-elementor-widgets' , AUXELS_ADMIN_URL . '/assets/js/elementor/widgets.js' , $dependencies, AUXELS_VERSION, true ); |
| 681 | wp_enqueue_script('wp-mediaelement'); |
| 682 | } |
| 683 | |
| 684 | /** |
| 685 | * Enqueue scripts. |
| 686 | * |
| 687 | * Enqueue all the backend scripts. |
| 688 | * |
| 689 | * @since 1.0.0 |
| 690 | * |
| 691 | * @access public |
| 692 | */ |
| 693 | public function editor_scripts() { |
| 694 | // Auxin Icons |
| 695 | wp_register_style( 'auxin-front-icon' , THEME_URL . 'css/auxin-icon.css', null, AUXELS_VERSION ); |
| 696 | // Elementor Custom Style |
| 697 | wp_register_style( 'auxin-elementor-editor', AUXELS_ADMIN_URL . '/assets/css/elementor-editor.css', array(), AUXELS_VERSION ); |
| 698 | // Elementor Custom Scripts |
| 699 | wp_register_script( 'auxin-elementor-editor', AUXELS_ADMIN_URL . '/assets/js/elementor/editor.js', array( 'jquery-elementor-select2' ), AUXELS_VERSION ); |
| 700 | } |
| 701 | |
| 702 | /** |
| 703 | * Enqueue scripts. |
| 704 | * |
| 705 | * Enqueue all the bac kend scripts after enqueuing editor scripts. |
| 706 | * |
| 707 | * @since 2.9.6 |
| 708 | * |
| 709 | */ |
| 710 | public function editor_after_enqueue_scripts() { |
| 711 | // Elementor Custom Scripts |
| 712 | wp_enqueue_script( 'auxin-elementor-editor-context-menus', AUXELS_ADMIN_URL . '/assets/js/elementor/context-menu.js', [], AUXELS_VERSION ); |
| 713 | } |
| 714 | |
| 715 | /** |
| 716 | * Admin notice |
| 717 | * |
| 718 | * Warning when the site doesn't have a minimum required Elementor version. |
| 719 | * |
| 720 | * @since 1.0.0 |
| 721 | * |
| 722 | * @access public |
| 723 | */ |
| 724 | public function admin_notice_minimum_elementor_version() { |
| 725 | |
| 726 | if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); |
| 727 | |
| 728 | $message = sprintf( |
| 729 | esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'auxin-elements' ), |
| 730 | '<strong>' . esc_html__( 'Phlox Core Elements', 'auxin-elements' ) . '</strong>', |
| 731 | '<strong>' . esc_html__( 'Elementor', 'auxin-elements' ) . '</strong>', |
| 732 | self::MINIMUM_ELEMENTOR_VERSION |
| 733 | ); |
| 734 | |
| 735 | printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); |
| 736 | } |
| 737 | |
| 738 | /** |
| 739 | * Admin notice |
| 740 | * |
| 741 | * Warning when the site doesn't have a minimum required PHP version. |
| 742 | * |
| 743 | * @since 1.0.0 |
| 744 | * |
| 745 | * @access public |
| 746 | */ |
| 747 | public function admin_notice_minimum_php_version() { |
| 748 | |
| 749 | if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); |
| 750 | |
| 751 | $message = sprintf( |
| 752 | /* translators: 1: Plugin name 2: PHP 3: Required PHP version */ |
| 753 | esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'auxin-elements' ), |
| 754 | '<strong>' . esc_html__( 'Phlox Core Elements', 'auxin-elements' ) . '</strong>', |
| 755 | '<strong>' . esc_html__( 'PHP', 'auxin-elements' ) . '</strong>', |
| 756 | self::MINIMUM_PHP_VERSION |
| 757 | ); |
| 758 | |
| 759 | printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); |
| 760 | } |
| 761 | |
| 762 | /** |
| 763 | * Set options on auxin load |
| 764 | * |
| 765 | * Change The Default Settings of Elementor. |
| 766 | * |
| 767 | * @since 1.0.0 |
| 768 | * |
| 769 | * @access public |
| 770 | */ |
| 771 | public function auxin_admin_loaded() { |
| 772 | |
| 773 | if( false !== auxin_get_transient( 'auxin_has_checked_to_disable_default_elementor_colors_fonts' ) ){ |
| 774 | return; |
| 775 | } |
| 776 | |
| 777 | if( ! function_exists( 'auxin_get_options' ) ){ |
| 778 | return; |
| 779 | } |
| 780 | |
| 781 | // If it's a fresh installation |
| 782 | if( ! auxin_get_options() ){ |
| 783 | update_option( 'elementor_disable_color_schemes', 'yes' ); |
| 784 | update_option( 'elementor_disable_typography_schemes', 'yes' ); |
| 785 | update_option( 'elementor_page_title_selector', '.page-title' ); |
| 786 | update_option( 'elementor_allow_svg', '1' ); |
| 787 | } |
| 788 | |
| 789 | auxin_set_transient( 'auxin_has_checked_to_disable_default_elementor_colors_fonts', THEME_VERSION, 3 * YEAR_IN_SECONDS ); |
| 790 | } |
| 791 | |
| 792 | /** |
| 793 | * Add Auxin Icons to elementor icons pack |
| 794 | * |
| 795 | * @param array $tabs Icon library tabs |
| 796 | * @return void |
| 797 | */ |
| 798 | public function add_auxin_font_icons( $tabs = [] ) { |
| 799 | |
| 800 | // Phlox Icon set 1 |
| 801 | $icons_list = array(); |
| 802 | $icons = Auxin()->Font_Icons->get_icons_list( 'fontastic' ); |
| 803 | |
| 804 | if( is_array( $icons ) ){ |
| 805 | foreach ( $icons as $icon ) { |
| 806 | $icons_list[] = str_replace( '.auxicon-', '', $icon->classname ); |
| 807 | } |
| 808 | } |
| 809 | |
| 810 | $tabs['auxicon'] = [ |
| 811 | 'name' => 'auxin-front-icon', |
| 812 | 'label' => __( 'Phlox Icons - Set 1', 'auxin-elements' ), |
| 813 | 'url' => THEME_URL . 'css/auxin-icon.css', |
| 814 | 'enqueue' => [ THEME_URL . 'css/auxin-icon.css' ], |
| 815 | 'prefix' => 'auxicon-', |
| 816 | 'displayPrefix' => 'auxicon', |
| 817 | 'labelIcon' => 'auxicon-sun', |
| 818 | 'ver' => '1.0.0', |
| 819 | 'icons' => $icons_list |
| 820 | ]; |
| 821 | |
| 822 | // Phlox Icon set 2 |
| 823 | $icons_list2 = array(); |
| 824 | $icons2 = Auxin()->Font_Icons->get_icons_list( 'auxicon2' ); |
| 825 | |
| 826 | if( is_array( $icons2 ) ){ |
| 827 | foreach ( $icons2 as $icon ) { |
| 828 | $icons_list2[] = str_replace( '.auxicon2-', '', $icon->classname ); |
| 829 | } |
| 830 | } |
| 831 | |
| 832 | $tabs['auxicon2'] = [ |
| 833 | 'name' => 'auxin-front-icon2', |
| 834 | 'label' => __( 'Phlox Icons - Set 2', 'auxin-elements' ), |
| 835 | 'url' => THEME_URL . 'css/auxin-icon.css', |
| 836 | 'enqueue' => [ THEME_URL . 'css/auxin-icon.css' ], |
| 837 | 'prefix' => 'auxicon2-', |
| 838 | 'displayPrefix' => 'auxicon2', |
| 839 | 'labelIcon' => 'auxicon-sun', |
| 840 | 'ver' => '1.0.0', |
| 841 | 'icons' => $icons_list2 |
| 842 | ]; |
| 843 | |
| 844 | return $tabs; |
| 845 | } |
| 846 | |
| 847 | /** |
| 848 | * Clear cache. |
| 849 | * |
| 850 | * Delete all meta containing files data. And delete the actual |
| 851 | * files from the upload directory. |
| 852 | * |
| 853 | */ |
| 854 | public function clear_cache(){ |
| 855 | // \Elementor\Plugin::instance()->files_manager->clear_cache(); |
| 856 | } |
| 857 | |
| 858 | public function additional_fonts( $fonts ) { |
| 859 | $fonts['Space Grotesk'] = 'googlefonts'; |
| 860 | return $fonts; |
| 861 | } |
| 862 | } |
| 863 | |
| 864 | Elements::instance(); |
| 865 |