-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponents.php
69 lines (58 loc) · 2.69 KB
/
components.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
class OPPComponents {
// to prevent re-initiating the instance, i'm using a singleton pattern
protected static $instance = null;
public static function get_instance() {
if ( null == static::$instance ) {
static::$instance = new static;
}
return static::$instance;
}
// register individual components within the directory
protected function __construct () {
require_once('home-user-directory.php');
require_once('page-directory.php');
require_once('button-list.php');
require_once('logo-buttons.php');
require_once('link-list.php');
require_once('on-this-page.php');
require_once('callout.php');
require_once('callout-download.php');
require_once('opp-divider.php');
add_action('elementor/widgets/widgets_registered', array($this, 'register_widgets'));
}
public function register_widgets() {
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor\HomeUserDirectory() );
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor\PageDirectory() );
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor\ButtonList() );
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor\LogoButtons() );
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor\LinkList() );
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor\OnThisPage() );
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor\CalloutGeneric() );
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor\CalloutDownloadBrochure() );
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor\OPPDivider() );
}
}
// Create the OPP Category
add_action( 'elementor/elements/categories_registered', 'add_new_category' );
function add_new_category( $elements_manager ) {
// new categories...
$categories = [];
$categories['opp'] =
[
'title' => 'Custom OPP Widgets',
'icon' => 'fa fa-plug'
];
// old categories, I'll be appending them so the OPP category sits up top
$old_categories = $elements_manager->get_categories();
$categories = array_merge($categories, $old_categories);
$set_categories = function ( $categories ) {
$this->categories = $categories;
};
$set_categories->call( $elements_manager, $categories );
}
// init custom components
add_action( 'init', 'opp_components_init' );
function opp_components_init() {
OPPComponents::get_instance();
}