forked from PopupMaker/Popup-Maker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup-maker.php
425 lines (349 loc) · 10.2 KB
/
popup-maker.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
<?php
/**
* Plugin Name: Popup Maker
* Plugin URI: https://wppopupmaker.com/?utm_campaign=plugin-info&utm_source=plugin-header&utm_medium=plugin-uri
* Description: Easily create & style popups with any content. Theme editor to quickly style your popups. Add forms, social media boxes, videos & more.
* Version: 1.18.1
* Requires PHP: 5.6
* Requires at least: 4.9
* Author: Popup Maker
* Author URI: https://wppopupmaker.com/?utm_campaign=plugin-info&utm_source=plugin-header&utm_medium=author-uri
* License: GPL2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: popup-maker
* Domain Path: /languages/
*
* @package PopupMaker
* @author Daniel Iser
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Autoloader
*
* @param $class
*/
function pum_autoloader( $class ) {
if ( strncmp( 'PUM_Newsletter_', $class, strlen( 'PUM_Newsletter_' ) ) === 0 && class_exists( 'PUM_MCI' ) && ! empty( PUM_MCI::$VER ) && version_compare( PUM_MCI::$VER, '1.3.0', '<' ) ) {
return;
}
$pum_autoloaders = apply_filters(
'pum_autoloaders',
[
[
'prefix' => 'PUM_',
'dir' => dirname( __FILE__ ) . '/classes/',
],
]
);
foreach ( $pum_autoloaders as $autoloader ) {
$autoloader = wp_parse_args(
$autoloader,
[
'prefix' => 'PUM_',
'dir' => dirname( __FILE__ ) . '/classes/',
'search' => '_',
'replace' => '/',
]
);
// project-specific namespace prefix
$prefix = $autoloader['prefix'];
// does the class use the namespace prefix?
$len = strlen( $prefix );
if ( strncmp( $prefix, $class, $len ) !== 0 ) {
// no, move to the next registered autoloader
continue;
}
// get the relative class name
$relative_class = substr( $class, $len );
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $autoloader['dir'] . str_replace( $autoloader['search'], $autoloader['replace'], $relative_class ) . '.php';
// if the file exists, require it
if ( file_exists( $file ) ) {
require_once $file;
}
}
}
if ( ! function_exists( 'spl_autoload_register' ) ) {
include 'includes/compat.php';
}
spl_autoload_register( 'pum_autoloader' ); // Register autoloader
/**
* Main Popup_Maker Class
*
* @since 1.0
*/
class Popup_Maker {
/**
* @var string Plugin Name
*/
public static $NAME = 'Popup Maker';
/**
* @var string Plugin Version
*/
public static $VER = '1.18.1';
/**
* @var int DB Version
*/
public static $DB_VER = 8;
/**
* @var string License API URL
*/
public static $API_URL = 'https://wppopupmaker.com';
/**
* @var string
*/
public static $MIN_PHP_VER = '5.6';
/**
* @var string
*/
public static $MIN_WP_VER = '4.9';
/**
* @var string Plugin URL
*/
public static $URL;
/**
* @var string Plugin Directory
*/
public static $DIR;
/**
* @var string Plugin FILE
*/
public static $FILE;
/**
* Used to test if debug_mode is enabled.
*
* @var bool
*/
public static $DEBUG_MODE = false;
/**
* @var PUM_Utils_Cron
*/
public $cron;
/**
* @var PUM_Repository_Popups
*/
public $popups;
/**
* @var PUM_Repository_Themes
*/
public $themes;
/**
* @var null|PUM_Model_Popup
*/
public $current_popup;
/**
* @var null|PUM_Model_Theme
*/
public $current_theme;
/**
* @var Popup_Maker The one true Popup_Maker
*/
private static $instance;
/**
* Main instance
*
* @return Popup_Maker
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Popup_Maker ) ) {
self::$instance = new Popup_Maker();
self::$instance->setup_constants();
self::$instance->includes();
add_action( 'init', [ self::$instance, 'load_textdomain' ] );
self::$instance->init();
}
return self::$instance;
}
/**
* Setup plugin constants
*/
private function setup_constants() {
self::$DIR = plugin_dir_path( __FILE__ );
self::$URL = plugins_url( '/', __FILE__ );
self::$FILE = __FILE__;
if ( isset( $_GET['pum_debug'] ) || PUM_Utils_Options::get( 'debug_mode', false ) ) {
self::$DEBUG_MODE = true;
}
if ( ! defined( 'POPMAKE' ) ) {
define( 'POPMAKE', self::$FILE );
}
if ( ! defined( 'POPMAKE_NAME' ) ) {
define( 'POPMAKE_NAME', self::$NAME );
}
if ( ! defined( 'POPMAKE_SLUG' ) ) {
define( 'POPMAKE_SLUG', trim( dirname( plugin_basename( __FILE__ ) ), '/' ) );
}
if ( ! defined( 'POPMAKE_DIR' ) ) {
define( 'POPMAKE_DIR', self::$DIR );
}
if ( ! defined( 'POPMAKE_URL' ) ) {
define( 'POPMAKE_URL', self::$URL );
}
if ( ! defined( 'POPMAKE_NONCE' ) ) {
define( 'POPMAKE_NONCE', 'popmake_nonce' );
}
if ( ! defined( 'POPMAKE_VERSION' ) ) {
define( 'POPMAKE_VERSION', self::$VER );
}
if ( ! defined( 'POPMAKE_DB_VERSION' ) ) {
define( 'POPMAKE_DB_VERSION', self::$DB_VER );
}
if ( ! defined( 'POPMAKE_API_URL' ) ) {
define( 'POPMAKE_API_URL', self::$API_URL );
}
}
/**
* Include required files
*/
private function includes() {
require_once self::$DIR . 'includes/compat.php';
// Initialize global options
PUM_Utils_Options::init();
/** Loads most of our core functions */
require_once self::$DIR . 'includes/functions.php';
/** Deprecated functionality */
require_once self::$DIR . 'includes/functions-backcompat.php';
require_once self::$DIR . 'includes/functions-deprecated.php';
require_once self::$DIR . 'includes/deprecated-classes.php';
require_once self::$DIR . 'includes/deprecated-filters.php';
require_once self::$DIR . 'includes/integrations.php';
// Old Stuff.
require_once self::$DIR . 'includes/defaults.php';
require_once self::$DIR . 'includes/input-options.php';
require_once self::$DIR . 'includes/importer/easy-modal-v2.php';
// Phasing Out
require_once self::$DIR . 'includes/class-popmake-fields.php';
require_once self::$DIR . 'includes/class-popmake-popup-fields.php';
/**
* v1.4 Additions
*/
require_once self::$DIR . 'includes/class-pum-fields.php';
require_once self::$DIR . 'includes/class-pum-form.php';
// Modules
require_once self::$DIR . 'includes/modules/menus.php';
require_once self::$DIR . 'includes/modules/admin-bar.php';
require_once self::$DIR . 'includes/modules/reviews.php';
require_once self::$DIR . 'includes/pum-install-functions.php';
}
/**
* Loads the plugin language files
*/
public function load_textdomain() {
// Set filter for plugin's languages directory
$lang_dir = apply_filters( 'pum_lang_dir', dirname( plugin_basename( POPMAKE ) ) . '/languages/' );
$lang_dir = apply_filters( 'popmake_languages_directory', $lang_dir );
// Try to load Langpacks first, if they are not available fallback to local files.
if ( ! load_plugin_textdomain( 'popup-maker', false, $lang_dir ) ) {
// Traditional WordPress plugin locale filter
$locale = apply_filters( 'plugin_locale', get_locale(), 'popup-maker' );
$mofile = sprintf( '%1$s-%2$s.mo', 'popup-maker', $locale );
// Setup paths to current locale file
$mofile_local = $lang_dir . $mofile;
$mofile_global = WP_LANG_DIR . '/popup-maker/' . $mofile;
if ( file_exists( $mofile_global ) ) {
// Look in global /wp-content/languages/popup-maker folder
load_textdomain( 'popup-maker', $mofile_global );
} elseif ( file_exists( $mofile_local ) ) {
// Look in local /wp-content/plugins/popup-maker/languages/ folder
load_textdomain( 'popup-maker', $mofile_local );
}
}
}
public function init() {
$this->cron = new PUM_Utils_Cron();
$this->popups = new PUM_Repository_Popups();
$this->themes = new PUM_Repository_Themes();
PUM_Types::init();
PUM_AssetCache::init();
PUM_Site::init();
PUM_Admin::init();
PUM_Utils_Upgrades::instance();
PUM_Newsletters::init();
PUM_Previews::init();
PUM_Integrations::init();
PUM_Privacy::init();
PUM_Utils_Alerts::init();
PUM_Shortcode_Popup::init();
PUM_Shortcode_PopupTrigger::init();
PUM_Shortcode_PopupClose::init();
PUM_Shortcode_PopupCookie::init();
PUM_Telemetry::init();
new PUM_Extensions();
}
/**
* Returns true when debug mode is enabled.
*
* @return bool
*/
public static function debug_mode() {
return true === self::$DEBUG_MODE;
}
}
/**
* The main function responsible for returning the one true Popup_Maker
* Instance to functions everywhere.
*
* Use this function like you would a global variable, except without needing
* to declare the global.
*
* @return Popup_Maker
* @since 1.8.0
*/
function pum() {
return Popup_Maker::instance();
}
/**
* Initialize Popup Maker if requirements are met.
*/
function pum_init() {
// TODO Replace this with PUM_Utils_Prerequisites.
if ( ! PUM_Install::meets_activation_requirements() ) {
require_once 'includes/failsafes.php';
add_action( 'admin_notices', [ 'PUM_Install', 'activation_failure_admin_notice' ] );
return;
}
// Get Popup Maker
pum();
add_action( 'plugins_loaded', 'popmake_initialize' );
}
// Get Popup Maker running
add_action( 'plugins_loaded', 'pum_init', 9 );
// Ensure plugin & environment compatibility.
register_activation_hook( __FILE__, [ 'PUM_Install', 'activation_check' ] );
// Register activation, deactivation & uninstall hooks.
register_activation_hook( __FILE__, [ 'PUM_Install', 'activate_plugin' ] );
register_deactivation_hook( __FILE__, [ 'PUM_Install', 'deactivate_plugin' ] );
register_uninstall_hook( __FILE__, [ 'PUM_Install', 'uninstall_plugin' ] );
/**
* @deprecated 1.7.0
*/
function popmake_initialize() {
// Disable Unlimited Themes extension if active.
remove_action( 'popmake_initialize', 'popmake_ut_initialize' );
// Initialize old PUM extensions
do_action( 'pum_initialize' );
do_action( 'popmake_initialize' );
}
/**
* The main function responsible for returning the one true Popup_Maker
* Instance to functions everywhere.
*
* Use this function like you would a global variable, except without needing
* to declare the global.
*
* Example: <?php $popmake = PopMake(); ?>
*
* @return object The one true Popup_Maker Instance
* @deprecated 1.7.0
*
* @since 1.0
*/
function PopMake() {
return Popup_Maker::instance();
}