| 1 |
<?php |
| 2 |
/** |
| 3 |
* Support Elementor. |
| 4 |
* |
| 5 |
* @package Sight |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Sight_Elementor; |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; // Exit if accessed directly. |
| 12 |
} |
| 13 |
|
| 14 |
/** |
| 15 |
* Class Sight_Elementor_Integraion |
| 16 |
*/ |
| 17 |
class Sight_Elementor_Integraion { |
| 18 |
|
| 19 |
/** |
| 20 |
* Instance |
| 21 |
* |
| 22 |
* @since 1.2.0 |
| 23 |
* @access private |
| 24 |
* @static |
| 25 |
* |
| 26 |
* @var Sight_Elementor_Integraion The single instance of the class. |
| 27 |
*/ |
| 28 |
private static $_instance = null; |
| 29 |
|
| 30 |
/** |
| 31 |
* Instance |
| 32 |
* |
| 33 |
* Ensures only one instance of the class is loaded or can be loaded. |
| 34 |
* |
| 35 |
* @return Sight_Elementor_Integraion An instance of the class. |
| 36 |
*/ |
| 37 |
public static function instance() { |
| 38 |
if ( is_null( self::$_instance ) ) { |
| 39 |
self::$_instance = new self(); |
| 40 |
} |
| 41 |
return self::$_instance; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Register Сontrols |
| 46 |
* |
| 47 |
* Register new Elementor controls. |
| 48 |
*/ |
| 49 |
public function register_controls() { |
| 50 |
// Its is now safe to include Сontrols files. |
| 51 |
require_once SIGHT_PATH . 'elementor/control-custom-post.php'; |
| 52 |
|
| 53 |
// Register Сontrols. |
| 54 |
\Elementor\Plugin::instance()->controls_manager->register_control( 'custom_post', new Controls\Sight_Control_Custom_Post() ); |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Register Widgets |
| 59 |
* |
| 60 |
* Register new Elementor widgets. |
| 61 |
*/ |
| 62 |
public function register_widgets() { |
| 63 |
// Its is now safe to include Widgets files. |
| 64 |
require_once SIGHT_PATH . 'elementor/widget-portfolio.php'; |
| 65 |
|
| 66 |
// Register Widgets. |
| 67 |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\Sight_Widget_Portfolio() ); |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Plugin class constructor |
| 72 |
* |
| 73 |
* Register plugin action hooks and filters |
| 74 |
*/ |
| 75 |
public function __construct() { |
| 76 |
require_once SIGHT_PATH . 'elementor/helper.php'; |
| 77 |
|
| 78 |
// Actions registered. |
| 79 |
add_action( 'elementor/controls/controls_registered', array( $this, 'register_controls' ) ); |
| 80 |
add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ) ); |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
// Instantiate Sight_Elementor_Integraion Class. |
| 85 |
Sight_Elementor_Integraion::instance(); |
| 86 |
|