-
Notifications
You must be signed in to change notification settings - Fork 1
/
class-widgets.php
107 lines (95 loc) · 1.92 KB
/
class-widgets.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* Widgets class.
*
* @category Class
* @package Magic
* @subpackage WordPress
* @author DigitalCube <[email protected]>
* @license https://opensource.org/licenses/GPL-3.0 GPL-3.0-only
* @link link(https://github.com/digitalcube/magic-wp-plugin, Magic for WordPress)
* @since 0.0.0
* php version 7.3.9
*/
namespace Magic;
// Security Note: Blocks direct access to the plugin PHP files.
defined('ABSPATH') || die();
/**
* Class Plugin
*
* Main Plugin class
*
* @since 0.0.0
*/
class Widgets
{
/**
* Instance
*
* @since 0.0.0
* @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.
*
* @since 0.0.0
* @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
*
* @since 0.0.0
* @access private
*/
private function include_widgets_files()
{
require_once 'elementor/widgets/class-magic-sign-in.php';
}
/**
* Register Widgets
*
* Register new Elementor widgets.
*
* @since 0.0.0
* @access public
*/
public function register_widgets()
{
// It's now safe to include Widgets files.
$this->include_widgets_files();
// Register the plugin widget classes.
\Elementor\Plugin::instance()->widgets_manager->register_widget_type(new Widgets\MagicSignIn());
}
/**
* Plugin class constructor
*
* Register plugin action hooks and filters
*
* @since 0.0.0
* @access public
*/
public function __construct()
{
// Register the widgets.
add_action('elementor/widgets/widgets_registered', array($this, 'register_widgets'));
}
}
// Instantiate the Widgets class.
Widgets::instance();