forked from MarieComet/elementor-custom-skins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.php
102 lines (93 loc) · 2.25 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
91
92
93
94
95
96
97
98
99
100
101
102
<?php
namespace MCElementorCustomSkins;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class Plugin {
/**
* Instance
*
* @since 0.0.1
* @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.1
* @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;
}
/**
* widget_scripts
*
* Load required plugin core files.
*
* @since 0.0.1
* @access public
*/
public function widget_scripts() {
wp_register_script( 'posts-skin-slide', plugins_url( '/assets/js/elementor-custom-skins.js', __FILE__ ), [ 'jquery' ], false, true );
}
/**
* widgets styles
*
* Load widgets styles
*
*/
public function widget_styles() {
wp_enqueue_style( 'elementor-custom-skins', plugins_url( 'assets/css/elementor-custom-skins.css', __FILE__ ) );
}
/**
* Include Widgets skins
*
* Load widgets skins
*
* @since 0.0.1
* @access private
*/
private function include_skins_files() {
require_once( __DIR__ . '/skins/button/skin-simple.php' );
}
/**
* Register Widgets
*
* Register new Elementor widgets.
*
* @since 0.0.1
* @access public
*/
public function elementor_init() {
// Its is now safe to include Widgets skins
$this->include_skins_files();
// Register skin
add_action( 'elementor/widget/button/skins_init', function( $widget ) {
$widget->add_skin( new Button\Skin_Simple($widget) );
} );
}
/**
* Plugin class constructor
*
* Register plugin action hooks and filters
*
* @since 0.0.1
* @access public
*/
public function __construct() {
// Register widget scripts
//add_action( 'elementor/frontend/after_register_scripts', [ $this, 'widget_scripts' ] );
//add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'widget_styles' ] );
add_action( 'elementor/init', [ $this, 'elementor_init' ], 0 );
}
}
Plugin::instance();