| 1 |
<?php |
| 2 |
|
| 3 |
namespace Bookit\Widgets; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly |
| 7 |
} |
| 8 |
|
| 9 |
/** |
| 10 |
* ElementorWidget Class |
| 11 |
* |
| 12 |
* Register new elementor widget. |
| 13 |
* |
| 14 |
* @since 1.0.0 |
| 15 |
*/ |
| 16 |
class ElementorWidget { |
| 17 |
|
| 18 |
/** |
| 19 |
* Constructor |
| 20 |
* |
| 21 |
* @since 1.0.0 |
| 22 |
* |
| 23 |
* @access public |
| 24 |
*/ |
| 25 |
public function __construct() { |
| 26 |
$this->add_actions(); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Add Actions |
| 31 |
* |
| 32 |
* @since 1.0.0 |
| 33 |
* |
| 34 |
* @access private |
| 35 |
*/ |
| 36 |
private function add_actions() { |
| 37 |
add_action( 'elementor/widgets/register', array( $this, 'on_widgets_registered' ) ); |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* On Widgets Registered |
| 42 |
* |
| 43 |
* @since 1.0.0 |
| 44 |
* |
| 45 |
* @access public |
| 46 |
*/ |
| 47 |
public function on_widgets_registered() { |
| 48 |
$this->includes(); |
| 49 |
$this->register_widget(); |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Includes |
| 54 |
* |
| 55 |
* @since 1.0.0 |
| 56 |
* |
| 57 |
* @access private |
| 58 |
*/ |
| 59 |
private function includes() { |
| 60 |
require BOOKIT_INCLUDES_PATH . '/widgets/ElementorWidgetSettings.php'; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Register Widget |
| 65 |
* |
| 66 |
* @since 1.0.0 |
| 67 |
* |
| 68 |
* @access private |
| 69 |
*/ |
| 70 |
private function register_widget() { |
| 71 |
\Elementor\Plugin::instance()->widgets_manager->register( new ElementorWidgetSettings() ); |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
new ElementorWidget(); |
| 76 |
|