CMP – Coming Soon & Maintenance Plugin by NiteoThemes - Version 4.1.4

Version Description

Download this release

Release Info

Developer niteo
Plugin Icon 128x128 CMP – Coming Soon & Maintenance Plugin by NiteoThemes
Version 4.1.4
Comparing to
See all releases

Code changes from version 4.1.3 to 4.1.4

Files changed (3) hide show
  1. inc/render/javascripts.php +1 -1
  2. niteo-cmp.php +1281 -1319
  3. readme.txt +11 -1
inc/render/javascripts.php CHANGED
@@ -422,7 +422,7 @@ if ( isset( $theme_supports['counter_script']) && $theme_supports['counter_scrip
422
 
423
  if ( $counter_script && get_option('niteoCS_counter', '1') == '1') {
424
  $countdown_action = get_option('niteoCS_countdown_action', 'no-action');
425
- $days_counter = array('delta', 'mercury', 'libra', 'thor', 'headliner', 'mosaic', 'saturn', 'nova');
426
  // counter script for day only
427
  if ( in_array($themeslug, $days_counter) ) { ?>
428
  <script>
422
 
423
  if ( $counter_script && get_option('niteoCS_counter', '1') == '1') {
424
  $countdown_action = get_option('niteoCS_countdown_action', 'no-action');
425
+ $days_counter = array('delta', 'mercury', 'libra', 'thor', 'headliner', 'mosaic', 'saturn', 'nova', 'titan');
426
  // counter script for day only
427
  if ( in_array($themeslug, $days_counter) ) { ?>
428
  <script>
niteo-cmp.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: CMP - Coming Soon & Maintenance Plugin
4
  Plugin URI: https://wordpress.org/plugins/cmp-coming-soon-maintenance/
5
  Description: Display customizable landing page for Coming Soon, Maintenance & Under Construction page.
6
- Version: 4.1.3
7
  Author: NiteoThemes
8
  Author URI: https://www.niteothemes.com
9
  Text Domain: cmp-coming-soon-maintenance
@@ -14,19 +14,18 @@
14
 
15
 
16
  // Exit if accessed directly.
17
- if (!defined('ABSPATH')) {
18
  exit;
19
  }
20
 
21
- if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
22
 
23
  /**
24
  * Main CMP Coming Soon and Maintenance class.
25
  *
26
  * @since 2.8
27
- */
28
- class CMP_Coming_Soon_and_Maintenance
29
- {
30
 
31
  /**
32
  * CMP_Coming_Soon_and_Maintenance The one true CMP_Coming_Soon_and_Maintenance
@@ -50,9 +49,8 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
50
  * @uses CMP_Coming_Soon_and_Maintenance::load_textdomain() load the language files.
51
  * @return object|CMP_Coming_Soon_and_Maintenance
52
  */
53
- public static function instance()
54
- {
55
- if (!isset(self::$instance) && !(self::$instance instanceof CMP_Coming_Soon_and_Maintenance)) {
56
  self::$instance = new CMP_Coming_Soon_and_Maintenance();
57
  self::$instance->constants();
58
  self::$instance->init();
@@ -63,69 +61,67 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
63
  }
64
 
65
  // define constants
66
- private function constants()
67
- {
68
- $this->define('CMP_VERSION', '4.1.3');
69
- $this->define('CMP_DEBUG', FALSE);
70
- $this->define('CMP_AUTHOR', 'NiteoThemes');
71
- $this->define('CMP_AUTHOR_HOMEPAGE', 'https://niteothemes.com');
72
- $this->define('CMP_PLUGIN_DIR', plugin_dir_path(__FILE__));
73
- $this->define('CMP_PREMIUM_THEMES_DIR', plugin_dir_path(__DIR__) . 'cmp-premium-themes/');
74
- $this->define('CMP_PLUGIN_URL', plugin_dir_url(__FILE__));
75
- $this->define('CMP_UPDATE_URL', 'https://niteothemes.com/updates/');
76
  CMP_DEBUG === TRUE
77
- ? $this->define('CMP_LICENSE_SERVER_URL', 'https://niteothemes.com/dev2/')
78
- : $this->define('CMP_LICENSE_SERVER_URL', 'https://niteothemes.com/');
79
  }
80
 
81
  /**
82
  * Inits and hooks
83
  */
84
- public function init()
85
- {
86
- do_action('cmp_plugin_loaded');
87
- add_action('init', array($this, 'load_textdomain'));
88
- add_action('plugins_loaded', array($this, 'cmp_update_process'), 0);
89
- add_action('template_redirect', array($this, 'cmp_displayPage'), 1);
90
- add_action('admin_init', array($this, 'cmp_adminInit'));
91
- add_action('admin_menu', array($this, 'cmp_adminMenu'));
92
- add_action('admin_notices', array($this, 'cmp_admin_notice'));
93
- add_action('wp_before_admin_bar_render', array($this, 'cmp_admin_bar'));
94
- add_action('admin_enqueue_scripts', array($this, 'cmp_add_topbar_scripts'));
95
- add_action('admin_enqueue_scripts', array($this, 'cmp_add_admin_style'));
96
- add_action('wp_enqueue_scripts', array($this, 'cmp_add_topbar_scripts'));
97
- add_action('wp_ajax_cmp_get_post_detail', array($this, 'cmp_get_post_detail'));
98
- add_action('wp_ajax_nopriv_cmp_get_post_detail', array($this, 'cmp_get_post_detail'));
99
- add_action('wp_ajax_cmp_check_update', array($this, 'cmp_check_update'));
100
- add_action('wp_ajax_cmp_ajax_dismiss_activation_notice', array($this, 'cmp_ajax_dismiss_activation_notice'));
101
- add_action('wp_ajax_niteo_themeinfo', array($this, 'niteo_themeinfo'));
102
- add_action('wp_ajax_niteo_unsplash', array($this, 'niteo_unsplash'));
103
- add_action('wp_ajax_niteo_export_csv', array($this, 'niteo_export_csv'));
104
- add_action('wp_ajax_cmp_theme_update_install', array($this, 'cmp_theme_update_install'));
105
- add_action('wp_ajax_cmp_toggle_activation', array($this, 'cmp_ajax_toggle_activation'));
106
- add_action('wp_ajax_nopriv_niteo_subscribe', array($this, 'niteo_subscribe'));
107
- add_action('wp_ajax_niteo_subscribe', array($this, 'niteo_subscribe'));
108
- add_action('wp_ajax_cmp_mailchimp_list_ajax', array($this, 'cmp_mailchimp_list_ajax'));
109
- add_action('wp_ajax_cmp_ajax_upload_font', array($this, 'cmp_ajax_upload_font'));
110
- add_action('wp_ajax_cmp_ajax_export_settings', array($this, 'cmp_ajax_export_settings'));
111
- add_action('wp_ajax_cmp_ajax_import_settings', array($this, 'cmp_ajax_import_settings'));
112
- add_action('wp_ajax_nopriv_cmp_disable_comingsoon_ajax', array($this, 'cmp_disable_comingsoon_ajax'));
113
- add_action('admin_head', array($this, 'cmp_admin_css'));
114
- add_action('after_setup_theme', array($this, 'cmp_create_translation'), 10);
115
- add_action('after_setup_theme', array($this, 'cmp_register_wpml_strings'), 20);
116
- add_filter('upload_mimes', array($this, 'cmp_allow_font_mimes'));
117
- add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'add_action_links'));
118
-
119
- register_activation_hook(__FILE__, array($this, 'cmp_activate'));
120
- register_deactivation_hook(__FILE__, array($this, 'cmp_deactivate'));
121
-
122
- require_once(dirname(__FILE__) . '/inc/class-cmp-render_html.php');
123
-
124
- if ($this->cmp_active() === '1' && get_option('niteoCS_rest_api_status', '1') !== '1') {
125
- add_filter('rest_authentication_errors', array($this, 'restrict_rest_api'), 0, 1);
126
- }
127
-
128
- add_action('init', array($this, 'jetpack_stats_compatibility'));
129
  }
130
 
131
 
@@ -135,40 +131,40 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
135
  * @param string|string $name Name of the definition.
136
  * @param string|bool $value Default value.
137
  */
138
- private function define($name, $value)
139
- {
140
- if (!defined($name)) {
141
- define($name, $value);
142
  }
143
  }
144
 
145
  /**
146
  * Admin Init - register and enqueue scripts nad styles
147
  */
148
- public function cmp_adminInit()
149
- {
150
  // include feedback class
151
- require_once('inc/class-cmp-feedback.php');
152
 
153
  // ini render-settings class
154
  require_once('inc/class-cmp-render_settings.php');
155
 
156
  $this->render_settings = new cmp_render_settings();
157
 
158
- if (current_user_can('administrator')) {
159
 
160
- wp_register_style('cmp-style', plugins_url('/css/cmp-settings-style' . CMP_ASSET_SUFFIX . '.css', __FILE__), '', CMP_VERSION);
161
- wp_register_style('cmp-font-awesome', plugins_url('/css/font-awesome.min.css', __FILE__));
162
- wp_register_style('countdown_flatpicker_css', plugins_url('/css/flatpickr.min.css', __FILE__));
163
- wp_register_style('animate-css', plugins_url('/css/animate' . CMP_ASSET_SUFFIX . '.css', __FILE__));
164
- wp_register_script('webfont', 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js', array(), '1.6.26', true);
165
- wp_register_script('cmp-select2-js', plugins_url('/js/external/select2.min.js', __FILE__));
166
- wp_register_script('cmp-typography', plugins_url('/js/typography' . CMP_ASSET_SUFFIX . '.js', __FILE__), array('cmp-select2-js'), CMP_VERSION);
167
- wp_register_script('cmp_settings_js', plugins_url('/js/settings' . CMP_ASSET_SUFFIX . '.js', __FILE__), array('webfont', 'cmp-select2-js'), CMP_VERSION);
168
- wp_register_script('cmp_advanced_js', plugins_url('/js/cmp-advanced' . CMP_ASSET_SUFFIX . '.js', __FILE__), array(), CMP_VERSION);
169
- wp_register_script('cmp-editor-translation', plugins_url('/js/cmp-editor-translation' . CMP_ASSET_SUFFIX . '.js', __FILE__), array(), CMP_VERSION, true);
170
- wp_register_script('countdown_flatpicker_js', plugins_url('/js/external/flatpickr.min.js', __FILE__));
 
171
  }
 
172
  }
173
 
174
  /**
@@ -176,8 +172,7 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
176
  *
177
  * @since 2.8.7
178
  */
179
- public function cmp_update_process()
180
- {
181
  require_once('inc/cmp-update-process.php');
182
  }
183
 
@@ -187,29 +182,28 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
187
  * @since 3.7.5
188
  */
189
 
190
- public function cmp_create_translation()
191
- {
192
  // Populate translation list, if not yet created
193
- if (!get_option('niteoCS_translation')) {
194
  $translation = array(
195
- 0 => array('id' => 0, 'name' => 'Counter Seconds Label', 'string' => __('Seconds', 'cmp-coming-soon-maintenance'), 'translation' => __('Seconds', 'cmp-coming-soon-maintenance')),
196
- 1 => array('id' => 1, 'name' => 'Counter Minutes Label', 'string' => __('Minutes', 'cmp-coming-soon-maintenance'), 'translation' => __('Minutes', 'cmp-coming-soon-maintenance')),
197
- 2 => array('id' => 2, 'name' => 'Counter Hours Label', 'string' => __('Hours', 'cmp-coming-soon-maintenance'), 'translation' => __('Hours', 'cmp-coming-soon-maintenance')),
198
- 3 => array('id' => 3, 'name' => 'Counter Days Label', 'string' => __('Days', 'cmp-coming-soon-maintenance'), 'translation' => __('Days', 'cmp-coming-soon-maintenance')),
199
- 4 => array('id' => 4, 'name' => 'Subscribe Form Placeholder', 'string' => __('Insert your email address.', 'cmp-coming-soon-maintenance'), 'translation' => __('Insert your email address.', 'cmp-coming-soon-maintenance')),
200
- 5 => array('id' => 5, 'name' => 'Subscribe Response Duplicate', 'string' => __('Oops! This email address is already on our list.', 'cmp-coming-soon-maintenance'), 'translation' => __('Oops! This email address is already on our list.', 'cmp-coming-soon-maintenance')),
201
- 6 => array('id' => 6, 'name' => 'Subscribe Response Not Valid', 'string' => __('Oops! We need a valid email address. Please try again.', 'cmp-coming-soon-maintenance'), 'translation' => __('Oops! We need a valid email address. Please try again.', 'cmp-coming-soon-maintenance')),
202
- 7 => array('id' => 7, 'name' => 'Subscribe Response Thanks', 'string' => __('Thank you! Your sign up request was successful.', 'cmp-coming-soon-maintenance'), 'translation' => __('Thank you! Your sign up request was successful.', 'cmp-coming-soon-maintenance')),
203
- 8 => array('id' => 8, 'name' => 'Subscribe Submit Button Label', 'string' => __('Submit', 'cmp-coming-soon-maintenance'), 'translation' => __('Submit', 'cmp-coming-soon-maintenance')),
204
- 9 => array('id' => 9, 'name' => 'CMP Eclipse Theme: Scroll Text', 'string' => __('Scroll', 'cmp-coming-soon-maintenance'), 'translation' => __('Scroll', 'cmp-coming-soon-maintenance')),
205
- 10 => array('id' => 10, 'name' => 'Subscribe Form First Name Placeholder', 'string' => __('First Name', 'cmp-coming-soon-maintenance'), 'translation' => __('First Name', 'cmp-coming-soon-maintenance')),
206
- 11 => array('id' => 11, 'name' => 'Subscribe Form Last Name Placeholder', 'string' => __('Last Name', 'cmp-coming-soon-maintenance'), 'translation' => __('Last Name', 'cmp-coming-soon-maintenance')),
207
- 12 => array('id' => 12, 'name' => 'Subscribe', 'string' => __('Subscribe', 'cmp-coming-soon-maintenance'), 'translation' => __('Subscribe', 'cmp-coming-soon-maintenance')),
208
- 13 => array('id' => 13, 'name' => 'Subscribe GDPR Checkbox', 'string' => __('You must agree with our Terms and Conditions.', 'cmp-coming-soon-maintenance'), 'translation' => __('You must agree with our Terms and Conditions.', 'cmp-coming-soon-maintenance')),
209
- 14 => array('id' => 14, 'name' => 'Subscribe Missing Email', 'string' => __('Oops! Email is empty.', 'cmp-coming-soon-maintenance'), 'translation' => __('Oops! Email is empty.', 'cmp-coming-soon-maintenance')),
210
  );
211
 
212
- update_option('niteoCS_translation', wp_json_encode($translation));
213
  }
214
  }
215
 
@@ -218,52 +212,51 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
218
  *
219
  * @since 3.7.5
220
  */
221
- public function cmp_register_wpml_strings()
222
- {
223
 
224
- if ($this->translation_active()) {
225
 
226
  $themeslug = $this->cmp_selectedTheme();
227
- $translation = json_decode(get_option('niteoCS_translation'), true);
228
  $overlay_status = get_option('niteoCS_overlay_text[status]', '0');
229
 
230
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Title', stripslashes(get_option('niteoCS_body_title', 'SOMETHING IS HAPPENING!')));
231
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Copyright', stripslashes(get_option('niteoCS_copyright', 'Made by <a href="https://niteothemes.com">NiteoThemes</a> with love.')));
232
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Subscribe GDPR Message', stripslashes(get_option('niteoCS_subscribe_label', '')));
233
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Social Icons Title', stripslashes(get_option('niteoCS_soc_title', 'GET SOCIAL WITH US')));
234
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Counter Title', stripslashes(get_option('niteoCS_counter_heading', 'STAY TUNED, WE ARE LAUNCHING SOON...')));
235
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Extended Footer Title', stripslashes(get_option('niteoCS_contact_title', 'Quick Contacts')));
236
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Extended Footer Content', stripslashes(get_option('niteoCS_contact_content', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.')));
237
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Contact Form Title', stripslashes(get_option('niteoCS_contact_form_label', 'Get in Touch')));
238
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'SEO Title', stripslashes(get_option('niteoCS_title', get_bloginfo('name') . ' Coming soon!')));
239
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'SEO Description', stripslashes(get_option('niteoCS_descr', 'Just Another Coming Soon Page')));
240
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Subscribe Popup Form Title', stripslashes(get_option('niteoCS_subscribe_popup_title', get_option('niteoCS_subscribe_title', 'SUBSCRIBE US'))));
241
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Popup Subscribe GDPR Message', stripslashes(get_option('niteoCS_subscribe_label_popup')));
242
-
243
- foreach ($translation as $translate) {
244
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', $translate['name'], stripslashes($translate['translation']));
245
  }
246
 
247
- if ($overlay_status == '1' && in_array($themeslug, $this->cmp_overlay_text_themes())) {
248
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Overlay Title', stripslashes(get_option('niteoCS_overlay_text[heading]', 'NEW WEBSITE ON THE WAY!')));
249
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Overlay Content', stripslashes(get_option('niteoCS_overlay_text[paragraph]', '')));
250
- $this->cmp_register_string('CMP - Coming Soon & Maintenance', 'Overlay Button Text', stripslashes(get_option('niteoCS_overlay_text[button_text]', 'Call to Action!')));
251
  }
252
 
253
  // register strings from themes
254
- if (file_exists($this->cmp_theme_dir($themeslug) . $themeslug . '/translation-strings.php') && function_exists('icl_register_string')) {
255
- require_once $this->cmp_theme_dir($themeslug) . $themeslug . '/translation-strings.php';
256
  }
257
  }
258
  }
259
 
260
- public function cmp_register_string($group, $name, $string, $multiline = false)
261
- {
262
 
263
- if (function_exists('pll_register_string')) {
264
- pll_register_string($name, $string, $group, $multiline);
265
- } else if (defined('ICL_SITEPRESS_VERSION')) {
266
- do_action('wpml_register_single_string', $group, $name, $string);
 
267
  }
268
  }
269
 
@@ -273,14 +266,13 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
273
  * @since 3.7.5
274
  * @return string
275
  */
276
- public function cmp_wpml_translate_string($translation, $name)
277
- {
278
-
279
- if (defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '3.2', '>=')) {
280
- $translation = apply_filters('wpml_translate_single_string', $translation, 'CMP - Coming Soon & Maintenance', $name);
281
- // WPML and Polylang compatibility
282
- } elseif (function_exists('icl_t')) {
283
- $translation = icl_t('CMP - Coming Soon & Maintenance', $name, $translation);
284
  }
285
 
286
  return $translation;
@@ -292,19 +284,18 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
292
  * @since 3.7.5
293
  * @return string
294
  */
295
- public function cmp_wpml_niteoCS_translation()
296
- {
297
-
298
- $translation = json_decode(get_option('niteoCS_translation'), true);
299
 
300
- if (defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '3.2', '>=')) {
301
- foreach ($translation as $key => $translate) {
302
- $translation[$key]['translation'] = apply_filters('wpml_translate_single_string', $translate['translation'], 'CMP - Coming Soon & Maintenance', $translate['name']);
303
  }
304
- // WPML and Polylang compatibility
305
- } elseif (function_exists('icl_t')) {
306
- foreach ($translation as $key => $translate) {
307
- $translation[$key]['translation'] = icl_t('CMP - Coming Soon & Maintenance', $translate['name'], $translate['translation']);
308
  }
309
  }
310
 
@@ -317,16 +308,16 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
317
  * @since 3.7.5
318
  * @return string
319
  */
320
- public function cmp_get_current_lang($type = 'slug')
321
- {
322
  $lang = null;
323
 
324
- if (function_exists('pll_current_language')) {
325
- $lang = pll_current_language($type);
326
- } else if (defined('ICL_LANGUAGE_CODE')) {
 
327
  $lang = $type === 'slug' ? ICL_LANGUAGE_CODE : ICL_LANGUAGE_NAME;
328
  }
329
-
330
  return $lang;
331
  }
332
 
@@ -336,15 +327,15 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
336
  * @since 3.7.5
337
  * @return array
338
  */
339
- public function cmp_get_language_list()
340
- {
341
  $langs = array();
342
 
343
- if (function_exists('pll_languages_list')) {
344
  $langs = pll_languages_list();
345
- } else if (defined('ICL_SITEPRESS_VERSION')) {
346
- $langs = apply_filters('wpml_active_languages', NULL, array('skip_missing' => 0));
347
- $langs = array_keys($langs);
 
348
  }
349
 
350
  return $langs;
@@ -356,13 +347,13 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
356
  * @since 3.7.5
357
  * @return string
358
  */
359
- public function cmp_get_default_language()
360
- {
361
  $default = null;
362
 
363
- if (function_exists('pll_default_language')) {
364
  $default = pll_default_language();
365
- } else if (defined('ICL_SITEPRESS_VERSION')) {
 
366
  global $sitepress;
367
  $default = $sitepress->get_default_language();
368
  }
@@ -376,13 +367,13 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
376
  * @since 3.7.5
377
  * @return object
378
  */
379
- public function cmp_get_translated_id($id)
380
- {
 
 
381
 
382
- if (function_exists('pll_get_post')) {
383
- $id = pll_get_post($id);
384
- } else if (defined('ICL_SITEPRESS_VERSION')) {
385
- $id = apply_filters('wpml_object_id', $id);
386
  }
387
 
388
  return $id;
@@ -394,20 +385,18 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
394
  * @since 2.8.3
395
  * @return array
396
  */
397
- public function cmp_themes_bundled()
398
- {
399
  return array('construct', 'countdown', 'hardwork');
400
  }
401
 
402
- public function cmp_theme_supports($themeslug, $supports)
403
- {
404
 
405
- if (file_exists($this->cmp_theme_dir($themeslug) . $themeslug . '/' . $themeslug . '-defaults.php')) {
406
- require $this->cmp_theme_dir($themeslug) . $themeslug . '/' . $themeslug . '-defaults.php';
 
 
407
 
408
- foreach ($theme_supports as $key => $value) {
409
-
410
- if ($key === $supports) {
411
  return $value;
412
  }
413
  }
@@ -422,9 +411,8 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
422
  * @since 2.8.3
423
  * @return array
424
  */
425
- public function cmp_font_animation_themes()
426
- {
427
- return array('hardwork_premium', 'fifty', 'orbit', 'stylo', 'apollo', 'vega', 'pluto');
428
  }
429
 
430
  /**
@@ -433,9 +421,8 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
433
  * @since 2.8.5
434
  * @return array
435
  */
436
- public function cmp_cf7_themes()
437
- {
438
- return array('stylo', 'agency');
439
  }
440
 
441
  /**
@@ -444,9 +431,8 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
444
  * @since 2.8.5
445
  * @return array
446
  */
447
- public function cmp_overlay_text_themes()
448
- {
449
- return array('agency');
450
  }
451
 
452
  /**
@@ -455,9 +441,8 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
455
  * @since 3.7.3
456
  * @return array
457
  */
458
- public function cmp_builder_themes()
459
- {
460
- return array('divi', 'elementor', 'oxygen_builder');
461
  }
462
 
463
  /**
@@ -466,51 +451,49 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
466
  * @since 3.7.9
467
  * @return array
468
  */
469
- public function translation_active()
470
- {
471
  return function_exists('pll_languages_list') || defined('ICL_SITEPRESS_VERSION');
472
  }
473
-
474
  /**
475
  * returns array list of premium themes => manually defined
476
  *
477
  * @return array
478
  */
479
- public function cmp_premium_themes()
480
- {
481
-
482
  $premium_themes = array();
483
- array_push($premium_themes, array('name' => 'nova', 'url' => 'https://niteothemes.com/downloads/cmp-nova-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=nova', 'price' => '12'));
484
- array_push($premium_themes, array('name' => 'mercury', 'url' => 'https://niteothemes.com/downloads/cmp-mercury-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=mercury', 'price' => '10'));
485
- array_push($premium_themes, array('name' => 'fifty', 'url' => 'https://niteothemes.com/downloads/cmp-fifty-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=fifty', 'price' => '10'));
486
- array_push($premium_themes, array('name' => 'apollo', 'url' => 'https://niteothemes.com/downloads/cmp-apollo-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=apollo', 'price' => '10'));
487
- array_push($premium_themes, array('name' => 'loki', 'url' => 'https://niteothemes.com/downloads/cmp-loki-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=loki', 'price' => '12'));
488
- array_push($premium_themes, array('name' => 'orion', 'url' => 'https://niteothemes.com/downloads/cmp-orion-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=orion', 'price' => '12'));
489
- array_push($premium_themes, array('name' => 'vega', 'url' => 'https://niteothemes.com/downloads/cmp-vega-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=vega', 'price' => '10'));
490
- array_push($premium_themes, array('name' => 'mosaic', 'url' => 'https://niteothemes.com/downloads/cmp-mosaic-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=mosaic', 'price' => '10'));
491
- array_push($premium_themes, array('name' => 'titan', 'url' => 'https://niteothemes.com/downloads/cmp-titan-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=titan', 'price' => '12'));
492
- array_push($premium_themes, array('name' => 'saturn', 'url' => 'https://niteothemes.com/downloads/cmp-saturn-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=saturn', 'price' => '12'));
493
- array_push($premium_themes, array('name' => 'atlas', 'url' => 'https://niteothemes.com/downloads/cmp-atlas-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=atlas', 'price' => '12'));
494
- array_push($premium_themes, array('name' => 'scout', 'url' => 'https://niteothemes.com/downloads/cmp-scout-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=scout', 'price' => '10'));
495
- array_push($premium_themes, array('name' => 'libra', 'url' => 'https://niteothemes.com/downloads/cmp-libra-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=libra', 'price' => '10'));
496
- array_push($premium_themes, array('name' => 'delta', 'url' => 'https://niteothemes.com/downloads/cmp-delta-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=delta', 'price' => '10'));
497
- array_push($premium_themes, array('name' => 'headliner', 'url' => 'https://niteothemes.com/downloads/cmp-headliner-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=headliner', 'price' => '10'));
498
- array_push($premium_themes, array('name' => 'elementor', 'url' => 'https://niteothemes.com/downloads/cmp-elementor-addon/?utm_source=cmp&utm_medium=referral&utm_campaign=elementor', 'price' => '29'));
499
- array_push($premium_themes, array('name' => 'divi', 'url' => 'https://niteothemes.com/downloads/cmp-divi-addon/?utm_source=cmp&utm_medium=referral&utm_campaign=divi', 'price' => '29'));
500
- array_push($premium_themes, array('name' => 'timex', 'url' => 'https://niteothemes.com/downloads/cmp-timex-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=timex', 'price' => '15'));
501
- array_push($premium_themes, array('name' => 'thor', 'url' => 'https://niteothemes.com/downloads/cmp-thor-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=thor', 'price' => '10'));
502
- array_push($premium_themes, array('name' => 'hardwork_premium', 'url' => 'https://niteothemes.com/downloads/cmp-hardwork-premium/?utm_source=cmp&utm_medium=referral&utm_campaign=hardwork_premium', 'price' => '10'));
503
- array_push($premium_themes, array('name' => 'tempie', 'url' => 'https://niteothemes.com/downloads/cmp-tempie-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=tempie', 'price' => '10'));
504
- array_push($premium_themes, array('name' => 'stylo', 'url' => 'https://niteothemes.com/downloads/cmp-stylo-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=stylo', 'price' => '10'));
505
- array_push($premium_themes, array('name' => 'ares', 'url' => 'https://niteothemes.com/downloads/cmp-ares-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=ares', 'price' => '10'));
506
- array_push($premium_themes, array('name' => 'juno', 'url' => 'https://niteothemes.com/downloads/cmp-juno-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=juno', 'price' => '10'));
507
- array_push($premium_themes, array('name' => 'pluto', 'url' => 'https://niteothemes.com/downloads/cmp-pluto-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=pluto', 'price' => '10'));
508
- array_push($premium_themes, array('name' => 'agency', 'url' => 'https://niteothemes.com/downloads/cmp-agency-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=agency', 'price' => '15'));
509
- array_push($premium_themes, array('name' => 'element', 'url' => 'https://niteothemes.com/downloads/cmp-element-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=element', 'price' => '10'));
510
- array_push($premium_themes, array('name' => 'postery', 'url' => 'https://niteothemes.com/downloads/cmp-postery/?utm_source=cmp&utm_medium=referral&utm_campaign=postery', 'price' => '10'));
511
- array_push($premium_themes, array('name' => 'frame', 'url' => 'https://niteothemes.com/downloads/cmp-frame-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=frame', 'price' => '10'));
512
- array_push($premium_themes, array('name' => 'eclipse', 'url' => 'https://niteothemes.com/downloads/cmp-eclipse-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=eclipse', 'price' => '0'));
513
- array_push($premium_themes, array('name' => 'orbit', 'url' => 'https://niteothemes.com/downloads/cmp-orbit-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=orbit', 'price' => '0'));
514
 
515
  return $premium_themes;
516
  }
@@ -520,14 +503,15 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
520
  * @since 2.8.3
521
  * @return array
522
  */
523
- public function cmp_premium_themes_installed()
524
- {
525
  $premium_themes = array();
526
- if (file_exists(CMP_PREMIUM_THEMES_DIR)) {
527
- $premium_themes = glob(CMP_PREMIUM_THEMES_DIR . '*', GLOB_ONLYDIR);
528
- $premium_themes = array_map('basename', $premium_themes);
 
529
  }
530
- return $premium_themes;
 
531
  }
532
 
533
  /**
@@ -536,56 +520,55 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
536
  * @since 2.8.3
537
  * @return array
538
  */
539
- public function cmp_themes_available()
540
- {
541
- return array_merge($this->cmp_themes_bundled(), $this->cmp_premium_themes_installed());
542
  }
543
 
544
  /**
545
  * Enqueue admin scripts and styles
546
  */
547
- public function cmp_add_topbar_scripts()
548
- {
549
 
550
  // return of user is not logged in
551
- if (!is_user_logged_in()) {
552
  return;
553
  }
554
 
555
  // return if Top Bar Icon is disabled
556
- if (get_option('niteoCS_topbar_icon', '1') == '0') {
557
  return;
558
  }
559
 
560
- wp_register_style('cmp-admin-head-style', plugins_url('/css/cmp-admin-head.css', __FILE__), array(), CMP_VERSION);
561
- wp_register_script('cmp_admin_script', plugins_url('/js/cmp-admin-head.js', __FILE__), array('jquery'), CMP_VERSION);
562
 
563
- $roles_topbar = json_decode(get_option('niteoCS_roles_topbar', '[]'), true);
564
 
565
  // push WP administrator to roles array, since it is default
566
- array_push($roles_topbar, 'administrator');
567
-
568
 
 
569
 
570
  // get current user
571
  $current_user = wp_get_current_user();
572
  // check for roles array length
573
- if (count($current_user->roles) > 0) {
574
  // enqueue topbar script and style only, if current user is allowed to display topbar, or is admin
575
- foreach ($current_user->roles as $role) {
576
- if (in_array($role, $roles_topbar)) {
577
- wp_enqueue_style('cmp-admin-head-style');
578
- wp_enqueue_script('cmp_admin_script');
579
- wp_localize_script('cmp_admin_script', 'cmp_ajax', array('ajax_url' => admin_url('admin-ajax.php')));
580
  break;
581
  }
582
  };
583
 
584
- // this one is for broken wp admin, where current user does not have any roles
585
  } else {
586
- wp_enqueue_script('cmp_admin_script');
587
- wp_enqueue_style('cmp-admin-head-style');
588
  }
 
589
  }
590
 
591
  /**
@@ -593,27 +576,26 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
593
  *
594
  * @since 2.8.9
595
  */
596
- public function cmp_add_admin_style($hook)
597
- {
598
  // return of user is not logged in
599
- if (!is_user_logged_in()) {
600
  return;
601
  }
602
 
603
- $prefix = sanitize_title(__('CMP Settings', 'cmp-coming-soon-maintenance'));
604
 
605
  $cmp_pages = array(
606
  'toplevel_page_cmp-settings',
607
- $prefix . '_page_cmp-advanced',
608
- $prefix . '_page_cmp-subscribers',
609
- $prefix . '_page_cmp-translate',
610
- $prefix . '_page_cmp-upload-theme',
611
- $prefix . '_page_cmp-themes-manager',
612
- $prefix . '_page_cmp-addons',
613
  );
614
 
615
- if (in_array($hook, $cmp_pages)) {
616
- wp_enqueue_style('cmp-style');
617
  }
618
  }
619
 
@@ -622,19 +604,18 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
622
  *
623
  * @since 2.8.1
624
  */
625
- public function cmp_assets_suffix()
626
- {
627
 
628
  // If there's no debug mode, use the minified assets supplied.
629
- if (!defined('CMP_DEBUG')) {
630
- define('CMP_ASSET_SUFFIX', '.min');
631
  return;
632
  }
633
 
634
- if (true === CMP_DEBUG) {
635
- define('CMP_ASSET_SUFFIX', null);
636
  } else {
637
- define('CMP_ASSET_SUFFIX', '.min');
638
  }
639
  }
640
 
@@ -642,112 +623,104 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
642
  /**
643
  * Register CMP menus pages
644
  */
645
- public function cmp_adminMenu()
646
- {
647
  /* Register our plugin page */
648
  $page = add_menu_page(__('CMP Settings', 'cmp-coming-soon-maintenance'), __('CMP Settings', 'cmp-coming-soon-maintenance'), 'manage_options', 'cmp-settings', array($this, 'cmp_settings_page'), plugins_url('/img/cmp.png', __FILE__));
649
- add_submenu_page('cmp-settings', __('CMP Basic Setup', 'cmp-coming-soon-maintenance'), __('CMP Basic Setup', 'cmp-coming-soon-maintenance'), 'manage_options', 'cmp-settings');
650
- add_submenu_page('cmp-settings', __('CMP Advanced Setup', 'cmp-coming-soon-maintenance'), __('CMP Advanced Setup', 'cmp-coming-soon-maintenance'), 'manage_options', 'cmp-advanced', array($this, 'cmp_advanced_page'));
651
- add_submenu_page('cmp-settings', __('CMP Subscribers', 'cmp-coming-soon-maintenance'), __('CMP Subscribers', 'cmp-coming-soon-maintenance'), 'manage_options', 'cmp-subscribers', array($this, 'cmp_subs_page'));
652
- add_submenu_page('cmp-settings', __('CMP Translation', 'cmp-coming-soon-maintenance'), __('CMP Translation', 'cmp-coming-soon-maintenance'), 'manage_options', 'cmp-translate', array($this, 'cmp_translate_page'));
653
- add_submenu_page('cmp-settings', __('Upload CMP Theme', 'cmp-coming-soon-maintenance'), __('Upload CMP Theme', 'cmp-coming-soon-maintenance'), 'manage_options', 'cmp-upload-theme', array($this, 'cmp_upload_page'));
654
  /* Using registered $page handle to hook script load */
655
- add_action('admin_print_scripts-' . $page, array($this, 'cmp_admin_scripts'));
 
656
  }
657
 
658
  /**
659
  * enqueue styles and scripts when navigated to CMP Settings page
660
  */
661
- public function cmp_admin_scripts()
662
- {
663
  wp_enqueue_media();
664
- if (function_exists('wp_enqueue_code_editor')) {
665
- wp_enqueue_code_editor(array('type' => 'text/css'));
666
  }
667
- wp_localize_script('cmp-typography', 'fonts', array('google' => $this->cmp_get_google_fonts()));
668
- wp_enqueue_script('cmp_settings_js');
669
- wp_enqueue_script('cmp-typography');
670
- wp_enqueue_script('wp-color-picker');
671
- wp_enqueue_script('webfont');
672
- wp_enqueue_script('cmp-select2-js');
673
 
674
- if ($this->translation_active()) {
675
  $langs = $this->cmp_get_language_list();
676
  $default_lang = $this->cmp_get_default_language();
677
- wp_localize_script('cmp-editor-translation', 'translation', array('langs' => $langs, 'default' => $default_lang));
678
- wp_enqueue_script('cmp-editor-translation');
679
  }
680
 
681
- wp_enqueue_style('wp-color-picker');
682
- wp_enqueue_style('cmp-font-awesome');
683
-
684
- if (in_array($this->cmp_selectedTheme(), $this->cmp_font_animation_themes())) {
685
  wp_enqueue_style('animate-css');
686
  }
687
  }
688
 
689
- function cmp_admin_css()
690
- { ?>
691
  <style type="text/css" media="screen">
692
- #toplevel_page_cmp-settings img {
693
- max-width: 14px !important;
694
- padding-top: 5px !important;
695
- }
696
  </style>
697
- <?php
698
- }
699
 
700
  /**
701
  * Render CMP Settings Page
702
  */
703
- public function cmp_settings_page()
704
- {
705
 
706
- $this->cmp_check_update($this->cmp_selectedTheme());
707
- require_once('cmp-settings.php');
708
  }
709
 
710
  /**
711
  * Render CMP Advanced Settings Sub Page
712
  */
713
- public function cmp_advanced_page()
714
- {
715
- wp_enqueue_script('cmp-select2-js');
716
- wp_enqueue_script('cmp_advanced_js');
717
- wp_enqueue_style('cmp-font-awesome');
718
- require_once('cmp-advanced.php');
719
  }
720
 
721
  /**
722
  * Render CMP Subscribers Sub Page
723
  */
724
- public function cmp_subs_page()
725
- {
726
- require_once('cmp-subscribers.php');
727
  }
728
 
729
  /**
730
  * Render CMP Translation Sub Page
731
  */
732
- public function cmp_translate_page()
733
- {
734
- require_once('cmp-translate.php');
735
  }
736
 
737
  /**
738
  * Render CMP Upload new Theme Sub Page
739
  */
740
- public function cmp_upload_page()
741
- {
742
- require_once('cmp-upload.php');
743
  }
744
 
745
  /**
746
  * Load text domain
747
  */
748
- public function load_textdomain()
749
- {
750
- load_plugin_textdomain('cmp-coming-soon-maintenance', false, dirname(plugin_basename(__FILE__)) . '/languages/');
751
  }
752
 
753
  /**
@@ -756,9 +729,8 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
756
  * @since 3.1.2
757
  * @return string
758
  */
759
- public function cmp_active()
760
- {
761
- return get_option('niteoCS_status', '0') === '0' ? '0' : '1';
762
  }
763
 
764
  /**
@@ -767,9 +739,9 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
767
  * @since 3.1.2
768
  * @return string
769
  */
770
- public function cmp_mode()
771
- {
772
- return get_option('niteoCS_activation', '2');
773
  }
774
 
775
  /**
@@ -780,9 +752,8 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
780
  * @param string
781
  * @return URL string
782
  */
783
- public function cmp_asset_url($filepath)
784
- {
785
- return plugins_url($filepath, __FILE__);
786
  }
787
 
788
  /**
@@ -802,8 +773,7 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
802
  // }
803
 
804
  // function to display CMP landing page
805
- public function cmp_displayPage()
806
- {
807
 
808
  $theme = $this->cmp_selectedTheme();
809
 
@@ -811,81 +781,82 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
811
  $html = new CMP_Coming_Soon_and_Maintenance_Render_HTML();
812
 
813
  // check if preview is set
814
- if (isset($_GET['cmp_preview']) && $_GET['cmp_preview'] == 'true') {
815
- $theme = isset($_GET['cmp_theme']) ? $_GET['cmp_theme'] : $theme;
816
 
817
- if (!in_array($theme, $this->cmp_themes_available())) {
818
  $theme = $this->cmp_selectedTheme();
819
  }
820
-
821
- // finally render theme preview cmp_preview=true
822
- if (file_exists($this->cmp_theme_dir($theme) . $theme . '/' . $theme . '-theme.php')) {
823
- require_once($this->cmp_theme_dir($theme) . $theme . '/' . $theme . '-theme.php');
824
  die();
825
  }
826
  }
827
 
828
  // return if CMP is disabled, user bypass by role or page is whitelisted
829
- if ($this->cmp_active() === '0' || $this->cmp_roles_filter() || !$this->cmp_page_filter()) {
830
  return;
831
  }
832
 
833
  // bypass CMP and set cookie for user defined period of time, if bypass is enabled, bypass ID is set, and match CMP bypass settings
834
- if (isset($_GET['cmp_bypass']) && $_GET['cmp_bypass'] == get_option('niteoCS_bypass_id', md5(get_home_url())) && get_option('niteoCS_bypass', '0') == '1') {
835
  nocache_headers();
836
  header('Cache-Control: max-age=0; private');
837
- setcookie('cmp_bypass', get_option('niteoCS_bypass_id', md5(get_home_url())), time() + get_option('niteoCS_bypass_expire', 172800));
838
  // exit CMP
839
  return;
840
  }
841
 
842
  // if bypass Cookie is set, return
843
- if (isset($_COOKIE['cmp_bypass']) && $_COOKIE['cmp_bypass'] == get_option('niteoCS_bypass_id', md5(get_home_url())) && get_option('niteoCS_bypass', '0') == '1') {
844
  // exit CMP
845
  return;
846
  }
847
 
848
  // if CMP in redirect mode with 0 timeout, die early with redirect
849
- if ($this->cmp_mode() == 3 && get_option('niteoCS_redirect_time') == 0) {
850
 
851
  $redirect_url = get_option('niteoCS_URL_redirect');
852
  // redirect to URL
853
- if ($redirect_url != '') {
854
- header('Location: ' . esc_url($redirect_url));
855
  die();
856
  }
857
  }
858
 
859
 
860
  // check for mailpoptin ajax
861
- if (isset($_GET['mailoptin-ajax'])) {
862
 
863
  $campaign_id = get_option('niteoCS_mailoptin_selected');
864
  $campaign = MailOptin\Core\Repositories\OptinCampaignsRepository::get_optin_campaign_by_id($campaign_id);
865
 
866
- if (isset($_POST['optin_data']) && $_POST['optin_data']['optin_uuid'] == $campaign['uuid']) {
867
  return;
868
  }
 
869
  }
870
 
871
  // if themes with countdown timer
872
- if ($this->cmp_theme_supports($theme, 'counter')) {
873
-
874
  // if counter is enabled - default yes
875
- if (get_option('niteoCS_counter', '1') == '1') {
876
 
877
  // if countdown date is set - default 24 hours
878
- if (get_option('niteoCS_counter_date') && get_option('niteoCS_counter_date') != '') {
879
-
880
  // if timer < timestamp do pre-set action
881
- if (get_option('niteoCS_counter_date') < time()) {
882
 
883
  $action = get_option('niteoCS_countdown_action', 'no-action');
884
 
885
  // send notification email if email transient is not set
886
- if (get_option('niteoCS_countdown_notification', '1') == '1' && get_option('niteoCS_counter_email', false) !== 'sent') {
887
 
888
- switch ($action) {
889
  case 'no-action':
890
  $message = __('Counter expired but it is set to make no action - you should login to your Wordpress Admin and adjust the expired timer or disable Coming Soon / Maintenance Mode.', 'cmp-coming-soon-maintenance');
891
  break;
@@ -906,171 +877,174 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
906
  break;
907
  }
908
 
909
- $to = get_option('niteoCS_countdown_email_address', get_option('admin_email'));
910
  $subject = 'Countdown timer just expired on your Coming Soon Page - ' . get_site_url();
911
  $body = $message . ' This is auto generated message from CMP - Coming Soon & Maintenance Plugin installed on ' . get_site_url();
912
  $headers = array('Content-Type: text/plain; charset=UTF-8');
913
  // send email
914
- wp_mail($to, $subject, $body, $headers);
915
 
916
  // set email option
917
- update_option('niteoCS_counter_email', 'sent');
918
- }
919
 
 
920
 
 
921
  // if action set to redirect
922
- if ($action == 'redirect') {
923
- $redirect_url = esc_url(get_option('niteoCS_countdown_redirect'));
924
- header('Location: ' . $redirect_url);
925
  die();
926
  }
 
927
  }
928
  }
929
  }
930
  }
931
 
932
  // if maintanance mode send correct 503 headers
933
- if ($this->cmp_mode() == '1') {
934
  header('HTTP/1.1 503 Service Temporarily Unavailable');
935
  header('Status: 503 Service Temporarily Unavailable');
936
  header('Retry-After: 86400'); // retry in a day
937
  }
938
 
939
  // send no-cache headers if set in Settings
940
- if (get_option('niteoCS_seo_nocache', '1') == '1') {
941
  nocache_headers();
942
  header('Cache-Control: no-cache; private');
943
  }
944
 
945
  // set cookie for WPML AJAX translation
946
- if (defined('ICL_LANGUAGE_CODE')) {
947
- setcookie('wp-wpml_current_language', ICL_LANGUAGE_CODE, time() + 3600, '/');
948
- setcookie('_icl_current_language', ICL_LANGUAGE_CODE, time() + 3600, '/');
949
  }
950
 
951
  // finally render selected CMP theme
952
- if (file_exists($this->cmp_theme_dir($theme) . $theme . '/' . $theme . '-theme.php')) {
953
- require_once($this->cmp_theme_dir($theme) . $theme . '/' . $theme . '-theme.php');
954
  die();
955
  }
 
956
  }
957
 
958
- // function to toggle CMP activation for admin menu icon
959
- public function cmp_ajax_toggle_activation()
960
- {
961
  // check for ajax payoload
962
- if (isset($_POST['payload']) && $_POST['payload'] == 'toggle_cmp_status') {
963
 
964
  // verify nonce
965
- check_ajax_referer('cmp-coming-soon-ajax-secret', 'security');
966
  // verify user rights
967
- if (!$this->cmp_user_can_admin_bar_activation()) {
968
- echo 'Current user cannot toggle CMP activation';
969
- wp_die();
970
- return;
971
- }
972
 
973
- if ($this->cmp_active() === '0') {
974
  update_option('niteoCS_status', '1');
975
  $this->cmp_send_notification('on');
976
- } else {
 
977
  update_option('niteoCS_status', '0');
978
  $this->cmp_send_notification('off');
979
- }
980
 
981
- $this->cmp_purge_cache();
982
 
983
- echo 'success';
984
- wp_die();
985
- return;
986
- }
987
- }
988
 
989
  // return selected theme, defaults to hardwork
990
- public function cmp_selectedTheme()
991
- {
992
  return get_option('niteoCS_theme', 'hardwork');
993
  }
994
 
995
 
996
  // return installed theme dir path
997
- public function cmp_theme_dir($slug)
998
- {
999
- if (in_array($slug, $this->cmp_themes_bundled())) {
1000
  return CMP_PLUGIN_DIR . 'themes/';
 
1001
  } else {
1002
  return CMP_PREMIUM_THEMES_DIR;
1003
  }
1004
  }
1005
 
1006
  // return installed theme URL
1007
- public function cmp_themeURL($slug)
1008
- {
1009
- if (in_array($slug, $this->cmp_themes_bundled())) {
1010
- return plugins_url('/themes/', __FILE__);
1011
  } else {
1012
- return plugins_url('/cmp-premium-themes/');
 
1013
  }
1014
  }
1015
 
1016
  // display admin topbar notice
1017
- public function cmp_admin_bar()
1018
- {
1019
 
1020
- $prefix = sanitize_title(__('CMP Settings', 'cmp-coming-soon-maintenance'));
1021
 
1022
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
1023
- if (current_user_can('publish_pages') && function_exists('get_current_screen') && is_admin() && get_current_screen()->id == $prefix . '_page_cmp-advanced' && wp_verify_nonce($_POST['save_options_field'], 'save_options')) {
1024
- // check POST if user wants to enable or disable the topbar from settings
1025
- if (isset($_POST['niteoCS_topbar_icon']) && is_numeric($_POST['niteoCS_topbar_icon'])) {
1026
- update_option('niteoCS_topbar_icon', sanitize_text_field($_POST['niteoCS_topbar_icon']));
1027
  }
1028
 
1029
- if (isset($_POST['niteoCS_topbar_version'])) {
1030
- update_option('niteoCS_topbar_version', sanitize_text_field($_POST['niteoCS_topbar_version']));
1031
  }
1032
  }
1033
  }
 
1034
 
1035
-
1036
- if (!$this->cmp_user_can_admin_bar_activation()) {
1037
- return false;
1038
- }
1039
 
1040
  // CMP PLUGIN ACTIVATION AND STATUS CHANGE SETTINGS!
1041
- if ($_SERVER['REQUEST_METHOD'] == 'POST' && (function_exists('get_current_screen') && is_admin() && get_current_screen()->id == 'toplevel_page_cmp-settings')) {
1042
 
1043
  // verify nonce and user rights
1044
- if (!wp_verify_nonce($_POST['save_options_field'], 'save_options') || !current_user_can('publish_pages')) {
1045
  die('Sorry, but this request is invalid');
1046
- }
1047
 
1048
- if (isset($_POST['activate']) && is_numeric($_POST['activate'])) {
1049
  update_option('niteoCS_activation', sanitize_text_field($_POST['activate']));
1050
  }
1051
 
1052
- if (isset($_POST['cmp_status'])) {
1053
  update_option('niteoCS_status', $this->sanitize_checkbox($_POST['cmp_status']));
1054
  $this->cmp_send_notification('on');
1055
- } else if (!isset($_POST['submit_theme'])) {
 
1056
  update_option('niteoCS_status', '0');
1057
  $this->cmp_send_notification('off');
1058
  }
1059
  }
1060
 
1061
- // create nonce for ajax request
1062
- $ajax_nonce = wp_create_nonce('cmp-coming-soon-ajax-secret');
1063
 
1064
- global $wp_admin_bar;
1065
 
1066
  $class = '';
1067
  $msg = '';
1068
- $icon = '<img src="' . plugins_url('/img/cmp.png', __FILE__) . '" alt="CMP Logo" class="cmp-logo" style="max-width:20px;">';
1069
 
1070
  $topbar_version = get_option('niteoCS_topbar_version', 'cmp-topbar-full');
1071
 
1072
- if ($topbar_version === 'cmp-topbar-full') {
1073
- switch ($this->cmp_mode()) {
1074
  case '1':
1075
  $msg = __('Maintenance Mode:', 'cmp-coming-soon-maintenance');
1076
  $class = ' maintenance';
@@ -1087,51 +1061,51 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1087
  break;
1088
  }
1089
 
1090
- $msg = '<span class="cmp-status-msg ab-label">' . $msg . '</span>';
1091
  }
1092
 
 
 
1093
 
1094
- $topbar = $icon . $msg . '<div class="toggle-wrapper"><div id="cmp-status-menubar" class="toggle-checkbox"></div><div id="cmp-toggle-adminbar" class="status-' . esc_attr($this->cmp_active()) . '" data-security="' . esc_attr($ajax_nonce) . '"><span class="toggle_handler"></span></div></div>';
1095
-
1096
- //Add the main siteadmin menu item
1097
- $wp_admin_bar->add_menu(array(
1098
- 'id' => 'cmp-admin-notice',
1099
- 'href' => admin_url() . 'admin.php?page=cmp-settings',
1100
- 'parent' => 'top-secondary',
1101
- 'title' => $topbar,
1102
- 'meta' => array('class' => 'cmp-notice' . $class),
1103
- ));
1104
-
1105
- // Display CMP Settings in topbar only for administrator
1106
- if (current_user_can('administrator')) {
1107
- $wp_admin_bar->add_node(array(
1108
- 'id' => 'cmp-basic-settings',
1109
- 'title' => __('CMP Basic Settings', 'cmp-coming-soon-maintenance'),
1110
- 'href' => admin_url('admin.php?page=cmp-settings'),
1111
- 'parent' => 'cmp-admin-notice'
1112
- ));
1113
 
1114
- $wp_admin_bar->add_node(array(
1115
- 'id' => 'cmp-advanced-settings',
1116
- 'title' => __('CMP Advanced Settings', 'cmp-coming-soon-maintenance'),
1117
- 'href' => admin_url('admin.php?page=cmp-advanced'),
1118
- 'parent' => 'cmp-admin-notice'
 
 
1119
  ));
 
 
 
 
 
 
 
1120
  }
1121
 
1122
- $wp_admin_bar->add_node(array(
1123
- 'id' => 'cmp-preview',
1124
- 'title' => __('CMP Preview', 'cmp-coming-soon-maintenance'),
1125
- 'href' => get_site_url() . '/?cmp_preview=true',
1126
- 'parent' => 'cmp-admin-notice',
1127
- 'meta' => array('target' => '_blank')
1128
- ));
1129
- }
1130
 
1131
- public function cmp_activate()
1132
- {
1133
 
1134
- if (get_option('niteoCS_archive')) {
 
 
1135
  //get all the options back from the archive
1136
  $options = get_option('niteoCS_archive');
1137
  // update options
@@ -1139,7 +1113,7 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1139
  update_option($option['name'], $option['value']);
1140
  }
1141
 
1142
- update_option('niteoCS_activation_notice', false);
1143
 
1144
  // delete archive
1145
  delete_option('niteoCS_archive');
@@ -1147,16 +1121,15 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1147
  }
1148
 
1149
  // archive plugin stuff when plugin is deactivated
1150
- public function cmp_deactivate()
1151
- {
1152
  //get all the options. store them in an array
1153
  $options = array();
1154
 
1155
  global $wpdb;
1156
- $saved_options = $wpdb->get_results("SELECT * FROM $wpdb->options WHERE option_name LIKE 'niteoCS_%'", OBJECT);
1157
  $i = 0;
1158
  foreach ($saved_options as $option) {
1159
- $options[$i] = array('name' => $option->option_name, 'value' => get_option($option->option_name));
1160
  $i++;
1161
  }
1162
 
@@ -1164,7 +1137,7 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1164
  update_option('niteoCS_archive', $options);
1165
 
1166
  //delete the separate ones
1167
- foreach ($options as $option) {
1168
  delete_option($option['name']);
1169
  }
1170
 
@@ -1178,14 +1151,13 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1178
  * @access public
1179
  * @return array
1180
  */
1181
- public function cmp_downloadable_themes()
1182
- {
1183
  $downloadable_themes = array();
1184
 
1185
- foreach ($this->cmp_premium_themes() as $premium) {
1186
- if (!in_array($premium['name'], $this->cmp_premium_themes_installed())) {
1187
- array_push($downloadable_themes, $premium);
1188
- }
1189
  }
1190
 
1191
  return $downloadable_themes;
@@ -1198,57 +1170,55 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1198
  * @access public
1199
  * @return JSON
1200
  */
1201
- public function cmp_disable_comingsoon_ajax()
1202
- {
1203
 
1204
  $theme = $this->cmp_selectedTheme();
1205
 
1206
- if (!in_array($theme, $this->cmp_builder_themes())) {
1207
- check_ajax_referer('cmp-coming-soon-maintenance-nonce', 'security');
1208
  }
1209
 
1210
- $result = array('message' => 'error');
1211
 
1212
- if (get_option('niteoCS_countdown_action', 'no-action') !== 'disable-cmp') {
1213
- echo json_encode($result);
1214
  wp_die();
1215
  }
1216
 
1217
- if (!empty($_REQUEST['status']) && $_REQUEST['status'] === 'disable-cmp' && get_option('niteoCS_counter_date') < time()) {
1218
  update_option('niteoCS_status', '0');
1219
  $this->cmp_purge_cache();
1220
- $result = array('message' => 'success');
1221
  }
1222
-
1223
- echo json_encode($result);
1224
 
1225
  wp_die();
1226
  }
1227
 
1228
  // theme updates function
1229
- public function cmp_check_update($theme_slug)
1230
- {
1231
 
1232
  $ajax = false;
1233
  // check for ajax
1234
- if (isset($_POST['theme_slug'])) {
1235
  // verify nonce
1236
- check_ajax_referer('cmp-coming-soon-ajax-secret', 'security');
1237
  // verify user rights
1238
- if (!current_user_can('publish_pages')) {
1239
  die('Sorry, but this request is invalid');
1240
  }
1241
 
1242
  // sanitize array
1243
  $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1244
 
1245
- if (!empty($_POST['theme_slug'])) {
1246
  $theme_slug = $_POST['theme_slug'];
1247
  $ajax = true;
1248
  }
1249
- }
1250
 
1251
- if (!in_array($theme_slug, $this->cmp_premium_themes_installed())) {
1252
  return;
1253
  }
1254
 
@@ -1256,141 +1226,145 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1256
  $remote_version = '';
1257
  $current_version = '';
1258
 
1259
- if (CMP_DEBUG === TRUE) {
1260
- delete_transient($theme_slug . '_updatecheck');
1261
  }
1262
 
1263
  // always check if update check transient is set or ajax request
1264
- if (false === ($updatecheck_transient = get_transient($theme_slug . '_updatecheck')) || $ajax === TRUE) {
1265
 
1266
  $current_version = $this->cmp_theme_version($theme_slug);
1267
  // get remote version from remote server
1268
- $request = wp_remote_post(CMP_UPDATE_URL . '?action=get_metadata&slug=' . $theme_slug, array('body' => array('action' => 'version')));
1269
-
1270
  // if no error, retrivee body
1271
- if (!is_wp_error($request)) {
1272
 
1273
- // decode to json
1274
- $remote_version = json_decode($request['body'], true);
1275
 
1276
- // get remove version key
1277
- if (isset($remote_version['version'])) {
1278
 
1279
- $remote_version = $remote_version['version'];
1280
 
1281
- // if remote version is bigger than current, display info about new version
1282
- if ((float)$remote_version > (float)$current_version) {
1283
 
1284
- $title = ucwords(str_replace('_', ' ', $theme_slug));
1285
 
1286
- // create nonce
1287
- $ajax_nonce = wp_create_nonce('cmp-coming-soon-ajax-secret');
1288
 
1289
- // if admin screen is not in updating theme
1290
- if (!isset($_GET['theme']) || (isset($_GET['theme']) && $_GET['theme'] != $theme_slug)) {
1291
 
1292
- $transient = '<div class="notice notice-warning"><p class="message">' . sprintf(__('There is a <b>recommended</b> update of <b>CMP Theme: %s</b> available:', 'cmp-coming-soon-maintenance'), $title) . ' <a href="' . admin_url() . 'options-general.php?page=cmp-settings&action=update-cmp-theme&theme=' . esc_attr($theme_slug) . '&type=premium" class="cmp update-theme" data-type="premium" data-security="' . esc_attr($ajax_nonce) . '" data-slug="' . esc_attr($theme_slug) . '" data-name="' . esc_attr($title) . '" data-remote_url="' . esc_url(CMP_UPDATE_URL) . '" data-new_ver="' . esc_attr($remote_version) . '">' . sprintf(__(' click to update to %s version from NiteoThemes server now', 'cmp-coming-soon-maintenance'), esc_attr($remote_version)) . '!</a></div>';
1293
 
1294
- // set transient with 12 hour expire
1295
- set_transient($theme_slug . '_updatecheck', $transient, 60 * 60 * 12);
1296
 
1297
- // die early if this is ajax request with status = true
1298
- if ($ajax) {
1299
  wp_die($remote_version);
1300
  return;
1301
  }
1302
 
1303
 
1304
- echo $transient;
1305
- }
1306
- } else {
1307
- // die early if this is ajax request with status = false
1308
- if ($ajax) {
 
1309
  wp_die('false');
1310
  return;
1311
  }
1312
- // set transient no update available with 12 hours expire
1313
- set_transient($theme_slug . '_updatecheck', '', 60 * 60 * 12);
1314
- }
1315
- }
1316
- }
1317
 
1318
- // empty transient means theme was updated in last 24 hours
1319
- } else if ($updatecheck_transient != '') {
 
 
 
1320
 
1321
  echo $updatecheck_transient;
1322
  }
1323
 
1324
- if ($ajax) {
1325
  wp_die('false');
1326
  }
1327
 
1328
  return;
1329
  }
1330
 
1331
- public function cmp_theme_upload($uploadedfile)
1332
- {
1333
 
1334
- if (!current_user_can('administrator')) {
1335
  return false;
1336
  }
1337
 
1338
  // allow zip file to upload
1339
- add_filter('upload_mimes', array($this, 'cmp_allow_mimes'));
1340
 
1341
- // load PHP WP FILE
1342
- if (!function_exists('wp_handle_upload')) {
1343
- require_once realpath('../../../wp-admin/includes/file.php');
1344
  }
1345
 
1346
  $filename = $uploadedfile['name'];
1347
  /* You can use wp_check_filetype() public function to check the
1348
  file type and go on wit the upload or stop it.*/
1349
- $filetype = wp_check_filetype($filename);
1350
 
1351
- if ($filetype['ext'] == 'zip') {
1352
  // Upload file
1353
- $movefile = wp_handle_upload($uploadedfile, array('test_form' => FALSE));
1354
 
1355
- if ($movefile && !isset($movefile['error'])) {
1356
 
1357
  WP_Filesystem();
1358
- $source_path = $movefile['file'];
1359
- $theme_name = str_replace('.zip', '', $filename);
1360
  $destination_path = CMP_PREMIUM_THEMES_DIR;
1361
 
1362
  // create new theme DIR
1363
- if (wp_mkdir_p($destination_path)) {
1364
  // Unzip FILE into that DIR
1365
- $unzipfile = unzip_file($source_path, $destination_path);
 
 
 
 
 
 
 
 
 
 
1366
 
1367
- if ($unzipfile) {
1368
- // delete FILE
1369
- wp_delete_file($source_path);
 
1370
 
1371
- if ($theme_name == 'pluto') {
1372
- delete_option('niteoCS_banner');
1373
- }
1374
- echo '<div class="notice notice-success is-dismissible"><p class="message">' . ucwords(str_replace('_', ' ', $theme_name)) . ' ' . __(' theme was successfully installed!', 'cmp-coming-soon-maintenance') . '</p></div>';
1375
- return;
1376
- } else {
1377
- echo '<div class="notice notice-error is-dismissible"><p>' . __('There was an error unzipping the file!', 'cmp-coming-soon-maintenance') . '</p></div>';
1378
- return;
1379
- }
1380
  } else {
1381
- echo '<div class="notice notice-error is-dismissible"><p>' . __('Error creating Theme subdirectory!', 'cmp-coming-soon-maintenance') . '</p></div>';
1382
  return;
1383
  }
 
1384
  } else {
1385
- /**
1386
- * Error generated by _wp_handle_upload()
1387
- * @see _wp_handle_upload() in wp-admin/includes/file.php
1388
- */
1389
- echo '<div class="notice notice-error is-dismissible"><p>' . $movefile['error'] . '</p></div>';
1390
- return;
1391
  }
1392
  } else {
1393
- echo '<div class="notice notice-error is-dismissible"><p>' . __('Unable to upload new Theme file .', 'cmp-coming-soon-maintenance') . strtoupper($filetype['ext']) . __(' file extension is not supported. Please upload ZIP file containing CMP Theme.', 'cmp-coming-soon-maintenance') . '</p></div>';
1394
  return;
1395
  }
1396
 
@@ -1398,86 +1372,89 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1398
  return;
1399
  }
1400
 
1401
- public function cmp_theme_update_install($file)
1402
- {
1403
  $ajax = false;
1404
  // check for ajax
1405
- if (isset($_POST['file'])) {
1406
  // verify nonce
1407
- check_ajax_referer('cmp-coming-soon-ajax-secret', 'security');
1408
  // verify user rights
1409
- if (!current_user_can('publish_pages')) {
1410
  die('Sorry, but this request is invalid');
1411
  }
1412
 
1413
  // sanitize array
1414
  $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1415
 
1416
- if (!empty($_POST['file'])) {
1417
  $file = $_POST['file'];
1418
  $ajax = true;
1419
  }
1420
- }
1421
 
1422
- // load PHP WP FILE
1423
- if (!empty($file)) {
1424
  // Download file to temp location.
1425
- $file['tmp_name'] = download_url($file['url']);
1426
  //WARNING: The file is not automatically deleted, The script must unlink() the file.
1427
 
1428
  // If error storing temporarily, return the error.
1429
- if (!is_wp_error($file['tmp_name'])) {
1430
  WP_Filesystem();
1431
 
1432
  // create new theme DIR
1433
- if (wp_mkdir_p(CMP_PREMIUM_THEMES_DIR)) {
1434
  // Unzip FILE into that DIR
1435
- $unzipfile = unzip_file($file['tmp_name'], CMP_PREMIUM_THEMES_DIR);
1436
 
1437
- if (!is_wp_error($unzipfile)) {
1438
  // delete tmp FILE
1439
- wp_delete_file($file['tmp_name']);
1440
 
1441
  // set transient no update available with 24 hours expire
1442
- set_transient($file['name'] . '_updatecheck', '', 60 * 60 * 24);
1443
 
1444
  // die
1445
- if ($ajax) {
1446
  wp_die('success');
1447
  return;
 
1448
  } else {
1449
- echo '<div class="notice notice-success is-dismissible"><p>CMP ' . ucwords(str_replace('_', ' ', $file['name'])) . ' ' . __('Theme has been updated to latest version!', 'cmp-coming-soon-maintenance') . '</p></div>';
1450
  return;
1451
  }
 
1452
  } else {
1453
- echo '<div class="notice notice-error is-dismissible"><p>' . __('There was an error unzipping the file due to error: ', 'cmp-coming-soon-maintenance') . $unzipfile->get_error_message() . '</p></div>';
1454
 
1455
- if ($ajax) {
1456
  wp_die('error');
1457
  return;
1458
- }
1459
  }
 
1460
  } else {
1461
- echo '<div class="notice notice-error is-dismissible"><p>' . __('Error creating Theme subdirectory!', 'cmp-coming-soon-maintenance') . '</p></div>';
1462
- if ($ajax) {
1463
  wp_die('error');
1464
  return;
1465
  }
1466
  }
 
1467
  } else {
1468
- echo '<div class="notice notice-error is-dismissible"><p>' . __('Error during updating Theme files:', 'cmp-coming-soon-maintenance') . ' ' . $file['tmp_name']->get_error_message() . '</p></div>';
1469
- if ($ajax === true) {
1470
  wp_die('error');
1471
  return;
1472
- }
1473
  }
1474
  } else {
1475
 
1476
- echo '<div class="notice notice-error is-dismissible"><p>' . __('General Error during updating Theme files.', 'cmp-coming-soon-maintenance') . '</p></div>';
1477
- if ($ajax === true) {
1478
  wp_die('error');
1479
  return;
1480
- }
1481
  }
1482
 
1483
  return;
@@ -1485,115 +1462,115 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1485
 
1486
 
1487
  // build unsplash api
1488
- public function cmp_unsplash_api($query)
1489
- {
1490
-
1491
- $api_url = 'https://api.unsplash.com/' . $query . '&client_id=41f043163758cf2e898e8a868bc142c20bc3f5966e7abac4779ee684088092ab';
1492
 
1493
- if (function_exists('wp_remote_get')) {
 
 
1494
 
1495
- $response = wp_remote_get($api_url);
1496
 
1497
- if (!is_object($response) && isset($response['body'])) {
1498
 
1499
  $body = $response['body'];
1500
- $data = array('response' => $response['response']['code'], 'body' => $body);
 
1501
  } else {
1502
- $data = array('response' => 'Unplash API', 'body' => 'Not responding after 5000ms');
1503
  }
 
1504
  } else {
1505
- $data = array('response' => '500', 'body' => 'You have neither cUrl installed nor allow_url_fopen activated. Ask your server hosting provider to allow on of those options.');
1506
  }
1507
 
1508
  return $data;
1509
  }
1510
 
1511
  // prepare unsplash url and get unsplash photo via cmp_unsplash_api()
1512
- public function niteo_unsplash($params)
1513
- {
1514
  $ajax = false;
1515
 
1516
  // check for ajax
1517
- if (isset($_POST['params'])) {
1518
  // verify nonce
1519
- check_ajax_referer('cmp-coming-soon-ajax-secret', 'security');
1520
  // verify user rights
1521
- if (!current_user_can('publish_pages')) {
1522
  die('Sorry, but this request is invalid');
1523
  }
1524
 
1525
  // sanitize array
1526
  $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1527
 
1528
- if (!empty($_POST['params'])) {
1529
  $params = $_POST['params'];
1530
  $ajax = true;
1531
  }
1532
- }
1533
 
1534
- array_key_exists('feed', $params) ? $feed = $params['feed'] : $feed = '';
1535
- array_key_exists('url', $params) ? $url = $params['url'] : $url = '';
1536
- array_key_exists('feat', $params) ? $feat = $params['feat'] : $feat = '';
1537
- array_key_exists('custom_str', $params) ? $custom_str = $params['custom_str'] : $custom_str = '';
1538
- array_key_exists('count', $params) ? $count = $params['count'] : $count = '1';
1539
 
1540
- switch ($feed) {
1541
- // specific unsplash photo by url/id
1542
  case '0':
1543
  $id = '';
1544
  // check if $query contains unsplash.com url
1545
- if (strpos($url, 'unsplash.com') !== false) {
1546
- $parts = parse_url($url);
1547
  // check for photo parameter in URL
1548
- if (isset($parts['query'])) {
1549
  parse_str($parts['query'], $query);
1550
- $id = $query['photo'];
1551
  }
1552
- // if no ID found, get last part of URL containing ID
1553
- if ($id == '') {
1554
 
1555
  $pathFragments = explode('/', $parts['path']);
1556
  $id = end($pathFragments);
1557
- }
1558
 
1559
- // $query is ID
1560
  } else {
1561
  $id = $url;
1562
  }
1563
 
1564
  // prepare query for single image
1565
- $api_query = 'photos/' . $id . '?';
1566
  break;
1567
 
1568
- // random from user
1569
  case '1':
1570
 
1571
- if ($custom_str[0] == '@') {
1572
  $custom_str = substr($custom_str, 1);
1573
  }
1574
 
1575
  // prepare query for random photo from collection
1576
- $api_query = 'photos/random/?username=' . $custom_str . '&count=' . $count;
1577
  break;
1578
 
1579
- // random from collection
1580
  case '2':
1581
- if (is_numeric($url)) {
1582
  $collection = $url;
1583
  } else {
1584
  $collection = filter_var($url, FILTER_SANITIZE_NUMBER_INT);
1585
- $collection = str_replace('-', '', $collection);
1586
  }
1587
 
1588
  // prepare query for random photo from collection
1589
- $api_query = 'photos/random/?collections=' . $collection . '&count=' . $count;
1590
  break;
1591
 
1592
- // random photo
1593
  case '3':
1594
 
1595
  // featured
1596
- if ($feat == '0' || $feat == '') {
1597
  $featured = 'false';
1598
  } else {
1599
  $featured = 'true';
@@ -1602,38 +1579,38 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1602
  // category
1603
  $search = str_replace(' ', ',', $url);
1604
 
1605
- if ($search !== '') {
1606
- $search = 'query=' . $search . '&';
1607
  }
1608
  // prepare query for random photo
1609
- $api_query = 'photos/random/?orientation=landscape&featured=' . $featured . '&' . $search . 'count=' . $count;
1610
  break;
1611
 
1612
  default:
1613
- $api_query = 'photos/random/?orientation=landscape&count=' . $count;
1614
  break;
1615
  }
1616
 
1617
- $unsplash_img = $this->cmp_unsplash_api($api_query);
1618
 
1619
- if ($ajax === true) {
1620
  echo json_encode($unsplash_img);
1621
  wp_die();
 
1622
  } else {
1623
  return $unsplash_img;
1624
  }
1625
  }
1626
-
1627
  // check value in multidimensional array
1628
- public function niteo_in_array_r($needle, $haystack, $strict = false)
1629
- {
1630
- foreach ($haystack as $item) {
1631
- if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->niteo_in_array_r($needle, $item, $strict))) {
1632
- return true;
1633
- }
1634
- }
1635
 
1636
- return false;
1637
  }
1638
  /**
1639
  * Recaptcha integration
@@ -1642,10 +1619,9 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1642
  * @access public
1643
  * @return boolean
1644
  */
1645
- public function is_human($token)
1646
- {
1647
 
1648
- $this->define('RECAPTCHA_SECRET', get_option('niteoCS_recaptcha_secret'));
1649
 
1650
  $request = array(
1651
  'body' => array(
@@ -1654,139 +1630,142 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1654
  ),
1655
  );
1656
 
1657
- $response = wp_remote_post(esc_url_raw('https://www.google.com/recaptcha/api/siteverify'), $request);
1658
- $response_body = wp_remote_retrieve_body($response);
1659
- $recaptcha = json_decode($response_body, true);
1660
 
1661
- if ($recaptcha['success'] === true & $recaptcha['score'] > 0.50) {
1662
  return true;
1663
  }
1664
 
1665
  return false;
 
1666
  }
1667
 
1668
  // save subscribe function
1669
  // $check must be true, to avoid duplicated requests after update to 2.1
1670
- public function niteo_subscribe($check)
1671
- {
1672
 
1673
  $subscribe_method = get_option('niteoCS_subscribe_method', 'cmp');
1674
  $response = '';
1675
 
1676
  // get translation lists
1677
- if (get_option('niteoCS_translation')) {
1678
- $translation = json_decode(get_option('niteoCS_translation'), TRUE);
1679
- $response_ok = $this->cmp_wpml_translate_string($translation[7]['translation'], 'Subscribe Response Thanks');
1680
- $response_duplicate = $this->cmp_wpml_translate_string($translation[5]['translation'], 'Subscribe Response Duplicate');
1681
- $response_invalid = $this->cmp_wpml_translate_string($translation[6]['translation'], 'Subscribe Response Not Valid');
1682
- }
1683
-
1684
- $ajax = (isset($_POST['ajax']) && $_POST['ajax'] == TRUE) ? TRUE : FALSE;
1685
-
1686
- if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['form_honeypot']) && $_POST['form_honeypot'] === '' && isset($_POST['email'])) :
1687
-
1688
- if ($ajax) {
1689
- check_ajax_referer('cmp-subscribe-action', 'security');
1690
  }
1691
 
1692
  // check recatpcha score if integration is enabled
1693
- if (get_option('niteoCS_recaptcha_status', '1') === '1' && !empty(get_option('niteoCS_recaptcha_site', ''))) {
1694
- if (!$this->is_human(sanitize_text_field($_POST['token']))) {
1695
- echo json_encode(array('status' => '0', 'message' => 'Sorry, robots not allowed.'));
1696
  wp_die();
1697
  }
1698
  }
1699
 
1700
- if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
1701
- // email already passed is_email, no need to sanitize
1702
- $email = sanitize_email($_POST['email']);
1703
 
1704
- // sanitize all inputs
1705
- $ip_address = (isset($_POST['lastname'])) ? sanitize_text_field($_SERVER['REMOTE_ADDR']) : '';
1706
- $firstname = (isset($_POST['firstname'])) ? sanitize_text_field($_POST['firstname']) : '';
1707
- $lastname = (isset($_POST['lastname'])) ? sanitize_text_field($_POST['lastname']) : '';
1708
  $timestamp = time();
1709
 
1710
- switch ($subscribe_method) {
1711
- // default custom CMP method
1712
- case 'cmp':
1713
  // get subscribe list
1714
  $subscribe_list = get_option('niteoCS_subscribers_list');
1715
 
1716
  // if no subscribe list yet, create first item and insert it into DB
1717
- if (!$subscribe_list) {
1718
  $new_list = array();
1719
- $new_email = array('id' => '0', 'timestamp' => $timestamp, 'email' => $email, 'ip_address' => $ip_address, 'firstname' => $firstname, 'lastname' => $lastname);
1720
- array_push($new_list, $new_email);
1721
- update_option('niteoCS_subscribers_list', $new_list);
1722
- $response = array('status' => '1', 'message' => $response_ok);
 
1723
  } else {
1724
  // check if email don`t already exists
1725
- if (!$this->niteo_in_array_r($email, $subscribe_list, true)) {
1726
- $count = count($subscribe_list);
1727
- $new_email = array('id' => $count, 'timestamp' => $timestamp, 'email' => $email, 'ip_address' => $ip_address, 'firstname' => $firstname, 'lastname' => $lastname);
1728
- array_push($subscribe_list, $new_email);
1729
  update_option('niteoCS_subscribers_list', $subscribe_list);
1730
- $response = array('status' => '1', 'message' => $response_ok);
1731
  // sent notif email
1732
- if (get_option('niteoCS_subscribe_notification', '0')) {
1733
- $subscribe_notif_email = get_option('niteoCS_subscribe_email_address', get_option('admin_email'));
1734
  $subject = sprintf(__('You have a new Subscriber on %s!', 'cmp-coming-soon-maintenance'), get_site_url());
1735
  $body = __('This is auto generated message from CMP - Coming Soon & Maintenance WordPress Plugin. You can disable these emails under CMP Advanced Settings > Email Notifications.', 'cmp-coming-soon-maintenance');
1736
  $headers = array('Content-Type: text/plain; charset=UTF-8');
1737
- wp_mail($subscribe_notif_email, $subject, $body, $headers);
1738
  }
1739
 
1740
- // if email exists return duplicate response
1741
  } else {
1742
- $response = array('status' => '0', 'message' => $response_duplicate);
1743
  }
1744
  }
1745
- break;
1746
-
1747
- // mailchimp API call
1748
- case 'mailchimp':
1749
- $api_key = esc_attr(get_option('niteoCS_mailchimp_apikey'));
1750
- $list_id = esc_attr(get_option('niteoCS_mailchimp_list_selected'));
1751
- $double_opt = get_option('niteoCS_mailchimp[double-opt]', '0');
1752
- $status = ($double_opt == '1') ? 'pending' : 'subscribed'; // subscribed, cleaned, pending
1753
-
1754
  $args = array(
1755
  'method' => 'PUT',
1756
- 'headers' => array(
1757
- 'Authorization' => 'Basic ' . base64_encode('user:' . $api_key)
1758
  ),
1759
  'body' => json_encode(array(
1760
- 'email_address' => $email,
1761
  'status' => $status,
1762
  'merge_fields' => array(
1763
- 'FNAME' => $firstname,
1764
- 'LNAME' => $lastname
1765
  )
1766
  ))
1767
  );
1768
 
1769
- $mailchimp = wp_remote_post('https://' . substr($api_key, strpos($api_key, '-') + 1) . '.api.mailchimp.com/3.0/lists/' . $list_id . '/members/' . md5(strtolower($email)), $args);
 
 
1770
 
1771
- if (!is_wp_error($mailchimp)) {
1772
 
1773
- $body = json_decode($mailchimp['body']);
 
1774
 
1775
- if ($mailchimp['response']['code'] == 200 && $body->status == $status) {
1776
- $response = array('status' => '1', 'message' => $response_ok);
1777
  } else {
1778
- $response = array('status' => '0', 'message' => 'Error ' . $mailchimp['response']['code'] . ' ' . $body->title . ': ' . $body->detail);
1779
  }
 
1780
  } else {
1781
  $error = $mailchimp->get_error_message();
1782
- $response = array('status' => '0', 'message' => $error);
1783
  }
1784
 
1785
  break;
1786
 
1787
- // MailPoet integration
1788
  case 'mailpoet':
1789
- $response = array('status' => '0', 'message' => __('Something went wrong please try again later.', 'cmp-coming-soon-maintenance'));
1790
  $mailpoet_list = get_option('niteoCS_mailpoet_list_selected');
1791
  $list_ids = array($mailpoet_list);
1792
  $firstname = $firstname === '' ? null : $firstname;
@@ -1797,40 +1776,42 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1797
  'last_name' => $lastname
1798
  );
1799
 
1800
- if (class_exists(\MailPoet\API\API::class)) {
1801
  // Get MailPoet API instance
1802
  $mailpoet_api = \MailPoet\API\API::MP('v1');
1803
 
1804
  // Check if subscriber exists. If subscriber doesn't exist an exception is thrown
1805
  try {
1806
- $subscribed = $mailpoet_api->getSubscriber($subscriber['email']);
1807
- } catch (\Exception $e) {
1808
- }
1809
 
1810
  try {
1811
  if (!$subscribed) {
1812
  // Subscriber doesn't exist let's create one
1813
- $mailpoet_api->addSubscriber($subscriber, $list_ids);
1814
- $response = array('status' => '1', 'message' => $response_ok);
 
1815
  } else {
1816
  // In case subscriber exists just add him to new lists
1817
- $mailpoet_api->subscribeToLists($subscriber['email'], $list_ids);
1818
- $response = array('status' => '1', 'message' => $response_ok);
 
1819
  }
1820
  } catch (\Exception $e) {
1821
- $error_message = $e->getMessage();
1822
- $response = array('status' => '0', 'message' => $error_message);
1823
  }
 
1824
  }
1825
 
1826
- break;
1827
 
1828
- // Mailster integration
1829
  case 'mailster':
1830
- $response = array('status' => '0', 'message' => __('Something went wrong please try again later.', 'cmp-coming-soon-maintenance'));
1831
  $mailster_list_id = get_option('niteoCS_mailster_list_selected');
1832
 
1833
- if (function_exists('mailster')) {
1834
  // define to overwrite existing users
1835
  $overwrite = true;
1836
 
@@ -1841,94 +1822,95 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1841
  'email' => $email,
1842
  'firstname' => $firstname,
1843
  'lastname' => $lastname,
1844
- 'status' => get_option('niteoCS_mailster_double_opt', '1') ? 0 : 1
1845
  );
1846
 
1847
  // add a new subscriber and $overwrite it if exists
1848
- $subscriber_id = mailster('subscribers')->add($subscriber, $overwrite);
1849
 
1850
  // if result isn't a WP_error assign the lists
1851
- if (!is_wp_error($subscriber_id)) {
1852
- mailster('subscribers')->assign_lists($subscriber_id, $mailster_list_id);
1853
- $response = array('status' => '1', 'message' => $response_ok);
 
1854
  } else {
1855
- $response = array('status' => '0', 'message' => $subscriber_id->get_error_message());
1856
  }
1857
  }
1858
 
1859
- break;
1860
 
1861
- default:
1862
- break;
1863
- }
1864
 
1865
- // if not email, set response invalid
1866
  } else {
1867
- $response = array('status' => '0', 'message' => $response_invalid);
1868
  }
1869
  endif;
1870
 
1871
- if ($ajax === TRUE) {
1872
- echo json_encode($response);
1873
  wp_die();
 
1874
  } else {
1875
- return ($response == '') ? $response : json_encode($response);
1876
  }
 
1877
  }
1878
 
1879
- public function niteo_export_csv()
1880
- {
1881
 
1882
- if (!current_user_can('publish_pages')) {
1883
  die('Sorry, but this request is invalid');
1884
  }
1885
 
1886
- check_ajax_referer('cmp-coming-soon-ajax-secret', 'security');
1887
 
1888
  // load subscribers array
1889
  $subscribers = get_option('niteoCS_subscribers_list');
1890
 
1891
- if (!empty($subscribers)) {
1892
  $filename = 'cmp-subscribers-export-' . date('Y-m-d') . '.csv';
1893
 
1894
  header('Content-Type: text/csv');
1895
- header('Content-Disposition: attachment;filename=' . $filename);
1896
 
1897
  $fp = fopen('php://output', 'w');
1898
 
1899
- fputcsv(
1900
- $fp,
1901
- array(
1902
- __('ID', 'cmp-coming-soon-maintenance'),
1903
- __('Date', 'cmp-coming-soon-maintenance'),
1904
- __('Email', 'cmp-coming-soon-maintenance'),
1905
- __('Firstname', 'cmp-coming-soon-maintenance'),
1906
- __('Lastname', 'cmp-coming-soon-maintenance'),
1907
- __('Fullname', 'cmp-coming-soon-maintenance')
1908
  )
1909
  );
1910
- foreach ($subscribers as $key => $value) {
1911
 
1912
- if (isset($value['ip_address'])) {
1913
  unset($subscribers[$key]['ip_address']);
1914
  }
1915
 
1916
- if (isset($value['timestamp'])) {
1917
- $format = "Y-m-d H:i:s";
1918
  $subscribers[$key]['timestamp'] = date_i18n($format, $subscribers[$key]['timestamp']);
1919
  }
1920
 
1921
  $subscribers[$key]['Name'] = '';
1922
 
1923
- if ($value['firstname'] !== '' || $value['lastname'] !== '') {
1924
  $subscribers[$key]['Name'] = $value['firstname'] . ' ' . $value['lastname'];
1925
  }
1926
 
1927
  $subscribers[$key]['Name'] = trim($subscribers[$key]['Name']);
 
1928
  }
1929
 
1930
- foreach ($subscribers as $key => $value) {
1931
- fputcsv($fp, $value, $delimiter = ',', $enclosure = '"');
1932
  }
1933
 
1934
  fclose($fp);
@@ -1936,79 +1918,74 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
1936
  die();
1937
  }
1938
 
1939
- public function cmp_allow_mimes($mimes = array())
1940
- {
1941
  // add your own extension here - as many as you like
1942
- $mimes['zip'] = 'application/zip';
1943
-
1944
  return $mimes;
1945
  }
1946
 
1947
- public function cmp_allow_font_mimes($mimes = array())
1948
- {
1949
  // add your own extension here - as many as you like
1950
  $mimes['woff'] = 'application/x-font-woff';
1951
  $mimes['woff2'] = 'application/x-font-woff2';
1952
  $mimes['ttf'] = 'application/x-font-ttf';
1953
  $mimes['eot'] = 'application/vnd.ms-fontobject';
1954
  $mimes['otf'] = 'font/otf';
1955
- if (current_user_can('administrator')) {
1956
  $mimes['svg'] = 'image/svg+xml';
1957
  }
1958
  return $mimes;
1959
  }
1960
 
1961
- public function cmp_admin_notice()
1962
- {
1963
  global $pagenow;
1964
 
1965
  // display save messages
1966
- if (isset($_GET['page']) && ($_GET['page'] == 'cmp-settings' || $_GET['page'] == 'cmp-translate' || $_GET['page'] == 'cmp-advanced')) {
1967
  if (isset($_GET['status']) && $_GET['status'] == 'settings-saved') {
1968
  $status = 'success';
1969
  $message = __('CMP Settings Saved', 'cmp-coming-soon-maintenance');
1970
 
1971
- echo '<div class="notice notice-' . $status . ' is-dismissible"><p>' . $message . '.</p></div>';
1972
  }
1973
  }
1974
 
1975
  // display activation notice
1976
- if (!get_option('niteoCS_activation_notice')) {
1977
- if (($pagenow == 'plugins.php')) {
1978
  // load the notices view
1979
- require_once(dirname(__FILE__) . '/inc/cmp-activation-notice.php');
1980
  }
1981
  }
1982
  return;
1983
- }
1984
 
1985
  // convert hex to rgba
1986
- public function hex2rgba($hex, $opacity = null)
1987
- {
1988
- list($red, $green, $blue) = sscanf($hex, '#%02x%02x%02x');
1989
 
1990
- if ($opacity === null) {
1991
  return $red . ',' . $green . ',' . $blue;
1992
  }
1993
 
1994
- $rgba = 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $opacity . ')';
1995
 
1996
  return $rgba;
1997
  }
1998
 
1999
  // convert hex to hsl css
2000
- public function hex2hsl($hex, $opacity)
2001
- {
2002
 
2003
- if ($hex[0] != '#') {
2004
- $rgba = explode(',', $hex);
2005
  $rgba[3] = str_replace(')', '', $rgba[3]);
2006
- $rgba[3] = $rgba[3] - ($opacity / 100);
2007
  $rgba = $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ',' . $rgba[3] . ')';
2008
  return $rgba;
2009
  }
2010
 
2011
- list($red, $green, $blue) = sscanf($hex, '#%02x%02x%02x');
2012
 
2013
  $r = $red / 255.0;
2014
  $g = $green / 255.0;
@@ -2017,112 +1994,107 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2017
  $S = 0;
2018
  $V = 0;
2019
 
2020
- $min = min($r, $g, $b);
2021
- $max = max($r, $g, $b);
2022
- $delta = ($max - $min);
2023
 
2024
- $L = ($max + $min) / 2.0;
2025
 
2026
- if ($delta == 0) {
2027
  $H = 0;
2028
  $S = 0;
2029
  } else {
2030
- $S = $L > 0.5 ? $delta / (2 - $max - $min) : $delta / ($max + $min);
2031
 
2032
- $dR = ((($max - $r) / 6) + ($delta / 2)) / $delta;
2033
- $dG = ((($max - $g) / 6) + ($delta / 2)) / $delta;
2034
- $dB = ((($max - $b) / 6) + ($delta / 2)) / $delta;
2035
 
2036
- if ($r == $max)
2037
  $H = $dB - $dG;
2038
- else if ($g == $max)
2039
- $H = (1 / 3) + $dR - $dB;
2040
  else
2041
- $H = (2 / 3) + $dG - $dR;
2042
 
2043
- if ($H < 0)
2044
  $H += 1;
2045
- if ($H > 1)
2046
  $H -= 1;
2047
  }
2048
 
2049
- $HSL = array('hue' => round(($H * 360), 0), 'saturation' => round(($S * 100), 0), 'luminosity' => round(($L * 100), 0));
2050
 
2051
  // if color is white {
2052
- if ($HSL['hue'] == 0 && $HSL['saturation'] == 0) {
2053
  $requested_lumi = $HSL['luminosity'] + $opacity;
2054
  } else {
2055
  $requested_lumi = $HSL['luminosity'] - $opacity;
2056
  }
2057
-
2058
  $requested_lumi = (int)round($requested_lumi);
2059
 
2060
- if ($requested_lumi > 90) {
2061
-
2062
  $requested_lumi = 90;
2063
  }
2064
 
2065
- $HSL = 'hsl( ' . $HSL['hue'] . ', ' . ($HSL['saturation']) . '%, ' . $requested_lumi . '%)';
2066
  return $HSL;
2067
  }
2068
 
2069
  // check if mobile
2070
- public function isMobile()
2071
- {
2072
- if (isset($_SERVER["HTTP_USER_AGENT"])) {
2073
  return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
 
2074
  } else {
2075
  return false;
2076
  }
2077
  }
2078
 
2079
  // sanitize function
2080
- public function sanitize_checkbox($input)
2081
- {
2082
- return ((isset($input) && true == $input) ? '1' : '0');
2083
  }
2084
 
2085
  // sanitize function
2086
- public function niteo_sanitize_html($html)
2087
- {
2088
 
2089
- if (!current_user_can('unfiltered_html')) {
2090
- $allowed = wp_kses_allowed_html('post');
2091
- $html = wp_kses($html, $allowed);
2092
- }
2093
 
2094
- return $html;
2095
  }
2096
 
2097
  // public function to sort social icons
2098
- public function sort_social($a, $b)
2099
- {
2100
- if ($a['hidden'] == $b['hidden']) {
2101
- if ($a['order'] == $b['order']) {
2102
- return 0;
2103
- }
2104
- return $a['order'] < $b['order'] ? -1 : 1;
2105
- } else {
2106
- return $a['hidden'] > $b['hidden'] ? 1 : -1;
2107
- }
2108
- }
2109
-
2110
- // public function to shift multidimensional array
2111
- public function customShift($array, $name)
2112
- {
2113
-
2114
- foreach ($array as $key => $val) { // loop all elements
2115
- if ($val['name'] == $name) { // check for id $id
2116
- unset($array[$key]); // unset the $array with id $id
2117
- array_unshift($array, $val); // unshift the array with $val to push in the beginning of array
2118
- return $array; // return new $array
2119
- }
2120
- }
2121
- }
2122
-
2123
- public function get_youtube_img($youtube_url)
2124
- {
2125
- $yt_id = $this->get_youtube_id($youtube_url);
2126
 
2127
  $youtube_image = 'http://img.youtube.com/vi/' . $yt_id . '/hqdefault.jpg';
2128
 
@@ -2130,27 +2102,25 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2130
  }
2131
 
2132
 
2133
- public function get_youtube_id($youtube_url)
2134
- {
2135
  $youtube = preg_match('/.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/', $youtube_url, $url);
2136
 
2137
  return $url[7];
2138
  }
2139
 
2140
- public function cmp_get_pages($post_status = 'publish,draft', $builder = false)
2141
- {
2142
  $meta_query = array();
2143
  $pages = array();
2144
 
2145
  // meta_query for pages built by elementor
2146
- if ($builder === 'elementor') {
2147
  $meta_query = array(
2148
  'key' => '_elementor_edit_mode',
2149
  'compare' => 'EXISTS'
2150
  );
2151
  }
2152
  // meta_query for pages built by Divi
2153
- if ($builder === 'divi') {
2154
  $meta_query = array(
2155
  'key' => '_et_pb_use_builder',
2156
  'compare' => 'EXISTS'
@@ -2164,13 +2134,13 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2164
  'meta_query' => array($meta_query)
2165
  );
2166
 
2167
- $the_query = new WP_Query($args);
2168
-
2169
- if ($the_query->have_posts()) {
2170
 
2171
- foreach ($the_query->posts as $post) {
 
 
2172
  // check for gutenberg pages
2173
- if ($builder === 'gutenberg' && !has_blocks($post->ID)) {
2174
  continue;
2175
  }
2176
 
@@ -2184,193 +2154,188 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2184
  }
2185
 
2186
  // send json data for theme info overlay AJAX request
2187
- public function niteo_themeinfo()
2188
- {
2189
 
2190
  // check for ajax
2191
- if (isset($_POST['theme_slug'])) {
2192
  // verify nonce
2193
- check_ajax_referer('cmp-coming-soon-ajax-secret', 'security');
2194
  // verify user rights
2195
- if (!current_user_can('publish_pages')) {
2196
  die('Sorry, but this request is invalid');
2197
  }
2198
 
2199
 
2200
  // sanitize $post
2201
- $theme_slug = sanitize_text_field($_POST['theme_slug']);
2202
- $data = array('result' => 'true', 'author_homepage' => CMP_AUTHOR_HOMEPAGE, 'author' => CMP_AUTHOR);
2203
-
2204
- if (!empty($theme_slug)) {
2205
  $headers = array('Theme Name', 'Description');
2206
- $theme_info = get_file_data(plugin_dir_path(__FILE__) . '/themes/' . $theme_slug . '.txt', $headers, '');
2207
-
2208
- $screenshots = array_map('basename', glob(plugin_dir_path(__FILE__) . 'img/thumbnails/' . $theme_slug . '/*'));
2209
 
2210
- foreach ($screenshots as $key => $screenshot) {
2211
- $screenshots[$key] = plugins_url('img/thumbnails/' . $theme_slug . '/' . $screenshot, __FILE__);
 
 
2212
  }
2213
 
2214
- $data['name'] = $theme_info[0];
2215
- $data['description'] = $theme_info[1];
2216
- $data['screenshots'] = $screenshots;
2217
  }
2218
 
2219
- echo json_encode($data);
2220
  wp_die();
2221
- }
2222
- }
2223
-
2224
- // legacy function for premium themes redirect
2225
- public function niteo_redirect()
2226
- {
2227
- return;
2228
- }
2229
-
2230
- // returns array of google fonts from /inc/webfonts.php
2231
- public function cmp_get_google_fonts()
2232
- {
2233
- $fonts = include_once wp_normalize_path(dirname(__FILE__) . '/inc/webfonts.php');
2234
- $google_fonts = json_decode($fonts, true);
2235
-
2236
- return $google_fonts;
2237
- }
2238
-
2239
- public function cmp_google_variant_title($variant)
2240
- {
2241
-
2242
- switch ($variant) {
2243
- case '100':
2244
- return 'Thin 100';
2245
- break;
2246
- case '100italic':
2247
- return 'Thin 100 Italic';
2248
- break;
2249
- case '200':
2250
- return 'Extra-light 200';
2251
- break;
2252
- case '200italic':
2253
- return 'Extra-light 200 Italic';
2254
- break;
2255
- case '300':
2256
- return 'Light 300';
2257
- break;
2258
- case '300italic':
2259
- return 'Light 300 Italic';
2260
- break;
2261
  case '400':
2262
  case 'regular':
2263
- return 'Regular 400';
2264
- break;
2265
  case '400italic':
2266
  case 'italic':
2267
- return 'Regular 400 Italic';
2268
- break;
2269
- case '500':
2270
- return 'Medium 500';
2271
- break;
2272
- case '500italic':
2273
- return 'Meidum 500 Italic';
2274
- break;
2275
- case '600':
2276
- return 'Semi-Bold 600';
2277
- break;
2278
- case '600italic':
2279
- return 'Semi-Bold 600 Italic';
2280
- break;
2281
- case '700':
2282
- return 'Bold 700';
2283
- break;
2284
- case '700italic':
2285
- return 'Bold 700 Italic';
2286
- break;
2287
- case '800':
2288
- return 'Extra-Bold 800';
2289
- break;
2290
- case '800italic':
2291
- return 'Extra-Bold Italic';
2292
- break;
2293
- case '900':
2294
- return 'Black 900';
2295
- break;
2296
- case '900italic':
2297
- return 'Black 900 Italic';
2298
- break;
2299
  case 'Not Applicable':
2300
  return 'Not Applicable';
2301
  break;
2302
- default:
2303
- break;
2304
  }
2305
  }
2306
 
2307
  // returns true if current page should display CMP page
2308
  // since 2.2
2309
- public function cmp_page_filter()
2310
- {
2311
  global $wp;
2312
 
2313
  $uri = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] : '';
2314
-
2315
- $current_url = trailingslashit((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $uri);
2316
 
2317
  $custom_login_url = get_option('niteoCS_custom_login_url', '');
2318
 
2319
  // return early if login page or ajax call
2320
- if (fnmatch('*wp-login.php*', $current_url) || wp_doing_ajax()) {
2321
  return false;
2322
  }
2323
 
2324
  // return early if custom login page
2325
- if ($custom_login_url !== '' && fnmatch('*' . $custom_login_url . '*', $current_url)) {
2326
  return false;
2327
  }
2328
 
2329
  // WPS HIDE login integration
2330
- if (defined('WPS_HIDE_LOGIN_BASENAME')) {
2331
- if (fnmatch('*' . get_option('whl_page'), $current_url)) {
2332
  return false;
2333
  }
2334
  }
2335
 
2336
  // allow / block RSS
2337
- if (get_option('niteoCS_rss_status', '1') && is_feed()) {
2338
  return false;
2339
  }
2340
 
2341
  // get current page IDs
2342
- if (is_front_page() && is_home()) {
2343
  // default homepage
 
 
 
2344
  $page_id = '-1';
2345
- } elseif (is_front_page()) {
2346
- // static homepage
2347
- $page_id = '-1';
2348
- } elseif (is_home()) {
2349
  // posts page
2350
- $page_id = get_option('page_for_posts');
2351
  } else {
2352
- //everyting else
2353
- $page_id = get_the_ID();
2354
  }
2355
 
2356
  // check whitelist or blacklist and return true/false
2357
- switch (get_option('niteoCS_page_filter', '0')) {
2358
- // disabled return true
2359
  case '0':
2360
  return true;
2361
  break;
2362
 
2363
- // whitelist
2364
  case '1':
2365
- $whitelist = json_decode(get_option('niteoCS_page_whitelist', '[]'), true);
2366
- if (!empty($whitelist) && in_array($page_id, $whitelist)) {
2367
  return true;
2368
  }
2369
 
2370
  $page_wl_custom = json_decode(get_option('niteoCS_page_whitelist_custom', '[]'), true);
2371
- if (!empty($page_wl_custom)) {
2372
- foreach ($page_wl_custom as $url) {
2373
- if (fnmatch($url, $current_url)) {
2374
  return true;
2375
  }
2376
  }
@@ -2379,19 +2344,19 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2379
  return false;
2380
  break;
2381
 
2382
- // blacklist
2383
  case '2':
2384
- $blacklist = json_decode(get_option('niteoCS_page_blacklist', '[]'), true);
2385
 
2386
- if (!empty($blacklist) && in_array($page_id, $blacklist)) {
2387
  return false;
2388
  }
2389
 
2390
  $page_bl_custom = json_decode(get_option('niteoCS_page_blacklist_custom', '[]'), true);
2391
 
2392
- if (!empty($page_bl_custom)) {
2393
- foreach ($page_bl_custom as $url) {
2394
- if (fnmatch($url, $current_url)) {
2395
  return false;
2396
  }
2397
  }
@@ -2410,16 +2375,15 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2410
 
2411
  // returns true if logged in user meet CMP roles filter
2412
  // since 2.2
2413
- public function cmp_roles_filter()
2414
- {
2415
- $roles = json_decode(get_option('niteoCS_roles', '[]'), true);
2416
  // push WP administrator to roles array, since it is default
2417
- array_push($roles, 'administrator');
2418
 
2419
  $current_user = wp_get_current_user();
2420
 
2421
- foreach ($current_user->roles as $role) {
2422
- if (in_array($role, $roles)) {
2423
  return true;
2424
  }
2425
  };
@@ -2428,30 +2392,29 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2428
  }
2429
 
2430
 
2431
- public function add_action_links($links)
2432
- {
2433
- $settings = array(
2434
- '<a href="' . admin_url('admin.php?page=cmp-settings') . '">CMP Settings</a>',
2435
- );
2436
- return array_merge($settings, $links);
2437
  }
2438
 
2439
 
2440
  // returns version of selected CMP theme
2441
- public function cmp_theme_version($theme_slug)
2442
- {
2443
 
2444
  $version = CMP_VERSION;
2445
 
2446
  // if premium theme style.css exists get its version
2447
- if (in_array($theme_slug, $this->cmp_premium_themes_installed())) {
2448
- if (file_exists(CMP_PREMIUM_THEMES_DIR . $theme_slug . '/style.css')) {
2449
- $version = get_file_data(CMP_PREMIUM_THEMES_DIR . $theme_slug . '/style.css', array('Version'), '');
2450
  }
2451
- }
 
2452
 
2453
  // if we have local version of theme and not in updating theme
2454
- if (is_array($version)) {
2455
  $version = $version[0];
2456
  }
2457
 
@@ -2465,15 +2428,14 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2465
  * @access public
2466
  * @return Object
2467
  */
2468
- public function cmp_mailchimp_list_ajax($apikey)
2469
- {
2470
 
2471
  // check for ajax
2472
- if (isset($_POST['params'])) {
2473
  // verify nonce
2474
- check_ajax_referer('cmp-coming-soon-ajax-secret', 'security');
2475
  // verify user rights
2476
- if (!current_user_can('publish_pages')) {
2477
  die('Sorry, but this request is invalid');
2478
  }
2479
 
@@ -2481,49 +2443,51 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2481
  $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
2482
 
2483
  // check params
2484
- if (!empty($_POST['params'])) {
2485
  $params = $_POST['params'];
2486
  }
2487
 
2488
  $api_key = $params['apikey'];
2489
 
2490
- $dc = substr($api_key, strpos($api_key, '-') + 1); // datacenter, it is the part of your api key - us5, us8 etc
2491
 
2492
  $args = array(
2493
- 'headers' => array(
2494
- 'Authorization' => 'Basic ' . base64_encode('user:' . $api_key)
2495
  )
2496
  );
2497
 
2498
 
2499
  // retrieve response from mailchimp
2500
- $response = wp_remote_get('https://' . $dc . '.api.mailchimp.com/3.0/lists/', $args);
2501
-
2502
  // if we have it, create new array with lists id and name, else push error messages into array
2503
- if (!is_wp_error($response)) {
2504
  $lists_array = array();
2505
 
2506
- $body = json_decode($response['body'], true);
2507
 
2508
- if ($response['response']['code'] == 200) {
2509
  $lists_array['response'] = 200;
2510
  $i = 0;
2511
- foreach ($body['lists'] as $list) {
2512
  $lists_array['lists'][$i]['id'] = $list['id'];
2513
  $lists_array['lists'][$i]['name'] = $list['name'];
2514
  $i++;
2515
  }
 
2516
  } else {
2517
  $lists_array['response'] = $response['response']['code'];
2518
  $lists_array['message'] = $body['title'] . ': ' . $body['detail'];
2519
  }
 
2520
  } else {
2521
  $lists_array['response'] = '500';
2522
  $lists_array['message'] = $response->get_error_message();
2523
  }
2524
 
2525
  // json encode response
2526
- $lists_json = json_encode($lists_array);
2527
 
2528
  // save it
2529
  update_option('niteoCS_mailchimp_lists', $lists_json);
@@ -2534,7 +2498,9 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2534
  // echo ajax result
2535
  echo $lists_json;
2536
  wp_die();
2537
- }
 
 
2538
  }
2539
 
2540
  /**
@@ -2544,124 +2510,125 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2544
  * @access public
2545
  * @return string
2546
  */
2547
- public function cmp_get_background_img_for_seo()
2548
- {
2549
-
2550
  $themeslug = $this->cmp_selectedTheme();
2551
  $default_img = '';
2552
 
2553
  $background_type = get_option('niteoCS_banner', '2');
2554
 
2555
- if (file_exists($this->cmp_theme_dir($this->cmp_selectedTheme()) . $this->cmp_selectedTheme() . '/img/' . $this->cmp_selectedTheme() . '_banner_large.jpg')) {
2556
- $default_img = $this->cmp_themeURL($this->cmp_selectedTheme()) . $this->cmp_selectedTheme() . '/img/' . $this->cmp_selectedTheme() . '_banner_large.jpg';
2557
- } elseif (file_exists($this->cmp_theme_dir($this->cmp_selectedTheme()) . $this->cmp_selectedTheme() . '/img/' . $this->cmp_selectedTheme() . '_banner_large.png')) {
2558
- $default_img = $this->cmp_themeURL($this->cmp_selectedTheme()) . $this->cmp_selectedTheme() . '/img/' . $this->cmp_selectedTheme() . '_banner_large.png';
2559
  }
2560
 
2561
- switch ($background_type) {
2562
- // custom img
2563
  case '0':
2564
- $banner_id = get_option('niteoCS_banner_id');
2565
-
2566
- if ($banner_id != '') {
2567
- $banner_ids = explode(',', $banner_id);
2568
- $image_url = wp_get_attachment_image_src($banner_ids[0], 'large');
2569
-
2570
- if (isset($image_url[0])) {
2571
- $image_url = $image_url[0];
2572
- }
2573
- } else {
2574
- // send default image
2575
- $image_url = $default_img;
2576
- }
2577
-
2578
- break;
2579
- // unsplash
2580
- case '1':
2581
- $unplash_feed = get_option('niteoCS_unsplash_feed', '3');
2582
-
2583
- switch ($unplash_feed) {
2584
- // specific photo from id
2585
- case '0':
2586
- $params = array('feed' => '0', 'url' => get_option('niteoCS_unsplash_0', ''));
2587
- $unsplash = $this->niteo_unsplash($params);
2588
- break;
2589
-
2590
- // random from user
2591
- case '1':
2592
- $params = array('feed' => '1', 'custom_str' => get_option('niteoCS_unsplash_1', ''));
2593
- $unsplash = $this->niteo_unsplash($params);
2594
- break;
2595
-
2596
- // random from collection
2597
- case '2':
2598
- $params = array('feed' => '2', 'url' => get_option('niteoCS_unsplash_2', ''));
2599
- $unsplash = $this->niteo_unsplash($params);
2600
- break;
2601
-
2602
- // random photo
2603
- case '3':
2604
- $params = array('feed' => '3', 'url' => get_option('niteoCS_unsplash_3', ''), 'feat' => get_option('niteoCS_unsplash_feat', '0'));
2605
- $unsplash = $this->niteo_unsplash($params);
2606
- break;
2607
- default:
2608
- break;
2609
- }
2610
-
2611
- // get raw url from response
2612
- if (isset($unsplash['response']) && $unsplash['response'] == '200') {
2613
- $body = json_decode($unsplash['body'], true);
2614
-
2615
- if (isset($body[0])) {
2616
- foreach ($body as $item) {
2617
- $unsplash_url = $item['urls']['raw'];
2618
- }
2619
- } else {
2620
- $unsplash_url = $body['urls']['raw'];
2621
- }
2622
-
2623
- $image_url = $unsplash_url . '?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&fit=crop&w=1200&h=630';
2624
- }
2625
-
2626
- break;
2627
- // default image
2628
- case '2':
2629
- $image_url = $default_img;
2630
- break;
2631
-
2632
- case '3':
2633
- // Pattern
2634
- $niteoCS_banner_pattern = get_option('niteoCS_banner_pattern', 'sakura');
2635
-
2636
- if ($niteoCS_banner_pattern != 'custom') {
2637
- $image_url = CMP_PLUGIN_URL . 'img/patterns/' . esc_attr($niteoCS_banner_pattern) . '.png';
2638
- } else {
2639
- $image_url = get_option('niteoCS_banner_pattern_custom');
2640
- $image_url = wp_get_attachment_image_src($image_url, 'large');
2641
- if (isset($image_url[0])) {
2642
- $image_url = $image_url[0];
2643
- }
2644
- }
2645
-
2646
- break;
2647
-
2648
- case '5':
2649
- $image_url = wp_get_attachment_image_src(get_option('niteoCS_video_thumb'), 'large');
2650
-
2651
- if (!empty($image_url)) {
2652
- $image_url = $image_url[0];
2653
- }
2654
-
2655
- break;
2656
-
2657
- case '6':
2658
- case '4':
2659
- default:
2660
- $image_url = '';
2661
- break;
2662
- }
2663
-
2664
- return $image_url;
 
 
2665
  }
2666
 
2667
 
@@ -2672,76 +2639,75 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2672
  * @access public
2673
  * @return string
2674
  */
2675
- public function cmp_purge_cache()
2676
- {
2677
 
2678
  // WP cache
2679
  wp_cache_flush();
2680
 
2681
  // W3 Total Cache
2682
- if (function_exists('w3tc_flush_all')) {
2683
  w3tc_flush_all();
2684
  }
2685
 
2686
- // wp super cache
2687
- if (function_exists('wp_cache_clear_cache')) {
2688
  wp_cache_clear_cache();
2689
- }
2690
 
2691
  // Clear Cachify Cache
2692
- if (has_action('cachify_flush_cache')) {
2693
  do_action('cachify_flush_cache');
2694
  }
2695
-
2696
- // endurance cache
2697
- if (class_exists('Endurance_Page_Cache') && method_exists('Endurance_Page_Cache', 'purge_all')) {
2698
  $epc = new Endurance_Page_Cache;
2699
  $epc->purge_all();
2700
- }
2701
 
2702
- // SG Optimizer
2703
- if (class_exists('SG_CachePress_Supercacher') && method_exists('SG_CachePress_Supercacher', 'purge_cache')) {
2704
- SG_CachePress_Supercacher::purge_cache(true);
2705
- }
2706
 
2707
  if (class_exists('SiteGround_Optimizer\Supercacher\Supercacher')) {
2708
  SiteGround_Optimizer\Supercacher\Supercacher::purge_cache();
2709
  }
2710
 
2711
- // WP Fastest Cache
2712
- if (isset($GLOBALS['wp_fastest_cache']) && method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')) {
2713
- $GLOBALS['wp_fastest_cache']->deleteCache(true);
2714
- }
2715
 
2716
- // Swift Performance
2717
- if (is_callable(array('Swift_Performance_Cache', 'clear_all_cache'))) {
2718
  Swift_Performance_Cache::clear_all_cache();
2719
- }
2720
 
2721
- // WP Rocket
2722
- if (function_exists('rocket_clean_domain')) {
2723
- rocket_clean_domain();
2724
  }
2725
 
2726
  if (is_callable(array('Hummingbird\WP_Hummingbird', 'flush_cache'))) {
2727
  Hummingbird\WP_Hummingbird::flush_cache(true, false);
2728
- }
2729
 
2730
  // wp-optimize
2731
- if (class_exists('WP_Optimize')) {
2732
  if (!class_exists('WP_Optimize_Cache_Commands')) include_once(WPO_PLUGIN_MAIN_PATH . 'cache/class-cache-commands.php');
2733
  $cache_commands = new WP_Optimize_Cache_Commands();
2734
  $cache_commands->purge_page_cache();
2735
  }
2736
 
2737
  // Clear Litespeed cache
2738
- if (class_exists('LiteSpeed_Cache_API') && method_exists('LiteSpeed_Cache_API', 'purge_all')) {
2739
  LiteSpeed_Cache_API::purge_all();
2740
  }
2741
 
2742
  if (function_exists('rocket_clean_domain')) {
2743
  rocket_clean_domain();
2744
- }
2745
  }
2746
 
2747
  /**
@@ -2751,28 +2717,27 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2751
  * @access public
2752
  * @return boolean
2753
  */
2754
- public function cmp_user_can_admin_bar_activation()
2755
- {
2756
 
2757
  // return if Top Bar Icon is disabled
2758
- if (get_option('niteoCS_topbar_icon', '1') == '0') {
2759
  return false;
2760
  }
2761
-
2762
- require_once(ABSPATH . 'wp-admin/includes/screen.php');
2763
 
2764
  // get defined roles for admin topbar access
2765
- $roles_topbar = json_decode(get_option('niteoCS_roles_topbar', '[]'), true);
2766
 
2767
  // push WP administrator to roles array, since it is default
2768
- array_push($roles_topbar, 'administrator');
2769
 
2770
  // get current user
2771
  $current_user = wp_get_current_user();
2772
 
2773
  // if current user can access topbar, return true
2774
- foreach ($current_user->roles as $role) {
2775
- if (in_array($role, $roles_topbar)) {
2776
  return true;
2777
  }
2778
  }
@@ -2787,8 +2752,7 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2787
  * @access public
2788
  * @return array
2789
  */
2790
- public function cmp_get_post_detail()
2791
- {
2792
  $id = isset($_POST['id']) ? esc_attr($_POST['id']) : '';
2793
  $size = $this->isMobile ? 'large' : 'large';
2794
 
@@ -2800,18 +2764,19 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2800
  'url' => '',
2801
  );
2802
 
2803
- if (get_post_status($id) === 'publish' && !post_password_required($id)) {
2804
 
2805
  $post = array(
2806
- 'img' => get_the_post_thumbnail($id, $size),
2807
- 'date' => get_the_date('F j, Y', $id),
2808
- 'title' => get_the_title($id),
2809
- 'body' => apply_filters('the_content', get_post_field('post_content', $id)),
2810
- 'url' => get_the_permalink($id),
2811
  );
2812
  }
2813
 
2814
- wp_send_json($post);
 
2815
  }
2816
 
2817
  /**
@@ -2821,11 +2786,10 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2821
  * @access public
2822
  * @return void
2823
  */
2824
- function cmp_ajax_dismiss_activation_notice()
2825
- {
2826
- check_ajax_referer('cmp-coming-soon-maintenance-nonce', 'nonce');
2827
  // user has dismissed the welcome notice
2828
- update_option('niteoCS_activation_notice', true);
2829
  wp_die();
2830
  exit;
2831
  }
@@ -2837,54 +2801,56 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2837
  * @access public
2838
  * @return string
2839
  */
2840
- public function cmp_ajax_upload_font()
2841
- {
2842
  // verify nonce
2843
- check_ajax_referer('cmp-coming-soon-ajax-secret', 'security');
2844
 
2845
  // verify user rights
2846
- if (!current_user_can('publish_pages')) {
2847
  die('Sorry, but this request is invalid');
2848
  }
 
2849
 
 
2850
 
2851
- if (isset($_POST['payload'])) {
2852
-
2853
- $payload = json_decode(stripslashes($_POST['payload']), true);
2854
  $action = $payload['action'];
2855
 
2856
- if ($action === 'upload_font') {
2857
-
2858
  $new_fonts = $payload['files'];
2859
 
2860
  // delete_option('niteoCS_custom_fonts');
2861
 
2862
- if (get_option('niteoCS_custom_fonts')) {
2863
 
2864
- $old_fonts = json_decode(get_option('niteoCS_custom_fonts'), true);
2865
 
2866
  $i = 0;
2867
 
2868
- foreach ($old_fonts as $old_font) {
 
 
 
2869
 
2870
- foreach ($new_fonts as $new_font) {
2871
- if ($old_font['id'] === $new_font['id']) {
2872
 
2873
- $old_fonts[$i]['urls'] = (is_array($old_font['urls'])) ? array_unique(array_merge($old_font['urls'], $new_font['urls'])) : $new_font['urls'];
2874
- $old_fonts[$i]['ids'] = (is_array($old_font['ids'])) ? array_unique(array_merge($old_font['ids'], $new_font['ids'])) : $new_font['ids'];
2875
- } else if (!$this->niteo_in_array_r($new_font['id'], $old_fonts)) {
2876
  array_push($old_fonts, $new_font);
2877
  }
2878
  }
2879
 
2880
- $i++;
2881
  }
2882
 
2883
  $new_fonts = $old_fonts;
2884
- }
 
 
2885
 
2886
- update_option('niteoCS_custom_fonts', json_encode($new_fonts));
2887
  }
 
2888
  }
2889
 
2890
  // echo confirmation
@@ -2899,34 +2865,33 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2899
  * @access public
2900
  * @return string
2901
  */
2902
- public function cmp_export_settings()
2903
- {
2904
-
2905
  $options = array();
2906
  // add default cmp identifier
2907
  $options[0] = 'CMP_EXPORT';
2908
 
2909
  global $wpdb;
2910
- $saved_options = $wpdb->get_results("SELECT * FROM $wpdb->options WHERE option_name LIKE 'niteoCS_%'", OBJECT);
2911
  $i = 1;
2912
 
2913
  foreach ($saved_options as $option) {
2914
 
2915
  $option_name = $option->option_name;
2916
- $option_value = get_option($option_name);
2917
 
2918
- $img_settings = array('niteoCS_banner_id', 'niteoCS_logo_id', 'niteoCS_seo_img_id', 'niteoCS_favicon_id', 'niteoCS_subs_img_id', 'niteoCS_subs_img_popup_id');
2919
 
2920
- if (in_array($option_name, $img_settings) && $option_value && $option_value != '') {
2921
  $option_value = $this->cmp_get_img_urls($option_value);
2922
  }
2923
 
2924
- if ($option_name === 'niteoCS_posts') {
2925
  $option_value = '[]';
2926
  }
2927
 
2928
 
2929
- $options[$i] = array($option_name => $option_value);
2930
  $i++;
2931
  }
2932
 
@@ -2941,8 +2906,7 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2941
  * @return string
2942
  */
2943
 
2944
- public function cmp_get_img_urls($ids)
2945
- {
2946
 
2947
  $id_array = explode(',', $ids);
2948
  $i = 1;
@@ -2950,19 +2914,19 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2950
 
2951
  foreach ($id_array as $id) {
2952
  $sep = ($i < count($id_array)) ? ',' : '';
2953
- $image_url = wp_get_attachment_image_src($id, 'full');
2954
 
2955
- if (isset($image_url[0])) {
2956
  $image_url = $image_url[0];
2957
  }
2958
 
2959
  $urls .= $image_url . $sep;
2960
-
2961
  $i++;
2962
- }
2963
-
2964
  return $urls;
2965
- }
2966
 
2967
  /**
2968
  * export settings to JSON via AJAX
@@ -2971,13 +2935,12 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2971
  * @access public
2972
  * @return string
2973
  */
2974
- public function cmp_ajax_export_settings()
2975
- {
2976
  // verify nonce
2977
- check_ajax_referer('cmp-coming-soon-ajax-secret', 'security');
2978
 
2979
  // verify user rights
2980
- if (!current_user_can('publish_pages')) {
2981
  die('Sorry, but this request is invalid');
2982
  }
2983
 
@@ -2986,15 +2949,15 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
2986
  $replace = array('https://', 'http://');
2987
  $home_url = str_replace($replace, '', get_home_url());
2988
 
2989
- if (!empty($settings)) {
2990
- $filename = $home_url . '-cmp-settings-' . date('Y-m-d') . '.json';
2991
 
2992
  header('Content-Type: application/json');
2993
  header('Content-Disposition: attachment;filename=' . $filename);
2994
 
2995
  $fp = fopen('php://output', 'w');
2996
 
2997
- fwrite($fp, $settings);
2998
  fclose($fp);
2999
  }
3000
  die();
@@ -3007,56 +2970,55 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
3007
  * @access public
3008
  * @return string
3009
  */
3010
- public function cmp_ajax_import_settings()
3011
- {
3012
 
3013
- check_ajax_referer('cmp-coming-soon-ajax-secret', 'security');
3014
 
3015
  // verify user rights
3016
- if (!current_user_can('publish_pages')) {
3017
  die('Sorry, but this request is invalid');
3018
  }
3019
 
3020
- $settings = json_decode(stripslashes($_POST['json']), true);
3021
 
3022
  $result = array(
3023
  'result' => 'success',
3024
  'message' => __('All done!', 'cmp-coming-soon-maintenance')
3025
  );
3026
 
3027
- if (json_last_error() == JSON_ERROR_NONE) {
3028
- if ($settings[0] === 'CMP_EXPORT') {
3029
  // remove first value used for JSON CMP Settings check
3030
  unset($settings[0]);
3031
 
3032
  // delete all current CMP Settings
3033
  global $wpdb;
3034
- $saved_options = $wpdb->get_results("SELECT * FROM $wpdb->options WHERE option_name LIKE 'niteoCS_%'", OBJECT);
3035
  foreach ($saved_options as $option) {
3036
  delete_option($option->option_name);
3037
  }
3038
-
3039
  // import cmp settings from JSON structure
3040
- foreach ($settings as $setting) {
3041
-
3042
- $img_settings = array('niteoCS_banner_id', 'niteoCS_logo_id', 'niteoCS_seo_img_id', 'niteoCS_favicon_id', 'niteoCS_subs_img_id', 'niteoCS_subs_img_popup_id');
3043
-
3044
  $name = key($setting);
3045
  $value = $setting[$name];
3046
-
3047
- if (in_array($name, $img_settings)) {
3048
-
3049
  $urls = explode(',', $value);
3050
-
3051
  if (is_array($urls)) {
3052
- foreach ($urls as $url) {
3053
  $value = $this->cmp_insert_attachment_from_url($url);
3054
  $value .= ',' . $value;
3055
  }
3056
  }
3057
  }
3058
-
3059
- update_option($name, $value);
3060
  }
3061
  } else {
3062
  $result = array(
@@ -3069,10 +3031,12 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
3069
  'result' => 'error',
3070
  'message' => __('Please insert valid JSON file and try again.', 'cmp-coming-soon-maintenance')
3071
  );
 
3072
  }
3073
 
3074
  echo json_encode($result);
3075
  wp_die();
 
3076
  }
3077
 
3078
  /**
@@ -3083,31 +3047,30 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
3083
  * @param Int $parent_post_id
3084
  * @return Int Attachment ID
3085
  */
3086
- private function cmp_insert_attachment_from_url($url, $parent_post_id = null)
3087
- {
3088
 
3089
- if (!class_exists('WP_Http')) {
3090
- include_once(ABSPATH . WPINC . '/class-http.php');
3091
  }
3092
-
3093
  $http = new WP_Http();
3094
 
3095
- $response = $http->request($url);
3096
 
3097
- if (is_wp_error($response) || $response['response']['code'] != 200) {
3098
  return false;
3099
  }
3100
 
3101
- $upload = wp_upload_bits(basename($url), null, $response['body']);
3102
 
3103
- if (!empty($upload['error'])) {
3104
  return false;
3105
  }
3106
 
3107
  $file_path = $upload['file'];
3108
- $file_name = basename($file_path);
3109
- $file_type = wp_check_filetype($file_name, null);
3110
- $attachment_title = sanitize_file_name(pathinfo($file_name, PATHINFO_FILENAME));
3111
  $wp_upload_dir = wp_upload_dir();
3112
  $post_info = array(
3113
  'guid' => $wp_upload_dir['url'] . '/' . $file_name,
@@ -3118,13 +3081,13 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
3118
  );
3119
 
3120
  // Create the attachment
3121
- $attach_id = wp_insert_attachment($post_info, $file_path, $parent_post_id);
3122
  // Include image.php
3123
- require_once(ABSPATH . 'wp-admin/includes/image.php');
3124
  // Define attachment metadata
3125
- $attach_data = wp_generate_attachment_metadata($attach_id, $file_path);
3126
  // Assign metadata to attachment
3127
- wp_update_attachment_metadata($attach_id, $attach_data);
3128
 
3129
  return $attach_id;
3130
  }
@@ -3135,30 +3098,29 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
3135
  *
3136
  * @param String $message
3137
  */
3138
- private function cmp_send_notification($status)
3139
- {
3140
  // send notification email to admin, if enabled
3141
- if (get_option('niteoCS_mode_change_notification', '0') == '1') {
3142
- switch ($this->cmp_mode()) {
3143
  case '1':
3144
- $mode = __('Maintenance', 'cmp-coming-soon-maintenance');
3145
  break;
3146
  case '2':
3147
- $mode = __('Coming Soon', 'cmp-coming-soon-maintenance');
3148
  break;
3149
  case '3':
3150
- $mode = __('Redirect', 'cmp-coming-soon-maintenance');
3151
  break;
3152
  default:
3153
  break;
3154
  }
3155
  $current_user = wp_get_current_user();
3156
- $email = get_option('niteoCS_mode_change_email_address', get_option('admin_email'));
3157
  $subject = $mode . ' mode on your website - ' . get_site_url() . ' - was just turned ' . $status . ' by ' . $current_user->user_login;
3158
  $body = 'This is auto generated message from CMP - Coming Soon & Maintenance WordPress Plugin. You can disable these messages under CMP Advanced Settings > Email Notifications.';
3159
  $headers = array('Content-Type: text/plain; charset=UTF-8');
3160
  // send email
3161
- wp_mail($email, $subject, $body, $headers);
3162
  }
3163
 
3164
  return;
@@ -3169,38 +3131,37 @@ if (!class_exists('CMP_Coming_Soon_and_Maintenance')) :
3169
  *
3170
  * @since 3.7.3
3171
  */
3172
- public function cmp_display_admin_notice($type, $dismisable, $message)
3173
- {
3174
 
3175
- echo '<div class="notice notice-' . $type . ' ' . $dismisable . '"><p class="message">' . $message . '</p></div>';
3176
  }
3177
 
3178
  /**
3179
  * Disable REST API if required
3180
  */
3181
- function restrict_rest_api($result)
3182
- {
3183
- if (true === $result || is_wp_error($result)) {
3184
  return $result;
3185
  }
3186
-
3187
  // No authentication has been performed yet.
3188
  // Return an error if user is not logged in.
3189
- if (!is_user_logged_in()) {
3190
  return new WP_Error(
3191
  'rest_disabled',
3192
- __('JSON API is disabled by CMP – Coming Soon & Maintenance Plugin.'),
3193
- array('status' => 401)
3194
  );
3195
  }
 
3196
  }
3197
 
3198
- function jetpack_stats_compatibility()
3199
- {
3200
- if (function_exists('stats_footer')) {
3201
- add_action('cmp_footer', 'stats_footer', 101);
3202
  }
3203
  }
 
3204
  }
3205
 
3206
 
@@ -3210,18 +3171,19 @@ endif;
3210
  * @since 2.8.1
3211
  * @return object|CMP_Coming_Soon_and_Maintenance instance.
3212
  */
3213
- function cmp_coming_soon_and_maintenance()
3214
- {
3215
  return CMP_Coming_Soon_and_Maintenance::instance();
3216
  }
3217
 
3218
  // Get the things running
3219
  cmp_coming_soon_and_maintenance();
3220
 
3221
- register_uninstall_hook(__FILE__, 'cmp_plugin_delete');
3222
 
3223
  // And here goes the uninstallation function:
3224
- function cmp_plugin_delete()
3225
- {
3226
- delete_option('niteoCS_archive');
3227
  }
 
 
 
3
  Plugin Name: CMP - Coming Soon & Maintenance Plugin
4
  Plugin URI: https://wordpress.org/plugins/cmp-coming-soon-maintenance/
5
  Description: Display customizable landing page for Coming Soon, Maintenance & Under Construction page.
6
+ Version: 4.1.4
7
  Author: NiteoThemes
8
  Author URI: https://www.niteothemes.com
9
  Text Domain: cmp-coming-soon-maintenance
14
 
15
 
16
  // Exit if accessed directly.
17
+ if ( ! defined( 'ABSPATH' ) ) {
18
  exit;
19
  }
20
 
21
+ if ( ! class_exists( 'CMP_Coming_Soon_and_Maintenance' ) ) :
22
 
23
  /**
24
  * Main CMP Coming Soon and Maintenance class.
25
  *
26
  * @since 2.8
27
+ */
28
+ class CMP_Coming_Soon_and_Maintenance {
 
29
 
30
  /**
31
  * CMP_Coming_Soon_and_Maintenance The one true CMP_Coming_Soon_and_Maintenance
49
  * @uses CMP_Coming_Soon_and_Maintenance::load_textdomain() load the language files.
50
  * @return object|CMP_Coming_Soon_and_Maintenance
51
  */
52
+ public static function instance() {
53
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof CMP_Coming_Soon_and_Maintenance ) ) {
 
54
  self::$instance = new CMP_Coming_Soon_and_Maintenance();
55
  self::$instance->constants();
56
  self::$instance->init();
61
  }
62
 
63
  // define constants
64
+ private function constants() {
65
+ $this->define( 'CMP_VERSION', '4.1.4' );
66
+ $this->define( 'CMP_DEBUG', FALSE );
67
+ $this->define( 'CMP_AUTHOR', 'NiteoThemes' );
68
+ $this->define( 'CMP_AUTHOR_HOMEPAGE', 'https://niteothemes.com' );
69
+ $this->define( 'CMP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
70
+ $this->define( 'CMP_PREMIUM_THEMES_DIR', plugin_dir_path( __DIR__ ) . 'cmp-premium-themes/' );
71
+ $this->define( 'CMP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
72
+ $this->define( 'CMP_UPDATE_URL', 'https://niteothemes.com/updates/' );
 
73
  CMP_DEBUG === TRUE
74
+ ? $this->define( 'CMP_LICENSE_SERVER_URL', 'https://niteothemes.com/dev2/' )
75
+ : $this->define( 'CMP_LICENSE_SERVER_URL', 'https://niteothemes.com/' );
76
  }
77
 
78
  /**
79
  * Inits and hooks
80
  */
81
+ public function init() {
82
+ do_action( 'cmp_plugin_loaded');
83
+ add_action( 'init', array( $this, 'load_textdomain' ));
84
+ add_action( 'plugins_loaded', array( $this, 'cmp_update_process' ), 0 );
85
+ add_action( 'template_redirect', array( $this, 'cmp_displayPage' ), 1 );
86
+ add_action( 'admin_init', array( $this, 'cmp_adminInit' ) ) ;
87
+ add_action( 'admin_menu', array( $this, 'cmp_adminMenu' ) );
88
+ add_action( 'admin_notices', array( $this, 'cmp_admin_notice' ) );
89
+ add_action( 'wp_before_admin_bar_render', array( $this, 'cmp_admin_bar' ) );
90
+ add_action( 'admin_enqueue_scripts', array( $this,'cmp_add_topbar_scripts' ) );
91
+ add_action( 'admin_enqueue_scripts', array( $this,'cmp_add_admin_style' ) );
92
+ add_action( 'wp_enqueue_scripts', array( $this,'cmp_add_topbar_scripts' ) );
93
+ add_action( 'wp_ajax_cmp_get_post_detail', array( $this, 'cmp_get_post_detail' ) );
94
+ add_action( 'wp_ajax_nopriv_cmp_get_post_detail', array( $this, 'cmp_get_post_detail' ) );
95
+ add_action( 'wp_ajax_cmp_check_update', array( $this, 'cmp_check_update' ) );
96
+ add_action( 'wp_ajax_cmp_ajax_dismiss_activation_notice', array( $this, 'cmp_ajax_dismiss_activation_notice' ) );
97
+ add_action( 'wp_ajax_niteo_themeinfo', array( $this, 'niteo_themeinfo' ) );
98
+ add_action( 'wp_ajax_niteo_unsplash', array( $this, 'niteo_unsplash' ) );
99
+ add_action( 'wp_ajax_niteo_export_csv', array( $this, 'niteo_export_csv' ) );
100
+ add_action( 'wp_ajax_cmp_theme_update_install', array( $this, 'cmp_theme_update_install' ) );
101
+ add_action( 'wp_ajax_cmp_toggle_activation', array( $this, 'cmp_ajax_toggle_activation') );
102
+ add_action( 'wp_ajax_nopriv_niteo_subscribe', array( $this, 'niteo_subscribe' ) );
103
+ add_action( 'wp_ajax_niteo_subscribe', array( $this, 'niteo_subscribe' ) );
104
+ add_action( 'wp_ajax_cmp_mailchimp_list_ajax', array( $this, 'cmp_mailchimp_list_ajax' ) );
105
+ add_action( 'wp_ajax_cmp_ajax_upload_font', array( $this, 'cmp_ajax_upload_font' ) );
106
+ add_action( 'wp_ajax_cmp_ajax_export_settings', array( $this, 'cmp_ajax_export_settings' ) );
107
+ add_action( 'wp_ajax_cmp_ajax_import_settings', array( $this, 'cmp_ajax_import_settings' ) );
108
+ add_action( 'wp_ajax_nopriv_cmp_disable_comingsoon_ajax', array( $this, 'cmp_disable_comingsoon_ajax' ) );
109
+ add_action( 'admin_head', array( $this, 'cmp_admin_css') );
110
+ add_action( 'after_setup_theme', array( $this, 'cmp_create_translation'), 10 );
111
+ add_action( 'after_setup_theme', array( $this, 'cmp_register_wpml_strings'), 20 );
112
+ add_filter( 'upload_mimes', array( $this, 'cmp_allow_font_mimes' ));
113
+ add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this,'add_action_links' ) );
114
+
115
+ register_activation_hook( __FILE__, array( $this, 'cmp_activate' ) );
116
+ register_deactivation_hook( __FILE__, array( $this, 'cmp_deactivate' ) );
117
+
118
+ require_once( dirname( __FILE__) . '/inc/class-cmp-render_html.php' );
119
+
120
+ if ( $this->cmp_active() === '1' && get_option('niteoCS_rest_api_status', '1') !== '1' ) {
121
+ add_filter( 'rest_authentication_errors', array( $this, 'restrict_rest_api'), 0, 1 );
122
+ }
123
+
124
+ add_action( 'init', array( $this, 'jetpack_stats_compatibility' ) );
 
125
  }
126
 
127
 
131
  * @param string|string $name Name of the definition.
132
  * @param string|bool $value Default value.
133
  */
134
+ private function define( $name, $value ) {
135
+ if ( ! defined( $name ) ) {
136
+ define( $name, $value );
 
137
  }
138
  }
139
 
140
  /**
141
  * Admin Init - register and enqueue scripts nad styles
142
  */
143
+ public function cmp_adminInit() {
 
144
  // include feedback class
145
+ require_once( 'inc/class-cmp-feedback.php' );
146
 
147
  // ini render-settings class
148
  require_once('inc/class-cmp-render_settings.php');
149
 
150
  $this->render_settings = new cmp_render_settings();
151
 
152
+ if ( current_user_can('administrator') ) {
153
 
154
+ wp_register_style( 'cmp-style', plugins_url('/css/cmp-settings-style'.CMP_ASSET_SUFFIX.'.css', __FILE__),'', CMP_VERSION );
155
+ wp_register_style( 'cmp-font-awesome', plugins_url('/css/font-awesome.min.css', __FILE__) );
156
+ wp_register_style( 'countdown_flatpicker_css', plugins_url('/css/flatpickr.min.css', __FILE__) );
157
+ wp_register_style( 'animate-css', plugins_url('/css/animate'.CMP_ASSET_SUFFIX.'.css', __FILE__) );
158
+ wp_register_script( 'webfont', 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js', array(), '1.6.26', true );
159
+ wp_register_script( 'cmp-select2-js', plugins_url('/js/external/select2.min.js', __FILE__) );
160
+ wp_register_script( 'cmp-typography', plugins_url('/js/typography'.CMP_ASSET_SUFFIX.'.js', __FILE__), array('cmp-select2-js' ), CMP_VERSION );
161
+ wp_register_script( 'cmp_settings_js', plugins_url('/js/settings'.CMP_ASSET_SUFFIX.'.js', __FILE__), array('webfont', 'cmp-select2-js'), CMP_VERSION );
162
+ wp_register_script( 'cmp_advanced_js', plugins_url('/js/cmp-advanced'.CMP_ASSET_SUFFIX.'.js', __FILE__), array(), CMP_VERSION );
163
+ wp_register_script( 'cmp-editor-translation', plugins_url('/js/cmp-editor-translation'.CMP_ASSET_SUFFIX.'.js', __FILE__), array(), CMP_VERSION, true );
164
+ wp_register_script( 'countdown_flatpicker_js', plugins_url('/js/external/flatpickr.min.js', __FILE__) );
165
+
166
  }
167
+
168
  }
169
 
170
  /**
172
  *
173
  * @since 2.8.7
174
  */
175
+ public function cmp_update_process() {
 
176
  require_once('inc/cmp-update-process.php');
177
  }
178
 
182
  * @since 3.7.5
183
  */
184
 
185
+ public function cmp_create_translation() {
 
186
  // Populate translation list, if not yet created
187
+ if ( !get_option('niteoCS_translation') ) {
188
  $translation = array(
189
+ 0 => array('id' => 0, 'name' => 'Counter Seconds Label', 'string' => __('Seconds', 'cmp-coming-soon-maintenance'), 'translation' => __('Seconds', 'cmp-coming-soon-maintenance') ),
190
+ 1 => array('id' => 1, 'name' => 'Counter Minutes Label', 'string' => __('Minutes', 'cmp-coming-soon-maintenance'), 'translation' => __('Minutes', 'cmp-coming-soon-maintenance') ),
191
+ 2 => array('id' => 2, 'name' => 'Counter Hours Label', 'string' => __('Hours', 'cmp-coming-soon-maintenance'), 'translation' => __('Hours', 'cmp-coming-soon-maintenance') ),
192
+ 3 => array('id' => 3, 'name' => 'Counter Days Label', 'string' => __('Days', 'cmp-coming-soon-maintenance'), 'translation' => __('Days', 'cmp-coming-soon-maintenance') ),
193
+ 4 => array('id' => 4, 'name' => 'Subscribe Form Placeholder', 'string' => __('Insert your email address.', 'cmp-coming-soon-maintenance'), 'translation' => __('Insert your email address.', 'cmp-coming-soon-maintenance') ),
194
+ 5 => array('id' => 5, 'name' => 'Subscribe Response Duplicate', 'string' => __('Oops! This email address is already on our list.', 'cmp-coming-soon-maintenance'), 'translation' => __('Oops! This email address is already on our list.', 'cmp-coming-soon-maintenance') ),
195
+ 6 => array('id' => 6, 'name' => 'Subscribe Response Not Valid', 'string' => __('Oops! We need a valid email address. Please try again.', 'cmp-coming-soon-maintenance'), 'translation' => __('Oops! We need a valid email address. Please try again.', 'cmp-coming-soon-maintenance') ),
196
+ 7 => array('id' => 7, 'name' => 'Subscribe Response Thanks', 'string' => __('Thank you! Your sign up request was successful.', 'cmp-coming-soon-maintenance'), 'translation' => __('Thank you! Your sign up request was successful.', 'cmp-coming-soon-maintenance') ),
197
+ 8 => array('id' => 8, 'name' => 'Subscribe Submit Button Label', 'string' => __('Submit', 'cmp-coming-soon-maintenance'), 'translation' => __('Submit', 'cmp-coming-soon-maintenance') ),
198
+ 9 => array('id' => 9, 'name' => 'CMP Eclipse Theme: Scroll Text', 'string' => __('Scroll', 'cmp-coming-soon-maintenance'), 'translation' => __('Scroll', 'cmp-coming-soon-maintenance') ),
199
+ 10 => array('id' => 10, 'name' => 'Subscribe Form First Name Placeholder', 'string' => __('First Name', 'cmp-coming-soon-maintenance'), 'translation' => __('First Name', 'cmp-coming-soon-maintenance') ),
200
+ 11 => array('id' => 11, 'name' => 'Subscribe Form Last Name Placeholder', 'string' => __('Last Name', 'cmp-coming-soon-maintenance'), 'translation' => __('Last Name', 'cmp-coming-soon-maintenance') ),
201
+ 12 => array('id' => 12, 'name' => 'Subscribe', 'string' => __('Subscribe', 'cmp-coming-soon-maintenance'), 'translation' => __('Subscribe', 'cmp-coming-soon-maintenance') ),
202
+ 13 => array('id' => 13, 'name' => 'Subscribe GDPR Checkbox', 'string' => __('You must agree with our Terms and Conditions.', 'cmp-coming-soon-maintenance'), 'translation' => __('You must agree with our Terms and Conditions.', 'cmp-coming-soon-maintenance') ),
203
+ 14 => array('id' => 14, 'name' => 'Subscribe Missing Email', 'string' => __('Oops! Email is empty.', 'cmp-coming-soon-maintenance'), 'translation' => __('Oops! Email is empty.', 'cmp-coming-soon-maintenance') ),
204
  );
205
 
206
+ update_option('niteoCS_translation', wp_json_encode( $translation ));
207
  }
208
  }
209
 
212
  *
213
  * @since 3.7.5
214
  */
215
+ public function cmp_register_wpml_strings() {
 
216
 
217
+ if ( $this->translation_active() ) {
218
 
219
  $themeslug = $this->cmp_selectedTheme();
220
+ $translation = json_decode( get_option('niteoCS_translation'), true );
221
  $overlay_status = get_option('niteoCS_overlay_text[status]', '0');
222
 
223
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Title', stripslashes( get_option('niteoCS_body_title', 'SOMETHING IS HAPPENING!') ) );
224
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Copyright', stripslashes( get_option('niteoCS_copyright', 'Made by <a href="https://niteothemes.com">NiteoThemes</a> with love.') ) );
225
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Subscribe GDPR Message', stripslashes( get_option('niteoCS_subscribe_label', '') ) );
226
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Social Icons Title', stripslashes( get_option('niteoCS_soc_title', 'GET SOCIAL WITH US') ) );
227
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Counter Title', stripslashes( get_option('niteoCS_counter_heading', 'STAY TUNED, WE ARE LAUNCHING SOON...') ) );
228
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Extended Footer Title', stripslashes( get_option('niteoCS_contact_title', 'Quick Contacts') ) );
229
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Extended Footer Content', stripslashes( get_option('niteoCS_contact_content', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.') ) );
230
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Contact Form Title', stripslashes( get_option('niteoCS_contact_form_label', 'Get in Touch') ) );
231
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'SEO Title', stripslashes( get_option('niteoCS_title', get_bloginfo('name').' Coming soon!') ) );
232
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'SEO Description', stripslashes( get_option('niteoCS_descr', 'Just Another Coming Soon Page') ) );
233
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Subscribe Popup Form Title', stripslashes( get_option('niteoCS_subscribe_popup_title', get_option('niteoCS_subscribe_title', 'SUBSCRIBE US') ) ) );
234
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Popup Subscribe GDPR Message', stripslashes(get_option('niteoCS_subscribe_label_popup') ) );
235
+
236
+ foreach ( $translation as $translate ) {
237
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', $translate['name'], stripslashes( $translate['translation'] ) );
238
  }
239
 
240
+ if ( $overlay_status == '1' && in_array( $themeslug, $this->cmp_overlay_text_themes() ) ) {
241
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Overlay Title', stripslashes( get_option('niteoCS_overlay_text[heading]', 'NEW WEBSITE ON THE WAY!') ) );
242
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Overlay Content', stripslashes( get_option('niteoCS_overlay_text[paragraph]', '') ) );
243
+ $this->cmp_register_string( 'CMP - Coming Soon & Maintenance', 'Overlay Button Text', stripslashes( get_option('niteoCS_overlay_text[button_text]', 'Call to Action!') ) );
244
  }
245
 
246
  // register strings from themes
247
+ if ( file_exists( $this->cmp_theme_dir( $themeslug ).$themeslug.'/translation-strings.php' ) && function_exists('icl_register_string') ) {
248
+ require_once $this->cmp_theme_dir( $themeslug ).$themeslug.'/translation-strings.php';
249
  }
250
  }
251
  }
252
 
253
+ public function cmp_register_string( $group, $name, $string, $multiline = false ) {
 
254
 
255
+ if ( function_exists('pll_register_string') ) {
256
+ pll_register_string( $name, $string, $group, $multiline );
257
+
258
+ } else if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
259
+ do_action( 'wpml_register_single_string', $group, $name, $string );
260
  }
261
  }
262
 
266
  * @since 3.7.5
267
  * @return string
268
  */
269
+ public function cmp_wpml_translate_string( $translation, $name ) {
270
+
271
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
272
+ $translation = apply_filters( 'wpml_translate_single_string', $translation , 'CMP - Coming Soon & Maintenance', $name );
273
+ // WPML and Polylang compatibility
274
+ } elseif ( function_exists( 'icl_t' ) ) {
275
+ $translation = icl_t( 'CMP - Coming Soon & Maintenance', $name, $translation );
 
276
  }
277
 
278
  return $translation;
284
  * @since 3.7.5
285
  * @return string
286
  */
287
+ public function cmp_wpml_niteoCS_translation() {
288
+
289
+ $translation = json_decode( get_option('niteoCS_translation'), true );
 
290
 
291
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
292
+ foreach ( $translation as $key => $translate ) {
293
+ $translation[$key]['translation'] = apply_filters( 'wpml_translate_single_string', $translate['translation'], 'CMP - Coming Soon & Maintenance', $translate['name'] );
294
  }
295
+ // WPML and Polylang compatibility
296
+ } elseif ( function_exists( 'icl_t' ) ) {
297
+ foreach ( $translation as $key => $translate ) {
298
+ $translation[$key]['translation'] = icl_t( 'CMP - Coming Soon & Maintenance', $translate['name'], $translate['translation'] );
299
  }
300
  }
301
 
308
  * @since 3.7.5
309
  * @return string
310
  */
311
+ public function cmp_get_current_lang( $type = 'slug' ) {
 
312
  $lang = null;
313
 
314
+ if ( function_exists('pll_current_language') ) {
315
+ $lang = pll_current_language( $type );
316
+
317
+ } else if ( defined('ICL_LANGUAGE_CODE') ) {
318
  $lang = $type === 'slug' ? ICL_LANGUAGE_CODE : ICL_LANGUAGE_NAME;
319
  }
320
+
321
  return $lang;
322
  }
323
 
327
  * @since 3.7.5
328
  * @return array
329
  */
330
+ public function cmp_get_language_list() {
 
331
  $langs = array();
332
 
333
+ if ( function_exists('pll_languages_list') ) {
334
  $langs = pll_languages_list();
335
+
336
+ } else if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
337
+ $langs = apply_filters( 'wpml_active_languages', NULL, array( 'skip_missing' => 0 ) );
338
+ $langs = array_keys( $langs );
339
  }
340
 
341
  return $langs;
347
  * @since 3.7.5
348
  * @return string
349
  */
350
+ public function cmp_get_default_language() {
 
351
  $default = null;
352
 
353
+ if ( function_exists('pll_default_language') ) {
354
  $default = pll_default_language();
355
+
356
+ } else if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
357
  global $sitepress;
358
  $default = $sitepress->get_default_language();
359
  }
367
  * @since 3.7.5
368
  * @return object
369
  */
370
+ public function cmp_get_translated_id( $id ) {
371
+
372
+ if ( function_exists('pll_get_post') ) {
373
+ $id = pll_get_post( $id );
374
 
375
+ } else if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
376
+ $id = apply_filters( 'wpml_object_id', $id );
 
 
377
  }
378
 
379
  return $id;
385
  * @since 2.8.3
386
  * @return array
387
  */
388
+ public function cmp_themes_bundled() {
 
389
  return array('construct', 'countdown', 'hardwork');
390
  }
391
 
392
+ public function cmp_theme_supports( $themeslug, $supports ) {
 
393
 
394
+ if ( file_exists($this->cmp_theme_dir( $themeslug ).$themeslug.'/'.$themeslug . '-defaults.php') ) {
395
+ require $this->cmp_theme_dir( $themeslug ).$themeslug.'/'.$themeslug . '-defaults.php';
396
+
397
+ foreach ($theme_supports as $key => $value ) {
398
 
399
+ if ( $key === $supports ) {
 
 
400
  return $value;
401
  }
402
  }
411
  * @since 2.8.3
412
  * @return array
413
  */
414
+ public function cmp_font_animation_themes() {
415
+ return array( 'hardwork_premium', 'fifty', 'orbit', 'stylo', 'apollo', 'vega', 'pluto' );
 
416
  }
417
 
418
  /**
421
  * @since 2.8.5
422
  * @return array
423
  */
424
+ public function cmp_cf7_themes() {
425
+ return array( 'stylo', 'agency' );
 
426
  }
427
 
428
  /**
431
  * @since 2.8.5
432
  * @return array
433
  */
434
+ public function cmp_overlay_text_themes() {
435
+ return array( 'agency' );
 
436
  }
437
 
438
  /**
441
  * @since 3.7.3
442
  * @return array
443
  */
444
+ public function cmp_builder_themes() {
445
+ return array( 'divi', 'elementor', 'oxygen_builder' );
 
446
  }
447
 
448
  /**
451
  * @since 3.7.9
452
  * @return array
453
  */
454
+ public function translation_active() {
 
455
  return function_exists('pll_languages_list') || defined('ICL_SITEPRESS_VERSION');
456
  }
457
+
458
  /**
459
  * returns array list of premium themes => manually defined
460
  *
461
  * @return array
462
  */
463
+ public function cmp_premium_themes() {
464
+
 
465
  $premium_themes = array();
466
+ array_push( $premium_themes, array('name' => 'nova', 'url' => 'https://niteothemes.com/downloads/cmp-nova-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=nova', 'price' => '12') );
467
+ array_push( $premium_themes, array('name' => 'mercury', 'url' => 'https://niteothemes.com/downloads/cmp-mercury-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=mercury', 'price' => '10') );
468
+ array_push( $premium_themes, array('name' => 'fifty', 'url' => 'https://niteothemes.com/downloads/cmp-fifty-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=fifty', 'price' => '10') );
469
+ array_push( $premium_themes, array('name' => 'apollo', 'url' => 'https://niteothemes.com/downloads/cmp-apollo-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=apollo', 'price' => '10') );
470
+ array_push( $premium_themes, array('name' => 'loki', 'url' => 'https://niteothemes.com/downloads/cmp-loki-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=loki', 'price' => '12') );
471
+ array_push( $premium_themes, array('name' => 'orion', 'url' => 'https://niteothemes.com/downloads/cmp-orion-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=orion', 'price' => '12') );
472
+ array_push( $premium_themes, array('name' => 'vega', 'url' => 'https://niteothemes.com/downloads/cmp-vega-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=vega', 'price' => '10') );
473
+ array_push( $premium_themes, array('name' => 'mosaic', 'url' => 'https://niteothemes.com/downloads/cmp-mosaic-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=mosaic', 'price' => '10') );
474
+ array_push( $premium_themes, array('name' => 'titan', 'url' => 'https://niteothemes.com/downloads/cmp-titan-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=titan', 'price' => '12') );
475
+ array_push( $premium_themes, array('name' => 'saturn', 'url' => 'https://niteothemes.com/downloads/cmp-saturn-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=saturn', 'price' => '12') );
476
+ array_push( $premium_themes, array('name' => 'atlas', 'url' => 'https://niteothemes.com/downloads/cmp-atlas-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=atlas', 'price' => '12') );
477
+ array_push( $premium_themes, array('name' => 'scout', 'url' => 'https://niteothemes.com/downloads/cmp-scout-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=scout', 'price' => '10') );
478
+ array_push( $premium_themes, array('name' => 'libra', 'url' => 'https://niteothemes.com/downloads/cmp-libra-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=libra', 'price' => '10') );
479
+ array_push( $premium_themes, array('name' => 'delta', 'url' => 'https://niteothemes.com/downloads/cmp-delta-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=delta', 'price' => '10') );
480
+ array_push( $premium_themes, array('name' => 'headliner', 'url' => 'https://niteothemes.com/downloads/cmp-headliner-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=headliner', 'price' => '10') );
481
+ array_push( $premium_themes, array('name' => 'elementor', 'url' => 'https://niteothemes.com/downloads/cmp-elementor-addon/?utm_source=cmp&utm_medium=referral&utm_campaign=elementor', 'price' => '29') );
482
+ array_push( $premium_themes, array('name' => 'divi', 'url' => 'https://niteothemes.com/downloads/cmp-divi-addon/?utm_source=cmp&utm_medium=referral&utm_campaign=divi', 'price' => '29') );
483
+ array_push( $premium_themes, array('name' => 'timex', 'url' => 'https://niteothemes.com/downloads/cmp-timex-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=timex', 'price' => '15') );
484
+ array_push( $premium_themes, array('name' => 'thor', 'url' => 'https://niteothemes.com/downloads/cmp-thor-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=thor', 'price' => '10') );
485
+ array_push( $premium_themes, array('name' => 'hardwork_premium', 'url' => 'https://niteothemes.com/downloads/cmp-hardwork-premium/?utm_source=cmp&utm_medium=referral&utm_campaign=hardwork_premium', 'price' => '10') );
486
+ array_push( $premium_themes, array('name' => 'tempie', 'url' => 'https://niteothemes.com/downloads/cmp-tempie-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=tempie', 'price' => '10') );
487
+ array_push( $premium_themes, array('name' => 'stylo', 'url' => 'https://niteothemes.com/downloads/cmp-stylo-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=stylo', 'price' => '10') );
488
+ array_push( $premium_themes, array('name' => 'ares', 'url' => 'https://niteothemes.com/downloads/cmp-ares-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=ares', 'price' => '10') );
489
+ array_push( $premium_themes, array('name' => 'juno', 'url' => 'https://niteothemes.com/downloads/cmp-juno-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=juno', 'price' => '10') );
490
+ array_push( $premium_themes, array('name' => 'pluto', 'url' => 'https://niteothemes.com/downloads/cmp-pluto-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=pluto', 'price' => '10') );
491
+ array_push( $premium_themes, array('name' => 'agency', 'url' => 'https://niteothemes.com/downloads/cmp-agency-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=agency', 'price' => '15') );
492
+ array_push( $premium_themes, array('name' => 'element', 'url' => 'https://niteothemes.com/downloads/cmp-element-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=element', 'price' => '10') );
493
+ array_push( $premium_themes, array('name' => 'postery', 'url' => 'https://niteothemes.com/downloads/cmp-postery/?utm_source=cmp&utm_medium=referral&utm_campaign=postery', 'price' => '10') );
494
+ array_push( $premium_themes, array('name' => 'frame', 'url' => 'https://niteothemes.com/downloads/cmp-frame-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=frame', 'price' => '10') );
495
+ array_push( $premium_themes, array('name' => 'eclipse', 'url' => 'https://niteothemes.com/downloads/cmp-eclipse-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=eclipse', 'price' =>'0') );
496
+ array_push( $premium_themes, array('name' => 'orbit', 'url' => 'https://niteothemes.com/downloads/cmp-orbit-theme/?utm_source=cmp&utm_medium=referral&utm_campaign=orbit', 'price' => '0') );
497
 
498
  return $premium_themes;
499
  }
503
  * @since 2.8.3
504
  * @return array
505
  */
506
+ public function cmp_premium_themes_installed() {
 
507
  $premium_themes = array();
508
+
509
+ if ( file_exists( CMP_PREMIUM_THEMES_DIR ) ) {
510
+ $premium_themes = glob( CMP_PREMIUM_THEMES_DIR . '*', GLOB_ONLYDIR );
511
+ $premium_themes = array_map( 'basename', $premium_themes );
512
  }
513
+
514
+ return $premium_themes;
515
  }
516
 
517
  /**
520
  * @since 2.8.3
521
  * @return array
522
  */
523
+ public function cmp_themes_available() {
524
+ return array_merge( $this->cmp_themes_bundled(), $this->cmp_premium_themes_installed() );
 
525
  }
526
 
527
  /**
528
  * Enqueue admin scripts and styles
529
  */
530
+ public function cmp_add_topbar_scripts() {
 
531
 
532
  // return of user is not logged in
533
+ if ( !is_user_logged_in() ) {
534
  return;
535
  }
536
 
537
  // return if Top Bar Icon is disabled
538
+ if ( get_option('niteoCS_topbar_icon', '1') == '0' ) {
539
  return;
540
  }
541
 
542
+ wp_register_style( 'cmp-admin-head-style', plugins_url('/css/cmp-admin-head.css', __FILE__), array(), CMP_VERSION);
543
+ wp_register_script( 'cmp_admin_script', plugins_url('/js/cmp-admin-head.js', __FILE__), array('jquery'), CMP_VERSION);
544
 
545
+ $roles_topbar = json_decode( get_option('niteoCS_roles_topbar', '[]'), true );
546
 
547
  // push WP administrator to roles array, since it is default
548
+ array_push( $roles_topbar, 'administrator' );
 
549
 
550
+
551
 
552
  // get current user
553
  $current_user = wp_get_current_user();
554
  // check for roles array length
555
+ if ( count( $current_user->roles ) > 0 ) {
556
  // enqueue topbar script and style only, if current user is allowed to display topbar, or is admin
557
+ foreach ( $current_user->roles as $role ) {
558
+ if ( in_array( $role, $roles_topbar ) ) {
559
+ wp_enqueue_style( 'cmp-admin-head-style' );
560
+ wp_enqueue_script( 'cmp_admin_script' );
561
+ wp_localize_script( 'cmp_admin_script', 'cmp_ajax', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
562
  break;
563
  }
564
  };
565
 
566
+ // this one is for broken wp admin, where current user does not have any roles
567
  } else {
568
+ wp_enqueue_script( 'cmp_admin_script' );
569
+ wp_enqueue_style( 'cmp-admin-head-style' );
570
  }
571
+
572
  }
573
 
574
  /**
576
  *
577
  * @since 2.8.9
578
  */
579
+ public function cmp_add_admin_style($hook) {
 
580
  // return of user is not logged in
581
+ if ( !is_user_logged_in() ) {
582
  return;
583
  }
584
 
585
+ $prefix = sanitize_title( __( 'CMP Settings', 'cmp-coming-soon-maintenance' ) );
586
 
587
  $cmp_pages = array(
588
  'toplevel_page_cmp-settings',
589
+ $prefix.'_page_cmp-advanced',
590
+ $prefix.'_page_cmp-subscribers',
591
+ $prefix.'_page_cmp-translate',
592
+ $prefix.'_page_cmp-upload-theme',
593
+ $prefix.'_page_cmp-themes-manager',
594
+ $prefix.'_page_cmp-addons',
595
  );
596
 
597
+ if ( in_array( $hook, $cmp_pages ) ) {
598
+ wp_enqueue_style( 'cmp-style' );
599
  }
600
  }
601
 
604
  *
605
  * @since 2.8.1
606
  */
607
+ public function cmp_assets_suffix() {
 
608
 
609
  // If there's no debug mode, use the minified assets supplied.
610
+ if ( ! defined( 'CMP_DEBUG' ) ) {
611
+ define( 'CMP_ASSET_SUFFIX', '.min' );
612
  return;
613
  }
614
 
615
+ if ( true === CMP_DEBUG ) {
616
+ define( 'CMP_ASSET_SUFFIX', null );
617
  } else {
618
+ define( 'CMP_ASSET_SUFFIX', '.min' );
619
  }
620
  }
621
 
623
  /**
624
  * Register CMP menus pages
625
  */
626
+ public function cmp_adminMenu() {
 
627
  /* Register our plugin page */
628
  $page = add_menu_page(__('CMP Settings', 'cmp-coming-soon-maintenance'), __('CMP Settings', 'cmp-coming-soon-maintenance'), 'manage_options', 'cmp-settings', array($this, 'cmp_settings_page'), plugins_url('/img/cmp.png', __FILE__));
629
+ add_submenu_page('cmp-settings', __('CMP Basic Setup', 'cmp-coming-soon-maintenance'), __('CMP Basic Setup', 'cmp-coming-soon-maintenance'), 'manage_options', 'cmp-settings' );
630
+ add_submenu_page('cmp-settings', __('CMP Advanced Setup', 'cmp-coming-soon-maintenance'), __('CMP Advanced Setup', 'cmp-coming-soon-maintenance'), 'manage_options', 'cmp-advanced', array($this, 'cmp_advanced_page') );
631
+ add_submenu_page('cmp-settings', __('CMP Subscribers', 'cmp-coming-soon-maintenance'), __('CMP Subscribers', 'cmp-coming-soon-maintenance'), 'manage_options', 'cmp-subscribers', array($this, 'cmp_subs_page') );
632
+ add_submenu_page('cmp-settings', __('CMP Translation', 'cmp-coming-soon-maintenance'), __('CMP Translation', 'cmp-coming-soon-maintenance'), 'manage_options', 'cmp-translate', array($this, 'cmp_translate_page') );
633
+ add_submenu_page('cmp-settings', __('Upload CMP Theme', 'cmp-coming-soon-maintenance'), __('Upload CMP Theme', 'cmp-coming-soon-maintenance'), 'manage_options', 'cmp-upload-theme', array($this, 'cmp_upload_page') );
634
  /* Using registered $page handle to hook script load */
635
+ add_action('admin_print_scripts-'.$page, array($this, 'cmp_admin_scripts'));
636
+
637
  }
638
 
639
  /**
640
  * enqueue styles and scripts when navigated to CMP Settings page
641
  */
642
+ public function cmp_admin_scripts() {
 
643
  wp_enqueue_media();
644
+ if ( function_exists( 'wp_enqueue_code_editor' ) ) {
645
+ wp_enqueue_code_editor( array( 'type' => 'text/css' ) );
646
  }
647
+ wp_localize_script( 'cmp-typography', 'fonts', array( 'google' => $this->cmp_get_google_fonts() ) );
648
+ wp_enqueue_script( 'cmp_settings_js' );
649
+ wp_enqueue_script( 'cmp-typography' );
650
+ wp_enqueue_script( 'wp-color-picker' );
651
+ wp_enqueue_script( 'webfont' );
652
+ wp_enqueue_script( 'cmp-select2-js' );
653
 
654
+ if ( $this->translation_active() ) {
655
  $langs = $this->cmp_get_language_list();
656
  $default_lang = $this->cmp_get_default_language();
657
+ wp_localize_script( 'cmp-editor-translation', 'translation', array( 'langs' => $langs, 'default' => $default_lang ) );
658
+ wp_enqueue_script( 'cmp-editor-translation' );
659
  }
660
 
661
+ wp_enqueue_style( 'wp-color-picker' );
662
+ wp_enqueue_style( 'cmp-font-awesome' );
663
+
664
+ if ( in_array( $this->cmp_selectedTheme(), $this->cmp_font_animation_themes() ) ) {
665
  wp_enqueue_style('animate-css');
666
  }
667
  }
668
 
669
+ function cmp_admin_css() { ?>
 
670
  <style type="text/css" media="screen">
671
+ #toplevel_page_cmp-settings img {
672
+ max-width: 14px!important;
673
+ padding-top: 5px!important;
674
+ }
675
  </style>
676
+ <?php
677
+ }
678
 
679
  /**
680
  * Render CMP Settings Page
681
  */
682
+ public function cmp_settings_page() {
 
683
 
684
+ $this->cmp_check_update( $this->cmp_selectedTheme() );
685
+ require_once ('cmp-settings.php');
686
  }
687
 
688
  /**
689
  * Render CMP Advanced Settings Sub Page
690
  */
691
+ public function cmp_advanced_page() {
692
+ wp_enqueue_script( 'cmp-select2-js' );
693
+ wp_enqueue_script( 'cmp_advanced_js' );
694
+ wp_enqueue_style( 'cmp-font-awesome' );
695
+ require_once ('cmp-advanced.php');
 
696
  }
697
 
698
  /**
699
  * Render CMP Subscribers Sub Page
700
  */
701
+ public function cmp_subs_page() {
702
+ require_once ('cmp-subscribers.php');
 
703
  }
704
 
705
  /**
706
  * Render CMP Translation Sub Page
707
  */
708
+ public function cmp_translate_page() {
709
+ require_once ('cmp-translate.php');
 
710
  }
711
 
712
  /**
713
  * Render CMP Upload new Theme Sub Page
714
  */
715
+ public function cmp_upload_page() {
716
+ require_once ('cmp-upload.php');
 
717
  }
718
 
719
  /**
720
  * Load text domain
721
  */
722
+ public function load_textdomain() {
723
+ load_plugin_textdomain( 'cmp-coming-soon-maintenance', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
 
724
  }
725
 
726
  /**
729
  * @since 3.1.2
730
  * @return string
731
  */
732
+ public function cmp_active() {
733
+ return get_option('niteoCS_status', '0') === '0' ? '0': '1';
 
734
  }
735
 
736
  /**
739
  * @since 3.1.2
740
  * @return string
741
  */
742
+ public function cmp_mode() {
743
+ return get_option( 'niteoCS_activation', '2' );
744
+
745
  }
746
 
747
  /**
752
  * @param string
753
  * @return URL string
754
  */
755
+ public function cmp_asset_url( $filepath ) {
756
+ return plugins_url( $filepath, __FILE__ );
 
757
  }
758
 
759
  /**
773
  // }
774
 
775
  // function to display CMP landing page
776
+ public function cmp_displayPage() {
 
777
 
778
  $theme = $this->cmp_selectedTheme();
779
 
781
  $html = new CMP_Coming_Soon_and_Maintenance_Render_HTML();
782
 
783
  // check if preview is set
784
+ if ( isset($_GET['cmp_preview']) && $_GET['cmp_preview'] == 'true' ) {
785
+ $theme = isset( $_GET['cmp_theme'] ) ? $_GET['cmp_theme'] : $theme;
786
 
787
+ if ( !in_array($theme, $this->cmp_themes_available()) ) {
788
  $theme = $this->cmp_selectedTheme();
789
  }
790
+
791
+ // finally render theme preview cmp_preview=true
792
+ if ( file_exists( $this->cmp_theme_dir( $theme ).$theme.'/'.$theme.'-theme.php') ) {
793
+ require_once ( $this->cmp_theme_dir( $theme ).$theme.'/'.$theme.'-theme.php' );
794
  die();
795
  }
796
  }
797
 
798
  // return if CMP is disabled, user bypass by role or page is whitelisted
799
+ if ( $this->cmp_active() === '0' || $this->cmp_roles_filter() || !$this->cmp_page_filter() ) {
800
  return;
801
  }
802
 
803
  // bypass CMP and set cookie for user defined period of time, if bypass is enabled, bypass ID is set, and match CMP bypass settings
804
+ if ( isset( $_GET['cmp_bypass'] ) && $_GET['cmp_bypass'] == get_option('niteoCS_bypass_id', md5( get_home_url() )) && get_option('niteoCS_bypass', '0') == '1' ) {
805
  nocache_headers();
806
  header('Cache-Control: max-age=0; private');
807
+ setcookie('cmp_bypass', get_option('niteoCS_bypass_id', md5( get_home_url() ) ), time() + get_option('niteoCS_bypass_expire', 172800));
808
  // exit CMP
809
  return;
810
  }
811
 
812
  // if bypass Cookie is set, return
813
+ if ( isset($_COOKIE['cmp_bypass']) && $_COOKIE['cmp_bypass'] == get_option('niteoCS_bypass_id', md5( get_home_url() ) ) && get_option('niteoCS_bypass', '0') == '1' ) {
814
  // exit CMP
815
  return;
816
  }
817
 
818
  // if CMP in redirect mode with 0 timeout, die early with redirect
819
+ if ( $this->cmp_mode() == 3 && get_option('niteoCS_redirect_time') == 0 ) {
820
 
821
  $redirect_url = get_option('niteoCS_URL_redirect');
822
  // redirect to URL
823
+ if ( $redirect_url != '' ) {
824
+ header('Location: '.esc_url( $redirect_url ));
825
  die();
826
  }
827
  }
828
 
829
 
830
  // check for mailpoptin ajax
831
+ if ( isset($_GET['mailoptin-ajax']) ) {
832
 
833
  $campaign_id = get_option('niteoCS_mailoptin_selected');
834
  $campaign = MailOptin\Core\Repositories\OptinCampaignsRepository::get_optin_campaign_by_id($campaign_id);
835
 
836
+ if ( isset($_POST['optin_data']) && $_POST['optin_data']['optin_uuid'] == $campaign['uuid'] ) {
837
  return;
838
  }
839
+
840
  }
841
 
842
  // if themes with countdown timer
843
+ if ( $this->cmp_theme_supports( $theme, 'counter' ) ) {
844
+
845
  // if counter is enabled - default yes
846
+ if ( get_option('niteoCS_counter', '1') == '1' ) {
847
 
848
  // if countdown date is set - default 24 hours
849
+ if ( get_option('niteoCS_counter_date' ) && get_option('niteoCS_counter_date' ) != '' ) {
850
+
851
  // if timer < timestamp do pre-set action
852
+ if ( get_option('niteoCS_counter_date' ) < time() ) {
853
 
854
  $action = get_option('niteoCS_countdown_action', 'no-action');
855
 
856
  // send notification email if email transient is not set
857
+ if ( get_option('niteoCS_countdown_notification', '1') == '1' && get_option( 'niteoCS_counter_email', false ) !== 'sent' ) {
858
 
859
+ switch ( $action ) {
860
  case 'no-action':
861
  $message = __('Counter expired but it is set to make no action - you should login to your Wordpress Admin and adjust the expired timer or disable Coming Soon / Maintenance Mode.', 'cmp-coming-soon-maintenance');
862
  break;
877
  break;
878
  }
879
 
880
+ $to = get_option('niteoCS_countdown_email_address', get_option( 'admin_email' ));
881
  $subject = 'Countdown timer just expired on your Coming Soon Page - ' . get_site_url();
882
  $body = $message . ' This is auto generated message from CMP - Coming Soon & Maintenance Plugin installed on ' . get_site_url();
883
  $headers = array('Content-Type: text/plain; charset=UTF-8');
884
  // send email
885
+ wp_mail( $to, $subject, $body, $headers );
886
 
887
  // set email option
888
+ update_option( 'niteoCS_counter_email', 'sent' );
 
889
 
890
+ }
891
 
892
+
893
  // if action set to redirect
894
+ if ( $action == 'redirect' ) {
895
+ $redirect_url = esc_url( get_option('niteoCS_countdown_redirect') );
896
+ header('Location: '.$redirect_url);
897
  die();
898
  }
899
+
900
  }
901
  }
902
  }
903
  }
904
 
905
  // if maintanance mode send correct 503 headers
906
+ if ( $this->cmp_mode() == '1' ) {
907
  header('HTTP/1.1 503 Service Temporarily Unavailable');
908
  header('Status: 503 Service Temporarily Unavailable');
909
  header('Retry-After: 86400'); // retry in a day
910
  }
911
 
912
  // send no-cache headers if set in Settings
913
+ if ( get_option('niteoCS_seo_nocache', '1') == '1' ){
914
  nocache_headers();
915
  header('Cache-Control: no-cache; private');
916
  }
917
 
918
  // set cookie for WPML AJAX translation
919
+ if ( defined('ICL_LANGUAGE_CODE') ) {
920
+ setcookie('wp-wpml_current_language', ICL_LANGUAGE_CODE, time()+3600, '/');
921
+ setcookie('_icl_current_language', ICL_LANGUAGE_CODE, time()+3600, '/');
922
  }
923
 
924
  // finally render selected CMP theme
925
+ if ( file_exists( $this->cmp_theme_dir( $theme ).$theme.'/'.$theme.'-theme.php') ) {
926
+ require_once ( $this->cmp_theme_dir( $theme ).$theme.'/'.$theme.'-theme.php' );
927
  die();
928
  }
929
+
930
  }
931
 
932
+ // function to toggle CMP activation for admin menu icon
933
+ public function cmp_ajax_toggle_activation() {
 
934
  // check for ajax payoload
935
+ if ( isset( $_POST['payload'] ) && $_POST['payload'] == 'toggle_cmp_status' ) {
936
 
937
  // verify nonce
938
+ check_ajax_referer( 'cmp-coming-soon-ajax-secret', 'security' );
939
  // verify user rights
940
+ if ( !$this->cmp_user_can_admin_bar_activation() ) {
941
+ echo 'Current user cannot toggle CMP activation';
942
+ wp_die();
943
+ return;
944
+ }
945
 
946
+ if ( $this->cmp_active() === '0' ) {
947
  update_option('niteoCS_status', '1');
948
  $this->cmp_send_notification('on');
949
+
950
+ } else {
951
  update_option('niteoCS_status', '0');
952
  $this->cmp_send_notification('off');
953
+ }
954
 
955
+ $this->cmp_purge_cache();
956
 
957
+ echo 'success';
958
+ wp_die();
959
+ return;
960
+ }
961
+ }
962
 
963
  // return selected theme, defaults to hardwork
964
+ public function cmp_selectedTheme() {
 
965
  return get_option('niteoCS_theme', 'hardwork');
966
  }
967
 
968
 
969
  // return installed theme dir path
970
+ public function cmp_theme_dir( $slug ) {
971
+ if ( in_array( $slug, $this->cmp_themes_bundled() ) ) {
 
972
  return CMP_PLUGIN_DIR . 'themes/';
973
+
974
  } else {
975
  return CMP_PREMIUM_THEMES_DIR;
976
  }
977
  }
978
 
979
  // return installed theme URL
980
+ public function cmp_themeURL( $slug ) {
981
+ if ( in_array( $slug, $this->cmp_themes_bundled() ) ) {
982
+ return plugins_url( '/themes/', __FILE__ );
983
+
984
  } else {
985
+ return plugins_url( '/cmp-premium-themes/');
986
+
987
  }
988
  }
989
 
990
  // display admin topbar notice
991
+ public function cmp_admin_bar() {
 
992
 
993
+ $prefix = sanitize_title( __( 'CMP Settings', 'cmp-coming-soon-maintenance' ) );
994
 
995
+ if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
996
+ if ( current_user_can('publish_pages') && function_exists('get_current_screen') && is_admin() && get_current_screen()->id == $prefix.'_page_cmp-advanced' && wp_verify_nonce( $_POST['save_options_field'], 'save_options' ) ) {
997
+ // check POST if user wants to enable or disable the topbar from settings
998
+ if ( isset( $_POST['niteoCS_topbar_icon'] ) && is_numeric( $_POST['niteoCS_topbar_icon'] ) ) {
999
+ update_option('niteoCS_topbar_icon', sanitize_text_field( $_POST['niteoCS_topbar_icon'] ));
1000
  }
1001
 
1002
+ if ( isset( $_POST['niteoCS_topbar_version'] ) ) {
1003
+ update_option('niteoCS_topbar_version', sanitize_text_field( $_POST['niteoCS_topbar_version'] ));
1004
  }
1005
  }
1006
  }
1007
+
1008
 
1009
+ if ( !$this->cmp_user_can_admin_bar_activation() ) {
1010
+ return false;
1011
+ }
 
1012
 
1013
  // CMP PLUGIN ACTIVATION AND STATUS CHANGE SETTINGS!
1014
+ if ( $_SERVER['REQUEST_METHOD'] == 'POST' && ( function_exists('get_current_screen') && is_admin() && get_current_screen()->id == 'toplevel_page_cmp-settings' ) ) {
1015
 
1016
  // verify nonce and user rights
1017
+ if ( !wp_verify_nonce($_POST['save_options_field'], 'save_options') || !current_user_can('publish_pages') ) {
1018
  die('Sorry, but this request is invalid');
1019
+ }
1020
 
1021
+ if ( isset($_POST['activate']) && is_numeric($_POST['activate']) ) {
1022
  update_option('niteoCS_activation', sanitize_text_field($_POST['activate']));
1023
  }
1024
 
1025
+ if ( isset($_POST['cmp_status']) ) {
1026
  update_option('niteoCS_status', $this->sanitize_checkbox($_POST['cmp_status']));
1027
  $this->cmp_send_notification('on');
1028
+
1029
+ } else if ( !isset($_POST['submit_theme']) ) {
1030
  update_option('niteoCS_status', '0');
1031
  $this->cmp_send_notification('off');
1032
  }
1033
  }
1034
 
1035
+ // create nonce for ajax request
1036
+ $ajax_nonce = wp_create_nonce( 'cmp-coming-soon-ajax-secret' );
1037
 
1038
+ global $wp_admin_bar;
1039
 
1040
  $class = '';
1041
  $msg = '';
1042
+ $icon = '<img src="'.plugins_url('/img/cmp.png', __FILE__).'" alt="CMP Logo" class="cmp-logo" style="max-width:20px;">';
1043
 
1044
  $topbar_version = get_option('niteoCS_topbar_version', 'cmp-topbar-full');
1045
 
1046
+ if ( $topbar_version === 'cmp-topbar-full' ) {
1047
+ switch ( $this->cmp_mode() ) {
1048
  case '1':
1049
  $msg = __('Maintenance Mode:', 'cmp-coming-soon-maintenance');
1050
  $class = ' maintenance';
1061
  break;
1062
  }
1063
 
1064
+ $msg = '<span class="cmp-status-msg ab-label">'.$msg.'</span>';
1065
  }
1066
 
1067
+
1068
+ $topbar = $icon.$msg.'<div class="toggle-wrapper"><div id="cmp-status-menubar" class="toggle-checkbox"></div><div id="cmp-toggle-adminbar" class="status-' . esc_attr( $this->cmp_active() ) . '" data-security="'. esc_attr( $ajax_nonce ).'"><span class="toggle_handler"></span></div></div>';
1069
 
1070
+ //Add the main siteadmin menu item
1071
+ $wp_admin_bar->add_menu( array(
1072
+ 'id' => 'cmp-admin-notice',
1073
+ 'href' => admin_url().'admin.php?page=cmp-settings',
1074
+ 'parent' => 'top-secondary',
1075
+ 'title' => $topbar,
1076
+ 'meta' => array( 'class' => 'cmp-notice'.$class ),
1077
+ ) );
 
 
 
 
 
 
 
 
 
 
 
1078
 
1079
+ // Display CMP Settings in topbar only for administrator
1080
+ if ( current_user_can( 'administrator' ) ) {
1081
+ $wp_admin_bar->add_node( array(
1082
+ 'id' => 'cmp-basic-settings',
1083
+ 'title' => __('CMP Basic Settings', 'cmp-coming-soon-maintenance'),
1084
+ 'href' => admin_url('admin.php?page=cmp-settings'),
1085
+ 'parent' => 'cmp-admin-notice'
1086
  ));
1087
+
1088
+ $wp_admin_bar->add_node( array(
1089
+ 'id' => 'cmp-advanced-settings',
1090
+ 'title' => __('CMP Advanced Settings', 'cmp-coming-soon-maintenance'),
1091
+ 'href' => admin_url('admin.php?page=cmp-advanced'),
1092
+ 'parent' => 'cmp-admin-notice'
1093
+ ));
1094
  }
1095
 
1096
+ $wp_admin_bar->add_node( array(
1097
+ 'id' => 'cmp-preview',
1098
+ 'title' => __('CMP Preview', 'cmp-coming-soon-maintenance'),
1099
+ 'href' => get_site_url().'/?cmp_preview=true',
1100
+ 'parent'=> 'cmp-admin-notice',
1101
+ 'meta' => array('target' => '_blank' )
1102
+ ));
 
1103
 
1104
+ }
 
1105
 
1106
+ public function cmp_activate() {
1107
+
1108
+ if ( get_option('niteoCS_archive') ) {
1109
  //get all the options back from the archive
1110
  $options = get_option('niteoCS_archive');
1111
  // update options
1113
  update_option($option['name'], $option['value']);
1114
  }
1115
 
1116
+ update_option( 'niteoCS_activation_notice', false );
1117
 
1118
  // delete archive
1119
  delete_option('niteoCS_archive');
1121
  }
1122
 
1123
  // archive plugin stuff when plugin is deactivated
1124
+ public function cmp_deactivate() {
 
1125
  //get all the options. store them in an array
1126
  $options = array();
1127
 
1128
  global $wpdb;
1129
+ $saved_options = $wpdb->get_results( "SELECT * FROM $wpdb->options WHERE option_name LIKE 'niteoCS_%'", OBJECT );
1130
  $i = 0;
1131
  foreach ($saved_options as $option) {
1132
+ $options[$i] = array('name' => $option->option_name, 'value' => get_option( $option->option_name) );
1133
  $i++;
1134
  }
1135
 
1137
  update_option('niteoCS_archive', $options);
1138
 
1139
  //delete the separate ones
1140
+ foreach ( $options as $option ) {
1141
  delete_option($option['name']);
1142
  }
1143
 
1151
  * @access public
1152
  * @return array
1153
  */
1154
+ public function cmp_downloadable_themes() {
 
1155
  $downloadable_themes = array();
1156
 
1157
+ foreach ( $this->cmp_premium_themes() as $premium ) {
1158
+ if ( !in_array($premium['name'], $this->cmp_premium_themes_installed()) ) {
1159
+ array_push( $downloadable_themes, $premium );
1160
+ }
1161
  }
1162
 
1163
  return $downloadable_themes;
1170
  * @access public
1171
  * @return JSON
1172
  */
1173
+ public function cmp_disable_comingsoon_ajax() {
 
1174
 
1175
  $theme = $this->cmp_selectedTheme();
1176
 
1177
+ if ( !in_array( $theme, $this->cmp_builder_themes() ) ) {
1178
+ check_ajax_referer( 'cmp-coming-soon-maintenance-nonce', 'security' );
1179
  }
1180
 
1181
+ $result = array( 'message' => 'error');
1182
 
1183
+ if ( get_option('niteoCS_countdown_action', 'no-action') !== 'disable-cmp' ) {
1184
+ echo json_encode( $result );
1185
  wp_die();
1186
  }
1187
 
1188
+ if ( !empty( $_REQUEST['status'] ) && $_REQUEST['status'] === 'disable-cmp' && get_option('niteoCS_counter_date' ) < time() ) {
1189
  update_option('niteoCS_status', '0');
1190
  $this->cmp_purge_cache();
1191
+ $result = array( 'message' => 'success');
1192
  }
1193
+
1194
+ echo json_encode( $result );
1195
 
1196
  wp_die();
1197
  }
1198
 
1199
  // theme updates function
1200
+ public function cmp_check_update( $theme_slug ) {
 
1201
 
1202
  $ajax = false;
1203
  // check for ajax
1204
+ if ( isset( $_POST['theme_slug'] ) ) {
1205
  // verify nonce
1206
+ check_ajax_referer( 'cmp-coming-soon-ajax-secret', 'security' );
1207
  // verify user rights
1208
+ if( !current_user_can('publish_pages') ) {
1209
  die('Sorry, but this request is invalid');
1210
  }
1211
 
1212
  // sanitize array
1213
  $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1214
 
1215
+ if ( !empty( $_POST['theme_slug'] ) ) {
1216
  $theme_slug = $_POST['theme_slug'];
1217
  $ajax = true;
1218
  }
1219
+ }
1220
 
1221
+ if ( !in_array( $theme_slug, $this->cmp_premium_themes_installed() ) ) {
1222
  return;
1223
  }
1224
 
1226
  $remote_version = '';
1227
  $current_version = '';
1228
 
1229
+ if ( CMP_DEBUG === TRUE ) {
1230
+ delete_transient( $theme_slug.'_updatecheck' );
1231
  }
1232
 
1233
  // always check if update check transient is set or ajax request
1234
+ if ( false === ( $updatecheck_transient = get_transient( $theme_slug.'_updatecheck' ) ) || $ajax === TRUE ) {
1235
 
1236
  $current_version = $this->cmp_theme_version($theme_slug);
1237
  // get remote version from remote server
1238
+ $request = wp_remote_post( CMP_UPDATE_URL .'?action=get_metadata&slug='.$theme_slug, array('body' => array('action' => 'version')) );
1239
+
1240
  // if no error, retrivee body
1241
+ if ( !is_wp_error( $request ) ) {
1242
 
1243
+ // decode to json
1244
+ $remote_version = json_decode( $request['body'], true );
1245
 
1246
+ // get remove version key
1247
+ if ( isset($remote_version['version']) ) {
1248
 
1249
+ $remote_version = $remote_version['version'];
1250
 
1251
+ // if remote version is bigger than current, display info about new version
1252
+ if ( (float)$remote_version > (float)$current_version ) {
1253
 
1254
+ $title = ucwords(str_replace('_', ' ', $theme_slug));
1255
 
1256
+ // create nonce
1257
+ $ajax_nonce = wp_create_nonce( 'cmp-coming-soon-ajax-secret' );
1258
 
1259
+ // if admin screen is not in updating theme
1260
+ if (!isset($_GET['theme']) || (isset($_GET['theme']) && $_GET['theme'] != $theme_slug)) {
1261
 
1262
+ $transient = '<div class="notice notice-warning"><p class="message">'.sprintf(__('There is a <b>recommended</b> update of <b>CMP Theme: %s</b> available:', 'cmp-coming-soon-maintenance'), $title).' <a href="'.admin_url().'options-general.php?page=cmp-settings&action=update-cmp-theme&theme='.esc_attr($theme_slug).'&type=premium" class="cmp update-theme" data-type="premium" data-security="'.esc_attr($ajax_nonce).'" data-slug="'.esc_attr($theme_slug).'" data-name="'.esc_attr($title).'" data-remote_url="' . esc_url( CMP_UPDATE_URL ) . '" data-new_ver="' . esc_attr( $remote_version ) . '">'.sprintf(__(' click to update to %s version from NiteoThemes server now','cmp-coming-soon-maintenance'), esc_attr( $remote_version )).'!</a></div>';
1263
 
1264
+ // set transient with 12 hour expire
1265
+ set_transient( $theme_slug.'_updatecheck', $transient, 60*60*12 );
1266
 
1267
+ // die early if this is ajax request with status = true
1268
+ if ( $ajax ) {
1269
  wp_die($remote_version);
1270
  return;
1271
  }
1272
 
1273
 
1274
+ echo $transient;
1275
+ }
1276
+
1277
+ } else {
1278
+ // die early if this is ajax request with status = false
1279
+ if ( $ajax ) {
1280
  wp_die('false');
1281
  return;
1282
  }
1283
+ // set transient no update available with 12 hours expire
1284
+ set_transient( $theme_slug.'_updatecheck', '', 60*60*12 );
1285
+ }
 
 
1286
 
1287
+ }
1288
+ }
1289
+
1290
+ // empty transient means theme was updated in last 24 hours
1291
+ } else if ( $updatecheck_transient != '' ) {
1292
 
1293
  echo $updatecheck_transient;
1294
  }
1295
 
1296
+ if ( $ajax ) {
1297
  wp_die('false');
1298
  }
1299
 
1300
  return;
1301
  }
1302
 
1303
+ public function cmp_theme_upload($uploadedfile) {
 
1304
 
1305
+ if ( !current_user_can('administrator') ) {
1306
  return false;
1307
  }
1308
 
1309
  // allow zip file to upload
1310
+ add_filter('upload_mimes', array( $this, 'cmp_allow_mimes') );
1311
 
1312
+ // load PHP WP FILE
1313
+ if ( ! function_exists( 'wp_handle_upload' ) ) {
1314
+ require_once realpath('../../../wp-admin/includes/file.php');
1315
  }
1316
 
1317
  $filename = $uploadedfile['name'];
1318
  /* You can use wp_check_filetype() public function to check the
1319
  file type and go on wit the upload or stop it.*/
1320
+ $filetype = wp_check_filetype( $filename );
1321
 
1322
+ if ( $filetype['ext'] == 'zip' ) {
1323
  // Upload file
1324
+ $movefile = wp_handle_upload( $uploadedfile, array('test_form' => FALSE) );
1325
 
1326
+ if ( $movefile && !isset( $movefile['error'] ) ) {
1327
 
1328
  WP_Filesystem();
1329
+ $source_path = $movefile['file'];
1330
+ $theme_name = str_replace('.zip', '', $filename);
1331
  $destination_path = CMP_PREMIUM_THEMES_DIR;
1332
 
1333
  // create new theme DIR
1334
+ if ( wp_mkdir_p( $destination_path ) ) {
1335
  // Unzip FILE into that DIR
1336
+ $unzipfile = unzip_file( $source_path, $destination_path);
1337
+
1338
+ if ( $unzipfile ) {
1339
+ // delete FILE
1340
+ wp_delete_file( $source_path );
1341
+
1342
+ if ( $theme_name == 'pluto' ) {
1343
+ delete_option('niteoCS_banner');
1344
+ }
1345
+ echo '<div class="notice notice-success is-dismissible"><p class="message">'.ucwords(str_replace('_', ' ', $theme_name)).' '.__(' theme was successfully installed!', 'cmp-coming-soon-maintenance').'</p></div>';
1346
+ return;
1347
 
1348
+ } else {
1349
+ echo '<div class="notice notice-error is-dismissible"><p>'.__('There was an error unzipping the file!', 'cmp-coming-soon-maintenance').'</p></div>';
1350
+ return;
1351
+ }
1352
 
 
 
 
 
 
 
 
 
 
1353
  } else {
1354
+ echo '<div class="notice notice-error is-dismissible"><p>'.__('Error creating Theme subdirectory!', 'cmp-coming-soon-maintenance').'</p></div>';
1355
  return;
1356
  }
1357
+
1358
  } else {
1359
+ /**
1360
+ * Error generated by _wp_handle_upload()
1361
+ * @see _wp_handle_upload() in wp-admin/includes/file.php
1362
+ */
1363
+ echo '<div class="notice notice-error is-dismissible"><p>'.$movefile['error'].'</p></div>';
1364
+ return;
1365
  }
1366
  } else {
1367
+ echo '<div class="notice notice-error is-dismissible"><p>'.__('Unable to upload new Theme file .', 'cmp-coming-soon-maintenance'). strtoupper($filetype['ext']) .__(' file extension is not supported. Please upload ZIP file containing CMP Theme.', 'cmp-coming-soon-maintenance').'</p></div>';
1368
  return;
1369
  }
1370
 
1372
  return;
1373
  }
1374
 
1375
+ public function cmp_theme_update_install( $file ) {
 
1376
  $ajax = false;
1377
  // check for ajax
1378
+ if ( isset( $_POST['file'] ) ) {
1379
  // verify nonce
1380
+ check_ajax_referer( 'cmp-coming-soon-ajax-secret', 'security' );
1381
  // verify user rights
1382
+ if( !current_user_can('publish_pages') ) {
1383
  die('Sorry, but this request is invalid');
1384
  }
1385
 
1386
  // sanitize array
1387
  $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1388
 
1389
+ if ( !empty( $_POST['file'] ) ) {
1390
  $file = $_POST['file'];
1391
  $ajax = true;
1392
  }
1393
+ }
1394
 
1395
+ // load PHP WP FILE
1396
+ if ( ! empty( $file ) ) {
1397
  // Download file to temp location.
1398
+ $file['tmp_name'] = download_url( $file['url'] );
1399
  //WARNING: The file is not automatically deleted, The script must unlink() the file.
1400
 
1401
  // If error storing temporarily, return the error.
1402
+ if ( !is_wp_error( $file['tmp_name'] ) ) {
1403
  WP_Filesystem();
1404
 
1405
  // create new theme DIR
1406
+ if ( wp_mkdir_p( CMP_PREMIUM_THEMES_DIR ) ) {
1407
  // Unzip FILE into that DIR
1408
+ $unzipfile = unzip_file( $file['tmp_name'], CMP_PREMIUM_THEMES_DIR );
1409
 
1410
+ if ( !is_wp_error( $unzipfile ) ) {
1411
  // delete tmp FILE
1412
+ wp_delete_file( $file['tmp_name'] );
1413
 
1414
  // set transient no update available with 24 hours expire
1415
+ set_transient( $file['name'] . '_updatecheck', '', 60*60*24 );
1416
 
1417
  // die
1418
+ if ( $ajax ) {
1419
  wp_die('success');
1420
  return;
1421
+
1422
  } else {
1423
+ echo '<div class="notice notice-success is-dismissible"><p>CMP '. ucwords( str_replace( '_', ' ', $file['name'] ) ) .' '. __( 'Theme has been updated to latest version!', 'cmp-coming-soon-maintenance' ).'</p></div>';
1424
  return;
1425
  }
1426
+
1427
  } else {
1428
+ echo '<div class="notice notice-error is-dismissible"><p>'.__('There was an error unzipping the file due to error: ', 'cmp-coming-soon-maintenance') . $unzipfile->get_error_message().'</p></div>';
1429
 
1430
+ if ( $ajax ) {
1431
  wp_die('error');
1432
  return;
1433
+ }
1434
  }
1435
+
1436
  } else {
1437
+ echo '<div class="notice notice-error is-dismissible"><p>'.__('Error creating Theme subdirectory!', 'cmp-coming-soon-maintenance').'</p></div>';
1438
+ if ( $ajax ) {
1439
  wp_die('error');
1440
  return;
1441
  }
1442
  }
1443
+
1444
  } else {
1445
+ echo '<div class="notice notice-error is-dismissible"><p>'.__('Error during updating Theme files:', 'cmp-coming-soon-maintenance').' '.$file['tmp_name']->get_error_message().'</p></div>';
1446
+ if ( $ajax === true ) {
1447
  wp_die('error');
1448
  return;
1449
+ }
1450
  }
1451
  } else {
1452
 
1453
+ echo '<div class="notice notice-error is-dismissible"><p>'.__('General Error during updating Theme files.', 'cmp-coming-soon-maintenance').'</p></div>';
1454
+ if ( $ajax === true ) {
1455
  wp_die('error');
1456
  return;
1457
+ }
1458
  }
1459
 
1460
  return;
1462
 
1463
 
1464
  // build unsplash api
1465
+ public function cmp_unsplash_api ( $query ) {
 
 
 
1466
 
1467
+ $api_url = 'https://api.unsplash.com/'.$query.'&client_id=41f043163758cf2e898e8a868bc142c20bc3f5966e7abac4779ee684088092ab' ;
1468
+
1469
+ if ( function_exists( 'wp_remote_get' ) ) {
1470
 
1471
+ $response = wp_remote_get( $api_url );
1472
 
1473
+ if ( !is_object( $response ) && isset( $response['body'] ) ) {
1474
 
1475
  $body = $response['body'];
1476
+ $data = array( 'response' => $response['response']['code'], 'body' => $body );
1477
+
1478
  } else {
1479
+ $data = array( 'response' => 'Unplash API', 'body' => 'Not responding after 5000ms' );
1480
  }
1481
+
1482
  } else {
1483
+ $data = array( 'response' => '500', 'body' => 'You have neither cUrl installed nor allow_url_fopen activated. Ask your server hosting provider to allow on of those options.' );
1484
  }
1485
 
1486
  return $data;
1487
  }
1488
 
1489
  // prepare unsplash url and get unsplash photo via cmp_unsplash_api()
1490
+ public function niteo_unsplash( $params ) {
 
1491
  $ajax = false;
1492
 
1493
  // check for ajax
1494
+ if ( isset( $_POST['params'] ) ) {
1495
  // verify nonce
1496
+ check_ajax_referer( 'cmp-coming-soon-ajax-secret', 'security' );
1497
  // verify user rights
1498
+ if( !current_user_can('publish_pages') ) {
1499
  die('Sorry, but this request is invalid');
1500
  }
1501
 
1502
  // sanitize array
1503
  $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1504
 
1505
+ if ( !empty( $_POST['params'] ) ) {
1506
  $params = $_POST['params'];
1507
  $ajax = true;
1508
  }
1509
+ }
1510
 
1511
+ array_key_exists ('feed', $params) ? $feed = $params['feed'] : $feed = '';
1512
+ array_key_exists ('url', $params) ? $url = $params['url'] : $url = '';
1513
+ array_key_exists ('feat', $params) ? $feat = $params['feat'] : $feat = '';
1514
+ array_key_exists ('custom_str', $params) ? $custom_str = $params['custom_str'] : $custom_str = '';
1515
+ array_key_exists ('count', $params) ? $count = $params['count'] : $count = '1';
1516
 
1517
+ switch ( $feed ) {
1518
+ // specific unsplash photo by url/id
1519
  case '0':
1520
  $id = '';
1521
  // check if $query contains unsplash.com url
1522
+ if ( strpos( $url, 'unsplash.com' ) !== false ) {
1523
+ $parts = parse_url( $url );
1524
  // check for photo parameter in URL
1525
+ if ( isset($parts['query'])) {
1526
  parse_str($parts['query'], $query);
1527
+ $id = $query['photo'];
1528
  }
1529
+ // if no ID found, get last part of URL containing ID
1530
+ if ( $id == '' ) {
1531
 
1532
  $pathFragments = explode('/', $parts['path']);
1533
  $id = end($pathFragments);
1534
+ }
1535
 
1536
+ // $query is ID
1537
  } else {
1538
  $id = $url;
1539
  }
1540
 
1541
  // prepare query for single image
1542
+ $api_query = 'photos/'.$id.'?';
1543
  break;
1544
 
1545
+ // random from user
1546
  case '1':
1547
 
1548
+ if ( $custom_str[0] == '@' ) {
1549
  $custom_str = substr($custom_str, 1);
1550
  }
1551
 
1552
  // prepare query for random photo from collection
1553
+ $api_query = 'photos/random/?username='.$custom_str.'&count='.$count;
1554
  break;
1555
 
1556
+ // random from collection
1557
  case '2':
1558
+ if ( is_numeric( $url ) ) {
1559
  $collection = $url;
1560
  } else {
1561
  $collection = filter_var($url, FILTER_SANITIZE_NUMBER_INT);
1562
+ $collection = str_replace('-', '', $collection );
1563
  }
1564
 
1565
  // prepare query for random photo from collection
1566
+ $api_query = 'photos/random/?collections='.$collection.'&count='.$count;
1567
  break;
1568
 
1569
+ // random photo
1570
  case '3':
1571
 
1572
  // featured
1573
+ if ( $feat == '0' || $feat == '') {
1574
  $featured = 'false';
1575
  } else {
1576
  $featured = 'true';
1579
  // category
1580
  $search = str_replace(' ', ',', $url);
1581
 
1582
+ if ( $search !== '' ) {
1583
+ $search = 'query='.$search.'&';
1584
  }
1585
  // prepare query for random photo
1586
+ $api_query = 'photos/random/?orientation=landscape&featured='.$featured.'&'.$search.'count='.$count;
1587
  break;
1588
 
1589
  default:
1590
+ $api_query = 'photos/random/?orientation=landscape&count='.$count;
1591
  break;
1592
  }
1593
 
1594
+ $unsplash_img = $this->cmp_unsplash_api( $api_query );
1595
 
1596
+ if ( $ajax === true ) {
1597
  echo json_encode($unsplash_img);
1598
  wp_die();
1599
+
1600
  } else {
1601
  return $unsplash_img;
1602
  }
1603
  }
1604
+
1605
  // check value in multidimensional array
1606
+ public function niteo_in_array_r($needle, $haystack, $strict = false) {
1607
+ foreach ( $haystack as $item ) {
1608
+ if ( ( $strict ? $item === $needle : $item == $needle ) || ( is_array( $item ) && $this->niteo_in_array_r( $needle, $item, $strict ) ) ) {
1609
+ return true;
1610
+ }
1611
+ }
 
1612
 
1613
+ return false;
1614
  }
1615
  /**
1616
  * Recaptcha integration
1619
  * @access public
1620
  * @return boolean
1621
  */
1622
+ public function is_human( $token ) {
 
1623
 
1624
+ $this->define( 'RECAPTCHA_SECRET', get_option('niteoCS_recaptcha_secret') );
1625
 
1626
  $request = array(
1627
  'body' => array(
1630
  ),
1631
  );
1632
 
1633
+ $response = wp_remote_post( esc_url_raw( 'https://www.google.com/recaptcha/api/siteverify' ), $request );
1634
+ $response_body = wp_remote_retrieve_body( $response );
1635
+ $recaptcha = json_decode( $response_body, true );
1636
 
1637
+ if ( $recaptcha['success'] === true & $recaptcha['score'] > 0.50 ) {
1638
  return true;
1639
  }
1640
 
1641
  return false;
1642
+
1643
  }
1644
 
1645
  // save subscribe function
1646
  // $check must be true, to avoid duplicated requests after update to 2.1
1647
+ public function niteo_subscribe( $check ) {
 
1648
 
1649
  $subscribe_method = get_option('niteoCS_subscribe_method', 'cmp');
1650
  $response = '';
1651
 
1652
  // get translation lists
1653
+ if ( get_option('niteoCS_translation') ) {
1654
+ $translation = json_decode( get_option('niteoCS_translation'), TRUE );
1655
+ $response_ok = $this->cmp_wpml_translate_string( $translation[7]['translation'], 'Subscribe Response Thanks' );
1656
+ $response_duplicate = $this->cmp_wpml_translate_string( $translation[5]['translation'], 'Subscribe Response Duplicate' );
1657
+ $response_invalid = $this->cmp_wpml_translate_string( $translation[6]['translation'], 'Subscribe Response Not Valid' );
1658
+ }
1659
+
1660
+ $ajax = ( isset( $_POST['ajax'] ) && $_POST['ajax'] == TRUE ) ? TRUE : FALSE;
1661
+
1662
+ if ( $_SERVER['REQUEST_METHOD'] == 'POST' && isset( $_POST['form_honeypot'] ) && $_POST['form_honeypot'] === '' && isset( $_POST['email'] ) ) :
1663
+
1664
+ if ( $ajax ) {
1665
+ check_ajax_referer( 'cmp-subscribe-action', 'security' );
1666
  }
1667
 
1668
  // check recatpcha score if integration is enabled
1669
+ if ( get_option( 'niteoCS_recaptcha_status', '1' ) === '1' && !empty(get_option('niteoCS_recaptcha_site', ''))) {
1670
+ if ( !$this->is_human( sanitize_text_field( $_POST['token'] ) ) ) {
1671
+ echo json_encode( array( 'status' => '0', 'message' => 'Sorry, robots not allowed.') );
1672
  wp_die();
1673
  }
1674
  }
1675
 
1676
+ if ( filter_var( $_POST['email'], FILTER_VALIDATE_EMAIL ) ) {
1677
+ // email already passed is_email, no need to sanitize
1678
+ $email = sanitize_email( $_POST['email'] );
1679
 
1680
+ // sanitize all inputs
1681
+ $ip_address = ( isset( $_POST['lastname'] ) ) ? sanitize_text_field($_SERVER['REMOTE_ADDR']) : '';
1682
+ $firstname = ( isset( $_POST['firstname'] ) ) ? sanitize_text_field( $_POST['firstname'] ) : '';
1683
+ $lastname = ( isset( $_POST['lastname'] ) ) ? sanitize_text_field( $_POST['lastname'] ) : '';
1684
  $timestamp = time();
1685
 
1686
+ switch ( $subscribe_method ) {
1687
+ // default custom CMP method
1688
+ case 'cmp':
1689
  // get subscribe list
1690
  $subscribe_list = get_option('niteoCS_subscribers_list');
1691
 
1692
  // if no subscribe list yet, create first item and insert it into DB
1693
+ if ( !$subscribe_list ) {
1694
  $new_list = array();
1695
+ $new_email = array( 'id' => '0', 'timestamp' => $timestamp, 'email' => $email, 'ip_address' => $ip_address, 'firstname' => $firstname, 'lastname' => $lastname );
1696
+ array_push( $new_list, $new_email );
1697
+ update_option( 'niteoCS_subscribers_list', $new_list );
1698
+ $response = array( 'status' => '1', 'message' => $response_ok);
1699
+
1700
  } else {
1701
  // check if email don`t already exists
1702
+ if ( !$this->niteo_in_array_r( $email, $subscribe_list, true ) ) {
1703
+ $count = count( $subscribe_list );
1704
+ $new_email = array( 'id' => $count, 'timestamp' => $timestamp, 'email' => $email, 'ip_address' => $ip_address, 'firstname' => $firstname, 'lastname' => $lastname );
1705
+ array_push( $subscribe_list, $new_email );
1706
  update_option('niteoCS_subscribers_list', $subscribe_list);
1707
+ $response = array( 'status' => '1', 'message' => $response_ok);
1708
  // sent notif email
1709
+ if ( get_option('niteoCS_subscribe_notification', '0') ) {
1710
+ $subscribe_notif_email = get_option('niteoCS_subscribe_email_address', get_option( 'admin_email' ));
1711
  $subject = sprintf(__('You have a new Subscriber on %s!', 'cmp-coming-soon-maintenance'), get_site_url());
1712
  $body = __('This is auto generated message from CMP - Coming Soon & Maintenance WordPress Plugin. You can disable these emails under CMP Advanced Settings > Email Notifications.', 'cmp-coming-soon-maintenance');
1713
  $headers = array('Content-Type: text/plain; charset=UTF-8');
1714
+ wp_mail( $subscribe_notif_email, $subject, $body, $headers );
1715
  }
1716
 
1717
+ // if email exists return duplicate response
1718
  } else {
1719
+ $response = array( 'status' => '0', 'message' => $response_duplicate);
1720
  }
1721
  }
1722
+ break;
1723
+
1724
+ // mailchimp API call
1725
+ case 'mailchimp':
1726
+ $api_key = esc_attr( get_option('niteoCS_mailchimp_apikey') );
1727
+ $list_id = esc_attr( get_option('niteoCS_mailchimp_list_selected') );
1728
+ $double_opt = get_option( 'niteoCS_mailchimp[double-opt]', '0' );
1729
+ $status = ( $double_opt == '1') ? 'pending' : 'subscribed'; // subscribed, cleaned, pending
1730
+
1731
  $args = array(
1732
  'method' => 'PUT',
1733
+ 'headers' => array(
1734
+ 'Authorization' => 'Basic ' . base64_encode( 'user:'. $api_key )
1735
  ),
1736
  'body' => json_encode(array(
1737
+ 'email_address' => $email,
1738
  'status' => $status,
1739
  'merge_fields' => array(
1740
+ 'FNAME' => $firstname,
1741
+ 'LNAME' => $lastname
1742
  )
1743
  ))
1744
  );
1745
 
1746
+ $mailchimp = wp_remote_post( 'https://' . substr($api_key,strpos($api_key,'-')+1) . '.api.mailchimp.com/3.0/lists/'. $list_id .'/members/' . md5(strtolower($email)), $args );
1747
+
1748
+ if ( !is_wp_error( $mailchimp ) ) {
1749
 
1750
+ $body = json_decode( $mailchimp['body'] );
1751
 
1752
+ if ( $mailchimp['response']['code'] == 200 && $body->status == $status ) {
1753
+ $response = array( 'status' => '1', 'message' => $response_ok);
1754
 
 
 
1755
  } else {
1756
+ $response = array( 'status' => '0', 'message' => 'Error ' . $mailchimp['response']['code'] . ' ' . $body->title . ': ' . $body->detail);
1757
  }
1758
+
1759
  } else {
1760
  $error = $mailchimp->get_error_message();
1761
+ $response = array( 'status' => '0', 'message' => $error);
1762
  }
1763
 
1764
  break;
1765
 
1766
+ // MailPoet integration
1767
  case 'mailpoet':
1768
+ $response = array( 'status' => '0', 'message' => __('Something went wrong please try again later.', 'cmp-coming-soon-maintenance') );
1769
  $mailpoet_list = get_option('niteoCS_mailpoet_list_selected');
1770
  $list_ids = array($mailpoet_list);
1771
  $firstname = $firstname === '' ? null : $firstname;
1776
  'last_name' => $lastname
1777
  );
1778
 
1779
+ if ( class_exists(\MailPoet\API\API::class) ) {
1780
  // Get MailPoet API instance
1781
  $mailpoet_api = \MailPoet\API\API::MP('v1');
1782
 
1783
  // Check if subscriber exists. If subscriber doesn't exist an exception is thrown
1784
  try {
1785
+ $subscribed = $mailpoet_api->getSubscriber( $subscriber['email'] );
1786
+ } catch (\Exception $e) {}
 
1787
 
1788
  try {
1789
  if (!$subscribed) {
1790
  // Subscriber doesn't exist let's create one
1791
+ $mailpoet_api->addSubscriber( $subscriber, $list_ids );
1792
+ $response = array( 'status' => '1', 'message' => $response_ok );
1793
+
1794
  } else {
1795
  // In case subscriber exists just add him to new lists
1796
+ $mailpoet_api->subscribeToLists( $subscriber['email'], $list_ids );
1797
+ $response = array( 'status' => '1', 'message' => $response_ok );
1798
+
1799
  }
1800
  } catch (\Exception $e) {
1801
+ $error_message = $e->getMessage();
1802
+ $response = array( 'status' => '0', 'message' => $error_message );
1803
  }
1804
+
1805
  }
1806
 
1807
+ break;
1808
 
1809
+ // Mailster integration
1810
  case 'mailster':
1811
+ $response = array( 'status' => '0', 'message' => __('Something went wrong please try again later.', 'cmp-coming-soon-maintenance') );
1812
  $mailster_list_id = get_option('niteoCS_mailster_list_selected');
1813
 
1814
+ if ( function_exists( 'mailster' ) ){
1815
  // define to overwrite existing users
1816
  $overwrite = true;
1817
 
1822
  'email' => $email,
1823
  'firstname' => $firstname,
1824
  'lastname' => $lastname,
1825
+ 'status' => get_option( 'niteoCS_mailster_double_opt', '1' ) ? 0 :1
1826
  );
1827
 
1828
  // add a new subscriber and $overwrite it if exists
1829
+ $subscriber_id = mailster( 'subscribers' )->add( $subscriber, $overwrite );
1830
 
1831
  // if result isn't a WP_error assign the lists
1832
+ if ( ! is_wp_error( $subscriber_id ) ) {
1833
+ mailster( 'subscribers' )->assign_lists( $subscriber_id, $mailster_list_id );
1834
+ $response = array( 'status' => '1', 'message' => $response_ok);
1835
+
1836
  } else {
1837
+ $response = array( 'status' => '0', 'message' => $subscriber_id->get_error_message() );
1838
  }
1839
  }
1840
 
1841
+ break;
1842
 
1843
+ default:
1844
+ break;
1845
+ }
1846
 
1847
+ // if not email, set response invalid
1848
  } else {
1849
+ $response = array( 'status' => '0', 'message' => $response_invalid);
1850
  }
1851
  endif;
1852
 
1853
+ if ( $ajax === TRUE ) {
1854
+ echo json_encode( $response );
1855
  wp_die();
1856
+
1857
  } else {
1858
+ return ( $response == '' ) ? $response : json_encode( $response );
1859
  }
1860
+
1861
  }
1862
 
1863
+ public function niteo_export_csv() {
 
1864
 
1865
+ if ( !current_user_can('publish_pages') ) {
1866
  die('Sorry, but this request is invalid');
1867
  }
1868
 
1869
+ check_ajax_referer( 'cmp-coming-soon-ajax-secret', 'security' );
1870
 
1871
  // load subscribers array
1872
  $subscribers = get_option('niteoCS_subscribers_list');
1873
 
1874
+ if( !empty($subscribers) ) {
1875
  $filename = 'cmp-subscribers-export-' . date('Y-m-d') . '.csv';
1876
 
1877
  header('Content-Type: text/csv');
1878
+ header('Content-Disposition: attachment;filename='.$filename);
1879
 
1880
  $fp = fopen('php://output', 'w');
1881
 
1882
+ fputcsv($fp, array(
1883
+ __('ID','cmp-coming-soon-maintenance'),
1884
+ __('Date','cmp-coming-soon-maintenance'),
1885
+ __('Email','cmp-coming-soon-maintenance'),
1886
+ __('Firstname','cmp-coming-soon-maintenance'),
1887
+ __('Lastname','cmp-coming-soon-maintenance'),
1888
+ __('Fullname', 'cmp-coming-soon-maintenance')
 
 
1889
  )
1890
  );
1891
+ foreach ( $subscribers as $key => $value ) {
1892
 
1893
+ if ( isset( $value['ip_address'] ) ) {
1894
  unset($subscribers[$key]['ip_address']);
1895
  }
1896
 
1897
+ if ( isset( $value['timestamp'] ) ) {
1898
+ $format="Y-m-d H:i:s";
1899
  $subscribers[$key]['timestamp'] = date_i18n($format, $subscribers[$key]['timestamp']);
1900
  }
1901
 
1902
  $subscribers[$key]['Name'] = '';
1903
 
1904
+ if ( $value['firstname'] !== '' || $value['lastname'] !== '' ) {
1905
  $subscribers[$key]['Name'] = $value['firstname'] . ' ' . $value['lastname'];
1906
  }
1907
 
1908
  $subscribers[$key]['Name'] = trim($subscribers[$key]['Name']);
1909
+
1910
  }
1911
 
1912
+ foreach ( $subscribers as $key => $value ) {
1913
+ fputcsv($fp, $value, $delimiter = ',', $enclosure = '"' );
1914
  }
1915
 
1916
  fclose($fp);
1918
  die();
1919
  }
1920
 
1921
+ public function cmp_allow_mimes( $mimes = array() ) {
 
1922
  // add your own extension here - as many as you like
1923
+ $mimes['zip'] = 'application/zip';
1924
+
1925
  return $mimes;
1926
  }
1927
 
1928
+ public function cmp_allow_font_mimes( $mimes = array() ) {
 
1929
  // add your own extension here - as many as you like
1930
  $mimes['woff'] = 'application/x-font-woff';
1931
  $mimes['woff2'] = 'application/x-font-woff2';
1932
  $mimes['ttf'] = 'application/x-font-ttf';
1933
  $mimes['eot'] = 'application/vnd.ms-fontobject';
1934
  $mimes['otf'] = 'font/otf';
1935
+ if ( current_user_can('administrator') ) {
1936
  $mimes['svg'] = 'image/svg+xml';
1937
  }
1938
  return $mimes;
1939
  }
1940
 
1941
+ public function cmp_admin_notice() {
 
1942
  global $pagenow;
1943
 
1944
  // display save messages
1945
+ if ( isset($_GET['page']) && ($_GET['page'] == 'cmp-settings' || $_GET['page'] == 'cmp-translate' || $_GET['page'] == 'cmp-advanced') ) {
1946
  if (isset($_GET['status']) && $_GET['status'] == 'settings-saved') {
1947
  $status = 'success';
1948
  $message = __('CMP Settings Saved', 'cmp-coming-soon-maintenance');
1949
 
1950
+ echo '<div class="notice notice-'.$status.' is-dismissible"><p>'.$message.'.</p></div>';
1951
  }
1952
  }
1953
 
1954
  // display activation notice
1955
+ if ( !get_option( 'niteoCS_activation_notice' ) ) {
1956
+ if ( ( $pagenow == 'plugins.php') ) {
1957
  // load the notices view
1958
+ require_once( dirname( __FILE__) . '/inc/cmp-activation-notice.php' );
1959
  }
1960
  }
1961
  return;
1962
+ }
1963
 
1964
  // convert hex to rgba
1965
+ public function hex2rgba ( $hex, $opacity = null ) {
1966
+ list( $red, $green, $blue ) = sscanf( $hex, '#%02x%02x%02x' );
 
1967
 
1968
+ if ( $opacity === null ) {
1969
  return $red . ',' . $green . ',' . $blue;
1970
  }
1971
 
1972
+ $rgba = 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $opacity.')';
1973
 
1974
  return $rgba;
1975
  }
1976
 
1977
  // convert hex to hsl css
1978
+ public function hex2hsl( $hex, $opacity ) {
 
1979
 
1980
+ if ( $hex[0] != '#' ) {
1981
+ $rgba = explode( ',', $hex);
1982
  $rgba[3] = str_replace(')', '', $rgba[3]);
1983
+ $rgba[3] = $rgba[3] - ( $opacity / 100 );
1984
  $rgba = $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ',' . $rgba[3] . ')';
1985
  return $rgba;
1986
  }
1987
 
1988
+ list( $red, $green, $blue ) = sscanf( $hex, '#%02x%02x%02x' );
1989
 
1990
  $r = $red / 255.0;
1991
  $g = $green / 255.0;
1994
  $S = 0;
1995
  $V = 0;
1996
 
1997
+ $min = min( $r, $g, $b );
1998
+ $max = max( $r, $g, $b );
1999
+ $delta = ( $max - $min );
2000
 
2001
+ $L = ( $max + $min ) / 2.0;
2002
 
2003
+ if( $delta == 0 ) {
2004
  $H = 0;
2005
  $S = 0;
2006
  } else {
2007
+ $S = $L > 0.5 ? $delta / ( 2 - $max - $min ) : $delta / ( $max + $min );
2008
 
2009
+ $dR = ( ( ( $max - $r ) / 6) + ( $delta / 2 ) ) / $delta;
2010
+ $dG = ( ( ( $max - $g ) / 6) + ( $delta / 2 ) ) / $delta;
2011
+ $dB = ( ( ( $max - $b ) / 6) + ( $delta / 2 ) ) / $delta;
2012
 
2013
+ if ( $r == $max )
2014
  $H = $dB - $dG;
2015
+ else if( $g == $max )
2016
+ $H = ( 1/3 ) + $dR - $dB;
2017
  else
2018
+ $H = ( 2/3 ) + $dG - $dR;
2019
 
2020
+ if ( $H < 0 )
2021
  $H += 1;
2022
+ if ( $H > 1 )
2023
  $H -= 1;
2024
  }
2025
 
2026
+ $HSL = array( 'hue' => round( ($H*360), 0 ), 'saturation'=> round( ($S*100), 0 ), 'luminosity' => round( ( $L*100 ), 0) );
2027
 
2028
  // if color is white {
2029
+ if ( $HSL['hue'] == 0 && $HSL['saturation'] == 0) {
2030
  $requested_lumi = $HSL['luminosity'] + $opacity;
2031
  } else {
2032
  $requested_lumi = $HSL['luminosity'] - $opacity;
2033
  }
2034
+
2035
  $requested_lumi = (int)round($requested_lumi);
2036
 
2037
+ if ( $requested_lumi > 90 ) {
2038
+
2039
  $requested_lumi = 90;
2040
  }
2041
 
2042
+ $HSL = 'hsl( '. $HSL['hue'] .', '.( $HSL['saturation']) .'%, '. $requested_lumi . '%)';
2043
  return $HSL;
2044
  }
2045
 
2046
  // check if mobile
2047
+ public function isMobile() {
2048
+ if ( isset($_SERVER["HTTP_USER_AGENT"]) ) {
 
2049
  return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
2050
+
2051
  } else {
2052
  return false;
2053
  }
2054
  }
2055
 
2056
  // sanitize function
2057
+ public function sanitize_checkbox( $input ) {
2058
+ return ( ( isset( $input ) && true == $input ) ? '1' : '0' );
 
2059
  }
2060
 
2061
  // sanitize function
2062
+ public function niteo_sanitize_html( $html ) {
 
2063
 
2064
+ if ( !current_user_can( 'unfiltered_html' ) ) {
2065
+ $allowed = wp_kses_allowed_html( 'post' );
2066
+ $html = wp_kses( $html, $allowed );
2067
+ }
2068
 
2069
+ return $html;
2070
  }
2071
 
2072
  // public function to sort social icons
2073
+ public function sort_social($a, $b){
2074
+ if ( $a['hidden'] == $b['hidden'] ) {
2075
+ if( $a['order'] == $b['order'] ) {
2076
+ return 0;
2077
+ }
2078
+ return $a['order'] < $b['order'] ? -1 : 1;
2079
+ } else {
2080
+ return $a['hidden'] > $b['hidden'] ? 1 : -1;
2081
+ }
2082
+ }
2083
+
2084
+ // public function to shift multidimensional array
2085
+ public function customShift($array, $name){
2086
+
2087
+ foreach($array as $key => $val){ // loop all elements
2088
+ if($val['name'] == $name){ // check for id $id
2089
+ unset($array[$key]); // unset the $array with id $id
2090
+ array_unshift($array, $val); // unshift the array with $val to push in the beginning of array
2091
+ return $array; // return new $array
2092
+ }
2093
+ }
2094
+ }
2095
+
2096
+ public function get_youtube_img( $youtube_url ) {
2097
+ $yt_id = $this->get_youtube_id( $youtube_url );
 
 
 
2098
 
2099
  $youtube_image = 'http://img.youtube.com/vi/' . $yt_id . '/hqdefault.jpg';
2100
 
2102
  }
2103
 
2104
 
2105
+ public function get_youtube_id( $youtube_url ) {
 
2106
  $youtube = preg_match('/.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/', $youtube_url, $url);
2107
 
2108
  return $url[7];
2109
  }
2110
 
2111
+ public function cmp_get_pages( $post_status = 'publish,draft', $builder = false) {
 
2112
  $meta_query = array();
2113
  $pages = array();
2114
 
2115
  // meta_query for pages built by elementor
2116
+ if ( $builder === 'elementor' ) {
2117
  $meta_query = array(
2118
  'key' => '_elementor_edit_mode',
2119
  'compare' => 'EXISTS'
2120
  );
2121
  }
2122
  // meta_query for pages built by Divi
2123
+ if ( $builder === 'divi' ) {
2124
  $meta_query = array(
2125
  'key' => '_et_pb_use_builder',
2126
  'compare' => 'EXISTS'
2134
  'meta_query' => array($meta_query)
2135
  );
2136
 
2137
+ $the_query = new WP_Query( $args );
 
 
2138
 
2139
+ if ( $the_query->have_posts() ) {
2140
+
2141
+ foreach( $the_query->posts as $post ) {
2142
  // check for gutenberg pages
2143
+ if ( $builder === 'gutenberg' && !has_blocks($post->ID) ) {
2144
  continue;
2145
  }
2146
 
2154
  }
2155
 
2156
  // send json data for theme info overlay AJAX request
2157
+ public function niteo_themeinfo( ) {
 
2158
 
2159
  // check for ajax
2160
+ if ( isset( $_POST['theme_slug'] ) ) {
2161
  // verify nonce
2162
+ check_ajax_referer( 'cmp-coming-soon-ajax-secret', 'security' );
2163
  // verify user rights
2164
+ if( !current_user_can('publish_pages') ) {
2165
  die('Sorry, but this request is invalid');
2166
  }
2167
 
2168
 
2169
  // sanitize $post
2170
+ $theme_slug = sanitize_text_field( $_POST['theme_slug'] );
2171
+ $data = array( 'result' => 'true', 'author_homepage' => CMP_AUTHOR_HOMEPAGE, 'author' => CMP_AUTHOR );
2172
+
2173
+ if ( !empty( $theme_slug ) ) {
2174
  $headers = array('Theme Name', 'Description');
2175
+ $theme_info = get_file_data(plugin_dir_path( __FILE__ ).'/themes/'. $theme_slug. '.txt', $headers, '');
 
 
2176
 
2177
+ $screenshots = array_map( 'basename', glob( plugin_dir_path( __FILE__ ) . 'img/thumbnails/'.$theme_slug.'/*' ) );
2178
+
2179
+ foreach ( $screenshots as $key => $screenshot ) {
2180
+ $screenshots[$key] = plugins_url('img/thumbnails/'.$theme_slug.'/'.$screenshot, __FILE__ );
2181
  }
2182
 
2183
+ $data['name'] = $theme_info[0];
2184
+ $data['description'] = $theme_info[1];
2185
+ $data['screenshots'] = $screenshots;
2186
  }
2187
 
2188
+ echo json_encode ($data);
2189
  wp_die();
2190
+ }
2191
+ }
2192
+
2193
+ // legacy function for premium themes redirect
2194
+ public function niteo_redirect() {
2195
+ return;
2196
+ }
2197
+
2198
+ // returns array of google fonts from /inc/webfonts.php
2199
+ public function cmp_get_google_fonts() {
2200
+ $fonts = include_once wp_normalize_path( dirname( __FILE__ ) . '/inc/webfonts.php' );
2201
+ $google_fonts = json_decode( $fonts, true);
2202
+
2203
+ return $google_fonts;
2204
+ }
2205
+
2206
+ public function cmp_google_variant_title( $variant ) {
2207
+
2208
+ switch( $variant ) {
2209
+ case '100':
2210
+ return 'Thin 100';
2211
+ break;
2212
+ case '100italic':
2213
+ return 'Thin 100 Italic';
2214
+ break;
2215
+ case '200':
2216
+ return 'Extra-light 200';
2217
+ break;
2218
+ case '200italic':
2219
+ return 'Extra-light 200 Italic';
2220
+ break;
2221
+ case '300':
2222
+ return 'Light 300';
2223
+ break;
2224
+ case '300italic':
2225
+ return 'Light 300 Italic';
2226
+ break;
 
 
 
2227
  case '400':
2228
  case 'regular':
2229
+ return 'Regular 400';
2230
+ break;
2231
  case '400italic':
2232
  case 'italic':
2233
+ return 'Regular 400 Italic';
2234
+ break;
2235
+ case '500':
2236
+ return 'Medium 500';
2237
+ break;
2238
+ case '500italic':
2239
+ return 'Meidum 500 Italic';
2240
+ break;
2241
+ case '600':
2242
+ return 'Semi-Bold 600';
2243
+ break;
2244
+ case '600italic':
2245
+ return 'Semi-Bold 600 Italic';
2246
+ break;
2247
+ case '700':
2248
+ return 'Bold 700';
2249
+ break;
2250
+ case '700italic':
2251
+ return 'Bold 700 Italic';
2252
+ break;
2253
+ case '800':
2254
+ return 'Extra-Bold 800';
2255
+ break;
2256
+ case '800italic':
2257
+ return 'Extra-Bold Italic';
2258
+ break;
2259
+ case '900':
2260
+ return 'Black 900';
2261
+ break;
2262
+ case '900italic':
2263
+ return 'Black 900 Italic';
2264
+ break;
2265
  case 'Not Applicable':
2266
  return 'Not Applicable';
2267
  break;
2268
+ default:
2269
+ break;
2270
  }
2271
  }
2272
 
2273
  // returns true if current page should display CMP page
2274
  // since 2.2
2275
+ public function cmp_page_filter() {
 
2276
  global $wp;
2277
 
2278
  $uri = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] : '';
2279
+
2280
+ $current_url = trailingslashit( (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $uri );
2281
 
2282
  $custom_login_url = get_option('niteoCS_custom_login_url', '');
2283
 
2284
  // return early if login page or ajax call
2285
+ if ( fnmatch( '*wp-login.php*', $current_url ) || wp_doing_ajax() ) {
2286
  return false;
2287
  }
2288
 
2289
  // return early if custom login page
2290
+ if ( $custom_login_url !== '' && fnmatch('*'.$custom_login_url.'*', $current_url) ) {
2291
  return false;
2292
  }
2293
 
2294
  // WPS HIDE login integration
2295
+ if ( defined('WPS_HIDE_LOGIN_BASENAME') ) {
2296
+ if ( fnmatch('*'.get_option( 'whl_page' ), $current_url) ) {
2297
  return false;
2298
  }
2299
  }
2300
 
2301
  // allow / block RSS
2302
+ if ( get_option('niteoCS_rss_status', '1') && is_feed() ) {
2303
  return false;
2304
  }
2305
 
2306
  // get current page IDs
2307
+ if ( is_front_page() && is_home() ) {
2308
  // default homepage
2309
+ $page_id = '-1';
2310
+ } elseif ( is_front_page() ) {
2311
+ // static homepage
2312
  $page_id = '-1';
2313
+ } elseif ( is_home() ) {
 
 
 
2314
  // posts page
2315
+ $page_id = get_option( 'page_for_posts' );
2316
  } else {
2317
+ //everyting else
2318
+ $page_id = get_the_ID();
2319
  }
2320
 
2321
  // check whitelist or blacklist and return true/false
2322
+ switch ( get_option('niteoCS_page_filter', '0') ) {
2323
+ // disabled return true
2324
  case '0':
2325
  return true;
2326
  break;
2327
 
2328
+ // whitelist
2329
  case '1':
2330
+ $whitelist = json_decode( get_option('niteoCS_page_whitelist', '[]'), true );
2331
+ if ( !empty( $whitelist ) && in_array( $page_id, $whitelist ) ) {
2332
  return true;
2333
  }
2334
 
2335
  $page_wl_custom = json_decode(get_option('niteoCS_page_whitelist_custom', '[]'), true);
2336
+ if ( !empty( $page_wl_custom ) ) {
2337
+ foreach ( $page_wl_custom as $url ) {
2338
+ if ( fnmatch( $url, $current_url ) ) {
2339
  return true;
2340
  }
2341
  }
2344
  return false;
2345
  break;
2346
 
2347
+ // blacklist
2348
  case '2':
2349
+ $blacklist = json_decode( get_option('niteoCS_page_blacklist', '[]'), true );
2350
 
2351
+ if ( !empty( $blacklist ) && in_array( $page_id, $blacklist ) ) {
2352
  return false;
2353
  }
2354
 
2355
  $page_bl_custom = json_decode(get_option('niteoCS_page_blacklist_custom', '[]'), true);
2356
 
2357
+ if ( !empty( $page_bl_custom ) ) {
2358
+ foreach ($page_bl_custom as $url ) {
2359
+ if ( fnmatch( $url, $current_url ) ) {
2360
  return false;
2361
  }
2362
  }
2375
 
2376
  // returns true if logged in user meet CMP roles filter
2377
  // since 2.2
2378
+ public function cmp_roles_filter() {
2379
+ $roles = json_decode( get_option('niteoCS_roles', '[]'), true );
 
2380
  // push WP administrator to roles array, since it is default
2381
+ array_push( $roles, 'administrator' );
2382
 
2383
  $current_user = wp_get_current_user();
2384
 
2385
+ foreach ( $current_user->roles as $role ) {
2386
+ if ( in_array( $role, $roles ) ) {
2387
  return true;
2388
  }
2389
  };
2392
  }
2393
 
2394
 
2395
+ public function add_action_links( $links ) {
2396
+ $settings = array(
2397
+ '<a href="' . admin_url( 'admin.php?page=cmp-settings' ) . '">CMP Settings</a>',
2398
+ );
2399
+ return array_merge( $settings, $links );
 
2400
  }
2401
 
2402
 
2403
  // returns version of selected CMP theme
2404
+ public function cmp_theme_version( $theme_slug ) {
 
2405
 
2406
  $version = CMP_VERSION;
2407
 
2408
  // if premium theme style.css exists get its version
2409
+ if ( in_array( $theme_slug, $this->cmp_premium_themes_installed() ) ) {
2410
+ if ( file_exists( CMP_PREMIUM_THEMES_DIR . $theme_slug . '/style.css' ) ) {
2411
+ $version = get_file_data( CMP_PREMIUM_THEMES_DIR . $theme_slug . '/style.css', array('Version'), '' );
2412
  }
2413
+
2414
+ }
2415
 
2416
  // if we have local version of theme and not in updating theme
2417
+ if ( is_array( $version ) ) {
2418
  $version = $version[0];
2419
  }
2420
 
2428
  * @access public
2429
  * @return Object
2430
  */
2431
+ public function cmp_mailchimp_list_ajax( $apikey ) {
 
2432
 
2433
  // check for ajax
2434
+ if ( isset( $_POST['params'] ) ) {
2435
  // verify nonce
2436
+ check_ajax_referer( 'cmp-coming-soon-ajax-secret', 'security' );
2437
  // verify user rights
2438
+ if( !current_user_can('publish_pages') ) {
2439
  die('Sorry, but this request is invalid');
2440
  }
2441
 
2443
  $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
2444
 
2445
  // check params
2446
+ if ( !empty( $_POST['params'] ) ) {
2447
  $params = $_POST['params'];
2448
  }
2449
 
2450
  $api_key = $params['apikey'];
2451
 
2452
+ $dc = substr( $api_key,strpos($api_key,'-') + 1 ); // datacenter, it is the part of your api key - us5, us8 etc
2453
 
2454
  $args = array(
2455
+ 'headers' => array(
2456
+ 'Authorization' => 'Basic ' . base64_encode( 'user:'. $api_key )
2457
  )
2458
  );
2459
 
2460
 
2461
  // retrieve response from mailchimp
2462
+ $response = wp_remote_get( 'https://'.$dc.'.api.mailchimp.com/3.0/lists/', $args );
2463
+
2464
  // if we have it, create new array with lists id and name, else push error messages into array
2465
+ if ( !is_wp_error( $response ) ) {
2466
  $lists_array = array();
2467
 
2468
+ $body = json_decode( $response['body'], true);
2469
 
2470
+ if ( $response['response']['code'] == 200 ) {
2471
  $lists_array['response'] = 200;
2472
  $i = 0;
2473
+ foreach ( $body['lists'] as $list ) {
2474
  $lists_array['lists'][$i]['id'] = $list['id'];
2475
  $lists_array['lists'][$i]['name'] = $list['name'];
2476
  $i++;
2477
  }
2478
+
2479
  } else {
2480
  $lists_array['response'] = $response['response']['code'];
2481
  $lists_array['message'] = $body['title'] . ': ' . $body['detail'];
2482
  }
2483
+
2484
  } else {
2485
  $lists_array['response'] = '500';
2486
  $lists_array['message'] = $response->get_error_message();
2487
  }
2488
 
2489
  // json encode response
2490
+ $lists_json = json_encode( $lists_array );
2491
 
2492
  // save it
2493
  update_option('niteoCS_mailchimp_lists', $lists_json);
2498
  // echo ajax result
2499
  echo $lists_json;
2500
  wp_die();
2501
+
2502
+ }
2503
+
2504
  }
2505
 
2506
  /**
2510
  * @access public
2511
  * @return string
2512
  */
2513
+ public function cmp_get_background_img_for_seo() {
2514
+
 
2515
  $themeslug = $this->cmp_selectedTheme();
2516
  $default_img = '';
2517
 
2518
  $background_type = get_option('niteoCS_banner', '2');
2519
 
2520
+ if ( file_exists( $this->cmp_theme_dir( $this->cmp_selectedTheme() ).$this->cmp_selectedTheme().'/img/'.$this->cmp_selectedTheme().'_banner_large.jpg' ) ) {
2521
+ $default_img = $this->cmp_themeURL( $this->cmp_selectedTheme() ).$this->cmp_selectedTheme().'/img/'.$this->cmp_selectedTheme().'_banner_large.jpg';
2522
+ } elseif ( file_exists( $this->cmp_theme_dir( $this->cmp_selectedTheme() ).$this->cmp_selectedTheme().'/img/'.$this->cmp_selectedTheme().'_banner_large.png' ) ) {
2523
+ $default_img = $this->cmp_themeURL( $this->cmp_selectedTheme() ).$this->cmp_selectedTheme().'/img/'.$this->cmp_selectedTheme().'_banner_large.png';
2524
  }
2525
 
2526
+ switch ( $background_type ) {
2527
+ // custom img
2528
  case '0':
2529
+ $banner_id = get_option('niteoCS_banner_id');
2530
+
2531
+ if ( $banner_id != '' ) {
2532
+ $banner_ids = explode(',', $banner_id);
2533
+ $image_url = wp_get_attachment_image_src( $banner_ids[0], 'large');
2534
+
2535
+ if ( isset( $image_url[0] ) ) {
2536
+ $image_url = $image_url[0];
2537
+ }
2538
+
2539
+ } else {
2540
+ // send default image
2541
+ $image_url = $default_img;
2542
+ }
2543
+
2544
+ break;
2545
+ // unsplash
2546
+ case '1':
2547
+ $unplash_feed = get_option('niteoCS_unsplash_feed', '3');
2548
+
2549
+ switch ( $unplash_feed ) {
2550
+ // specific photo from id
2551
+ case '0':
2552
+ $params = array('feed' => '0', 'url' => get_option('niteoCS_unsplash_0', '') );
2553
+ $unsplash = $this->niteo_unsplash( $params );
2554
+ break;
2555
+
2556
+ // random from user
2557
+ case '1':
2558
+ $params = array('feed' => '1', 'custom_str' => get_option('niteoCS_unsplash_1', '') );
2559
+ $unsplash = $this->niteo_unsplash( $params );
2560
+ break;
2561
+
2562
+ // random from collection
2563
+ case '2':
2564
+ $params = array('feed' => '2', 'url' => get_option('niteoCS_unsplash_2', '') );
2565
+ $unsplash = $this->niteo_unsplash( $params );
2566
+ break;
2567
+
2568
+ // random photo
2569
+ case '3':
2570
+ $params = array('feed' => '3', 'url' => get_option('niteoCS_unsplash_3', ''), 'feat' => get_option('niteoCS_unsplash_feat', '0') );
2571
+ $unsplash = $this->niteo_unsplash( $params );
2572
+ break;
2573
+ default:
2574
+ break;
2575
+ }
2576
+
2577
+ // get raw url from response
2578
+ if ( isset( $unsplash['response'] ) && $unsplash['response'] == '200' ) {
2579
+ $body = json_decode ($unsplash['body'], true );
2580
+
2581
+ if ( isset( $body[0] ) ) {
2582
+ foreach ( $body as $item ) {
2583
+ $unsplash_url = $item['urls']['raw'];
2584
+ }
2585
+ } else {
2586
+ $unsplash_url = $body['urls']['raw'];
2587
+ }
2588
+
2589
+ $image_url = $unsplash_url . '?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&fit=crop&w=1200&h=630';
2590
+ }
2591
+
2592
+ break;
2593
+ // default image
2594
+ case '2':
2595
+ $image_url = $default_img;
2596
+ break;
2597
+
2598
+ case '3':
2599
+ // Pattern
2600
+ $niteoCS_banner_pattern = get_option('niteoCS_banner_pattern', 'sakura');
2601
+
2602
+ if ( $niteoCS_banner_pattern != 'custom' ) {
2603
+ $image_url = CMP_PLUGIN_URL.'img/patterns/'.esc_attr($niteoCS_banner_pattern).'.png';
2604
+
2605
+ } else {
2606
+ $image_url = get_option('niteoCS_banner_pattern_custom');
2607
+ $image_url = wp_get_attachment_image_src( $image_url, 'large' );
2608
+ if ( isset($image_url[0]) ){
2609
+ $image_url = $image_url[0];
2610
+ }
2611
+ }
2612
+
2613
+ break;
2614
+
2615
+ case '5':
2616
+ $image_url = wp_get_attachment_image_src( get_option('niteoCS_video_thumb'), 'large' );
2617
+
2618
+ if ( !empty( $image_url ) ) {
2619
+ $image_url = $image_url[0];
2620
+ }
2621
+
2622
+ break;
2623
+
2624
+ case '6':
2625
+ case '4':
2626
+ default:
2627
+ $image_url = '';
2628
+ break;
2629
+ }
2630
+
2631
+ return $image_url;
2632
  }
2633
 
2634
 
2639
  * @access public
2640
  * @return string
2641
  */
2642
+ public function cmp_purge_cache() {
 
2643
 
2644
  // WP cache
2645
  wp_cache_flush();
2646
 
2647
  // W3 Total Cache
2648
+ if ( function_exists('w3tc_flush_all') ) {
2649
  w3tc_flush_all();
2650
  }
2651
 
2652
+ // wp super cache
2653
+ if ( function_exists( 'wp_cache_clear_cache' ) ) {
2654
  wp_cache_clear_cache();
2655
+ }
2656
 
2657
  // Clear Cachify Cache
2658
+ if ( has_action('cachify_flush_cache') ) {
2659
  do_action('cachify_flush_cache');
2660
  }
2661
+
2662
+ // endurance cache
2663
+ if ( class_exists( 'Endurance_Page_Cache' ) && method_exists('Endurance_Page_Cache','purge_all')) {
2664
  $epc = new Endurance_Page_Cache;
2665
  $epc->purge_all();
2666
+ }
2667
 
2668
+ // SG Optimizer
2669
+ if ( class_exists( 'SG_CachePress_Supercacher' ) && method_exists( 'SG_CachePress_Supercacher', 'purge_cache' ) ) {
2670
+ SG_CachePress_Supercacher::purge_cache( true );
2671
+ }
2672
 
2673
  if (class_exists('SiteGround_Optimizer\Supercacher\Supercacher')) {
2674
  SiteGround_Optimizer\Supercacher\Supercacher::purge_cache();
2675
  }
2676
 
2677
+ // WP Fastest Cache
2678
+ if ( isset( $GLOBALS['wp_fastest_cache'] ) && method_exists( $GLOBALS['wp_fastest_cache'], 'deleteCache' ) ) {
2679
+ $GLOBALS['wp_fastest_cache']->deleteCache( true );
2680
+ }
2681
 
2682
+ // Swift Performance
2683
+ if ( is_callable( array( 'Swift_Performance_Cache', 'clear_all_cache' ) ) ) {
2684
  Swift_Performance_Cache::clear_all_cache();
2685
+ }
2686
 
2687
+ // WP Rocket
2688
+ if ( function_exists( 'rocket_clean_domain' ) ) {
2689
+ rocket_clean_domain();
2690
  }
2691
 
2692
  if (is_callable(array('Hummingbird\WP_Hummingbird', 'flush_cache'))) {
2693
  Hummingbird\WP_Hummingbird::flush_cache(true, false);
2694
+ }
2695
 
2696
  // wp-optimize
2697
+ if ( class_exists('WP_Optimize') ) {
2698
  if (!class_exists('WP_Optimize_Cache_Commands')) include_once(WPO_PLUGIN_MAIN_PATH . 'cache/class-cache-commands.php');
2699
  $cache_commands = new WP_Optimize_Cache_Commands();
2700
  $cache_commands->purge_page_cache();
2701
  }
2702
 
2703
  // Clear Litespeed cache
2704
+ if ( class_exists('LiteSpeed_Cache_API') && method_exists( 'LiteSpeed_Cache_API', 'purge_all' ) ) {
2705
  LiteSpeed_Cache_API::purge_all();
2706
  }
2707
 
2708
  if (function_exists('rocket_clean_domain')) {
2709
  rocket_clean_domain();
2710
+ }
2711
  }
2712
 
2713
  /**
2717
  * @access public
2718
  * @return boolean
2719
  */
2720
+ public function cmp_user_can_admin_bar_activation() {
 
2721
 
2722
  // return if Top Bar Icon is disabled
2723
+ if ( get_option('niteoCS_topbar_icon', '1') == '0' ) {
2724
  return false;
2725
  }
2726
+
2727
+ require_once(ABSPATH . 'wp-admin/includes/screen.php');
2728
 
2729
  // get defined roles for admin topbar access
2730
+ $roles_topbar = json_decode( get_option('niteoCS_roles_topbar', '[]'), true );
2731
 
2732
  // push WP administrator to roles array, since it is default
2733
+ array_push( $roles_topbar, 'administrator' );
2734
 
2735
  // get current user
2736
  $current_user = wp_get_current_user();
2737
 
2738
  // if current user can access topbar, return true
2739
+ foreach ( $current_user->roles as $role ) {
2740
+ if ( in_array( $role, $roles_topbar ) ) {
2741
  return true;
2742
  }
2743
  }
2752
  * @access public
2753
  * @return array
2754
  */
2755
+ public function cmp_get_post_detail() {
 
2756
  $id = isset($_POST['id']) ? esc_attr($_POST['id']) : '';
2757
  $size = $this->isMobile ? 'large' : 'large';
2758
 
2764
  'url' => '',
2765
  );
2766
 
2767
+ if ( get_post_status( $id ) === 'publish' && !post_password_required( $id ) ) {
2768
 
2769
  $post = array(
2770
+ 'img' => get_the_post_thumbnail( $id, $size ),
2771
+ 'date' => get_the_date( 'F j, Y', $id ),
2772
+ 'title' => get_the_title( $id ),
2773
+ 'body' => apply_filters( 'the_content', get_post_field('post_content', $id) ),
2774
+ 'url' => get_the_permalink( $id ),
2775
  );
2776
  }
2777
 
2778
+ wp_send_json( $post );
2779
+
2780
  }
2781
 
2782
  /**
2786
  * @access public
2787
  * @return void
2788
  */
2789
+ function cmp_ajax_dismiss_activation_notice() {
2790
+ check_ajax_referer( 'cmp-coming-soon-maintenance-nonce', 'nonce' );
 
2791
  // user has dismissed the welcome notice
2792
+ update_option( 'niteoCS_activation_notice', true );
2793
  wp_die();
2794
  exit;
2795
  }
2801
  * @access public
2802
  * @return string
2803
  */
2804
+ public function cmp_ajax_upload_font() {
 
2805
  // verify nonce
2806
+ check_ajax_referer( 'cmp-coming-soon-ajax-secret', 'security' );
2807
 
2808
  // verify user rights
2809
+ if( !current_user_can('publish_pages') ) {
2810
  die('Sorry, but this request is invalid');
2811
  }
2812
+
2813
 
2814
+ if ( isset($_POST['payload']) ) {
2815
 
2816
+ $payload = json_decode( stripslashes($_POST['payload']), true );
 
 
2817
  $action = $payload['action'];
2818
 
2819
+ if ( $action === 'upload_font' ) {
2820
+
2821
  $new_fonts = $payload['files'];
2822
 
2823
  // delete_option('niteoCS_custom_fonts');
2824
 
2825
+ if ( get_option('niteoCS_custom_fonts') ) {
2826
 
2827
+ $old_fonts = json_decode( get_option('niteoCS_custom_fonts'), true );
2828
 
2829
  $i = 0;
2830
 
2831
+ foreach ( $old_fonts as $old_font ) {
2832
+
2833
+ foreach ( $new_fonts as $new_font ) {
2834
+ if ( $old_font['id'] === $new_font['id'] ) {
2835
 
2836
+ $old_fonts[$i]['urls'] = ( is_array($old_font['urls']) ) ? array_unique(array_merge( $old_font['urls'], $new_font['urls'] )) : $new_font['urls'];
2837
+ $old_fonts[$i]['ids'] = ( is_array($old_font['ids']) ) ? array_unique(array_merge( $old_font['ids'], $new_font['ids'] )) : $new_font['ids'];
2838
 
2839
+ } else if ( !$this->niteo_in_array_r($new_font['id'], $old_fonts) ) {
 
 
2840
  array_push($old_fonts, $new_font);
2841
  }
2842
  }
2843
 
2844
+ $i++;
2845
  }
2846
 
2847
  $new_fonts = $old_fonts;
2848
+ }
2849
+
2850
+ update_option( 'niteoCS_custom_fonts', json_encode( $new_fonts ) );
2851
 
 
2852
  }
2853
+
2854
  }
2855
 
2856
  // echo confirmation
2865
  * @access public
2866
  * @return string
2867
  */
2868
+ public function cmp_export_settings() {
2869
+
 
2870
  $options = array();
2871
  // add default cmp identifier
2872
  $options[0] = 'CMP_EXPORT';
2873
 
2874
  global $wpdb;
2875
+ $saved_options = $wpdb->get_results( "SELECT * FROM $wpdb->options WHERE option_name LIKE 'niteoCS_%'", OBJECT );
2876
  $i = 1;
2877
 
2878
  foreach ($saved_options as $option) {
2879
 
2880
  $option_name = $option->option_name;
2881
+ $option_value = get_option( $option_name );
2882
 
2883
+ $img_settings = array( 'niteoCS_banner_id', 'niteoCS_logo_id', 'niteoCS_seo_img_id', 'niteoCS_favicon_id', 'niteoCS_subs_img_id', 'niteoCS_subs_img_popup_id' );
2884
 
2885
+ if ( in_array($option_name, $img_settings) && $option_value && $option_value != '' ) {
2886
  $option_value = $this->cmp_get_img_urls($option_value);
2887
  }
2888
 
2889
+ if ( $option_name === 'niteoCS_posts' ) {
2890
  $option_value = '[]';
2891
  }
2892
 
2893
 
2894
+ $options[$i] = array( $option_name => $option_value );
2895
  $i++;
2896
  }
2897
 
2906
  * @return string
2907
  */
2908
 
2909
+ public function cmp_get_img_urls( $ids ) {
 
2910
 
2911
  $id_array = explode(',', $ids);
2912
  $i = 1;
2914
 
2915
  foreach ($id_array as $id) {
2916
  $sep = ($i < count($id_array)) ? ',' : '';
2917
+ $image_url = wp_get_attachment_image_src( $id, 'full');
2918
 
2919
+ if ( isset( $image_url[0] ) ) {
2920
  $image_url = $image_url[0];
2921
  }
2922
 
2923
  $urls .= $image_url . $sep;
2924
+
2925
  $i++;
2926
+ }
2927
+
2928
  return $urls;
2929
+ }
2930
 
2931
  /**
2932
  * export settings to JSON via AJAX
2935
  * @access public
2936
  * @return string
2937
  */
2938
+ public function cmp_ajax_export_settings() {
 
2939
  // verify nonce
2940
+ check_ajax_referer( 'cmp-coming-soon-ajax-secret', 'security' );
2941
 
2942
  // verify user rights
2943
+ if( !current_user_can('publish_pages') ) {
2944
  die('Sorry, but this request is invalid');
2945
  }
2946
 
2949
  $replace = array('https://', 'http://');
2950
  $home_url = str_replace($replace, '', get_home_url());
2951
 
2952
+ if ( !empty($settings) ) {
2953
+ $filename = $home_url. '-cmp-settings-' . date('Y-m-d') . '.json';
2954
 
2955
  header('Content-Type: application/json');
2956
  header('Content-Disposition: attachment;filename=' . $filename);
2957
 
2958
  $fp = fopen('php://output', 'w');
2959
 
2960
+ fwrite($fp , $settings);
2961
  fclose($fp);
2962
  }
2963
  die();
2970
  * @access public
2971
  * @return string
2972
  */
2973
+ public function cmp_ajax_import_settings( ) {
 
2974
 
2975
+ check_ajax_referer( 'cmp-coming-soon-ajax-secret', 'security' );
2976
 
2977
  // verify user rights
2978
+ if( !current_user_can('publish_pages') ) {
2979
  die('Sorry, but this request is invalid');
2980
  }
2981
 
2982
+ $settings = json_decode( stripslashes($_POST['json']), true );
2983
 
2984
  $result = array(
2985
  'result' => 'success',
2986
  'message' => __('All done!', 'cmp-coming-soon-maintenance')
2987
  );
2988
 
2989
+ if ( json_last_error() == JSON_ERROR_NONE ) {
2990
+ if ( $settings[0] === 'CMP_EXPORT' ) {
2991
  // remove first value used for JSON CMP Settings check
2992
  unset($settings[0]);
2993
 
2994
  // delete all current CMP Settings
2995
  global $wpdb;
2996
+ $saved_options = $wpdb->get_results( "SELECT * FROM $wpdb->options WHERE option_name LIKE 'niteoCS_%'", OBJECT );
2997
  foreach ($saved_options as $option) {
2998
  delete_option($option->option_name);
2999
  }
3000
+
3001
  // import cmp settings from JSON structure
3002
+ foreach ( $settings as $setting ) {
3003
+
3004
+ $img_settings = array( 'niteoCS_banner_id', 'niteoCS_logo_id', 'niteoCS_seo_img_id', 'niteoCS_favicon_id', 'niteoCS_subs_img_id', 'niteoCS_subs_img_popup_id' );
3005
+
3006
  $name = key($setting);
3007
  $value = $setting[$name];
3008
+
3009
+ if ( in_array($name, $img_settings) ) {
3010
+
3011
  $urls = explode(',', $value);
3012
+
3013
  if (is_array($urls)) {
3014
+ foreach ( $urls as $url ) {
3015
  $value = $this->cmp_insert_attachment_from_url($url);
3016
  $value .= ',' . $value;
3017
  }
3018
  }
3019
  }
3020
+
3021
+ update_option( $name, $value );
3022
  }
3023
  } else {
3024
  $result = array(
3031
  'result' => 'error',
3032
  'message' => __('Please insert valid JSON file and try again.', 'cmp-coming-soon-maintenance')
3033
  );
3034
+
3035
  }
3036
 
3037
  echo json_encode($result);
3038
  wp_die();
3039
+
3040
  }
3041
 
3042
  /**
3047
  * @param Int $parent_post_id
3048
  * @return Int Attachment ID
3049
  */
3050
+ private function cmp_insert_attachment_from_url($url, $parent_post_id = null) {
 
3051
 
3052
+ if( !class_exists( 'WP_Http' ) ) {
3053
+ include_once( ABSPATH . WPINC . '/class-http.php' );
3054
  }
3055
+
3056
  $http = new WP_Http();
3057
 
3058
+ $response = $http->request( $url );
3059
 
3060
+ if( is_wp_error( $response ) || $response['response']['code'] != 200 ) {
3061
  return false;
3062
  }
3063
 
3064
+ $upload = wp_upload_bits( basename($url), null, $response['body'] );
3065
 
3066
+ if( !empty( $upload['error'] ) ) {
3067
  return false;
3068
  }
3069
 
3070
  $file_path = $upload['file'];
3071
+ $file_name = basename( $file_path );
3072
+ $file_type = wp_check_filetype( $file_name, null );
3073
+ $attachment_title = sanitize_file_name( pathinfo( $file_name, PATHINFO_FILENAME ) );
3074
  $wp_upload_dir = wp_upload_dir();
3075
  $post_info = array(
3076
  'guid' => $wp_upload_dir['url'] . '/' . $file_name,
3081
  );
3082
 
3083
  // Create the attachment
3084
+ $attach_id = wp_insert_attachment( $post_info, $file_path, $parent_post_id );
3085
  // Include image.php
3086
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
3087
  // Define attachment metadata
3088
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $file_path );
3089
  // Assign metadata to attachment
3090
+ wp_update_attachment_metadata( $attach_id, $attach_data );
3091
 
3092
  return $attach_id;
3093
  }
3098
  *
3099
  * @param String $message
3100
  */
3101
+ private function cmp_send_notification( $status ) {
 
3102
  // send notification email to admin, if enabled
3103
+ if ( get_option('niteoCS_mode_change_notification', '0') == '1' ) {
3104
+ switch ( $this->cmp_mode() ) {
3105
  case '1':
3106
+ $mode = __('Maintenance','cmp-coming-soon-maintenance');
3107
  break;
3108
  case '2':
3109
+ $mode = __('Coming Soon','cmp-coming-soon-maintenance');
3110
  break;
3111
  case '3':
3112
+ $mode = __('Redirect','cmp-coming-soon-maintenance');
3113
  break;
3114
  default:
3115
  break;
3116
  }
3117
  $current_user = wp_get_current_user();
3118
+ $email = get_option('niteoCS_mode_change_email_address', get_option( 'admin_email' ));
3119
  $subject = $mode . ' mode on your website - ' . get_site_url() . ' - was just turned ' . $status . ' by ' . $current_user->user_login;
3120
  $body = 'This is auto generated message from CMP - Coming Soon & Maintenance WordPress Plugin. You can disable these messages under CMP Advanced Settings > Email Notifications.';
3121
  $headers = array('Content-Type: text/plain; charset=UTF-8');
3122
  // send email
3123
+ wp_mail( $email, $subject, $body, $headers );
3124
  }
3125
 
3126
  return;
3131
  *
3132
  * @since 3.7.3
3133
  */
3134
+ public function cmp_display_admin_notice( $type, $dismisable, $message ) {
 
3135
 
3136
+ echo '<div class="notice notice-'.$type.' '.$dismisable.'"><p class="message">'.$message.'</p></div>';
3137
  }
3138
 
3139
  /**
3140
  * Disable REST API if required
3141
  */
3142
+ function restrict_rest_api( $result ) {
3143
+ if ( true === $result || is_wp_error( $result ) ) {
 
3144
  return $result;
3145
  }
3146
+
3147
  // No authentication has been performed yet.
3148
  // Return an error if user is not logged in.
3149
+ if ( ! is_user_logged_in() ) {
3150
  return new WP_Error(
3151
  'rest_disabled',
3152
+ __( 'JSON API is disabled by CMP – Coming Soon & Maintenance Plugin.' ),
3153
+ array( 'status' => 401 )
3154
  );
3155
  }
3156
+
3157
  }
3158
 
3159
+ function jetpack_stats_compatibility() {
3160
+ if ( function_exists( 'stats_footer' ) ) {
3161
+ add_action( 'cmp_footer', 'stats_footer', 101 );
 
3162
  }
3163
  }
3164
+
3165
  }
3166
 
3167
 
3171
  * @since 2.8.1
3172
  * @return object|CMP_Coming_Soon_and_Maintenance instance.
3173
  */
3174
+ function cmp_coming_soon_and_maintenance() {
 
3175
  return CMP_Coming_Soon_and_Maintenance::instance();
3176
  }
3177
 
3178
  // Get the things running
3179
  cmp_coming_soon_and_maintenance();
3180
 
3181
+ register_uninstall_hook( __FILE__, 'cmp_plugin_delete' );
3182
 
3183
  // And here goes the uninstallation function:
3184
+ function cmp_plugin_delete() {
3185
+ delete_option('niteoCS_archive');
 
3186
  }
3187
+
3188
+
3189
+
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: coming soon, coming soon page, launch page, maintenance mode, under constr
5
  Requires at least: 3.0
6
  Requires PHP: 5.6
7
  Tested up to: 6.0
8
- Stable tag: 4.1.3
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -160,6 +160,16 @@ https://www.youtube.com/watch?v=uxuJfHzwdtE
160
  <p>Nothing is better than a good feedback! Please go to <a href="https://wordpress.org/support/plugin/cmp-coming-soon-maintenance/reviews/">Plugin reviews</a> and rate it! Alternatively you can click on a Donate button too!:)</p>
161
 
162
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
163
  <h4>CMP 4.1.2 - 17-May-22</h4>
164
  <ul>
165
  <li>Added option to load font awesome from a local server. Requested by @blauemango</li>
5
  Requires at least: 3.0
6
  Requires PHP: 5.6
7
  Tested up to: 6.0
8
+ Stable tag: 4.1.4
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
160
  <p>Nothing is better than a good feedback! Please go to <a href="https://wordpress.org/support/plugin/cmp-coming-soon-maintenance/reviews/">Plugin reviews</a> and rate it! Alternatively you can click on a Donate button too!:)</p>
161
 
162
  == Changelog ==
163
+ <h4>CMP 4.1.4 - 11-Oct-22</h4>
164
+ <ul>
165
+ <li>Resolve counter issue in Titan theme</li>
166
+ </ul>
167
+
168
+ <h4>CMP 4.1.3 - 01-Oct-22</h4>
169
+ <ul>
170
+ <li>Small security update</li>
171
+ </ul>
172
+
173
  <h4>CMP 4.1.2 - 17-May-22</h4>
174
  <ul>
175
  <li>Added option to load font awesome from a local server. Requested by @blauemango</li>