| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly |
| 4 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 5 |
|
| 6 |
use Elementor\Controls_Manager; |
| 7 |
|
| 8 |
class PB_Elementor { |
| 9 |
private static $_instance = null; |
| 10 |
public $locations = array( |
| 11 |
array( |
| 12 |
'element' => 'common', |
| 13 |
'action' => '_section_style', |
| 14 |
), |
| 15 |
array( |
| 16 |
'element' => 'section', |
| 17 |
'action' => 'section_advanced', |
| 18 |
) |
| 19 |
); |
| 20 |
public $section_name = 'pb_section_visibility_settings'; |
| 21 |
|
| 22 |
/** |
| 23 |
* Register plugin action hooks and filters |
| 24 |
*/ |
| 25 |
public function __construct() { |
| 26 |
// Add category |
| 27 |
add_action( 'elementor/elements/categories_registered', array( $this, 'add_category' ) ); |
| 28 |
|
| 29 |
// Register widgets |
| 30 |
add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ) ); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* |
| 35 |
* Ensures only one instance of the class is loaded or can be loaded. |
| 36 |
* |
| 37 |
* @return PB_Elementor An instance of the class. |
| 38 |
*/ |
| 39 |
public static function instance() { |
| 40 |
if ( is_null( self::$_instance ) ) |
| 41 |
self::$_instance = new self(); |
| 42 |
|
| 43 |
return self::$_instance; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Include Widgets files |
| 48 |
*/ |
| 49 |
private function include_widgets_files() { |
| 50 |
require_once(__DIR__ . '/widgets/class-pb-widget-epf.php'); |
| 51 |
require_once(__DIR__ . '/widgets/class-pb-widget-l.php'); |
| 52 |
require_once(__DIR__ . '/widgets/class-pb-widget-rp.php'); |
| 53 |
require_once(__DIR__ . '/widgets/class-pb-widget-rf.php'); |
| 54 |
require_once(__DIR__ . '/widgets/class-pb-widget-ul.php'); |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Register Widgets |
| 59 |
*/ |
| 60 |
public function register_widgets() { |
| 61 |
$this->include_widgets_files(); |
| 62 |
|
| 63 |
if( version_compare( ELEMENTOR_VERSION, '3.5,', '>=' ) ){ |
| 64 |
\Elementor\Plugin::instance()->widgets_manager->register( new PB_Elementor_Edit_Profile_Widget() ); |
| 65 |
\Elementor\Plugin::instance()->widgets_manager->register( new PB_Elementor_Login_Widget() ); |
| 66 |
\Elementor\Plugin::instance()->widgets_manager->register( new PB_Elementor_Recover_Password_Widget() ); |
| 67 |
\Elementor\Plugin::instance()->widgets_manager->register( new PB_Elementor_Register_Widget() ); |
| 68 |
\Elementor\Plugin::instance()->widgets_manager->register( new PB_Elementor_User_Listing_Widget() ); |
| 69 |
} else { |
| 70 |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new PB_Elementor_Edit_Profile_Widget() ); |
| 71 |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new PB_Elementor_Login_Widget() ); |
| 72 |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new PB_Elementor_Recover_Password_Widget() ); |
| 73 |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new PB_Elementor_Register_Widget() ); |
| 74 |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new PB_Elementor_User_Listing_Widget() ); |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
public function add_category( $elements_manager ) { |
| 79 |
$elements_manager->add_category( |
| 80 |
'profile-builder', |
| 81 |
array( |
| 82 |
'title' => __( 'Profile Builder Forms', 'profile-builder' ), |
| 83 |
'icon' => 'fa fa-plug', |
| 84 |
) |
| 85 |
); |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
// Instantiate Plugin Class |
| 90 |
PB_Elementor::instance(); |
| 91 |
|