| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Enter Addons |
| 4 |
* Plugin URI: https://themelooks.org/demo/enteraddons |
| 5 |
* Description: Ultimate Template Builder for Elementor |
| 6 |
* Version: 2.2.8 |
| 7 |
* Author: ThemeLooks |
| 8 |
* Author URI: https://themelooks.com |
| 9 |
* License: GPL v2 or later |
| 10 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 11 |
* Text Domain: enteraddons |
| 12 |
* Domain Path: /languages |
| 13 |
* |
| 14 |
*/ |
| 15 |
|
| 16 |
/** |
| 17 |
* Define all constant |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
// Version constant |
| 22 |
if (!defined('ENTERADDONS_VERSION')) { |
| 23 |
define('ENTERADDONS_VERSION', '2.2.8'); |
| 24 |
} |
| 25 |
// Current phpversion |
| 26 |
if (!defined('ENTERADDONS_CURRENT_PHPVERSION')) { |
| 27 |
define('ENTERADDONS_CURRENT_PHPVERSION', PHP_VERSION); |
| 28 |
} |
| 29 |
|
| 30 |
if (!defined('ENTERADDONS_VERSION_TYPE')) { |
| 31 |
define('ENTERADDONS_VERSION_TYPE', 'LITE'); |
| 32 |
} |
| 33 |
// Version plugin mode constant ( PRODUCTION, DEV ) |
| 34 |
if (!defined('ENTERADDONS_PLUGIN_MODE')) { |
| 35 |
define('ENTERADDONS_PLUGIN_MODE', 'PRODUCTION'); |
| 36 |
} |
| 37 |
// API source |
| 38 |
if (!defined('ENTERADDONS_API_SOURCE')) { |
| 39 |
define('ENTERADDONS_API_SOURCE', 'enteraddons-api'); |
| 40 |
} |
| 41 |
// Dir FILE |
| 42 |
if (!defined('ENTERADDONS_FILE')) { |
| 43 |
define('ENTERADDONS_FILE', __FILE__); |
| 44 |
} |
| 45 |
// Plugin dir path constant |
| 46 |
if (!defined('ENTERADDONS_DIR_PATH')) { |
| 47 |
define('ENTERADDONS_DIR_PATH', trailingslashit(plugin_dir_path(ENTERADDONS_FILE))); |
| 48 |
} |
| 49 |
// Plugin dir url constant |
| 50 |
if (!defined('ENTERADDONS_DIR_URL')) { |
| 51 |
define('ENTERADDONS_DIR_URL', trailingslashit(plugin_dir_url(ENTERADDONS_FILE))); |
| 52 |
} |
| 53 |
// Admin dir path |
| 54 |
if (!defined('ENTERADDONS_DIR_ADMIN')) { |
| 55 |
define('ENTERADDONS_DIR_ADMIN', trailingslashit(ENTERADDONS_DIR_PATH . 'admin')); |
| 56 |
} |
| 57 |
// Core dir path |
| 58 |
if (!defined('ENTERADDONS_DIR_CORE')) { |
| 59 |
define('ENTERADDONS_DIR_CORE', trailingslashit(ENTERADDONS_DIR_PATH . 'core')); |
| 60 |
} |
| 61 |
// Inc dir path |
| 62 |
if (!defined('ENTERADDONS_DIR_INC')) { |
| 63 |
define('ENTERADDONS_DIR_INC', trailingslashit(ENTERADDONS_DIR_PATH . 'inc')); |
| 64 |
} |
| 65 |
// Widgets dir path |
| 66 |
if (!defined('ENTERADDONS_DIR_WIDGETS')) { |
| 67 |
define('ENTERADDONS_DIR_WIDGETS', trailingslashit(ENTERADDONS_DIR_PATH . 'widgets')); |
| 68 |
} |
| 69 |
// Assets dir url |
| 70 |
if (!defined('ENTERADDONS_DIR_ASSETS_URL')) { |
| 71 |
define('ENTERADDONS_DIR_ASSETS_URL', trailingslashit(ENTERADDONS_DIR_URL . 'assets')); |
| 72 |
} |
| 73 |
// Admin assets dir url |
| 74 |
if (!defined('ENTERADDONS_DIR_ADMIN_ASSETS')) { |
| 75 |
define('ENTERADDONS_DIR_ADMIN_ASSETS', trailingslashit(ENTERADDONS_DIR_URL . 'admin/assets')); |
| 76 |
} |
| 77 |
// Core dir url |
| 78 |
if (!defined('ENTERADDONS_DIR_CORE_URL')) { |
| 79 |
define('ENTERADDONS_DIR_CORE_URL', trailingslashit(ENTERADDONS_DIR_URL . 'core')); |
| 80 |
} |
| 81 |
// Widgets dir url |
| 82 |
if (!defined('ENTERADDONS_DIR_WIDGETS_URL')) { |
| 83 |
define('ENTERADDONS_DIR_WIDGETS_URL', trailingslashit(ENTERADDONS_DIR_URL . 'widgets')); |
| 84 |
} |
| 85 |
|
| 86 |
// Option Key |
| 87 |
if (!defined('ENTERADDONS_OPTION_KEY')) { |
| 88 |
define('ENTERADDONS_OPTION_KEY', 'enteraddons_widgets_activation'); |
| 89 |
} |
| 90 |
|
| 91 |
// Include autoloader |
| 92 |
require_once(ENTERADDONS_DIR_PATH . 'vendor/autoload.php'); |
| 93 |
|
| 94 |
/** |
| 95 |
* Enteraddons Final Class |
| 96 |
* |
| 97 |
*/ |
| 98 |
|
| 99 |
final class Enteraddons |
| 100 |
{ |
| 101 |
|
| 102 |
private static $instance = null; |
| 103 |
|
| 104 |
/** |
| 105 |
* Notice Button. |
| 106 |
* |
| 107 |
* @var array |
| 108 |
*/ |
| 109 |
|
| 110 |
private static $ElementorNoticeBtn; |
| 111 |
|
| 112 |
private function __construct() |
| 113 |
{ |
| 114 |
// |
| 115 |
add_action('init', [$this, 'client_insights']); |
| 116 |
// |
| 117 |
register_activation_hook(ENTERADDONS_FILE, [$this, 'activationTask']); |
| 118 |
// |
| 119 |
if (self::enteraddons_check_elementor() == 'active') { |
| 120 |
add_action('plugins_loaded', [$this, 'initTask']); |
| 121 |
} |
| 122 |
// |
| 123 |
add_action('admin_notices', [__CLASS__, 'dependency_plugin_activation_notice']); |
| 124 |
// |
| 125 |
add_filter('plugin_action_links_' . plugin_basename(__FILE__), [__CLASS__, 'add_action_links']); |
| 126 |
|
| 127 |
} |
| 128 |
|
| 129 |
public static function getInstance() |
| 130 |
{ |
| 131 |
if (is_null(self::$instance)) { |
| 132 |
self::$instance = new self; |
| 133 |
} |
| 134 |
return self::$instance; |
| 135 |
} |
| 136 |
|
| 137 |
public function activationTask() |
| 138 |
{ |
| 139 |
Enteraddons\Classes\Activation::register_activation(); |
| 140 |
Enteraddons\Classes\Helper::change_permissions_mode(); |
| 141 |
} |
| 142 |
|
| 143 |
public function initTask() |
| 144 |
{ |
| 145 |
$is_active = get_option(ENTERADDONS_OPTION_KEY); |
| 146 |
$this->includeFiles(); |
| 147 |
|
| 148 |
// Admin Init |
| 149 |
\Enteraddons\Admin\Admin::getInstance(); |
| 150 |
// Header Footer Builder |
| 151 |
$extensions = !empty($is_active['extensions']) ? $is_active['extensions'] : []; |
| 152 |
if (in_array('header-footer', $extensions)) { |
| 153 |
\Enteraddons\HeaderFooterBuilder\Header_Footer_Builder::getInstance(); |
| 154 |
} |
| 155 |
// Widgets Base |
| 156 |
Enteraddons\Core\Base\Widgets_Base::getInstance(); |
| 157 |
// Enqueue Scripts |
| 158 |
new \Enteraddons\Inc\Enqueue(); |
| 159 |
// Css Cache Manager |
| 160 |
\Enteraddons\Classes\Cache_Manager::init(); |
| 161 |
// init Editor_Widgets_Assets |
| 162 |
new \Enteraddons\Classes\Editor_Widgets_Assets(); |
| 163 |
// Ajax Handler |
| 164 |
new \Enteraddons\Classes\Ajax_Handler(); |
| 165 |
} |
| 166 |
|
| 167 |
private function includeFiles() |
| 168 |
{ |
| 169 |
// Core |
| 170 |
require_once(ENTERADDONS_DIR_CORE . 'libs/editor/editor.php'); |
| 171 |
require_once(ENTERADDONS_DIR_CORE . 'libs/custom-controls/custom-control.php'); |
| 172 |
require_once(ENTERADDONS_DIR_CORE . 'libs/injecting-controls/Injecting_Controls.php'); |
| 173 |
} |
| 174 |
|
| 175 |
/** |
| 176 |
* Admin Notices |
| 177 |
* |
| 178 |
* Dependency plugin ( Elementor ) activation notice |
| 179 |
* |
| 180 |
* |
| 181 |
*/ |
| 182 |
public static function dependency_plugin_activation_notice() |
| 183 |
{ |
| 184 |
|
| 185 |
$is_active = self::enteraddons_check_elementor(); |
| 186 |
$btn = self::get_elementor_notice_button(); |
| 187 |
if ($is_active != 'active'): |
| 188 |
|
| 189 |
if ($is_active == 'notinstalled') { |
| 190 |
$getBtn = $btn['install']; |
| 191 |
} else { |
| 192 |
$getBtn = $btn['active']; |
| 193 |
} |
| 194 |
?> |
| 195 |
<div class="notice notice-warning is-dismissible" style="padding-bottom: 15px;background: #ffe2e6;"> |
| 196 |
<?php |
| 197 |
printf('<p style="padding: 13px 0"><strong style="font-size: 20px;">EnterAddons</strong> %1$s <strong>Elementor</strong> %2$s</p>', esc_html__('requires', 'enteraddons'), esc_html__('to be installed and activated to work properly.', 'enteraddons')); |
| 198 |
|
| 199 |
echo '<a href="' . esc_url($getBtn['url']) . '" class="btn s-btn">' . esc_html($getBtn['label']) . '</a>'; |
| 200 |
?> |
| 201 |
</div> |
| 202 |
<?php |
| 203 |
endif; |
| 204 |
|
| 205 |
} |
| 206 |
|
| 207 |
/** |
| 208 |
* add plugin settings and documentation link on the plugins page |
| 209 |
* @param [array] $actions |
| 210 |
*/ |
| 211 |
public static function add_action_links($actions) |
| 212 |
{ |
| 213 |
$proLink = 'https://enteraddons.com/pricing/'; |
| 214 |
$docLink = 'https://enteraddons.com/documentation/'; |
| 215 |
$actions[] = '<a href="' . esc_url(get_admin_url(null, 'admin.php?page=enteraddons')) . '">' . esc_html__('Settings', 'enteraddons') . '</a>'; |
| 216 |
$actions[] = '<a href="' . esc_url($docLink) . '" target="_blank">' . esc_html__('Documentation', 'enteraddons') . '</a>'; |
| 217 |
|
| 218 |
// |
| 219 |
if (!Enteraddons\Classes\Helper::is_pro_active()) { |
| 220 |
$actions[] = '<a style="color:#E82A5C;font-weight: bold;" href="' . esc_url($proLink) . '" target="_blank">' . esc_html__('Go Pro', 'enteraddons') . '</a>'; |
| 221 |
} |
| 222 |
|
| 223 |
return $actions; |
| 224 |
} |
| 225 |
|
| 226 |
/** |
| 227 |
* Admin Notices |
| 228 |
* |
| 229 |
* Sets Elementor plugin active and install url with button label |
| 230 |
* |
| 231 |
* |
| 232 |
*/ |
| 233 |
private static function set_elementor_notice_button() |
| 234 |
{ |
| 235 |
|
| 236 |
self::$ElementorNoticeBtn = [ |
| 237 |
|
| 238 |
'install' => [ |
| 239 |
'url' => wp_nonce_url('update.php?action=install-plugin&plugin=elementor', 'install-plugin_elementor'), |
| 240 |
'label' => esc_html__('Install Elementor', 'enteraddons') |
| 241 |
], |
| 242 |
'active' => [ |
| 243 |
'url' => wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php'), |
| 244 |
'label' => esc_html__('Activate Elementor', 'enteraddons') |
| 245 |
] |
| 246 |
|
| 247 |
]; |
| 248 |
|
| 249 |
} |
| 250 |
|
| 251 |
/** |
| 252 |
* Admin Notices |
| 253 |
* |
| 254 |
* Elementor plugin active and install url with button label |
| 255 |
* |
| 256 |
* @return array |
| 257 |
* |
| 258 |
*/ |
| 259 |
private static function get_elementor_notice_button() |
| 260 |
{ |
| 261 |
self::set_elementor_notice_button(); |
| 262 |
return self::$ElementorNoticeBtn; |
| 263 |
} |
| 264 |
|
| 265 |
/** |
| 266 |
* |
| 267 |
* Check elementor plugin activities |
| 268 |
* |
| 269 |
* @return string |
| 270 |
* |
| 271 |
*/ |
| 272 |
public static function enteraddons_check_elementor() |
| 273 |
{ |
| 274 |
|
| 275 |
$elementorFile = WP_PLUGIN_DIR . '/elementor/elementor.php'; |
| 276 |
$activatedPlugin = get_option('active_plugins'); |
| 277 |
|
| 278 |
if (!file_exists($elementorFile)) { |
| 279 |
$has_elementor = 'notinstalled'; |
| 280 |
} else if (file_exists($elementorFile) && !in_array('elementor/elementor.php', $activatedPlugin)) { |
| 281 |
$has_elementor = 'deactive'; |
| 282 |
} else { |
| 283 |
$has_elementor = 'active'; |
| 284 |
} |
| 285 |
return $has_elementor; |
| 286 |
} |
| 287 |
|
| 288 |
public function client_insights() |
| 289 |
{ |
| 290 |
|
| 291 |
if (!class_exists('Appsero\Client')) { |
| 292 |
require_once __DIR__ . '/appsero/src/Client.php'; |
| 293 |
} |
| 294 |
|
| 295 |
$client = new Appsero\Client('946b12bd-9cec-4255-8cd8-941a699d27a4', 'Enter Addons – Ultimate Template Builder for Elementor', __FILE__); |
| 296 |
|
| 297 |
// Active insights |
| 298 |
$client->insights()->init(); |
| 299 |
|
| 300 |
} |
| 301 |
|
| 302 |
} |
| 303 |
|
| 304 |
/** |
| 305 |
* |
| 306 |
* Init Enteraddons |
| 307 |
* |
| 308 |
*/ |
| 309 |
Enteraddons::getInstance(); |
| 310 |
|