| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { exit; } // No, Direct access Sir !!! |
| 4 |
|
| 5 |
if( !class_exists('Master_Elementor_Addons') ){ |
| 6 |
final class Master_Elementor_Addons { |
| 7 |
|
| 8 |
const VERSION = "1.0.8"; |
| 9 |
|
| 10 |
const MINIMUM_PHP_VERSION = '5.4'; |
| 11 |
|
| 12 |
const MINIMUM_ELEMENTOR_VERSION = '2.0.0'; |
| 13 |
|
| 14 |
private $_localize_settings = []; |
| 15 |
|
| 16 |
private static $plugin_path; |
| 17 |
private static $plugin_url; |
| 18 |
private static $plugin_slug; |
| 19 |
public static $plugin_dir_url; |
| 20 |
public static $plugin_name = 'Master Addons for Elementor'; |
| 21 |
|
| 22 |
private static $instance = null; |
| 23 |
|
| 24 |
public $pro_enabled; |
| 25 |
|
| 26 |
public static $maad_el_default_widgets; |
| 27 |
public static $maad_el_default_form_widgets; |
| 28 |
|
| 29 |
|
| 30 |
public static function get_instance() { |
| 31 |
if ( ! self::$instance ) { |
| 32 |
self::$instance = new self; |
| 33 |
|
| 34 |
self::$instance -> ma_el_init(); |
| 35 |
} |
| 36 |
|
| 37 |
return self::$instance; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
public function __construct() { |
| 42 |
|
| 43 |
self::$maad_el_default_widgets = [ |
| 44 |
'ma-headlines', |
| 45 |
'ma-call-to-action', |
| 46 |
'ma-dual-heading', |
| 47 |
'ma-accordion', |
| 48 |
'ma-tabs', |
| 49 |
'ma-tooltip', |
| 50 |
'ma-progressbar', |
| 51 |
'ma-progressbars', |
| 52 |
'ma-team-members', |
| 53 |
'ma-team-members-slider', |
| 54 |
'ma-creative-buttons', |
| 55 |
|
| 56 |
// 'ma-creative-links', |
| 57 |
|
| 58 |
'contact-form-7', |
| 59 |
'ninja-forms', |
| 60 |
['gravity-forms','pro'], |
| 61 |
'wpforms', |
| 62 |
'caldera-forms', |
| 63 |
'weforms', |
| 64 |
|
| 65 |
// 'ma-piechart', |
| 66 |
// 'ma-infobox', |
| 67 |
// 'ma-flipbox', |
| 68 |
// 'ma-cards', |
| 69 |
// 'ma-counter-up', |
| 70 |
// 'ma-countdown-timer', |
| 71 |
|
| 72 |
// 'ma-image-comparison', |
| 73 |
// 'ma-business-hours', |
| 74 |
// 'countdown-timer', |
| 75 |
// 'post-grid', |
| 76 |
// 'post-timeline', |
| 77 |
// 'testimonial-carousel', |
| 78 |
// 'pricing-table', |
| 79 |
// 'post-carousel', |
| 80 |
// 'google-maps', |
| 81 |
// 'tooltip', |
| 82 |
// ['contact-form-7','pro'], |
| 83 |
]; |
| 84 |
|
| 85 |
self::$maad_el_default_form_widgets = [ |
| 86 |
// 'contact-form-7' |
| 87 |
|
| 88 |
]; |
| 89 |
|
| 90 |
|
| 91 |
// search for pro version |
| 92 |
// $this->pro_enabled = apply_filters( 'ma_el/pro_enabled', false ); |
| 93 |
|
| 94 |
$this->constants(); |
| 95 |
$this->maad_el_include_files(); |
| 96 |
$this->mela_define_admin_hooks(); |
| 97 |
|
| 98 |
self::$plugin_slug = 'master-addons'; |
| 99 |
self::$plugin_path = untrailingslashit( plugin_dir_path( '/', __FILE__ ) ); |
| 100 |
self::$plugin_url = untrailingslashit( plugins_url( '/', __FILE__ ) ); |
| 101 |
|
| 102 |
// Initialize Plugin |
| 103 |
add_action('plugins_loaded', [$this, 'ma_el_plugins_loaded']); |
| 104 |
|
| 105 |
|
| 106 |
//Init Function |
| 107 |
// add_action( 'init', [ $this, 'ma_el_init' ] ); |
| 108 |
|
| 109 |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), [ $this, 'plugin_actions_links' ] ); |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
add_action( 'elementor/init', [ $this, 'mela_category' ] ); |
| 114 |
|
| 115 |
// Enqueue Styles and Scripts |
| 116 |
add_action( 'wp_enqueue_scripts', [ $this, 'maad_el_enqueue_scripts' ], 20 ); |
| 117 |
|
| 118 |
|
| 119 |
// Elementor Dependencies |
| 120 |
|
| 121 |
add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'maad_el_editor_styles' ] ); |
| 122 |
|
| 123 |
// Add Elementor Widgets |
| 124 |
add_action( 'elementor/widgets/widgets_registered', [ $this, 'maad_el_init_widgets' ] ); |
| 125 |
|
| 126 |
// add_action( 'elementor/frontend/after_register_scripts', [ $this, 'ma_el_enqueue_frontend_scripts' ] ); |
| 127 |
// add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'ma_el_enqueue_frontend_styles' ] ); |
| 128 |
|
| 129 |
|
| 130 |
//Body Class |
| 131 |
add_filter( 'body_class', [ $this, 'mela_ea_body_class' ] ); |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
public function ma_el_init() { |
| 137 |
|
| 138 |
// $this->mela_load_textdomain(); |
| 139 |
$this->ma_el_image_size(); |
| 140 |
|
| 141 |
//Premium Addons |
| 142 |
// $this->ma_el_premium_addons(); |
| 143 |
|
| 144 |
//Redirect Hook |
| 145 |
add_action( 'admin_init', [ $this, 'mael_ad_redirect_hook' ]); |
| 146 |
|
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
// Initialize |
| 151 |
public function ma_el_plugins_loaded(){ |
| 152 |
|
| 153 |
// Check if Elementor installed and activated |
| 154 |
if ( ! did_action( 'elementor/loaded' ) ) { |
| 155 |
add_action( 'admin_notices', array( $this, 'mela_admin_notice_missing_main_plugin' ) ); |
| 156 |
return; |
| 157 |
} |
| 158 |
|
| 159 |
// Check for required Elementor version |
| 160 |
if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) { |
| 161 |
add_action( 'admin_notices', array( $this, 'mela_admin_notice_minimum_elementor_version' ) ); |
| 162 |
return; |
| 163 |
} |
| 164 |
|
| 165 |
// Check for required PHP version |
| 166 |
if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) { |
| 167 |
add_action( 'admin_notices', array( $this, 'mela_admin_notice_minimum_php_version' ) ); |
| 168 |
return; |
| 169 |
} |
| 170 |
|
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
public function constants() { |
| 175 |
|
| 176 |
//Defined Constants |
| 177 |
if ( ! defined( 'MELA' ) ) { |
| 178 |
define( 'MELA', self::$plugin_name ); |
| 179 |
} |
| 180 |
|
| 181 |
if ( ! defined( 'MELA_VERSION' ) ) { |
| 182 |
define( 'MELA_VERSION', self::version() ); |
| 183 |
} |
| 184 |
|
| 185 |
if ( ! defined( 'MA_EL_SCRIPT_SUFFIX' ) ) { |
| 186 |
define( 'MA_EL_SCRIPT_SUFFIX', defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min' ); |
| 187 |
} |
| 188 |
|
| 189 |
if ( ! defined( 'MELA_BASE' ) ) { |
| 190 |
define( 'MELA_BASE', plugin_basename( __FILE__ ) ); |
| 191 |
} |
| 192 |
|
| 193 |
if ( ! defined( 'MELA_PLUGIN_URL' ) ) { |
| 194 |
define( 'MELA_PLUGIN_URL', self::mela_plugin_url() ); |
| 195 |
} |
| 196 |
|
| 197 |
if ( ! defined( 'MELA_PLUGIN_PATH' ) ) { |
| 198 |
define( 'MELA_PLUGIN_PATH', self::mela_plugin_path() ); |
| 199 |
} |
| 200 |
|
| 201 |
if ( ! defined( 'MELA_PLUGIN_PATH_URL' ) ) { |
| 202 |
define( 'MELA_PLUGIN_PATH_URL', self::mela_plugin_dir_url() ); |
| 203 |
} |
| 204 |
|
| 205 |
if ( ! defined( 'MELA_IMAGE_DIR' ) ) { |
| 206 |
define( 'MELA_IMAGE_DIR', self::mela_plugin_dir_url() . '/assets/images/' ); |
| 207 |
} |
| 208 |
|
| 209 |
if ( ! defined( 'MELA_ADMIN_ASSETS' ) ) { |
| 210 |
define( 'MELA_ADMIN_ASSETS', self::mela_plugin_dir_url() . '/inc/admin/assets/' ); |
| 211 |
} |
| 212 |
|
| 213 |
if ( ! defined( 'MAAD_EL_ADDONS' ) ) { |
| 214 |
define( 'MAAD_EL_ADDONS', plugin_dir_path( __FILE__ ) . 'addons/' ); |
| 215 |
} |
| 216 |
|
| 217 |
if ( ! defined( 'MELA_TEMPLATES' ) ) { |
| 218 |
define( 'MELA_TEMPLATES', plugin_dir_path( __FILE__ ) . 'inc/template-parts/' ); |
| 219 |
} |
| 220 |
|
| 221 |
// Master Addons Text Domain |
| 222 |
if ( ! defined( 'MELA_TD' ) ) { |
| 223 |
define( 'MELA_TD', $this->mela_load_textdomain() ); |
| 224 |
} |
| 225 |
|
| 226 |
if ( ! defined( 'MELA_FILE' ) ) { |
| 227 |
define( 'MELA_FILE', __FILE__ ); |
| 228 |
} |
| 229 |
|
| 230 |
if ( ! defined( 'MELA_DIR' ) ) { |
| 231 |
define( 'MELA_DIR', dirname( __FILE__ ) ); |
| 232 |
} |
| 233 |
if ( ! defined( 'MA_EL_FREEMIUS_ID' ) ) { |
| 234 |
define( 'MA_EL_FREEMIUS_ID', '4015' ); |
| 235 |
} |
| 236 |
if ( ! defined( 'MA_EL_FREEMIUS_PUBLIC_KEY' ) ) { |
| 237 |
define( 'MA_EL_FREEMIUS_PUBLIC_KEY', 'pk_3c9b5b4e47a06288e3500c7bf812e' ); |
| 238 |
} |
| 239 |
if ( ! defined( 'MA_EL_FREEMIUS_SECRET_KEY' ) ) { |
| 240 |
define( 'MA_EL_FREEMIUS_SECRET_KEY', 'sk_3AARVId*C!kTXIUeYO0Cq>w%Vl?d@' ); |
| 241 |
} |
| 242 |
|
| 243 |
} |
| 244 |
|
| 245 |
function mela_category() { |
| 246 |
|
| 247 |
\Elementor\Plugin::instance()->elements_manager->add_category( |
| 248 |
'master-addons', |
| 249 |
[ |
| 250 |
'title' => esc_html__( 'Master Addons', MELA_TD ), |
| 251 |
'icon' => 'font', |
| 252 |
], |
| 253 |
1 ); |
| 254 |
} |
| 255 |
|
| 256 |
public function ma_el_image_size() { |
| 257 |
add_image_size( 'master_addons_team_thumb', 250, 330, true ); |
| 258 |
} |
| 259 |
|
| 260 |
|
| 261 |
public static function activated_widgets() { |
| 262 |
$maad_el_default_settings = array_fill_keys( ma_el_array_flatten( self::$maad_el_default_widgets ), |
| 263 |
true ); |
| 264 |
$maad_el_get_settings = get_option( 'maad_el_save_settings', $maad_el_default_settings ); |
| 265 |
$maad_el_new_settings = array_diff_key( $maad_el_default_settings, $maad_el_get_settings ); |
| 266 |
|
| 267 |
if ( ! empty( $maad_el_new_settings ) ) { |
| 268 |
$maad_el_updated_settings = array_merge( $maad_el_get_settings, $maad_el_new_settings ); |
| 269 |
update_option( 'maad_el_save_settings', $maad_el_updated_settings ); |
| 270 |
} |
| 271 |
|
| 272 |
return $maad_el_get_settings = get_option( 'maad_el_save_settings', $maad_el_default_settings ); |
| 273 |
|
| 274 |
} |
| 275 |
|
| 276 |
|
| 277 |
public function maad_el_init_widgets() { |
| 278 |
|
| 279 |
$activated_widgets = $this->activated_widgets(); |
| 280 |
|
| 281 |
foreach ( ma_el_array_flatten( self::$maad_el_default_widgets ) as $widget ) { |
| 282 |
if ( $activated_widgets[ $widget ] == true ) { |
| 283 |
require_once MAAD_EL_ADDONS . $widget . '/' . $widget . '.php'; |
| 284 |
} |
| 285 |
} |
| 286 |
|
| 287 |
foreach ( self::$maad_el_default_form_widgets as $form_widgets ) { |
| 288 |
// print_r( $form_widgets ); |
| 289 |
if ( $activated_widgets[ $form_widgets ] == true ) { |
| 290 |
if ( $form_widgets == 'contact-form-7' ) { |
| 291 |
if ( function_exists( 'wpcf7' ) ) { |
| 292 |
require_once MAAD_EL_ADDONS . $form_widgets . '/' . $form_widgets . '.php'; |
| 293 |
} |
| 294 |
} else { |
| 295 |
require_once MAAD_EL_ADDONS . $form_widgets . '/' . $form_widgets . '.php'; |
| 296 |
} |
| 297 |
} |
| 298 |
} |
| 299 |
|
| 300 |
} |
| 301 |
|
| 302 |
|
| 303 |
/** |
| 304 |
* |
| 305 |
* Enqueue Elementor Editor Styles |
| 306 |
* |
| 307 |
*/ |
| 308 |
public function maad_el_editor_styles() { |
| 309 |
wp_enqueue_style( 'master-addons-editor', MELA_PLUGIN_URL . '/assets/css/master-addons-editor.css' ); |
| 310 |
} |
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
/** |
| 315 |
* Enqueue Plugin Styles and Scripts |
| 316 |
* |
| 317 |
*/ |
| 318 |
public function maad_el_enqueue_scripts() { |
| 319 |
|
| 320 |
$is_activated_widget = $this->activated_widgets(); |
| 321 |
wp_enqueue_style( 'master-addons-main-style', MELA_PLUGIN_URL . '/assets/css/master-addons-styles.css' ); |
| 322 |
|
| 323 |
wp_enqueue_script( 'master-addons-scripts', MELA_PLUGIN_URL . '/assets/js/master-addons-scripts.js', [ 'jquery' ], self::VERSION, true ); |
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
/* |
| 329 |
* Register Styles |
| 330 |
*/ |
| 331 |
|
| 332 |
// wp_register_style( 'master-addons-main-style', MELA_PLUGIN_URL . '/assets/css/master-addons-styles.css' ); |
| 333 |
// wp_register_script( 'animated-main', MELA_PLUGIN_URL . '/assets/js/animated-main'.MA_EL_SCRIPT_SUFFIX.'.js', array( 'jquery' ), '1.0', true ); |
| 334 |
|
| 335 |
wp_register_style( 'master-addons-headlines', MELA_PLUGIN_URL . '/assets/css/headlines.css' ); |
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
/* |
| 341 |
* Register Scripts |
| 342 |
*/ |
| 343 |
|
| 344 |
wp_register_script( 'master-addons-progressbar', MELA_PLUGIN_URL . '/assets/js/loading-bar.js', [ 'jquery' ], |
| 345 |
self::VERSION, true ); |
| 346 |
|
| 347 |
wp_register_script( |
| 348 |
'jquery-stats', |
| 349 |
MELA_PLUGIN_URL . '/assets/js/jquery.stats' . MA_EL_SCRIPT_SUFFIX . '.js', |
| 350 |
[ 'jquery' ], |
| 351 |
MELA_VERSION, |
| 352 |
true |
| 353 |
); |
| 354 |
|
| 355 |
wp_register_script( 'master-addons-waypoints', MELA_PLUGIN_URL . '/assets/vendor/jquery.waypoints.min.js', [ 'jquery' ], self::VERSION, true ); |
| 356 |
|
| 357 |
wp_register_script( 'master-addons-team-members', MELA_PLUGIN_URL . '/assets/vendor/owlcarousel/owl.carousel.min.js', [ 'jquery' ], MELA_VERSION, true ); |
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
// Master Addons Dependencies |
| 363 |
|
| 364 |
//Progressbar |
| 365 |
if ( $is_activated_widget['ma-progressbar'] ) { |
| 366 |
wp_enqueue_script('master-addons-progressbar'); |
| 367 |
wp_enqueue_script( 'master-addons-waypoints'); |
| 368 |
} |
| 369 |
|
| 370 |
|
| 371 |
//Team Members |
| 372 |
if ( $is_activated_widget['ma-team-members'] ) { |
| 373 |
wp_enqueue_script( 'master-addons-team-members' ); |
| 374 |
} |
| 375 |
|
| 376 |
|
| 377 |
//Animated Headlines |
| 378 |
if ( $is_activated_widget['ma-headlines'] ) { |
| 379 |
wp_enqueue_style( 'master-addons-headlines' ); |
| 380 |
} |
| 381 |
|
| 382 |
//Creative Buttons |
| 383 |
if ( isset( $is_activated_widget['ma-creative-buttons'] ) ) { |
| 384 |
wp_enqueue_style( 'ma-creative-buttons', MELA_PLUGIN_URL . '/assets/vendor/creative-btn/buttons.css' ); |
| 385 |
|
| 386 |
if ( ma_el_fs()->can_use_premium_code__premium_only() ) { |
| 387 |
wp_enqueue_style( 'ma-creative-buttons-pro', MELA_PLUGIN_URL . '/assets/vendor/creative-btn/buttons-pro.css' ); |
| 388 |
} |
| 389 |
|
| 390 |
} |
| 391 |
|
| 392 |
|
| 393 |
//Creative Links |
| 394 |
if (isset( $is_activated_widget['ma-creative-links'] )) { |
| 395 |
wp_enqueue_style( 'ma-creative-links', MELA_PLUGIN_URL . '/assets/vendor/creative-links/creative-links.css' ); |
| 396 |
} |
| 397 |
|
| 398 |
|
| 399 |
//Counter Up |
| 400 |
if ( isset($is_activated_widget['ma-counter-up'] )) { |
| 401 |
wp_register_script( 'ma-counter-up', MELA_PLUGIN_URL . '/assets/js/counterup.min.js' ); |
| 402 |
wp_enqueue_script( 'ma-counter-up' ); |
| 403 |
} |
| 404 |
|
| 405 |
|
| 406 |
//Google Maps |
| 407 |
// if ( $is_activated_widget['google-maps'] ) { |
| 408 |
// wp_enqueue_script( 'master-addons-google-map-api', 'https://maps.googleapis.com/maps/api/js?key=' |
| 409 |
//.get_option |
| 410 |
//('exad_google_map_api_option'), array('jquery'),'1.8', false ); |
| 411 |
// // Gmap 3 Js |
| 412 |
// wp_enqueue_script( 'master-addons-gmap3', MELA_PLUGIN_URL . 'assets/js/vendor/gmap3.min.js', array( |
| 413 |
// 'jquery' ) |
| 414 |
//, self::VERSION, true ); |
| 415 |
// } |
| 416 |
|
| 417 |
|
| 418 |
if ( isset($is_activated_widget['ma-countdown-timer'] )) { |
| 419 |
// jQuery Countdown Js |
| 420 |
wp_register_script( 'master-addons-countdown', MELA_PLUGIN_URL . '/assets/vendor/countdown/jquery.countdown.js', |
| 421 |
array( 'jquery' ) |
| 422 |
, self::VERSION, true ); |
| 423 |
|
| 424 |
wp_enqueue_script('master-addons-countdown'); |
| 425 |
|
| 426 |
} |
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
$localize_data = array( |
| 431 |
'plugin_url' => MELA_PLUGIN_URL |
| 432 |
); |
| 433 |
wp_localize_script( 'master-addons-scripts', 'ma_el_editor', $localize_data ); |
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
} |
| 438 |
|
| 439 |
|
| 440 |
public function is_elementor_activated( $plugin_path = 'elementor/elementor.php' ) { |
| 441 |
$installed_plugins_list = get_plugins(); |
| 442 |
|
| 443 |
return isset( $installed_plugins_list[ $plugin_path ] ); |
| 444 |
} |
| 445 |
|
| 446 |
|
| 447 |
/* |
| 448 |
* Activation Plugin redirect hook |
| 449 |
*/ |
| 450 |
public function mael_ad_redirect_hook() { |
| 451 |
if ( is_plugin_active( 'elementor/elementor.php' ) ) { |
| 452 |
if ( get_option( 'maad_el_update_redirect', false ) ) { |
| 453 |
delete_option( 'maad_el_update_redirect' ); |
| 454 |
delete_transient( 'maad_el_update_redirect' ); |
| 455 |
if ( ! isset( $_GET['activate-multi'] ) && $this->is_elementor_activated() ) { |
| 456 |
wp_redirect( 'admin.php?page=master-addons-settings' ); |
| 457 |
exit; |
| 458 |
} |
| 459 |
} |
| 460 |
} |
| 461 |
} |
| 462 |
|
| 463 |
|
| 464 |
public static function version() { |
| 465 |
return self::VERSION; |
| 466 |
} |
| 467 |
|
| 468 |
|
| 469 |
// Text Domains |
| 470 |
public function mela_load_textdomain() { |
| 471 |
load_plugin_textdomain( 'mela' ); |
| 472 |
} |
| 473 |
|
| 474 |
|
| 475 |
// Admin Hooks |
| 476 |
public function mela_define_admin_hooks() { |
| 477 |
|
| 478 |
} |
| 479 |
|
| 480 |
// Plugin URL |
| 481 |
public static function mela_plugin_url() { |
| 482 |
|
| 483 |
if ( self::$plugin_url ) { |
| 484 |
return self::$plugin_url; |
| 485 |
} |
| 486 |
|
| 487 |
return self::$plugin_url = untrailingslashit( plugins_url( '/', __FILE__ ) ); |
| 488 |
|
| 489 |
} |
| 490 |
|
| 491 |
// Plugin Path |
| 492 |
public static function mela_plugin_path() { |
| 493 |
if ( self::$plugin_path ) { |
| 494 |
return self::$plugin_path; |
| 495 |
} |
| 496 |
|
| 497 |
return self::$plugin_path = untrailingslashit( plugin_dir_path( __FILE__ ) ); |
| 498 |
} |
| 499 |
|
| 500 |
// Plugin Dir Path |
| 501 |
public static function mela_plugin_dir_url() { |
| 502 |
|
| 503 |
if ( self::$plugin_dir_url ) { |
| 504 |
return self::$plugin_dir_url; |
| 505 |
} |
| 506 |
|
| 507 |
return self::$plugin_dir_url = untrailingslashit( plugin_dir_url( __FILE__ ) ); |
| 508 |
} |
| 509 |
|
| 510 |
|
| 511 |
public function plugin_actions_links( $links ) { |
| 512 |
if ( is_admin() ) { |
| 513 |
$links[] = sprintf( '<a href="admin.php?page=master-addons-settings">' . __( 'Settings', MELA_TD ) . '</a>' ); |
| 514 |
$links[] = '<a href="https://jeweltheme.com/support/forum/wordpress-plugins/master-addons/" target="_blank">' . esc_html__( 'Support', MELA_TD ) . '</a>'; |
| 515 |
$links[] = '<a href="https://docs.jeweltheme.com/master-addons" target="_blank">' . esc_html__( 'Documentation', |
| 516 |
MELA_TD ) . '</a>'; |
| 517 |
} |
| 518 |
|
| 519 |
// go pro |
| 520 |
if (!$this->pro_enabled) { |
| 521 |
$links[] = sprintf('<a href="https://master-addons.com/" target="_blank" style="color: #39b54a; font-weight: bold;">' . __('Go Pro') . '</a>'); |
| 522 |
} |
| 523 |
|
| 524 |
return $links; |
| 525 |
} |
| 526 |
|
| 527 |
|
| 528 |
// Include Files |
| 529 |
public function maad_el_include_files() { |
| 530 |
|
| 531 |
// Master Addons Class |
| 532 |
// require_once $this->mela_plugin_path() . '/class-master-elementor-addon.php'; |
| 533 |
|
| 534 |
// Helper Class |
| 535 |
include_once MELA_PLUGIN_PATH . '/inc/classes/helper-class.php'; |
| 536 |
|
| 537 |
// Dashboard Settings |
| 538 |
include_once MELA_PLUGIN_PATH . '/inc/admin/dashboard-settings.php'; |
| 539 |
|
| 540 |
//Utils |
| 541 |
include_once MELA_PLUGIN_PATH . '/inc/classes/utils.php'; |
| 542 |
|
| 543 |
include_once MELA_PLUGIN_PATH . '/inc/modules/animated-gradient/animated-gradient.php'; |
| 544 |
include_once MELA_PLUGIN_PATH . '/inc/modules/particles/particles.php'; |
| 545 |
include_once MELA_PLUGIN_PATH . '/inc/modules/bg-slider/bg-slider.php'; |
| 546 |
|
| 547 |
} |
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
public function mela_ea_body_class($classes){ |
| 553 |
if ( !\Elementor\Plugin::$instance->preview->is_preview_mode() ) { |
| 554 |
$classes[] = 'master-addons-elementor'; |
| 555 |
} |
| 556 |
return $classes; |
| 557 |
} |
| 558 |
|
| 559 |
public function include_files(){ |
| 560 |
require \Master_Elementor_Addons::mela_plugin_path() . '/inc/classes/addons-manager.php'; |
| 561 |
} |
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
public function get_localize_settings() { |
| 566 |
return $this->_localize_settings; |
| 567 |
} |
| 568 |
|
| 569 |
public function add_localize_settings( $setting_key, $setting_value = null ) { |
| 570 |
if ( is_array( $setting_key ) ) { |
| 571 |
$this->_localize_settings = array_replace_recursive( $this->_localize_settings, $setting_key ); |
| 572 |
|
| 573 |
return; |
| 574 |
} |
| 575 |
|
| 576 |
if ( ! is_array( $setting_value ) || ! isset( $this->_localize_settings[ $setting_key ] ) || ! is_array( $this->_localize_settings[ $setting_key ] ) ) { |
| 577 |
$this->_localize_settings[ $setting_key ] = $setting_value; |
| 578 |
|
| 579 |
return; |
| 580 |
} |
| 581 |
|
| 582 |
$this->_localize_settings[ $setting_key ] = array_replace_recursive( $this->_localize_settings[ $setting_key ], $setting_value ); |
| 583 |
} |
| 584 |
|
| 585 |
|
| 586 |
public function mela_admin_notice_missing_main_plugin() { |
| 587 |
$plugin = 'elementor/elementor.php'; |
| 588 |
|
| 589 |
if ( $this->is_elementor_activated() ) { |
| 590 |
if ( ! current_user_can( 'activate_plugins' ) ) { |
| 591 |
return; |
| 592 |
} |
| 593 |
$activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin ); |
| 594 |
$message = __( 'Master Addons requires <b>Elementor plugin to be active. Please activate Elementor to continue.', MELA_TD ); |
| 595 |
$button_text = __( 'Activate Elementor', MELA_TD ); |
| 596 |
|
| 597 |
} else { |
| 598 |
if ( ! current_user_can( 'install_plugins' ) ) { |
| 599 |
return; |
| 600 |
} |
| 601 |
|
| 602 |
$activation_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' ); |
| 603 |
$message = sprintf( __( 'Master Addons requires %1$s"Elementor"%2$s plugin to be installed and activated. Please install Elementor to continue.', MELA_TD ), '<strong>', '</strong>' ); |
| 604 |
$button_text = __( 'Install Elementor', MELA_TD ); |
| 605 |
} |
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
$button = '<p><a href="' . $activation_url . '" class="button-primary">' . $button_text . '</a></p>'; |
| 611 |
|
| 612 |
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p>%2$s</div>', $message , $button ); |
| 613 |
|
| 614 |
} |
| 615 |
|
| 616 |
public function mela_admin_notice_minimum_elementor_version() { |
| 617 |
if ( isset( $_GET['activate'] ) ) { |
| 618 |
unset( $_GET['activate'] ); |
| 619 |
} |
| 620 |
|
| 621 |
$message = sprintf( |
| 622 |
/* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */ |
| 623 |
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', MELA_TD ), |
| 624 |
'<strong>' . esc_html__( 'Master Addons for Elementor', MELA_TD ) . '</strong>', |
| 625 |
'<strong>' . esc_html__( 'Elementor', MELA_TD ) . '</strong>', |
| 626 |
self::MINIMUM_ELEMENTOR_VERSION |
| 627 |
); |
| 628 |
|
| 629 |
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); |
| 630 |
} |
| 631 |
|
| 632 |
public function mela_admin_notice_minimum_php_version() { |
| 633 |
if ( isset( $_GET['activate'] ) ) { |
| 634 |
unset( $_GET['activate'] ); |
| 635 |
} |
| 636 |
|
| 637 |
$message = sprintf( |
| 638 |
/* translators: 1: Plugin name 2: PHP 3: Required PHP version */ |
| 639 |
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', MELA_TD ), |
| 640 |
'<strong>' . esc_html__( 'Master Addons for Elementor', MELA_TD ) . '</strong>', |
| 641 |
'<strong>' . esc_html__( 'PHP', MELA_TD ) . '</strong>', |
| 642 |
self::MINIMUM_PHP_VERSION |
| 643 |
); |
| 644 |
|
| 645 |
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); |
| 646 |
} |
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
} |
| 652 |
|
| 653 |
|
| 654 |
Master_Elementor_Addons::get_instance(); |
| 655 |
|
| 656 |
} |
| 657 |
|
| 658 |
|
| 659 |
/** |
| 660 |
* Plugin Redirect Option Added by register_activation_hook |
| 661 |
* |
| 662 |
*/ |
| 663 |
function master_addons_el_redirect() { |
| 664 |
add_option( 'maad_el_update_redirect', true ); |
| 665 |
} |
| 666 |
register_activation_hook( __FILE__ , 'master_addons_el_redirect' ); |
| 667 |
|
| 668 |
|
| 669 |
// Deactivation Hook |
| 670 |
function master_addons_el_welcome_deactivate() { |
| 671 |
delete_transient( 'maad_el_update_redirect' ); |
| 672 |
} |
| 673 |
register_deactivation_hook( __FILE__, 'master_addons_el_welcome_deactivate' ); |
| 674 |
|