| @@ -2,52 +2,88 @@ | ||
| 2 | 2 | |
| 3 | 3 | // don't load directly |
| 4 | 4 | defined( 'ABSPATH' ) || exit; |
| 5 | 5 | |
| 6 | -/*-----------------------------------------------------------------------------------*/ | |
| 7 | -/* *. Borderless Category | |
| 8 | -/*-----------------------------------------------------------------------------------*/ | |
| 6 | +final class Borderless_Elementor { | |
| 9 | 7 | |
| 10 | -function add_elementor_widget_categories( $elements_manager ) { | |
| 11 | - $elements_manager->add_category( | |
| 12 | - 'borderless', | |
| 13 | - [ | |
| 14 | - 'title' => __( 'Borderless', 'borderless' ), | |
| 15 | - 'icon' => 'fa fa-plug', | |
| 16 | - ] | |
| 17 | - ); | |
| 18 | -} | |
| 19 | -add_action( 'elementor/elements/categories_registered', 'add_elementor_widget_categories' ); | |
| 8 | + private static $_instance = null; | |
| 20 | 9 | |
| 10 | + public static function instance() { | |
| 21 | 11 | |
| 22 | -/*-----------------------------------------------------------------------------------*/ | |
| 23 | -/* *. Borderless Widgets | |
| 24 | -/*-----------------------------------------------------------------------------------*/ | |
| 12 | + if ( is_null( self::$_instance ) ) { | |
| 13 | + self::$_instance = new self(); | |
| 14 | + } | |
| 15 | + return self::$_instance; | |
| 25 | 16 | |
| 26 | -class Borderless_Widgets { | |
| 17 | + } | |
| 27 | 18 | |
| 28 | - protected static $instance = null; | |
| 19 | + public function __construct() { | |
| 29 | 20 | |
| 30 | - public static function get_instance() { | |
| 31 | - if ( ! isset( static::$instance ) ) { | |
| 32 | - static::$instance = new static; | |
| 21 | + add_action( 'plugins_loaded', [ $this, 'on_plugins_loaded' ] ); | |
| 22 | + | |
| 23 | + } | |
| 24 | + | |
| 25 | + public function on_plugins_loaded() { | |
| 26 | + | |
| 27 | + if ( $this->is_compatible() ) { | |
| 28 | + add_action( 'elementor/init', [ $this, 'init' ] ); | |
| 33 | 29 | } |
| 34 | 30 | |
| 35 | - return static::$instance; | |
| 36 | 31 | } |
| 37 | 32 | |
| 38 | - protected function __construct() { | |
| 39 | - include('helper.php'); | |
| 40 | - include('widgets/contact-form-7.php'); | |
| 41 | - add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_widgets' ] ); | |
| 33 | + public function is_compatible() { | |
| 34 | + | |
| 35 | + return true; | |
| 36 | + | |
| 42 | 37 | } |
| 43 | 38 | |
| 44 | - public function register_widgets() { | |
| 39 | + public function init() { | |
| 40 | + | |
| 41 | + wp_register_style( | |
| 42 | + 'font-awesome-5', | |
| 43 | + ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/all.min.css', | |
| 44 | + false, | |
| 45 | + BORDERLESS__VERSION | |
| 46 | + ); | |
| 47 | + | |
| 48 | + // Add Plugin actions | |
| 49 | + add_action( 'elementor/widgets/widgets_registered', [ $this, 'init_widgets' ] ); | |
| 50 | + add_action( 'elementor/elements/categories_registered', [ $this, 'register_borderless_elementor_category' ] ); | |
| 51 | + | |
| 52 | + } | |
| 53 | + | |
| 54 | + public function init_widgets() { | |
| 55 | + | |
| 56 | + // Include Widget files | |
| 57 | + require_once('helper.php'); | |
| 58 | + require_once('widgets/circular-progress-bar.php'); | |
| 59 | + require_once('widgets/contact-form-7.php'); | |
| 60 | + require_once('widgets/marquee-text.php'); | |
| 61 | + require_once('widgets/progress-bar.php'); | |
| 62 | + require_once('widgets/semi-circular-progress-bar.php'); | |
| 63 | + require_once('widgets/team-member.php'); | |
| 64 | + require_once('widgets/testimonial.php'); | |
| 65 | + | |
| 66 | + // Register widget | |
| 67 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Circular_Progress_Bar() ); | |
| 45 | 68 | \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Contact_Form_7() ); |
| 69 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Marquee_text() ); | |
| 70 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Progress_Bar() ); | |
| 71 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Semi_Circular_Progress_Bar() ); | |
| 72 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Team_Member() ); | |
| 73 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Testimonial() ); | |
| 74 | + | |
| 46 | 75 | } |
| 47 | 76 | |
| 77 | + public function register_borderless_elementor_category( $elements_manager ) { | |
| 78 | + $elements_manager->add_category( | |
| 79 | + 'borderless', | |
| 80 | + [ | |
| 81 | + 'title' => __( 'Borderless', 'borderless' ), | |
| 82 | + 'icon' => 'fa fa-plug', | |
| 83 | + ] | |
| 84 | + ); | |
| 85 | + } | |
| 86 | + | |
| 48 | 87 | } |
| 49 | 88 | |
| 50 | -add_action( 'init', 'my_elementor_init' ); | |
| 51 | -function my_elementor_init() { | |
| 52 | - Borderless_Widgets::get_instance(); | |
| 53 | -} | |
| 89 | +Borderless_Elementor::instance(); | |