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