-
Notifications
You must be signed in to change notification settings - Fork 1
/
magical-addons-for-elementor.php
251 lines (223 loc) · 5.59 KB
/
magical-addons-for-elementor.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
/**
* @link http://wpthemespace.com
* @since 1.1.0
* @package Magical Addons For Elementor
*
* @wordpress-plugin
* Plugin Name: Magical Addons For Elementor
* Plugin URI:
* Description: Premium addons for Elementor page builder
* Version: 1.1.8
* Author: Noor alam
* Author URI: https://profiles.wordpress.org/nalam-1
* Elementor tested up to: 3.8
* Elementor Pro tested up to: 3.7
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: magical-addons-for-elementor
* Domain Path: /languages
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
/**
* Main Magical Addons For Elementor Class
*
* The main class that initiates and runs the plugin.
*
* @since 1.0.0
*/
final class Magical_Addons_Elementor
{
/**
* Plugin Version
*
* @since 1.0.0
*
* @var string The plugin version.
*/
const VERSION = '1.1.8';
/**
* Minimum Elementor Version
*
* @since 1.0.0
*
* @var string Minimum Elementor version required to run the plugin.
*/
const MINIMUM_ELEMENTOR_VERSION = '2.6.0';
/**
* Minimum PHP Version
*
* @since 1.0.0
*
* @var string Minimum PHP version required to run the plugin.
*/
const MINIMUM_PHP_VERSION = '5.6';
/**
* Instance
*
* @since 1.0.0
*
* @access private
* @static
*
* @var Elementor_Test_Extension 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 1.0.0
*
* @access public
* @static
*
* @return Elementor_Test_Extension An instance of the class.
*/
public static function instance()
{
if (is_null(self::$_instance)) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Constructor
*
* @since 1.0.0
*
* @access public
*/
public function __construct()
{
$this->define_main();
// add_action('activated_plugin', [$this, 'go_welcome_page']);
add_action('init', [$this, 'i18n']);
add_action('plugins_loaded', [$this, 'init']);
$this->call_main_file();
}
/**
* Constract define
* @since 1.0.0
*
* @access public
*/
public function define_main()
{
define('MAGICAL_ADDON_VERSION', self::VERSION);
define('MAGICAL_ADDON_URL', plugin_dir_url(__FILE__));
define('MAGICAL_ADDON_ASSETS', plugin_dir_url(__FILE__) . '/assets/');
define('MAGICAL_ADDON_PATH', plugin_dir_path(__FILE__));
define('MAGICAL_ADDON_ROOT', __FILE__);
}
/**
* regirect welcome page
* @since 1.0.0
*
* @access public
*/
public function go_welcome_page($plugin)
{
if (plugin_basename(__FILE__) == $plugin) {
wp_redirect(admin_url('admin.php?page=magical-addons'));
die();
}
}
/**
* Load Textdomain
*
* Load plugin localization files.
*
* Fired by `init` action hook.
*
* @since 1.0.0
*
* @access public
*/
public function i18n()
{
load_plugin_textdomain('magical-addons-for-elementor');
}
/**
* Initialize the plugin
*
* Load the plugin only after Elementor (and other plugins) are loaded.
* Checks for basic plugin requirements, if one check fail don't continue,
* if all check have passed load the files required to run the plugin.
*
* Fired by `plugins_loaded` action hook.
*
* @since 1.0.0
*
* @access public
*/
public function init()
{
$mgadmin_notices = new mgAdminNotice();
$enque_file = new mgAddonsEnqueueFile();
// Add Plugin actions
add_action('elementor/widgets/widgets_registered', [$this, 'init_widgets']);
add_action('elementor/elements/categories_registered', [$this, 'register_new_category']);
add_action('elementor/editor/after_enqueue_styles', [$this, 'editor_widget_styles']);
add_action('elementor/preview/enqueue_styles', [$this, 'editor_preview_widget_styles']);
// version update
if (get_option('mgaddon_version') != MAGICAL_ADDON_VERSION) {
update_option('mgaddon_version', MAGICAL_ADDON_VERSION);
}
}
public function register_new_category($manager)
{
$manager->add_category('magical', [
'title' => esc_html__('Magical Elements', 'magical-addons-for-elementor'),
'icon' => 'fa fa-magic',
]);
}
function editor_widget_styles()
{
wp_enqueue_style('mg-editor-style', plugins_url('/assets/css/mg-editor-style.css', __FILE__), array(), MAGICAL_ADDON_VERSION, 'all');
}
function editor_preview_widget_styles()
{
wp_enqueue_style('mg-editor-style', plugins_url('/assets/css/mg-editor-style-preview.css', __FILE__), array(), MAGICAL_ADDON_VERSION, 'all');
}
/**
* Init Widgets
*
* Include widgets files and register them
*
* @since 1.0.0
*
* @access public
*/
public function init_widgets()
{
// Include Widget files
require_once(__DIR__ . '/includes/magical-init-widgets.php');
magicalWidgetInit::mg_addons_widget_init();
}
/**
* Call base file
*
* Include files
*
* @since 1.0.0
*
* @access public
*/
public function call_main_file()
{
// include file
require_once(MAGICAL_ADDON_PATH . '/includes/basic/assets-managment.php');
require_once(MAGICAL_ADDON_PATH . '/includes/functions.php');
require_once(MAGICAL_ADDON_PATH . '/libs/class.settings-api.php');
require_once(MAGICAL_ADDON_PATH . '/includes/admin/admin-page.php');
require_once(MAGICAL_ADDON_PATH . '/includes/btn-icons-class.php');
include_once MAGICAL_ADDON_PATH . '/includes/admin/helper/admin-info.php';
include_once MAGICAL_ADDON_PATH . '/includes/admin/helper/activation.php';
require_once(MAGICAL_ADDON_PATH . '/libs/lib/index.php');
}
}
Magical_Addons_Elementor::instance();