| 1 |
<?php |
| 2 |
|
| 3 |
namespace MasterAddons\Inc\Admin\Templates\Includes\Classes; |
| 4 |
|
| 5 |
/** |
| 6 |
* Author Name: Liton Arefin |
| 7 |
* Author URL: https://jeweltheme.com |
| 8 |
* Date: 9/8/19 |
| 9 |
*/ |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
if (!defined('ABSPATH')) exit; // No access of directly access |
| 14 |
|
| 15 |
if (!class_exists(__NAMESPACE__ . '\\Config')) { |
| 16 |
|
| 17 |
class Config |
| 18 |
{ |
| 19 |
|
| 20 |
private static $instance = null; |
| 21 |
private $config; |
| 22 |
private $slug = 'master-addons-pro-license'; |
| 23 |
public function __construct() |
| 24 |
{ |
| 25 |
$this->config = array( |
| 26 |
'master_addons_templates' => esc_html__('Master Addons', 'master-addons'), |
| 27 |
'key' => $this->get_license_key(), |
| 28 |
'status' => $this->get_license_status(), |
| 29 |
'license_page' => $this->get_license_page(), |
| 30 |
'pro_message' => $this->get_pro_message(), |
| 31 |
'banner' => array( |
| 32 |
'enabled' => true, |
| 33 |
'url' => 'https://master-addons.com/pricing/?utm_source=dashboard&utm_medium=template_preview&utm_campaign=pricing&utm_content=buy_now&utm_term=upgarde-to-pro', |
| 34 |
'image' => JLTMA_URL . '/assets/images/banner.png', |
| 35 |
'alt' => 'Master Addons Template Library - 530+ Redefined Designs', |
| 36 |
'target' => '_blank' |
| 37 |
), |
| 38 |
'api' => array( |
| 39 |
'enabled' => true, |
| 40 |
'base' => 'https://el.master-addons.com/', |
| 41 |
'path' => 'wp-json/masteraddons/v2', |
| 42 |
'endpoints' => array( |
| 43 |
'templates' => '/templates/', |
| 44 |
'keywords' => '/keywords/', |
| 45 |
'categories' => '/categories/', |
| 46 |
'template' => '/template/', |
| 47 |
'info' => '/info/', |
| 48 |
), |
| 49 |
) |
| 50 |
); |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
/** |
| 55 |
* Check if user has an active paid license via Freemius. |
| 56 |
*/ |
| 57 |
private function has_active_license() |
| 58 |
{ |
| 59 |
if (function_exists('ma_el_fs')) { |
| 60 |
return ma_el_fs()->can_use_premium_code(); |
| 61 |
} |
| 62 |
return false; |
| 63 |
} |
| 64 |
|
| 65 |
public function get_license_key() |
| 66 |
{ |
| 67 |
if (!$this->has_active_license()) { |
| 68 |
$key = add_query_arg(array('page' => $this->slug,), esc_url(admin_url('admin.php?page=master-addons-account'))); |
| 69 |
} else { |
| 70 |
$key = ""; |
| 71 |
} |
| 72 |
|
| 73 |
return $key; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
public function get_license_status() |
| 78 |
{ |
| 79 |
return $this->has_active_license() ? 'valid' : 'invalid'; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
public function get_license_page() |
| 84 |
{ |
| 85 |
if ($this->has_active_license()) { |
| 86 |
return esc_url(admin_url('admin.php?page=master-addons-settings-account')); |
| 87 |
} |
| 88 |
return 'https://master-addons.com/pricing/?utm_source=dashboard&utm_medium=template_preview&utm_campaign=pricing&utm_content=buy_now&utm_term=upgrade-to-pro'; |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
public function get_pro_message() |
| 93 |
{ |
| 94 |
return __('Upgrade to Pro', 'master-addons'); |
| 95 |
} |
| 96 |
|
| 97 |
public function get_plugin_status($plugin_file) |
| 98 |
{ |
| 99 |
if (is_plugin_active($plugin_file)) { |
| 100 |
return 'active'; |
| 101 |
} |
| 102 |
|
| 103 |
// Check if plugin is installed but not active |
| 104 |
if (file_exists(WP_PLUGIN_DIR . '/' . $plugin_file)) { |
| 105 |
return 'installed'; |
| 106 |
} |
| 107 |
|
| 108 |
return 'not_installed'; |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
public function get($key = '') |
| 114 |
{ |
| 115 |
|
| 116 |
return isset($this->config[$key]) ? $this->config[$key] : false; |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
public static function get_instance() |
| 122 |
{ |
| 123 |
|
| 124 |
if (self::$instance == null) { |
| 125 |
|
| 126 |
self::$instance = new self; |
| 127 |
} |
| 128 |
|
| 129 |
return self::$instance; |
| 130 |
} |
| 131 |
} |
| 132 |
} |
| 133 |
|