| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
final class Eshb_Elementor_Extension { |
| 4 |
/** |
| 5 |
* Instance |
| 6 |
* |
| 7 |
* @since 1.0.0 |
| 8 |
* |
| 9 |
* @access private |
| 10 |
* @static |
| 11 |
* |
| 12 |
* @var Elementor_Test_Extension The single instance of the class. |
| 13 |
*/ |
| 14 |
private static $_instance = null; |
| 15 |
|
| 16 |
/** |
| 17 |
* Instance |
| 18 |
* |
| 19 |
* Ensures only one instance of the class is loaded or can be loaded. |
| 20 |
* |
| 21 |
* @since 1.0.0 |
| 22 |
* |
| 23 |
* @access public |
| 24 |
* @static |
| 25 |
* |
| 26 |
* @return Elementor_Test_Extension An instance of the class. |
| 27 |
*/ |
| 28 |
public static function instance() { |
| 29 |
|
| 30 |
if ( is_null( self::$_instance ) ) { |
| 31 |
self::$_instance = new self(); |
| 32 |
} |
| 33 |
return self::$_instance; |
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Constructor |
| 39 |
* |
| 40 |
* @since 1.0.0 |
| 41 |
* |
| 42 |
* @access public |
| 43 |
*/ |
| 44 |
public function __construct() { |
| 45 |
add_action( 'plugins_loaded', [ $this, 'init' ] ); |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
/** |
| 50 |
* Initialize the plugin |
| 51 |
* |
| 52 |
* Load the plugin only after Elementor (and other plugins) are loaded. |
| 53 |
* Checks for basic plugin requirements, if one check fail don't continue, |
| 54 |
* if all check have passed load the files required to run the plugin. |
| 55 |
* |
| 56 |
* Fired by `plugins_loaded` action hook. |
| 57 |
* |
| 58 |
* @since 1.0.0 |
| 59 |
* |
| 60 |
* @access public |
| 61 |
*/ |
| 62 |
public function init() { |
| 63 |
|
| 64 |
// Add Plugin actions |
| 65 |
add_action( 'elementor/widgets/register', [ $this, 'init_widgets' ] ); |
| 66 |
add_action( 'elementor/elements/categories_registered', [ $this, 'add_category' ] ); |
| 67 |
|
| 68 |
|
| 69 |
$this->include_files(); |
| 70 |
} |
| 71 |
|
| 72 |
public function include_files() { |
| 73 |
|
| 74 |
} |
| 75 |
|
| 76 |
public function add_category( $elements_manager ) { |
| 77 |
$elements_manager->add_category( |
| 78 |
'easy_hotel_category', |
| 79 |
[ |
| 80 |
'title' => esc_html__('Easy Hotel', 'easy-hotel' ), |
| 81 |
'icon' => esc_attr('fa fa-smile-o'), |
| 82 |
] |
| 83 |
); |
| 84 |
} |
| 85 |
|
| 86 |
public function init_widgets() { |
| 87 |
|
| 88 |
//Search Form |
| 89 |
require_once(__DIR__ . '/search-form/search-form.php'); |
| 90 |
\Elementor\Plugin::instance()->widgets_manager->register(new \Eshb_Search_Widget()); |
| 91 |
|
| 92 |
//Booking Form |
| 93 |
require_once(__DIR__ . '/booking-form/booking-form.php'); |
| 94 |
\Elementor\Plugin::instance()->widgets_manager->register(new \Eshb_Booking_Form_Widget()); |
| 95 |
|
| 96 |
//Availability Calendar |
| 97 |
require_once(__DIR__ . '/availability-calendar/availability-calendar.php'); |
| 98 |
\Elementor\Plugin::instance()->widgets_manager->register(new \Eshb_Availability_Calendar_Widget()); |
| 99 |
|
| 100 |
|
| 101 |
//room grid |
| 102 |
require_once(__DIR__ . '/room-grid/room-grid-widget.php'); |
| 103 |
\Elementor\Plugin::instance()->widgets_manager->register(new \Eshb_Room_Grid_Widget()); |
| 104 |
|
| 105 |
//room grid |
| 106 |
require_once(__DIR__ . '/room-slider/room-slider-widget.php'); |
| 107 |
\Elementor\Plugin::instance()->widgets_manager->register(new \Eshb_Room_Slider_Widget()); |
| 108 |
|
| 109 |
//room gaallery |
| 110 |
require_once(__DIR__ . '/room-gallery/room-gallery.php'); |
| 111 |
\Elementor\Plugin::instance()->widgets_manager->register(new \Eshb_Room_Gallery_Widget()); |
| 112 |
|
| 113 |
// room basic info |
| 114 |
require_once(__DIR__ . '/room-basic-info/room-basic-info.php'); |
| 115 |
\Elementor\Plugin::instance()->widgets_manager->register(new \Eshb_Room_Basic_Info_Widget()); |
| 116 |
|
| 117 |
} |
| 118 |
} |
| 119 |
Eshb_Elementor_Extension::instance(); |
| 120 |
|
| 121 |
add_action( 'init', function() { |
| 122 |
if( ! class_exists( '\Bricks\Elements' ) ) { |
| 123 |
return; // Bricks is not active |
| 124 |
} |
| 125 |
$element_files = [ |
| 126 |
__DIR__ . '/bricks/room-gallery/room-gallery.php', |
| 127 |
__DIR__ . '/bricks/room-grid/room-grid.php', |
| 128 |
__DIR__ . '/bricks/room-slider/room-slider.php', |
| 129 |
]; |
| 130 |
|
| 131 |
foreach ( $element_files as $file ) { |
| 132 |
\Bricks\Elements::register_element( $file ); |
| 133 |
} |
| 134 |
}, 11 ); |
| 135 |
|
| 136 |
|