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