forked from dettogatto/elementor-super-cat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.php
executable file
·90 lines (81 loc) · 2.26 KB
/
plugin.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace ElementorSuperCat;
/**
* Class Plugin
*
* Main Plugin class
*/
class Plugin {
/**
* Instance
*
* @access private
* @static
*
* @var Plugin The single instance of the class.
*/
private static $_instance = null;
/**
* Instance
*
* Ensures only one instance of the class is loaded or can be loaded.
*
* @access public
*
* @return Plugin An instance of the class.
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Include Widgets files
*
* Load widgets files
*
* @access private
*/
private function include_widgets_files() {
require_once( __DIR__ . '/widgets/form-poster.php' );
require_once( __DIR__ . '/widgets/post-filter.php' );
require_once( __DIR__ . '/widgets/param-button.php' );
require_once( __DIR__ . '/widgets/checkbox-filter.php' );
require_once( __DIR__ . '/widgets/dropdown-filter.php' );
}
/**
* Register Widgets
*
* Register new Elementor widgets.
*
* @access public
*/
public function register_widgets() {
// Its is now safe to include Widgets files
$this->include_widgets_files();
// Register Widgets
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\Form_Poster() );
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\Post_Filter() );
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\Param_Button() );
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\Checkbox_Filter() );
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\Dropdown_Filter() );
}
/**
* Plugin class constructor
*
* Register plugin action hooks and filters
*
* @access public
*/
public function __construct() {
// Register widgets
add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_widgets' ] );
add_action("wp_enqueue_scripts", function(){
wp_register_script( 'gatto-generic-js', plugins_url( '/assets/js/generic.js', __FILE__ ), array('jquery'));
wp_enqueue_script('gatto-generic-js');
});
}
}
// Instantiate Plugin Class
Plugin::instance();