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

Version Description

Download this release

Release Info

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

Code changes from version 2.0 to 2.1

cmp-settings.php CHANGED
@@ -173,21 +173,17 @@ if (isset($_POST['niteoCS_unsplash_3_'.$themeslug])) {
173
  update_option('niteoCS_unsplash_3['.$themeslug.']', sanitize_text_field($_POST['niteoCS_unsplash_3_'.$themeslug]));
174
  }
175
 
176
- if (isset($_POST['unsplash_category_'.$themeslug])) {
177
- update_option('niteoCS_unsplash_category['.$themeslug.']', sanitize_text_field($_POST['unsplash_category_'.$themeslug]));
178
- }
179
- if (isset($_POST['niteoCS_cat_keyword_'.$themeslug])) {
180
- update_option('niteoCS_cat_keyword['.$themeslug.']', sanitize_text_field($_POST['niteoCS_cat_keyword_'.$themeslug]));
181
  }
182
 
183
  if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
184
 
185
  if (isset($_POST['niteoCS_unsplash_feat_'.$themeslug])) {
186
- update_option('niteoCS_unsplash_feat', $this->sanitize_checkbox($_POST['niteoCS_unsplash_feat_'.$themeslug]));
187
  } else {
188
  update_option('niteoCS_unsplash_feat['.$themeslug.']', false);
189
  }
190
-
191
  }
192
 
193
  if (isset($_POST['niteoCS_favicon_id']) && ( is_numeric($_POST['niteoCS_favicon_id']) || empty($_POST['niteoCS_favicon_id']))) {
@@ -297,6 +293,7 @@ $niteoCS_content_animation = get_option('niteoCS_content_animation['.$themeslu
297
  $niteoCS_banner_custom_id = get_option('niteoCS_banner_id['.$themeslug.']');
298
  $niteoCS_unsplash_feed = get_option('niteoCS_unsplash_feed['.$themeslug.']', '3');
299
  $niteoCS_unsplash_0 = get_option('niteoCS_unsplash_0['.$themeslug.']');
 
300
  $niteoCS_unsplash_2 = get_option('niteoCS_unsplash_2['.$themeslug.']');
301
  $niteoCS_unsplash_3 = get_option('niteoCS_unsplash_3['.$themeslug.']');
302
  $niteoCS_unsplash_category = get_option('niteoCS_unsplash_category['.$themeslug.']', 'buildings');
@@ -466,7 +463,7 @@ add_thickbox();
466
 
467
  <a class="nav-tab theme-setup" href="<?php echo admin_url(); ?>admin.php?page=cmp-settings" data-tab="theme-setup"><i class="fa fa-wrench" aria-hidden="true"></i><?php _e('Theme Setup', 'cmp-coming-soon-maintenance');?></a>
468
 
469
- <a class="nav-tab seo" href="<?php echo admin_url(); ?>admin.php?page=cmp-settings" data-tab="seo"><i class="fa fa-users" aria-hidden="true"></i><?php _e('SEO', 'cmp-coming-soon-maintenance');?></a>
470
 
471
  <a class="nav-tab custom_css" href="<?php echo admin_url(); ?>admin.php?page=cmp-settings" data-tab="custom_css"><i class="fa fa-code" aria-hidden="true"></i><?php _e('Custom CSS', 'cmp-coming-soon-maintenance');?></a>
472
 
173
  update_option('niteoCS_unsplash_3['.$themeslug.']', sanitize_text_field($_POST['niteoCS_unsplash_3_'.$themeslug]));
174
  }
175
 
176
+ if (isset($_POST['niteoCS_unsplash_1_'.$themeslug])) {
177
+ update_option('niteoCS_unsplash_1['.$themeslug.']', sanitize_text_field($_POST['niteoCS_unsplash_1_'.$themeslug]));
 
 
 
178
  }
179
 
180
  if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
181
 
182
  if (isset($_POST['niteoCS_unsplash_feat_'.$themeslug])) {
183
+ update_option('niteoCS_unsplash_feat['.$themeslug.']', $this->sanitize_checkbox($_POST['niteoCS_unsplash_feat_'.$themeslug]));
184
  } else {
185
  update_option('niteoCS_unsplash_feat['.$themeslug.']', false);
186
  }
 
187
  }
188
 
189
  if (isset($_POST['niteoCS_favicon_id']) && ( is_numeric($_POST['niteoCS_favicon_id']) || empty($_POST['niteoCS_favicon_id']))) {
293
  $niteoCS_banner_custom_id = get_option('niteoCS_banner_id['.$themeslug.']');
294
  $niteoCS_unsplash_feed = get_option('niteoCS_unsplash_feed['.$themeslug.']', '3');
295
  $niteoCS_unsplash_0 = get_option('niteoCS_unsplash_0['.$themeslug.']');
296
+ $niteoCS_unsplash_1 = get_option('niteoCS_unsplash_1['.$themeslug.']');
297
  $niteoCS_unsplash_2 = get_option('niteoCS_unsplash_2['.$themeslug.']');
298
  $niteoCS_unsplash_3 = get_option('niteoCS_unsplash_3['.$themeslug.']');
299
  $niteoCS_unsplash_category = get_option('niteoCS_unsplash_category['.$themeslug.']', 'buildings');
463
 
464
  <a class="nav-tab theme-setup" href="<?php echo admin_url(); ?>admin.php?page=cmp-settings" data-tab="theme-setup"><i class="fa fa-wrench" aria-hidden="true"></i><?php _e('Theme Setup', 'cmp-coming-soon-maintenance');?></a>
465
 
466
+ <a class="nav-tab seo" href="<?php echo admin_url(); ?>admin.php?page=cmp-settings" data-tab="seo"><i class="fa fa-line-chart" aria-hidden="true"></i><?php _e('SEO', 'cmp-coming-soon-maintenance');?></a>
467
 
468
  <a class="nav-tab custom_css" href="<?php echo admin_url(); ?>admin.php?page=cmp-settings" data-tab="custom_css"><i class="fa fa-code" aria-hidden="true"></i><?php _e('Custom CSS', 'cmp-coming-soon-maintenance');?></a>
469
 
cmp-translate.php CHANGED
@@ -13,8 +13,8 @@ if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
13
  2 => array('id' => 2, 'string' => 'Hours', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_2'] )),
14
  3 => array('id' => 3, 'string' => 'Days', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_3'] )),
15
  4 => array('id' => 4, 'string' => 'Insert your email address.', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_4'] )),
16
- 5 => array('id' => 5, 'string' => 'This email address has already been on our subscriber list.', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_5'] )),
17
- 6 => array('id' => 6, 'string' => 'Please insert valid email.', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_6'] )),
18
  7 => array('id' => 7, 'string' => 'Thank you, your sign-up request was successful!', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_7'] )),
19
  8 => array('id' => 8, 'string' => 'Submit', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_8'] )),
20
  9 => array('id' => 9, 'string' => 'Scroll', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_9'] )),
@@ -31,8 +31,8 @@ if ( !get_option('niteoCS_translation') ) {
31
  2 => array('id' => 2, 'string' => 'Hours', 'translation' => 'Hours' ),
32
  3 => array('id' => 3, 'string' => 'Days', 'translation' => 'Days' ),
33
  4 => array('id' => 4, 'string' => 'Insert your email address.', 'translation' => 'Insert your email address.' ),
34
- 5 => array('id' => 5, 'string' => 'This email address has already been on our subscriber list.', 'translation' => 'This email address has already been on our subscriber list.'),
35
- 6 => array('id' => 6, 'string' => 'Please insert valid email.', 'translation' => 'Please insert valid email.'),
36
  7 => array('id' => 7, 'string' => 'Thank you, your sign-up request was successful!', 'translation' => 'Thank you, your sign-up request was successful!'),
37
  8 => array('id' => 8, 'string' => 'Submit', 'translation' => 'Submit'),
38
  9 => array('id' => 9, 'string' => 'Scroll', 'translation' => 'Scroll'),
13
  2 => array('id' => 2, 'string' => 'Hours', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_2'] )),
14
  3 => array('id' => 3, 'string' => 'Days', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_3'] )),
15
  4 => array('id' => 4, 'string' => 'Insert your email address.', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_4'] )),
16
+ 5 => array('id' => 5, 'string' => 'This Email address has already been on our subscriber list.', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_5'] )),
17
+ 6 => array('id' => 6, 'string' => 'Please insert valid Email address.', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_6'] )),
18
  7 => array('id' => 7, 'string' => 'Thank you, your sign-up request was successful!', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_7'] )),
19
  8 => array('id' => 8, 'string' => 'Submit', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_8'] )),
20
  9 => array('id' => 9, 'string' => 'Scroll', 'translation' => sanitize_text_field( $_POST['niteoCS_translate_9'] )),
31
  2 => array('id' => 2, 'string' => 'Hours', 'translation' => 'Hours' ),
32
  3 => array('id' => 3, 'string' => 'Days', 'translation' => 'Days' ),
33
  4 => array('id' => 4, 'string' => 'Insert your email address.', 'translation' => 'Insert your email address.' ),
34
+ 5 => array('id' => 5, 'string' => 'This Email address has already been on our subscriber list.', 'translation' => 'This Email address has already been on our subscriber list.'),
35
+ 6 => array('id' => 6, 'string' => 'Please insert valid Email address.', 'translation' => 'Please insert valid Email address.'),
36
  7 => array('id' => 7, 'string' => 'Thank you, your sign-up request was successful!', 'translation' => 'Thank you, your sign-up request was successful!'),
37
  8 => array('id' => 8, 'string' => 'Submit', 'translation' => 'Submit'),
38
  9 => array('id' => 9, 'string' => 'Scroll', 'translation' => 'Scroll'),
inc/class-cmp-render_html.php CHANGED
@@ -41,51 +41,69 @@ class cmp_render_html extends niteo_cmp {
41
  $background_class = 'image';
42
  $unplash_feed = get_option('niteoCS_unsplash_feed['.$themeslug.']', '0');
43
  switch ( $unplash_feed ) {
44
- // SINGLE IMAGE
45
  case '0':
46
  $params = array('feed' => '0', 'url' => get_option('niteoCS_unsplash_0['.$themeslug.']', '') );
47
- $banner_url = $this->niteo_unsplash( $params );
48
  break;
49
 
50
- // category random
51
  case '1':
52
- $params = array('feed' => '1', 'cat' => get_option('niteoCS_unsplash_category['.$themeslug.']'), 'custom_str' => get_option('niteoCS_cat_keyword['.$themeslug.']', '') );
53
- $banner_url = $this->niteo_unsplash( $params );
54
  break;
55
 
56
- // collection
57
  case '2':
58
  $params = array('feed' => '2', 'url' => get_option('niteoCS_unsplash_2['.$themeslug.']', '') );
59
- $banner_url = $this->niteo_unsplash( $params );
60
  break;
61
 
62
  // random photo
63
  case '3':
64
- $params = array('feed' => '3', 'url' => get_option('niteoCS_unsplash_3['.$themeslug.']', ''), 'cat' => get_option('niteoCS_unsplash_feat['.$themeslug.']', '0') );
65
- $banner_url = $this->niteo_unsplash( $params );
66
  break;
67
  default:
68
  break;
69
  }
70
 
71
- $html = '<script>
72
- var screenWidth = Math.round(screen.width*window.devicePixelRatio);
73
- var screenHeight = screenWidth / 1.77777;
74
- screenHeight = screenHeight.toFixed(0);
75
 
76
- var banner = \'<div id="background-image" class="image" style="background-image:url(\\\''.esc_url( $banner_url ).'\\\')"></div>\';
77
- banner = banner.replace("WIDTHxHEIGHT", screenWidth + "x" + screenHeight);
78
- var container = document.getElementById("background-wrapper");
79
 
80
- if ( container == null ) {
81
- container = document.getElementById("banner-wrapper");
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
- container.innerHTML = banner;
85
-
86
- </script>';
 
 
 
 
 
 
 
 
 
 
87
 
88
- return $html;
89
  break;
90
 
91
  case '2':
@@ -156,7 +174,7 @@ class cmp_render_html extends niteo_cmp {
156
  // render slider
157
  public function cmp_slider( $themeslug ) {
158
 
159
- // change background if preview background is set
160
  if ( isset($_GET['background']) && is_numeric($_GET['background']) ) {
161
  if ( $_GET['background'] != 1 ) {
162
  $this->cmp_background($_GET['background'], $themeslug);
@@ -164,20 +182,23 @@ class cmp_render_html extends niteo_cmp {
164
  }
165
  }
166
 
167
- $size = $this->isMobile() ? 'large' : 'full'; ?>
 
 
 
 
 
168
  <div id="slider-wrapper">
169
  <div id="slider">
170
  <?php
171
- $niteoCS_banner = get_option('niteoCS_banner['.$themeslug.']', '2');
172
- $slider_count = get_option('niteoCS_slider_count['.$themeslug.']', '3');
173
- $slider_fade = get_option('niteoCS_slider_effect['.$themeslug.']', 'false');
174
- $slider_auto = get_option('niteoCS_slider_auto['.$themeslug.']', '1');
175
 
176
  switch ( $niteoCS_banner ) {
177
 
178
  // custom media
179
  case '0':
180
  $banner_id = get_option('niteoCS_banner_id['.$themeslug.']');
 
181
 
182
  if ( $banner_id != '' ) {
183
  $banner_ids = explode(',', $banner_id);
@@ -196,59 +217,86 @@ class cmp_render_html extends niteo_cmp {
196
  <?php
197
  }
198
  }
 
199
  break;
200
 
 
201
  case '1':
202
- // unsplash feed
203
  $unplash_feed = get_option('niteoCS_unsplash_feed['.$themeslug.']', '0');
204
 
205
  switch ( $unplash_feed ) {
206
- // SINGLE IMAGE
207
  case '0':
208
- $params = array('feed' => '0', 'url' => get_option('niteoCS_unsplash_0['.$themeslug.']', '') );
 
209
  break;
210
- // category random
 
211
  case '1':
212
- $params = array('feed' => '1', 'cat' => get_option('niteoCS_unsplash_category['.$themeslug.']'), 'custom_str' => get_option('niteoCS_cat_keyword['.$themeslug.']', '') );
 
213
  break;
214
- // collection
 
215
  case '2':
216
- $params = array('feed' => '2', 'url' => get_option('niteoCS_unsplash_2['.$themeslug.']', '') );
 
217
  break;
 
218
  // random photo
219
  case '3':
220
- $params = array('feed' => '3', 'url' => get_option('niteoCS_unsplash_3['.$themeslug.']', ''), 'cat' => get_option('niteoCS_unsplash_feat['.$themeslug.']', '0') );
 
221
  break;
 
222
  default:
223
  break;
224
- } ?>
225
 
226
- <script>
227
- var screenWidth = Math.round(screen.width*window.devicePixelRatio);
228
- var screenHeight = screenWidth / 1.77777;
229
- screenHeight = screenHeight.toFixed(0);
230
 
231
- <?php
232
- if ( get_option('niteoCS_overlay_opacity['.$themeslug.']', '1') == '1' ) { ?>
233
 
234
- if ( !navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i) && screenWidth > 1200 ) {
235
- screenWidth = screenWidth / 2;
 
236
  }
237
- <?php
238
- } ?>
239
-
240
- for (i=0; i<<?php echo esc_attr($slider_count);?>; i++) {
241
- <?php $banner_url = $this->niteo_unsplash( $params ); ?>
242
- var slide = document.createElement('div');
243
- slide.className = 'slide';
244
- var slide_background = '<div class="slide-background" style="background-image:url(\'<?php echo esc_url( $banner_url ); ?>'+Math.floor(Math.random() * 1000) + 1 +'\')"></div>';
245
- slide_background = slide_background.replace('WIDTHxHEIGHT', screenWidth + 'x' + screenHeight);
246
 
247
- slide.innerHTML = slide_background;
248
- document.getElementById('slider').appendChild(slide);
249
  }
250
- </script>
251
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  default:
253
  break;
254
  } ?>
@@ -418,27 +466,21 @@ class cmp_render_html extends niteo_cmp {
418
  // add loaded class to background media
419
  } else { ?>
420
  <script>
 
 
 
421
 
422
- (function(window, document, undefined){
 
423
 
424
- // code that should be taken care of right away
425
-
426
- window.onload = init;
427
-
428
- function init(){
429
- var image = document.getElementById('background-image');
430
-
431
- if ( image === null ) {
432
- image = document.getElementById('body');
433
- }
434
-
435
- if ( image != null ) {
436
- image.className += " loaded";
437
- }
438
- }
439
-
440
- })(window, document, undefined);
441
 
 
 
 
 
442
  </script>
443
  <?php
444
  }
@@ -464,7 +506,11 @@ class cmp_render_html extends niteo_cmp {
464
 
465
  // render subscribe form
466
  public function cmp_subscribe_form() {
 
 
 
467
  $subscribe = get_option('niteoCS_subscribe_type', '2');
 
468
  $html = '';
469
  // if subscribers is 3rd party plugin, render form by shortcode
470
  if ( $subscribe == '1' ) {
@@ -499,16 +545,64 @@ class cmp_render_html extends niteo_cmp {
499
  <label for="EMAIL"><?php echo esc_html($niteoCS_subscribe_label);?></label>
500
  <?php
501
  } ?>
502
- <input type="email" name="EMAIL" placeholder="<?php echo esc_attr($placeholder);?>" required>
503
 
504
- <input type="submit" value="<?php echo esc_attr($submit);?>">
505
 
506
  <div style="display: none;">
507
  <input type="text" name="form_honeypot" value="" tabindex="-1" autocomplete="off">
508
  </div>
509
 
510
- <div class="subsribe-response"><?php echo isset( $subscribe_response ) ? $subscribe_response : '';?></div>
511
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
  <?php
513
  }
514
 
41
  $background_class = 'image';
42
  $unplash_feed = get_option('niteoCS_unsplash_feed['.$themeslug.']', '0');
43
  switch ( $unplash_feed ) {
44
+ // specific photo from id
45
  case '0':
46
  $params = array('feed' => '0', 'url' => get_option('niteoCS_unsplash_0['.$themeslug.']', '') );
47
+ $unsplash = $this->niteo_unsplash( $params );
48
  break;
49
 
50
+ // random from user
51
  case '1':
52
+ $params = array('feed' => '1', 'custom_str' => get_option('niteoCS_unsplash_1['.$themeslug.']', '') );
53
+ $unsplash = $this->niteo_unsplash( $params );
54
  break;
55
 
56
+ // random from collection
57
  case '2':
58
  $params = array('feed' => '2', 'url' => get_option('niteoCS_unsplash_2['.$themeslug.']', '') );
59
+ $unsplash = $this->niteo_unsplash( $params );
60
  break;
61
 
62
  // random photo
63
  case '3':
64
+ $params = array('feed' => '3', 'url' => get_option('niteoCS_unsplash_3['.$themeslug.']', ''), 'feat' => get_option('niteoCS_unsplash_feat['.$themeslug.']', '0') );
65
+ $unsplash = $this->niteo_unsplash( $params );
66
  break;
67
  default:
68
  break;
69
  }
70
 
 
 
 
 
71
 
72
+ // get raw url from response
73
+ if ( isset( $unsplash['response'] ) && $unsplash['response'] == '200' ) {
74
+ $body = json_decode($unsplash['body'], true);
75
 
76
+ if ( isset( $body[0] ) ) {
77
+ foreach ( $body as $item ) {
78
+ $unsplash_url = $item['urls']['raw'];
79
+ }
80
+ } else {
81
+ $unsplash_url = $body['urls']['raw'];
82
+ } ?>
83
+
84
+ <script>
85
+ var unsplash_img = '<?php echo esc_url( $unsplash_url );?>';
86
+ var width = document.documentElement.clientWidth;
87
+ var height = document.documentElement.clientHeight;
88
+ var dimension = 'w=' + width;
89
+ if ( width < height ) {
90
+ dimension = 'h=' + height;
91
+ }
92
 
93
+ unsplash_img = unsplash_img + '?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&fit=max&' + dimension;
94
+ var banner = '<div id="background-image" class="image" style="background-image:url('+unsplash_img+')"></div>';
95
+
96
+ var container = document.getElementById("background-wrapper");
97
+
98
+ if ( container == null ) {
99
+ container = document.getElementById("banner-wrapper");
100
+ }
101
+
102
+ container.innerHTML = banner;
103
+ </script>
104
+ <?php
105
+ }
106
 
 
107
  break;
108
 
109
  case '2':
174
  // render slider
175
  public function cmp_slider( $themeslug ) {
176
 
177
+ // change to background if preview background is set
178
  if ( isset($_GET['background']) && is_numeric($_GET['background']) ) {
179
  if ( $_GET['background'] != 1 ) {
180
  $this->cmp_background($_GET['background'], $themeslug);
182
  }
183
  }
184
 
185
+ $niteoCS_banner = get_option('niteoCS_banner['.$themeslug.']', '2');
186
+ $slider_count = get_option('niteoCS_slider_count['.$themeslug.']', '3');
187
+ $slider_fade = get_option('niteoCS_slider_effect['.$themeslug.']', 'false');
188
+ $slider_auto = get_option('niteoCS_slider_auto['.$themeslug.']', '1');
189
+ ?>
190
+
191
  <div id="slider-wrapper">
192
  <div id="slider">
193
  <?php
194
+
 
 
 
195
 
196
  switch ( $niteoCS_banner ) {
197
 
198
  // custom media
199
  case '0':
200
  $banner_id = get_option('niteoCS_banner_id['.$themeslug.']');
201
+ $size = $this->isMobile() ? 'large' : 'full';
202
 
203
  if ( $banner_id != '' ) {
204
  $banner_ids = explode(',', $banner_id);
217
  <?php
218
  }
219
  }
220
+
221
  break;
222
 
223
+ // unsplash
224
  case '1':
 
225
  $unplash_feed = get_option('niteoCS_unsplash_feed['.$themeslug.']', '0');
226
 
227
  switch ( $unplash_feed ) {
228
+ // specific photo from id
229
  case '0':
230
+ $params = array( 'feed' => '0', 'url' => get_option('niteoCS_unsplash_0['.$themeslug.']', ''), 'count' => $slider_count );
231
+ $unsplash = $this->niteo_unsplash( $params );
232
  break;
233
+
234
+ // random from user
235
  case '1':
236
+ $params = array( 'feed' => '1', 'custom_str' => get_option('niteoCS_unsplash_1['.$themeslug.']', ''), 'count' => $slider_count );
237
+ $unsplash = $this->niteo_unsplash( $params );
238
  break;
239
+
240
+ // random from collection
241
  case '2':
242
+ $params = array( 'feed' => '2', 'url' => get_option('niteoCS_unsplash_2['.$themeslug.']', ''), 'count' => $slider_count );
243
+ $unsplash = $this->niteo_unsplash( $params );
244
  break;
245
+
246
  // random photo
247
  case '3':
248
+ $params = array( 'feed' => '3', 'url' => get_option('niteoCS_unsplash_3['.$themeslug.']', ''), 'feat' => get_option('niteoCS_unsplash_feat['.$themeslug.']', '0'), 'count' => $slider_count );
249
+ $unsplash = $this->niteo_unsplash( $params );
250
  break;
251
+
252
  default:
253
  break;
254
+ }
255
 
256
+ // get raw url from response
257
+ if ( isset( $unsplash['response'] ) && $unsplash['response'] == '200' ) {
258
+ $body = json_decode($unsplash['body'], true);
 
259
 
260
+ $imgs = array();
 
261
 
262
+ if ( isset( $body[0] ) ) {
263
+ foreach ( $body as $item ) {
264
+ array_push( $imgs, $item['urls']['raw']);
265
  }
 
 
 
 
 
 
 
 
 
266
 
267
+ } else {
268
+ $imgs[0] = $body['urls']['raw'];
269
  }
270
+
271
+ $imgs = json_encode( $imgs ); ?>
272
+
273
+ <script>
274
+ var imgs = <?php echo $imgs;?>;
275
+
276
+ var width = document.documentElement.clientWidth;
277
+ var height = document.documentElement.clientHeight;
278
+ var dimension = 'w=' + width;
279
+ if ( width < height ) {
280
+ dimension = 'h=' + height;
281
+ }
282
+ var query = '?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&fit=max&' + dimension;
283
+ var img = '';
284
+
285
+ for ( i=0; i < imgs.length; i++ ) {
286
+ var slide = document.createElement('div');
287
+
288
+ slide.className = 'slide';
289
+ img = imgs[i] + query;
290
+ var slide_background = '<div class="slide-background" style="background-image:url(\''+img+'\')"></div>';
291
+
292
+ slide.innerHTML = slide_background;
293
+ document.getElementById('slider').appendChild(slide);
294
+ }
295
+ </script>
296
+
297
+ <?php
298
+ }
299
+
300
  default:
301
  break;
302
  } ?>
466
  // add loaded class to background media
467
  } else { ?>
468
  <script>
469
+ window.addEventListener("load",function(event) {
470
+ init();
471
+ });
472
 
473
+ function init(){
474
+ var image = document.getElementById('background-image');
475
 
476
+ if ( image === null ) {
477
+ image = document.getElementById('body');
478
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
479
 
480
+ if ( image != null ) {
481
+ image.className += " loaded";
482
+ }
483
+ }
484
  </script>
485
  <?php
486
  }
506
 
507
  // render subscribe form
508
  public function cmp_subscribe_form() {
509
+ // process emails first
510
+ $response = $this->niteo_subscribe( true );
511
+
512
  $subscribe = get_option('niteoCS_subscribe_type', '2');
513
+
514
  $html = '';
515
  // if subscribers is 3rd party plugin, render form by shortcode
516
  if ( $subscribe == '1' ) {
545
  <label for="EMAIL"><?php echo esc_html($niteoCS_subscribe_label);?></label>
546
  <?php
547
  } ?>
548
+ <input type="email" id="email-subscribe" name="EMAIL" placeholder="<?php echo esc_attr($placeholder);?>" required>
549
 
550
+ <input type="submit" id="submit-subscribe" value="<?php echo esc_attr($submit);?>">
551
 
552
  <div style="display: none;">
553
  <input type="text" name="form_honeypot" value="" tabindex="-1" autocomplete="off">
554
  </div>
555
 
556
+ <div id="subscribe-response"><?php echo isset( $response ) ? $response : '';?></div>
557
  </form>
558
+
559
+ <script>
560
+
561
+ var ajaxurl = "<?php echo admin_url('admin-ajax.php');?>";
562
+
563
+ function AJAXform( formID, buttonID, resultID, emailID, formMethod = 'POST' ){
564
+
565
+ var selectForm = document.getElementById(formID); // Select the form by ID.
566
+ var selectButton = document.getElementById(buttonID); // Select the button by ID.
567
+ var selectResult = document.getElementById(resultID); // Select result element by ID.
568
+ var emailInput = document.getElementById(emailID); // Select result element by ID.
569
+
570
+ function XMLhttp(){
571
+
572
+ var httpRequest = new XMLHttpRequest();
573
+
574
+ httpRequest.onreadystatechange = function(){
575
+ if ( this.readyState == 4 && this.status == 200 ) {
576
+ selectResult.innerHTML = this.responseText; // Display the result inside result element.
577
+ emailInput.value = '';
578
+ }
579
+
580
+ };
581
+
582
+ httpRequest.open(formMethod, ajaxurl, true);
583
+ httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
584
+ httpRequest.send('action=niteo_subscribe&check=true&form_honeypot&EMAIL=' + emailInput.value);
585
+ }
586
+
587
+ selectButton.onclick = function(){ // If clicked on the button.
588
+
589
+ if ( emailInput.value != '' ) {
590
+ XMLhttp();
591
+ }
592
+
593
+ }
594
+
595
+ selectForm.onsubmit = function(){ // Prevent page refresh
596
+ return false;
597
+ }
598
+ }
599
+
600
+ /* Usage */
601
+ window.addEventListener("load",function(event) {
602
+ AJAXform( 'subscribe-form', 'submit-subscribe', 'subscribe-response', 'email-subscribe', 'POST' );
603
+ });
604
+
605
+ </script>
606
  <?php
607
  }
608
 
inc/settings-background.php CHANGED
@@ -76,50 +76,50 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
76
  </fieldset>
77
 
78
  <fieldset id="unsplash_banner">
79
- <p class="unplash-description"><a href="http://unsplash.com" target="_blank">Unsplash</a> <?php _e('is a world leading source for free to use high quality stock images. All of the images that are submitted and published on Unsplash fall under under the Creative Commons Zero (CC0) license, which means you can use the image for any personal or commercial use.', 'cmp-coming-soon-maintenance');?></p>
80
  <label for="unsplash_feed_<?php echo esc_attr($themeslug);?>"><?php _e('Choose Unsplash Feed', 'cmp-coming-soon-maintenance');?></label><br>
81
  <select name="unsplash_feed_<?php echo esc_attr($themeslug);?>">
 
 
 
82
  <option value="0" <?php if ( $niteoCS_unsplash_feed == '0' ) { echo ' selected="selected"'; } ?>><?php _e('Specific Photo', 'cmp-coming-soon-maintenance');?></option>
83
- <option value="1" <?php if ( $niteoCS_unsplash_feed == '1' ) { echo ' selected="selected"'; } ?>><?php _e('Random from Category', 'cmp-coming-soon-maintenance');?></option>
84
  <option value="2" <?php if ( $niteoCS_unsplash_feed == '2' ) { echo ' selected="selected"'; } ?>><?php _e('Random from Collection', 'cmp-coming-soon-maintenance');?></option>
85
- <option value="3" <?php if ( $niteoCS_unsplash_feed == '3' ) { echo ' selected="selected"'; } ?>><?php _e('Random Photo', 'cmp-coming-soon-maintenance');?></option>
 
 
86
  </select>
87
 
88
  <p class="unsplash-feed" id="unsplash-feed-0">
89
- <label for="niteoCS_unsplash_0_<?php echo esc_attr($themeslug);?>"><?php _e('Enter Unsplash Photo URL or Photo ID', 'cmp-coming-soon-maintenance');?></label>
90
  <input type="text" class="widefat" id="niteoCS-unsplash-0" name="niteoCS_unsplash_0_<?php echo esc_attr($themeslug);?>" type="text" value="<?php echo esc_attr($niteoCS_unsplash_0); ?>" />
91
  </p>
92
 
93
- <p class="unsplash-feed" id="unsplash-feed-1">
94
- <label for="unsplash_category_<?php echo esc_attr($themeslug);?>"><?php _e('Select Category', 'cmp-coming-soon-maintenance');?></label><br>
95
- <select name="unsplash_category_<?php echo esc_attr($themeslug);?>">
96
- <option value="buildings" <?php if ( $niteoCS_unsplash_category == 'buildings') { echo ' selected="selected"'; } ?>><?php _e('Buildings', 'cmp-coming-soon-maintenance');?></option>
97
- <option value="food" <?php if ( $niteoCS_unsplash_category == 'food') { echo ' selected="selected"'; } ?>><?php _e('Food', 'cmp-coming-soon-maintenance');?></option>
98
- <option value="nature" <?php if ( $niteoCS_unsplash_category == 'nature') { echo ' selected="selected"'; } ?>><?php _e('Nature', 'cmp-coming-soon-maintenance');?></option>
99
- <option value="people" <?php if ( $niteoCS_unsplash_category == 'people') { echo ' selected="selected"'; } ?>><?php _e('People', 'cmp-coming-soon-maintenance');?></option>
100
- <option value="technology" <?php if ( $niteoCS_unsplash_category == 'technology') { echo ' selected="selected"'; } ?>><?php _e('Technology', 'cmp-coming-soon-maintenance');?></option>
101
- <option value="objects" <?php if ( $niteoCS_unsplash_category == 'objects') { echo ' selected="selected"'; } ?>><?php _e('Objects', 'cmp-coming-soon-maintenance');?></option>
102
- </select><br>
103
-
104
- <label for="niteoCS_cat_keyword"><?php _e('You can limit Category to Specific Keyword', 'cmp-coming-soon-maintenance');?></label>
105
- <input type="text" class="widefat" id="niteoCS-category-keyword" name="niteoCS_cat_keyword_<?php echo esc_attr($themeslug);?>" type="text" value="<?php echo esc_attr($niteoCS_cat_keyword); ?>" />
106
- </p>
107
-
108
  <p class="unsplash-feed" id="unsplash-feed-2">
109
- <label for="niteoCS_unsplash_2_<?php echo esc_attr($themeslug);?>"><?php _e('Enter Unsplash Collection URL or Collection ID. Doesn`t work for Curated Collections.', 'cmp-coming-soon-maintenance');?></label>
110
  <input type="text" class="widefat" id="niteoCS-unsplash-2" name="niteoCS_unsplash_2_<?php echo esc_attr($themeslug);?>" type="text" value="<?php echo esc_attr($niteoCS_unsplash_2); ?>" />
111
  </p>
112
 
113
- <div class="unsplash-feed" id="unsplash-feed-3">
114
- <label for="niteoCS_unsplash_3_<?php echo esc_attr($themeslug);?>"><?php _e('Specify search terms', 'cmp-coming-soon-maintenance');?></label>
115
  <input type="text" class="widefat" id="niteoCS-unsplash-3" name="niteoCS_unsplash_3_<?php echo esc_attr($themeslug);?>" type="text" value="<?php echo esc_attr($niteoCS_unsplash_3); ?>" />
116
 
117
  <br><br>
118
- <input type="checkbox" name="niteoCS_unsplash_feat_<?php echo esc_attr($themeslug);?>" id="niteoCS_unsplash_feat" value="1" <?php checked( '1', get_option( 'niteoCS_unsplash_feat', '0' ) ); ?> class="regular-text code"><label for="niteoCS_unsplash_feat"><?php _e('Limit search only to Featured/Curated Photos', 'cmp-coming-soon-maintenance');?></label>
119
- </div><br>
120
 
121
- <button id="test-unsplash" class="button" data-security="<?php echo esc_attr($ajax_nonce);?>"><?php _e('Test Unsplash', 'cmp-coming-soon-maintenance');?></button>
 
 
 
 
 
 
 
 
 
122
  <div id="unsplash-media"></div>
 
 
 
123
  </fieldset>
124
 
125
  <fieldset id="default_banner">
76
  </fieldset>
77
 
78
  <fieldset id="unsplash_banner">
79
+
80
  <label for="unsplash_feed_<?php echo esc_attr($themeslug);?>"><?php _e('Choose Unsplash Feed', 'cmp-coming-soon-maintenance');?></label><br>
81
  <select name="unsplash_feed_<?php echo esc_attr($themeslug);?>">
82
+
83
+ <option value="3" <?php if ( $niteoCS_unsplash_feed == '3' ) { echo ' selected="selected"'; } ?>><?php _e('Random Photo', 'cmp-coming-soon-maintenance');?></option>
84
+
85
  <option value="0" <?php if ( $niteoCS_unsplash_feed == '0' ) { echo ' selected="selected"'; } ?>><?php _e('Specific Photo', 'cmp-coming-soon-maintenance');?></option>
86
+
87
  <option value="2" <?php if ( $niteoCS_unsplash_feed == '2' ) { echo ' selected="selected"'; } ?>><?php _e('Random from Collection', 'cmp-coming-soon-maintenance');?></option>
88
+
89
+ <option value="1" <?php if ( $niteoCS_unsplash_feed == '1' ) { echo ' selected="selected"'; } ?>><?php _e('Random from User', 'cmp-coming-soon-maintenance');?></option>
90
+
91
  </select>
92
 
93
  <p class="unsplash-feed" id="unsplash-feed-0">
94
+ <label for="niteoCS_unsplash_0_<?php echo esc_attr($themeslug);?>"><?php _e('Enter Unsplash Photo URL or Unsplash Photo ID', 'cmp-coming-soon-maintenance');?></label>
95
  <input type="text" class="widefat" id="niteoCS-unsplash-0" name="niteoCS_unsplash_0_<?php echo esc_attr($themeslug);?>" type="text" value="<?php echo esc_attr($niteoCS_unsplash_0); ?>" />
96
  </p>
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  <p class="unsplash-feed" id="unsplash-feed-2">
99
+ <label for="niteoCS_unsplash_2_<?php echo esc_attr($themeslug);?>"><?php printf(__('Enter <a href="%s">Unsplash Collection</a> URL or Collection ID.', 'cmp-coming-soon-maintenance'), 'https://unsplash.com/collections/');?></label>
100
  <input type="text" class="widefat" id="niteoCS-unsplash-2" name="niteoCS_unsplash_2_<?php echo esc_attr($themeslug);?>" type="text" value="<?php echo esc_attr($niteoCS_unsplash_2); ?>" />
101
  </p>
102
 
103
+ <p><div class="unsplash-feed" id="unsplash-feed-3">
104
+ <label for="niteoCS_unsplash_3_<?php echo esc_attr($themeslug);?>"><?php _e('Limit photos to specific keyword (fashion, nature, technology..)', 'cmp-coming-soon-maintenance');?></label>
105
  <input type="text" class="widefat" id="niteoCS-unsplash-3" name="niteoCS_unsplash_3_<?php echo esc_attr($themeslug);?>" type="text" value="<?php echo esc_attr($niteoCS_unsplash_3); ?>" />
106
 
107
  <br><br>
 
 
108
 
109
+ <input type="checkbox" name="niteoCS_unsplash_feat_<?php echo esc_attr($themeslug);?>" id="niteoCS_unsplash_feat" value="1" <?php checked( '1', get_option( 'niteoCS_unsplash_feat['.esc_attr($themeslug).']', '0' ) ); ?> class="regular-text code"><label for="niteoCS_unsplash_feat"><?php _e('Only Unsplash Featured Photos', 'cmp-coming-soon-maintenance');?></label>
110
+ </div></p>
111
+
112
+ <p class="unsplash-feed" id="unsplash-feed-1">
113
+ <label for="niteoCS_unsplash_1_<?php echo esc_attr($themeslug);?>"><?php _e('Enter Unsplash User ID', 'cmp-coming-soon-maintenance');?></label>
114
+ <input type="text" class="widefat" id="niteoCS-unsplash-1" name="niteoCS_unsplash_1_<?php echo esc_attr($themeslug);?>" type="text" value="<?php echo esc_attr($niteoCS_unsplash_1); ?>" placeholder="@"/>
115
+ </p>
116
+
117
+ <button id="test-unsplash" class="button" data-security="<?php echo esc_attr($ajax_nonce);?>"><?php _e('Display Unsplash Photo', 'cmp-coming-soon-maintenance');?></button>
118
+
119
  <div id="unsplash-media"></div>
120
+
121
+ <p class="unplash-description"><a href="http://unsplash.com" target="_blank">Unsplash</a> <?php _e('is a world leading source for free to use high quality stock images. All of the images that are submitted and published on Unsplash fall under under the <a href="https://unsplash.com/license"> Unsplash license</a>, which means you can use the image for any personal or commercial use.', 'cmp-coming-soon-maintenance');?></p>
122
+
123
  </fieldset>
124
 
125
  <fieldset id="default_banner">
inc/settings-slider.php CHANGED
@@ -153,7 +153,7 @@ jQuery(document).ready(function($){
153
  jQuery('.table-wrapper.slider input, .table-wrapper.slider select').prop('disabled', true);
154
  }
155
  });
156
- jQuery('#csoptions input[name="niteoCS_banner_<?php echo esc_attr($themeslug);?>"]').trigger('change');
157
  }
158
 
159
  });
153
  jQuery('.table-wrapper.slider input, .table-wrapper.slider select').prop('disabled', true);
154
  }
155
  });
156
+ // jQuery('#csoptions input[name="niteoCS_banner_<?php echo esc_attr($themeslug);?>"]').trigger('change');
157
  }
158
 
159
  });
js/settings.js CHANGED
@@ -103,73 +103,111 @@ jQuery(document).ready(function($){
103
  var media_wrapper = jQuery('#unsplash-media'),
104
  unsplash_feed = jQuery('#unsplash_banner select[name^="unsplash_feed"] option:selected').val(),
105
  unsp_url = '',
106
- cat = '',
107
  custom_str = '',
108
  security = jQuery(this).data('security');
109
 
110
  switch( unsplash_feed ) {
 
111
  case '0':
112
  unsp_url = jQuery('#niteoCS-unsplash-0').val();
113
  break;
114
 
 
115
  case '1':
116
- unsp_url = jQuery('#niteoCS-unsplash-1').val();
117
- cat = jQuery('#unsplash_banner select[name^="unsplash_category"] option:selected').val();
118
- custom_str = jQuery('#niteoCS-category-keyword').val();
119
  break;
120
 
 
121
  case '2':
122
  unsp_url = jQuery('#niteoCS-unsplash-2').val();
123
  break;
124
 
 
125
  case '3':
126
  unsp_url = jQuery('#niteoCS-unsplash-3').val();
127
  if ( jQuery('#niteoCS_unsplash_feat' ).is( ':checked' ) ) {
128
- cat = '1';
129
  } else {
130
- cat = '0';
131
  }
132
  break;
133
 
134
  default:
135
- // code block
136
  }
137
 
138
- var params = {feed: unsplash_feed, url: unsp_url, cat: cat, custom_str: custom_str};
139
 
140
- jQuery(this).prop('disabled', true);
141
- jQuery(this).html('<i class="fa fa-cog fa-spin fa-1x fa-fw"></i><span> loading..</span>');
142
- media_wrapper.html('');
143
 
 
144
 
145
- var data = {
146
- action: 'niteo_unsplash',
147
- security: security,
148
- params: params
149
- };
 
 
 
 
 
 
 
 
150
 
151
- $.post(ajaxurl, data, function(response) {
152
  jQuery('#unsplash_img').remove();
153
- img_url = response.replace('WIDTHxHEIGHT', '588x330');
154
 
155
  var loadingTimeout = setTimeout(function(){
156
  jQuery('#test-unsplash').prop('disabled', false);
157
- jQuery('#test-unsplash').text('Test Again');
158
- jQuery('#unsplash-media').html('<p>It seems <a href="http://source.unsplash.com" target="_blank">source.unsplash.com</a> is not responding. Please try again later.');
159
  }, 5000);
160
 
161
- jQuery('<img />', {src: img_url, id: 'unsplash_img'}).
162
- one('load', function() { //Set something to run when it finishes loading
163
- jQuery(this).appendTo(media_wrapper);
164
- jQuery(this).fadeIn();
165
- jQuery('#test-unsplash').prop('disabled', false);
166
- jQuery('#test-unsplash').text('Test Unsplash');
167
- clearTimeout(loadingTimeout);
168
- });
169
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
 
171
  });
172
 
 
 
173
  // change all selects to select2
174
  jQuery('select:not(.headings-google-font):not(.content-google-font )').select2({
175
  width: '100%',
@@ -317,9 +355,11 @@ jQuery(document).ready(function($){
317
  default:
318
  jQuery('#custom_banner').css('display','block');
319
  jQuery('.theme_background fieldset:not(#custom_banner)').css('display','none');
 
320
  }
321
  });
322
- jQuery('#csoptions .niteoCS_banner').trigger('change');
 
323
 
324
  // display selected unsplash feed
325
  var unsplasfeed = jQuery('#unsplash_banner select[name^="unsplash_feed"] option:selected').val();
@@ -329,7 +369,13 @@ jQuery(document).ready(function($){
329
  unsplasfeed = jQuery('#unsplash_banner select[name^="unsplash_feed"] option:selected').val();
330
  jQuery('.unsplash-feed').css('display', 'none');
331
  jQuery('#unsplash-feed-' + unsplasfeed).css('display', 'block');
332
- })
 
 
 
 
 
 
333
 
334
 
335
  // preview gradient on select change
@@ -803,7 +849,6 @@ jQuery(document).ready(function($){
803
 
804
  });
805
 
806
- jQuery('#csoptions input[name="niteoCS_banner"]').trigger('change');
807
  jQuery('#csoptions input[name="niteoCS_subscribe_type"]').trigger('change');
808
 
809
  media_upload_button('logo', false, 'image');
103
  var media_wrapper = jQuery('#unsplash-media'),
104
  unsplash_feed = jQuery('#unsplash_banner select[name^="unsplash_feed"] option:selected').val(),
105
  unsp_url = '',
106
+ feat = '',
107
  custom_str = '',
108
  security = jQuery(this).data('security');
109
 
110
  switch( unsplash_feed ) {
111
+ // specific photo
112
  case '0':
113
  unsp_url = jQuery('#niteoCS-unsplash-0').val();
114
  break;
115
 
116
+ // random from user
117
  case '1':
118
+ custom_str = jQuery('#niteoCS-unsplash-1').val();
 
 
119
  break;
120
 
121
+ // random from collection
122
  case '2':
123
  unsp_url = jQuery('#niteoCS-unsplash-2').val();
124
  break;
125
 
126
+ // random photo
127
  case '3':
128
  unsp_url = jQuery('#niteoCS-unsplash-3').val();
129
  if ( jQuery('#niteoCS_unsplash_feat' ).is( ':checked' ) ) {
130
+ feat = '1';
131
  } else {
132
+ feat = '0';
133
  }
134
  break;
135
 
136
  default:
137
+ break;
138
  }
139
 
 
140
 
141
+ if ( unsplash_feed == 3 || unsp_url != '' || custom_str != '' ) {
 
 
142
 
143
+ var params = {feed: unsplash_feed, url: unsp_url, feat: feat, custom_str: custom_str};
144
 
145
+ jQuery(this).prop('disabled', true);
146
+ jQuery(this).html('<i class="fa fa-cog fa-spin fa-1x fa-fw"></i><span> loading..</span>');
147
+ media_wrapper.html('');
148
+
149
+ var data = {
150
+ action: 'niteo_unsplash',
151
+ security: security,
152
+ params: params
153
+ };
154
+
155
+ $.post(ajaxurl, data, function(response) {
156
+
157
+ var unsplash = jQuery.parseJSON(response);
158
 
 
159
  jQuery('#unsplash_img').remove();
 
160
 
161
  var loadingTimeout = setTimeout(function(){
162
  jQuery('#test-unsplash').prop('disabled', false);
163
+ jQuery('#test-unsplash').text('Display Unsplash Photo');
164
+ jQuery('#unsplash-media').html('<p>It seems <a href="https://status.unsplash.com/" target="_blank">Unsplash API</a> is not responding. Please try again later.</p>');
165
  }, 5000);
166
 
167
+ if ( unsplash.response == '200' ) {
168
+ var unsplash = jQuery.parseJSON(unsplash.body);
169
+
170
+ if ( unsplash[0]) {
171
+ var img = unsplash[0]['urls']['raw']+'?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&fit=max&w=588';
172
+ var author = unsplash[0]['user']['name'];
173
+ var author_url = unsplash[0]['user']['links']['html'];
174
+ var img_url = unsplash[0]['links']['html'];
175
+ var img_id = unsplash[0]['id'];
176
+ } else {
177
+ var img = unsplash['urls']['raw']+'?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&fit=max&w=588';
178
+ var author = unsplash['user']['name'];
179
+ var author_url = unsplash['user']['links']['html'];
180
+ var img_url = unsplash['links']['html'];
181
+ var img_id = unsplash['id'];
182
+ }
183
+
184
+ jQuery('<img />', {src: img, id: 'unsplash_img'}).
185
+ one('load', function() { //Set something to run when it finishes loading
186
+ jQuery(this).appendTo(media_wrapper);
187
+ jQuery(this).fadeIn();
188
+ jQuery('#test-unsplash').prop('disabled', false);
189
+ jQuery('#test-unsplash').text('Display Unsplash Photo');
190
+ jQuery('#unsplash-media').append('<span><a href="'+img_url+'" target="_blank">Photo</a> (ID: '+img_id+') by <a href="'+author_url+'" target="_blank">' +author+ '</a> / <a href="https://unsplash.com/" target="_blank">Unsplash</a></span>')
191
+ clearTimeout(loadingTimeout);
192
+ });
193
+
194
+ } else {
195
+ var error = jQuery.parseJSON(unsplash.body);
196
+ jQuery('#test-unsplash').prop('disabled', false);
197
+ jQuery('#test-unsplash').text('Display Unsplash Photo');
198
+ jQuery('#unsplash-media').html('<p>Error '+unsplash.response+': <span style="text-transform:lowercase;">'+error.errors+' '+custom_str+'</span></p>');
199
+ clearTimeout(loadingTimeout);
200
+ }
201
+
202
+ });
203
+ } else {
204
+ jQuery('#unsplash_img').remove();
205
+ }
206
 
207
  });
208
 
209
+
210
+
211
  // change all selects to select2
212
  jQuery('select:not(.headings-google-font):not(.content-google-font )').select2({
213
  width: '100%',
355
  default:
356
  jQuery('#custom_banner').css('display','block');
357
  jQuery('.theme_background fieldset:not(#custom_banner)').css('display','none');
358
+ break;
359
  }
360
  });
361
+
362
+ jQuery('#csoptions .niteoCS_banner:first').trigger('change');
363
 
364
  // display selected unsplash feed
365
  var unsplasfeed = jQuery('#unsplash_banner select[name^="unsplash_feed"] option:selected').val();
369
  unsplasfeed = jQuery('#unsplash_banner select[name^="unsplash_feed"] option:selected').val();
370
  jQuery('.unsplash-feed').css('display', 'none');
371
  jQuery('#unsplash-feed-' + unsplasfeed).css('display', 'block');
372
+ jQuery('#test-unsplash').trigger('click');
373
+ });
374
+
375
+ // load unsplash upon load if unsplash is selected
376
+ if ( jQuery('#csoptions .niteoCS_banner:checked').val() == 1 ) {
377
+ jQuery('#test-unsplash').trigger('click');
378
+ }
379
 
380
 
381
  // preview gradient on select change
849
 
850
  });
851
 
 
852
  jQuery('#csoptions input[name="niteoCS_subscribe_type"]').trigger('change');
853
 
854
  media_upload_button('logo', false, 'image');
js/settings.min.js CHANGED
@@ -1,32 +1,34 @@
1
- jQuery(document).ready(function($){var formChanged=false;var tab=document.location.hash.substring(1);var action=jQuery('#csoptions').attr('action');navtab=function(tab){jQuery('.nav-tab-wrapper .nav-tab').removeClass('nav-tab-active');jQuery('.nav-tab-wrapper .'+tab).addClass('nav-tab-active');jQuery('.table-wrapper.'+tab).css('display','block');jQuery('.comingsoon.'+tab).css('display','block');jQuery('.table-wrapper:not(.'+tab+')').css('display','none');jQuery('.comingsoon:not(.'+tab+')').css('display','none');if(tab=='install'){jQuery('.submit').css('display','none');jQuery('#csoptions').attr('action',action);}else{jQuery('.submit').css('display','block');jQuery('#csoptions').attr('action',action+'#'+tab);}}
2
- if(tab!=''){navtab(tab);}
3
- window.onhashchange=function(){tab=document.location.hash.substring(1);navtab(tab);}
4
- $('.nav-tab:not(.theme-preview)').click(function(e){e.preventDefault();tab=$(this).data('tab');document.location.hash=tab;});jQuery('#cmp-status').click(function(){jQuery('.cmp-status input[type=radio]').prop("disabled",(_,val)=>!val);jQuery('#cmp-status-menubar').prop("checked",(_,val)=>!val);});cmp_status_inputs();function cmp_status_inputs(){jQuery('.cmp-status legend:not(.disabled)').click(function(){if(jQuery('#cmp-status').prop('checked')==false){return;}
5
- var $children=jQuery(this).children('input');$children.prop("checked",true);jQuery('.cmp-status legend').removeClass('active');jQuery(this).addClass('active');$children.trigger('change');if($children.val()=='3'){jQuery('.redirect-inputs').fadeIn('fast');}else{jQuery('.redirect-inputs').fadeOut('fast');}});}
6
- jQuery('.table-wrapper h3').click(function(){jQuery(this).parent().toggleClass('closed');});jQuery('.niteoCS-logo-type').change(function(){if(jQuery('.niteoCS-logo-type:checked').val()=='text'){jQuery('.text-logo').css('display','block');jQuery('.graphic-logo').css('display','none');jQuery('.disabled-logo').css('display','none');}else if(jQuery('.niteoCS-logo-type:checked').val()=='graphic'){jQuery('.text-logo').css('display','none');jQuery('.graphic-logo').css('display','block');jQuery('.disabled-logo').css('display','none');}else if(jQuery('.niteoCS-logo-type:checked').val()=='disabled'){jQuery('.text-logo').css('display','none');jQuery('.graphic-logo').css('display','none');jQuery('.disabled-logo').css('display','block');}});jQuery('#test-unsplash').click(function(e){e.preventDefault();var media_wrapper=jQuery('#unsplash-media'),unsplash_feed=jQuery('#unsplash_banner select[name^="unsplash_feed"] option:selected').val(),unsp_url='',cat='',custom_str='',security=jQuery(this).data('security');switch(unsplash_feed){case'0':unsp_url=jQuery('#niteoCS-unsplash-0').val();break;case'1':unsp_url=jQuery('#niteoCS-unsplash-1').val();cat=jQuery('#unsplash_banner select[name^="unsplash_category"] option:selected').val();custom_str=jQuery('#niteoCS-category-keyword').val();break;case'2':unsp_url=jQuery('#niteoCS-unsplash-2').val();break;case'3':unsp_url=jQuery('#niteoCS-unsplash-3').val();if(jQuery('#niteoCS_unsplash_feat').is(':checked')){cat='1';}else{cat='0';}
7
- break;default:}
8
- var params={feed:unsplash_feed,url:unsp_url,cat:cat,custom_str:custom_str};jQuery(this).prop('disabled',true);jQuery(this).html('<i class="fa fa-cog fa-spin fa-1x fa-fw"></i><span> loading..</span>');media_wrapper.html('');var data={action:'niteo_unsplash',security:security,params:params};$.post(ajaxurl,data,function(response){jQuery('#unsplash_img').remove();img_url=response.replace('WIDTHxHEIGHT','588x330');var loadingTimeout=setTimeout(function(){jQuery('#test-unsplash').prop('disabled',false);jQuery('#test-unsplash').text('Test Again');jQuery('#unsplash-media').html('<p>It seems <a href="http://source.unsplash.com" target="_blank">source.unsplash.com</a> is not responding. Please try again later.');},5000);jQuery('<img />',{src:img_url,id:'unsplash_img'}).one('load',function(){jQuery(this).appendTo(media_wrapper);jQuery(this).fadeIn();jQuery('#test-unsplash').prop('disabled',false);jQuery('#test-unsplash').text('Test Unsplash');clearTimeout(loadingTimeout);});});});jQuery('select:not(.headings-google-font):not(.content-google-font )').select2({width:'100%',minimumResultsForSearch:-1,});videoPreview=function(){var source=$('.banner-video-source').val();$('.video-wrapper').css('padding-top','0');if(source=='YouTube'){var youtubeLink=$('#niteoCS-youtube-url').val();if(youtubeLink.match(/(youtube.com)/)){var split_c='v=';var split_n=1;}
9
- if(youtubeLink.match(/(youtu.be)/)||youtubeLink.match(/(vimeo.com\/)+[0-9]/)){var split_c='/';var split_n=3;}
10
- if(source=='vimeo'){var youtubeLink=$('#niteoCS-vimeo-url').val();if(youtubeLink.match(/(vimeo.com\/)+[a-zA-Z]/)){var split_c='/';var split_n=5;}}
11
- if(youtubeLink){var getYouTubeVideoID=youtubeLink.split(split_c)[split_n];if(getYouTubeVideoID!=undefined){var cleanVideoID=getYouTubeVideoID.replace(/(&)+(.*)/,'');if(source=='banner_youtube'&&youtubeLink.match(/(youtu.be)/)||youtubeLink.match(/(youtube.com)/)){var videoEmbedLink='https://www.youtube.com/embed/'+cleanVideoID+'?autoplay=0';}
12
- if(source=='banner_vimeo'&&youtubeLink.match(/(vimeo.com\/)+[0-9]/)||youtubeLink.match(/(vimeo.com\/)+[a-zA-Z]/)){var videoEmbedLink='https://player.vimeo.com/video/'+cleanVideoID+'?autoplay=0';}
13
- var $iframe=$('<iframe src="'+videoEmbedLink+'" allowfullscreen></iframe>');$('.video-wrapper').html($iframe);var videoRatio=($iframe.height()/ $iframe.width())*100;$iframe.css('position','absolute');$iframe.css('top','0');$iframe.css('left','0');$iframe.css('width','100%');$iframe.css('height','100%');$('.video-wrapper').css('padding-top',videoRatio+'%');$('#niteoCS-vimeo-url').css('border','1px solid #ddd');$('#niteoCS-youtube-url').css('border','1px solid #ddd');}else{$('.video-wrapper').text('Please enter correct '+source+' URL.').css('padding-top','0');$('#niteoCS-vimeo-url').css('border','1px solid #d60000');$('#niteoCS-youtube-url').css('border','1px solid #d60000');}}else{$('.video-wrapper').text('Please enter '+source+' URL.').css('padding-top','0');$('#niteoCS-vimeo-url').css('border','1px solid #d60000');$('#niteoCS-youtube-url').css('border','1px solid #d60000');}}
14
- if(source=='video/mp4'){var videoURL=jQuery('#niteoCS-video-id').data('url');if(videoURL!=''){$('.video-wrapper').html('<video width="600" height="400" controls><source src="'+videoURL+'" type="video/mp4">Your browser does not support the video tag.</video>');}}};jQuery('#niteoCS-youtube-url').keyup(function(){videoPreview();});jQuery('#csoptions .banner-video-source').change(function(){switch(jQuery('#csoptions .banner-video-source').val()){case'YouTube':jQuery('.youtube-source-input').css('display','block');jQuery('.vimeo-source-input').css('display','none');jQuery('.file-source-input').css('display','none');break;case'vimeo':jQuery('.youtube-source-input').css('display','none');jQuery('.vimeo-source-input').css('display','block');jQuery('.file-source-input').css('display','none');break;case'video/mp4':jQuery('.youtube-source-input').css('display','none');jQuery('.vimeo-source-input').css('display','none');jQuery('.file-source-input').css('display','block');videoPreview();break;default:jQuery('.file-source-input').css('display','block');jQuery('.youtube-source-input').css('display','none');jQuery('.vimeo-source-input').css('display','none');}});jQuery('#csoptions .banner-video-source').trigger('change');jQuery('#csoptions .niteoCS_banner').change(function(){switch(jQuery('#csoptions .niteoCS_banner:checked').val()){case'0':jQuery('#custom_banner').css('display','block');jQuery('.theme_background fieldset:not(#custom_banner)').css('display','none');break;case'1':jQuery('#unsplash_banner').css('display','block');jQuery('.theme_background fieldset:not(#unsplash_banner)').css('display','none');break;case'2':jQuery('#default_banner').css('display','block');jQuery('.theme_background fieldset:not(#default_banner)').css('display','none');break;case'3':jQuery('#graphic_pattern').css('display','block');jQuery('.theme_background fieldset:not(#graphic_pattern)').css('display','none');break;case'4':jQuery('#solid_color').css('display','block');jQuery('.theme_background fieldset:not(#solid_color)').css('display','none');break;case'5':jQuery('#video_banner').css('display','block');jQuery('.theme_background fieldset:not(#video_banner)').css('display','none');videoPreview();break;case'6':jQuery('#gradient_background').css('display','block');jQuery('.theme_background fieldset:not(#gradient_background)').css('display','none');break;default:jQuery('#custom_banner').css('display','block');jQuery('.theme_background fieldset:not(#custom_banner)').css('display','none');}});jQuery('#csoptions .niteoCS_banner').trigger('change');var unsplasfeed=jQuery('#unsplash_banner select[name^="unsplash_feed"] option:selected').val();jQuery('#unsplash-feed-'+unsplasfeed).css('display','block');jQuery('#unsplash_banner select[name^="unsplash_feed"]').on('change',function(){unsplasfeed=jQuery('#unsplash_banner select[name^="unsplash_feed"] option:selected').val();jQuery('.unsplash-feed').css('display','none');jQuery('#unsplash-feed-'+unsplasfeed).css('display','block');})
15
- jQuery('select.background-gradient').on('change',function(){var gradient=jQuery('select.background-gradient option:selected').val();if(gradient=='custom'){jQuery('.custom-gradient').css('display','block');jQuery('.gradient-preview').css({'background':'-moz-linear-gradient(-45deg, '+jQuery('#niteoCS_gradient_one').val()+' 0%, '+jQuery('#niteoCS_gradient_two').val()+' 100%)','background':'-webkit-linear-gradient(-45deg, '+jQuery('#niteoCS_gradient_one').val()+' 0%, '+jQuery('#niteoCS_gradient_two').val()+' 100%)','background':'linear-gradient(135deg, '+jQuery('#niteoCS_gradient_one').val()+' 0%, '+jQuery('#niteoCS_gradient_two').val()+' 100%)'});}else{colors=gradient.split(':');jQuery('.custom-gradient').css('display','none');jQuery('.gradient-preview').css({'background':'-moz-linear-gradient(-45deg, '+colors[0]+' 0%, '+colors[1]+' 100%)','background':'-webkit-linear-gradient(-45deg, '+colors[0]+' 0%, '+colors[1]+' 100%)','background':'linear-gradient(135deg, '+colors[0]+' 0%, '+colors[1]+' 100%)'});}});jQuery('#niteoCS_banner_color').wpColorPicker({change:function(event,ui){jQuery('.color-preview').css('background-color',ui.color.toString());}});jQuery('#niteoCS_gradient_one').wpColorPicker({change:function(event,ui){jQuery('.gradient-preview').css({'background':'-moz-linear-gradient(-45deg, '+ui.color.toString()+' 0%, '+jQuery('#niteoCS_gradient_two').val()+' 100%)','background':'-webkit-linear-gradient(-45deg, '+ui.color.toString()+' 0%, '+jQuery('#niteoCS_gradient_two').val()+' 100%)','background':'linear-gradient(135deg, '+ui.color.toString()+' 0%, '+jQuery('#niteoCS_gradient_two').val()+' 100%)'});}});jQuery('#niteoCS_gradient_two').wpColorPicker({change:function(event,ui){jQuery('.gradient-preview').css({'background':'-moz-linear-gradient(-45deg, '+jQuery('#niteoCS_gradient_one').val()+' 0%, '+ui.color.toString()+' 100%)','background':'-webkit-linear-gradient(-45deg, '+jQuery('#niteoCS_gradient_one').val()+' 0%, '+ui.color.toString()+' 100%)','background':'linear-gradient(135deg, '+jQuery('#niteoCS_gradient_one').val()+' 0%, '+ui.color.toString()+' 100%)'});}});jQuery('select[name^="niteoCS_banner_pattern"]').on('change',function(){var pattern=jQuery('select[name^="niteoCS_banner_pattern"] option:selected').val();if(pattern!='custom'){var pattern_url=jQuery(this).data('url');jQuery('#add-pattern').css('display','none');jQuery('.pattern-wrapper').css('background-image','url(\''+pattern_url+pattern+'.png\')');}else{var pattern_url=jQuery('#niteoCS_banner_pattern_custom').val();jQuery('#add-pattern').css('display','block');jQuery('.pattern-wrapper').css('background-image','url(\''+pattern_url+'\')');}});if(jQuery('#niteoCS_subscribe').prop('checked')==true){jQuery('.subscribe').css('display','block')}
16
- jQuery('#niteoCS_subscribe').change(function(){if(jQuery(this)[0].checked){jQuery('.subscribe').css('display','block')}else{jQuery('.subscribe').css('display','none')}});jQuery('#csoptions input[name="niteoCS_subscribe_type"]').change(function(){if(jQuery('#csoptions input[name="niteoCS_subscribe_type"]:checked').val()==0){jQuery('#subscribe-disabled').css('display','block');jQuery('#subscribe-3rdparty').css('display','none');jQuery('#subscribe-niteo').css('display','none');}else if(jQuery('#csoptions input[name="niteoCS_subscribe_type"]:checked').val()==1){jQuery('#subscribe-disabled').css('display','none');jQuery('#subscribe-3rdparty').css('display','block');jQuery('#subscribe-niteo').css('display','none');}else{jQuery('#subscribe-disabled').css('display','none');jQuery('#subscribe-3rdparty').css('display','none');jQuery('#subscribe-niteo').css('display','block');}});jQuery('.heading-animation').on('change',function(){heading_anim=jQuery('.heading-animation option:selected').val();jQuery('#heading-example').removeClass().addClass('animated '+heading_anim);});jQuery('.content-animation').on('change',function(){heading_anim=jQuery('.content-animation option:selected').val();jQuery('#content-example').removeClass().addClass('animated '+heading_anim);});var update_social=function(name,key,val){var socialmedia=$('#niteoCS_socialmedia').attr('value');socialmedia=$.parseJSON(socialmedia);$.each(socialmedia,function(i,ele){if(ele['name']==name){ele[key]=val;}});$('#niteoCS_socialmedia').attr('value',JSON.stringify(socialmedia));};var $sortableList=$('.social-inputs');var sortEventHandler=function(event,ui){var inputs=$sortableList.find('input[type="text"]');var order=ui.item.index();inputs.each(function(i,ele){var name=$(ele).data('name');update_social(name,'order',i);});};$sortableList.sortable({stop:sortEventHandler});$sortableList.on('sortchange',sortEventHandler);(function($){$.fn.toggleDisabled=function(){return this.each(function(){var $this=$(this);var active;var name=$this.data('name');if($this.attr('disabled')){$this.prop('disabled',false);active='1';}else{$this.prop('disabled',true);active='0';}
17
- update_social(name,'active',active);});};})(jQuery);jQuery('.social-inputs input[type="text"]').focusout(function(){var name=jQuery(this).data('name');var socialurl=jQuery(this).attr('value');update_social(name,'url',socialurl);});jQuery('.social-inputs input[type="checkbox"]').click(function(e){var $this=$(this).siblings('input[type="text"]');$this.toggleDisabled();});jQuery('.social-media i').click(function(){var name=jQuery(this).data('name');jQuery(this).toggleClass('active');jQuery('.social-inputs li.'+name).toggleClass('active');jQuery('.social-inputs li.'+name+' input').trigger('change');if(jQuery(this).hasClass('active')){update_social(name,'hidden','0');}else{update_social(name,'hidden','1');}
18
- if(jQuery('.social-media i.active').length){jQuery('.social-inputs .label').css('display','block');}else{jQuery('.social-inputs .label').css('display','none');}});if(jQuery('.social-media i.active').length){jQuery('.social-inputs .label').css('display','block');}
19
- jQuery('.view-release').click(function(e){e.preventDefault();$this=jQuery(this);var release_url=$this.attr('href');jQuery.get(release_url,function(release){$this.closest('.notice').find('.release-note .notes').remove();$this.closest('.notice').find('.release-note').append('<div class="notes">'+release+'</div>');}).fail(function(){$this.closest('.notice').find('.release-note p').remove();$this.closest('.notice').find('.release-note').append('<p>There was an error loading release notes. Please try again later.</p>');});});jQuery('.update-theme').click(function(e){e.preventDefault();var $this=$(this),$parent=$this.parents('.notice'),security=$this.data('security'),slug=$this.data('slug'),type=$this.data('type'),themeName=$parent.find('.theme-name').text(),remoteUrl=jQuery(this).data('remote_url');update={'name':slug,'tmp_name':'','type':type,'url':remoteUrl+'?action=download&slug='+slug,}
20
- var data={action:'cmp_theme_update_install',security:security,file:update};$parent.find('.message').html('<i class="fa fa-cog fa-spin fa-1x fa-fw"></i><span class="sr-only">Updating heme...</span><span> working hard on updating Theme...</span>');$.post(ajaxurl,data,function(response){if(response=='success'){setTimeout(function(){$parent.removeClass('notice-warning').addClass('notice-success');$parent.find('.message').html('<span> '+themeName+' Theme was updated sucessfully! </span><i class="fa fa-smile-o" aria-hidden="true"></i>');},1500);}else{response=response.slice(0,-1);var error=$('p',$(response)).text();$parent.removeClass('notice-warning').addClass('notice-error');$parent.find('.message').html('<i class="fa fa-frown-o" aria-hidden="true"></i><span> '+error+'</span>');}});});jQuery('.theme-select').click(function(){jQuery(this).parent().find('input[name="select_theme"]').prop("checked",true).trigger('change');jQuery('.theme-select').removeClass('selected');jQuery(this).parent().find('.theme-select').addClass('selected');});jQuery('.theme-update.button').one('click',function(e){e.preventDefault();var $this=$(this),$wrapper=$this.closest('.theme-wrapper'),security=$wrapper.data('security'),slug=$wrapper.data('slug'),type=$wrapper.data('type'),remoteUrl=$wrapper.data('remote_url');var update={'name':slug,'tmp_name':'','type':type,'url':remoteUrl+'?action=download&slug='+slug,}
21
- var data={action:'cmp_theme_update_install',security:security,file:update};$this.html('<i class="fa fa-cog fa-spin fa-1x fa-fw"></i><span>Updating..</span>');$.post(ajaxurl,data,function(response){if(response=='success'){setTimeout(function(){$this.html('<i class="fa fa-smile-o" aria-hidden="true"></i><span>Updated!</span>');setTimeout(function(){$this.fadeOut();},1500);},1500);}else{response=response.slice(0,-1);$this.html('<i class="fa fa-frown-o" aria-hidden="true"></i><span>Update Failed!</span>');}});});jQuery('.theme-details').click(function(){var $this=$(this),$wrapper=$this.closest('.theme-wrapper'),slug=$wrapper.data('slug'),version=$wrapper.data('version'),remoteUrl=$wrapper.data('remote_url'),type=$wrapper.data('type'),purchased=$wrapper.data('purchased'),freebie=$wrapper.data('freebie'),noticeHtml='',security=jQuery('.update-theme').data('security'),i=0;var data={action:'niteo_themeinfo',security:jQuery('.theme-wrapper').data('security'),theme_slug:jQuery(this).parents('.theme-wrapper').data('slug'),};$.post(ajaxurl,data,function(response){var buttonDisabled='';var buyButton='';var versionInfo='';var noticeHtml='';response=jQuery.parseJSON(response);if(response.result=='true'){jQuery('body').addClass('modal-open');if(purchased=='1'&&type=='premium'){versionInfo='<span class="theme-version">Version: '+version+'</span>';if(jQuery('.update-theme').length){var newVer=jQuery('.update-theme').data('new_ver');noticeHtml='<div class="notice notice-warning notice-alt notice-large"><h3 class="notice-title">Update Available</h3><p class="message"><strong>There is a new version of '+response['name']+' theme available. <a href="'+remoteUrl+'readme/'+slug+'-readme.php" class="view-release">View update '+newVer+' notes</a> or <a href="'+window.location.href+'&action=update-cmp-theme&theme='+slug+'&type='+type+'" class="update-theme" data-type="'+type+'" data-security="'+security+'" data-slug="'+slug+'" data-remote_url="'+remoteUrl+'">Update now.</a></strong></p><div class="release-note"></div></div>';}else{noticeHtml='<div class="notice notice-success notice-alt notice-large"><p>Theme is up to date.</p></div>';}}
22
- if(purchased!='1'&&type=='premium'){var buttonDisabled='disabled ';var buyURL=$wrapper.find('a').attr('href');if(!freebie){var buyButton='<button type="button" class="theme-purchase button hide"><a href="'+buyURL+'" target="_blank"><i class="fa fa-cart-arrow-down" aria-hidden="true"></i>Buy</a></button>';}else if(freebie){var buyButton='<button type="button" class="theme-purchase button hide"><a href="'+buyURL+'" target="_blank"><i class="fa fa-download" aria-hidden="true"></i>FREE Download</a></button>';}}
23
- var screenshots=response.screenshots;var arrows='';if(Object.keys(screenshots).length>1){arrows='<div class="screenshots-nav"><div class="left"><i class="fa fa-chevron-left" aria-hidden="true"></i></div><div class="right"><i class="fa fa-chevron-right" aria-hidden="true"></i></div></div>';}
24
- var html=$(['<div class="theme-backdrop">',' <div class="theme-wrap">',' <div class="theme-header">',' <button class="close dashicons dashicons-no"><span class="screen-reader-text">Close details dialog</span></button>',' </div>',' <div class="theme-about">',' <div class="theme-screenshots">',' <div class="screenshot" style="background-image:url(\''+screenshots['0']+'\')">'+arrows+'</div>',' </div>',' <div class="theme-info">',' <h2 class="theme-name">'+response['name']+versionInfo+'</h2>',' <p class="theme-author">By <a href="'+response['author_homepage']+'" target="_blank">'+response['author']+'</a></p>',noticeHtml,' <div class="theme-description">'+response['description']+'</div>',buyButton,' </div>',' </div>',' <div class="theme-actions">',' <button type="submit" '+buttonDisabled+'class="button activate" name="Submit" aria-label="Select '+response['name']+'">Activate</button>',' <a href="http://cmp.niteothemes.com/?cmp_preview=true&selector=true&theme='+slug+'&utm_source=cmp&utm_medium=referral&utm_campaign='+slug+'" class="button cmp-preview" target="_blank" aria-label="Preview '+response['name']+'">Live Preview</a>',' </div>',' </div>','</div>',].join("\n"));jQuery('.theme-overlay.cmp').append(html);jQuery('.theme-overlay.cmp .view-release').click(function(e){e.preventDefault();$this=jQuery(this);var release_url=$this.attr('href');jQuery.get(release_url,function(release){$this.closest('.notice').find('.release-note .notes').remove();$this.closest('.notice').find('.release-note').append('<div class="notes">'+release+'</div>');}).fail(function(){$this.closest('.notice').find('.release-note p').remove();$this.closest('.notice').find('.release-note').append('<p>There was an error loading release notes. Please try again later.</p>');});});jQuery('.theme-overlay.cmp .close').click(function(e){e.preventDefault();jQuery('body').removeClass('modal-open');jQuery('.theme-overlay.cmp .theme-backdrop').fadeOut('fast');});jQuery('.theme-overlay.cmp .activate').click(function(e){e.preventDefault();jQuery('input[name="select_theme"]').each(function(){if(jQuery(this).val()==slug){jQuery(this).prop('checked',true);jQuery('.theme-select').removeClass('selected');jQuery(this).parent().addClass('selected');}});jQuery('#csoptions').submit();});jQuery('.screenshots-nav .right').click(function(){i++;if(i==Object.keys(screenshots).length){i=0;}
25
- if((i in screenshots)){jQuery('.screenshot').css('background-image','url(\''+screenshots[i]+'\')');}});jQuery('.screenshots-nav .left').click(function(){i--;if(i<0){i=Object.keys(screenshots).length-1;}
26
- if((i in screenshots)){jQuery('.screenshot').css('background-image','url(\''+screenshots[i]+'\')');}});}});});jQuery('#csoptions input[name="niteoCS_banner"]').trigger('change');jQuery('#csoptions input[name="niteoCS_subscribe_type"]').trigger('change');media_upload_button('logo',false,'image');media_upload_button('favicon',false,'image');media_upload_button('banner',true,'image');media_upload_button('pattern',false,'image');media_upload_button('video-thumb',false,'image');media_upload_button('video',false,'video');$('#niteoCS_overlay_opacity').on('input',function(){$(this).trigger('change');});jQuery('#niteoCS_overlay_opacity').change(function(){if(this.value==0){jQuery('#current-opacity').html(': transparent');}else{jQuery('#current-opacity').html(': '+this.value);}});function ucwords(str){return(str+'').replace(/^([a-z])|\s+([a-z])/g,function($1){return $1.toUpperCase();});}
27
- function strtolower(str){return(str+'').toLowerCase();}
28
- function media_upload_button(name,multiple,type){var $container=jQuery('.'+name+'-wrapper');var $add_button=jQuery('#add-'+name);var $delete_button=jQuery('#delete-'+name);var image;var imgID='';var title=name.replace('-',' ');title=title[0].toUpperCase()+title.slice(1);if(jQuery('#niteoCS-'+name+'-id').val()!=''){$delete_button.css('display','block');}
29
- $add_button.click(function(e){e.preventDefault();if(media_uploader){media_uploader.open();return;}
30
- var media_uploader=wp.media({title:'Select '+title,button:{text:'Insert '+title},multiple:multiple,library:{type:[type]},}).on('select',function(){var attachment=media_uploader.state().get('selection').toJSON();if(attachment.length>0){$container.empty();jQuery(attachment).each(function(i){if(attachment[i].sizes&&attachment[i].sizes.large){image=attachment[i].sizes.large.url;}else{image=attachment[i].url;}
31
- var comma=i===0?'':',';imgID+=(comma+attachment[i].id);if(name=='pattern'){$container.css('background-image','url(\''+image+'\')');}else if(name=='video'){$container.append('<video width="600" height="400" controls><source src="'+image+'" type="video/mp4">Your browser does not support the video tag.</video>');}else{$container.append('<img src="'+image+'" alt="" style="max-width:588px"/>');}});$delete_button.css('display','block');}
32
- jQuery('#niteoCS-'+name+'-id').val(imgID).trigger('change');}).open();if(name=='pattern'){$container.css('background-image','url(\''+image+'\')');}});$delete_button.click(function(e){jQuery(this).css('display','none');$container.empty();jQuery('#niteoCS-'+name+'-id').val('');jQuery('#niteoCS-'+name+'-id').trigger('change');});}});
 
 
1
+ jQuery(document).ready(function($){var formChanged=!1;var tab=document.location.hash.substring(1);var action=jQuery('#csoptions').attr('action');navtab=function(tab){jQuery('.nav-tab-wrapper .nav-tab').removeClass('nav-tab-active');jQuery('.nav-tab-wrapper .'+tab).addClass('nav-tab-active');jQuery('.table-wrapper.'+tab).css('display','block');jQuery('.comingsoon.'+tab).css('display','block');jQuery('.table-wrapper:not(.'+tab+')').css('display','none');jQuery('.comingsoon:not(.'+tab+')').css('display','none');if(tab=='install'){jQuery('.submit').css('display','none');jQuery('#csoptions').attr('action',action)}else{jQuery('.submit').css('display','block');jQuery('#csoptions').attr('action',action+'#'+tab)}}
2
+ if(tab!=''){navtab(tab)}
3
+ window.onhashchange=function(){tab=document.location.hash.substring(1);navtab(tab)}
4
+ $('.nav-tab:not(.theme-preview)').click(function(e){e.preventDefault();tab=$(this).data('tab');document.location.hash=tab});jQuery('#cmp-status').click(function(){jQuery('.cmp-status input[type=radio]').prop("disabled",(_,val)=>!val);jQuery('#cmp-status-menubar').prop("checked",(_,val)=>!val)});cmp_status_inputs();function cmp_status_inputs(){jQuery('.cmp-status legend:not(.disabled)').click(function(){if(jQuery('#cmp-status').prop('checked')==!1){return}
5
+ var $children=jQuery(this).children('input');$children.prop("checked",!0);jQuery('.cmp-status legend').removeClass('active');jQuery(this).addClass('active');$children.trigger('change');if($children.val()=='3'){jQuery('.redirect-inputs').fadeIn('fast')}else{jQuery('.redirect-inputs').fadeOut('fast')}})}
6
+ jQuery('.table-wrapper h3').click(function(){jQuery(this).parent().toggleClass('closed')});jQuery('.niteoCS-logo-type').change(function(){if(jQuery('.niteoCS-logo-type:checked').val()=='text'){jQuery('.text-logo').css('display','block');jQuery('.graphic-logo').css('display','none');jQuery('.disabled-logo').css('display','none')}else if(jQuery('.niteoCS-logo-type:checked').val()=='graphic'){jQuery('.text-logo').css('display','none');jQuery('.graphic-logo').css('display','block');jQuery('.disabled-logo').css('display','none')}else if(jQuery('.niteoCS-logo-type:checked').val()=='disabled'){jQuery('.text-logo').css('display','none');jQuery('.graphic-logo').css('display','none');jQuery('.disabled-logo').css('display','block')}});jQuery('#test-unsplash').click(function(e){e.preventDefault();var media_wrapper=jQuery('#unsplash-media'),unsplash_feed=jQuery('#unsplash_banner select[name^="unsplash_feed"] option:selected').val(),unsp_url='',feat='',custom_str='',security=jQuery(this).data('security');switch(unsplash_feed){case '0':unsp_url=jQuery('#niteoCS-unsplash-0').val();break;case '1':custom_str=jQuery('#niteoCS-unsplash-1').val();break;case '2':unsp_url=jQuery('#niteoCS-unsplash-2').val();break;case '3':unsp_url=jQuery('#niteoCS-unsplash-3').val();if(jQuery('#niteoCS_unsplash_feat').is(':checked')){feat='1'}else{feat='0'}
7
+ break;default:break}
8
+ if(unsplash_feed==3||unsp_url!=''||custom_str!=''){var params={feed:unsplash_feed,url:unsp_url,feat:feat,custom_str:custom_str};jQuery(this).prop('disabled',!0);jQuery(this).html('<i class="fa fa-cog fa-spin fa-1x fa-fw"></i><span> loading..</span>');media_wrapper.html('');var data={action:'niteo_unsplash',security:security,params:params};$.post(ajaxurl,data,function(response){var unsplash=jQuery.parseJSON(response);jQuery('#unsplash_img').remove();var loadingTimeout=setTimeout(function(){jQuery('#test-unsplash').prop('disabled',!1);jQuery('#test-unsplash').text('Display Unsplash Photo');jQuery('#unsplash-media').html('<p>It seems <a href="https://status.unsplash.com/" target="_blank">Unsplash API</a> is not responding. Please try again later.</p>')},5000);if(unsplash.response=='200'){var unsplash=jQuery.parseJSON(unsplash.body);if(unsplash[0]){var img=unsplash[0].urls.raw+'?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&fit=max&w=588';var author=unsplash[0].user.name;var author_url=unsplash[0].user.links.html;var img_url=unsplash[0].links.html;var img_id=unsplash[0].id}else{var img=unsplash.urls.raw+'?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&fit=max&w=588';var author=unsplash.user.name;var author_url=unsplash.user.links.html;var img_url=unsplash.links.html;var img_id=unsplash.id}
9
+ jQuery('<img />',{src:img,id:'unsplash_img'}).one('load',function(){jQuery(this).appendTo(media_wrapper);jQuery(this).fadeIn();jQuery('#test-unsplash').prop('disabled',!1);jQuery('#test-unsplash').text('Display Unsplash Photo');jQuery('#unsplash-media').append('<span><a href="'+img_url+'" target="_blank">Photo</a> (ID: '+img_id+') by <a href="'+author_url+'" target="_blank">'+author+'</a> / <a href="https://unsplash.com/" target="_blank">Unsplash</a></span>')
10
+ clearTimeout(loadingTimeout)})}else{var error=jQuery.parseJSON(unsplash.body);jQuery('#test-unsplash').prop('disabled',!1);jQuery('#test-unsplash').text('Display Unsplash Photo');jQuery('#unsplash-media').html('<p>Error '+unsplash.response+': <span style="text-transform:lowercase;">'+error.errors+' '+custom_str+'</span></p>');clearTimeout(loadingTimeout)}})}else{jQuery('#unsplash_img').remove()}});jQuery('select:not(.headings-google-font):not(.content-google-font )').select2({width:'100%',minimumResultsForSearch:-1,});videoPreview=function(){var source=$('.banner-video-source').val();$('.video-wrapper').css('padding-top','0');if(source=='YouTube'){var youtubeLink=$('#niteoCS-youtube-url').val();if(youtubeLink.match(/(youtube.com)/)){var split_c='v=';var split_n=1}
11
+ if(youtubeLink.match(/(youtu.be)/)||youtubeLink.match(/(vimeo.com\/)+[0-9]/)){var split_c='/';var split_n=3}
12
+ if(source=='vimeo'){var youtubeLink=$('#niteoCS-vimeo-url').val();if(youtubeLink.match(/(vimeo.com\/)+[a-zA-Z]/)){var split_c='/';var split_n=5}}
13
+ if(youtubeLink){var getYouTubeVideoID=youtubeLink.split(split_c)[split_n];if(getYouTubeVideoID!=undefined){var cleanVideoID=getYouTubeVideoID.replace(/(&)+(.*)/,'');if(source=='banner_youtube'&&youtubeLink.match(/(youtu.be)/)||youtubeLink.match(/(youtube.com)/)){var videoEmbedLink='https://www.youtube.com/embed/'+cleanVideoID+'?autoplay=0'}
14
+ if(source=='banner_vimeo'&&youtubeLink.match(/(vimeo.com\/)+[0-9]/)||youtubeLink.match(/(vimeo.com\/)+[a-zA-Z]/)){var videoEmbedLink='https://player.vimeo.com/video/'+cleanVideoID+'?autoplay=0'}
15
+ var $iframe=$('<iframe src="'+videoEmbedLink+'" allowfullscreen></iframe>');$('.video-wrapper').html($iframe);var videoRatio=($iframe.height()/$iframe.width())*100;$iframe.css('position','absolute');$iframe.css('top','0');$iframe.css('left','0');$iframe.css('width','100%');$iframe.css('height','100%');$('.video-wrapper').css('padding-top',videoRatio+'%');$('#niteoCS-vimeo-url').css('border','1px solid #ddd');$('#niteoCS-youtube-url').css('border','1px solid #ddd')}else{$('.video-wrapper').text('Please enter correct '+source+' URL.').css('padding-top','0');$('#niteoCS-vimeo-url').css('border','1px solid #d60000');$('#niteoCS-youtube-url').css('border','1px solid #d60000')}}else{$('.video-wrapper').text('Please enter '+source+' URL.').css('padding-top','0');$('#niteoCS-vimeo-url').css('border','1px solid #d60000');$('#niteoCS-youtube-url').css('border','1px solid #d60000')}}
16
+ if(source=='video/mp4'){var videoURL=jQuery('#niteoCS-video-id').data('url');if(videoURL!=''){$('.video-wrapper').html('<video width="600" height="400" controls><source src="'+videoURL+'" type="video/mp4">Your browser does not support the video tag.</video>')}}};jQuery('#niteoCS-youtube-url').keyup(function(){videoPreview()});jQuery('#csoptions .banner-video-source').change(function(){switch(jQuery('#csoptions .banner-video-source').val()){case 'YouTube':jQuery('.youtube-source-input').css('display','block');jQuery('.vimeo-source-input').css('display','none');jQuery('.file-source-input').css('display','none');break;case 'vimeo':jQuery('.youtube-source-input').css('display','none');jQuery('.vimeo-source-input').css('display','block');jQuery('.file-source-input').css('display','none');break;case 'video/mp4':jQuery('.youtube-source-input').css('display','none');jQuery('.vimeo-source-input').css('display','none');jQuery('.file-source-input').css('display','block');videoPreview();break;default:jQuery('.file-source-input').css('display','block');jQuery('.youtube-source-input').css('display','none');jQuery('.vimeo-source-input').css('display','none')}});jQuery('#csoptions .banner-video-source').trigger('change');jQuery('#csoptions .niteoCS_banner').change(function(){switch(jQuery('#csoptions .niteoCS_banner:checked').val()){case '0':jQuery('#custom_banner').css('display','block');jQuery('.theme_background fieldset:not(#custom_banner)').css('display','none');break;case '1':jQuery('#unsplash_banner').css('display','block');jQuery('.theme_background fieldset:not(#unsplash_banner)').css('display','none');break;case '2':jQuery('#default_banner').css('display','block');jQuery('.theme_background fieldset:not(#default_banner)').css('display','none');break;case '3':jQuery('#graphic_pattern').css('display','block');jQuery('.theme_background fieldset:not(#graphic_pattern)').css('display','none');break;case '4':jQuery('#solid_color').css('display','block');jQuery('.theme_background fieldset:not(#solid_color)').css('display','none');break;case '5':jQuery('#video_banner').css('display','block');jQuery('.theme_background fieldset:not(#video_banner)').css('display','none');videoPreview();break;case '6':jQuery('#gradient_background').css('display','block');jQuery('.theme_background fieldset:not(#gradient_background)').css('display','none');break;default:jQuery('#custom_banner').css('display','block');jQuery('.theme_background fieldset:not(#custom_banner)').css('display','none');break}});jQuery('#csoptions .niteoCS_banner:first').trigger('change');var unsplasfeed=jQuery('#unsplash_banner select[name^="unsplash_feed"] option:selected').val();jQuery('#unsplash-feed-'+unsplasfeed).css('display','block');jQuery('#unsplash_banner select[name^="unsplash_feed"]').on('change',function(){unsplasfeed=jQuery('#unsplash_banner select[name^="unsplash_feed"] option:selected').val();jQuery('.unsplash-feed').css('display','none');jQuery('#unsplash-feed-'+unsplasfeed).css('display','block');jQuery('#test-unsplash').trigger('click')});if(jQuery('#csoptions .niteoCS_banner:checked').val()==1){jQuery('#test-unsplash').trigger('click')}
17
+ jQuery('select.background-gradient').on('change',function(){var gradient=jQuery('select.background-gradient option:selected').val();if(gradient=='custom'){jQuery('.custom-gradient').css('display','block');jQuery('.gradient-preview').css({'background':'-moz-linear-gradient(-45deg, '+jQuery('#niteoCS_gradient_one').val()+' 0%, '+jQuery('#niteoCS_gradient_two').val()+' 100%)','background':'-webkit-linear-gradient(-45deg, '+jQuery('#niteoCS_gradient_one').val()+' 0%, '+jQuery('#niteoCS_gradient_two').val()+' 100%)','background':'linear-gradient(135deg, '+jQuery('#niteoCS_gradient_one').val()+' 0%, '+jQuery('#niteoCS_gradient_two').val()+' 100%)'})}else{colors=gradient.split(':');jQuery('.custom-gradient').css('display','none');jQuery('.gradient-preview').css({'background':'-moz-linear-gradient(-45deg, '+colors[0]+' 0%, '+colors[1]+' 100%)','background':'-webkit-linear-gradient(-45deg, '+colors[0]+' 0%, '+colors[1]+' 100%)','background':'linear-gradient(135deg, '+colors[0]+' 0%, '+colors[1]+' 100%)'})}});jQuery('#niteoCS_banner_color').wpColorPicker({change:function(event,ui){jQuery('.color-preview').css('background-color',ui.color.toString())}});jQuery('#niteoCS_gradient_one').wpColorPicker({change:function(event,ui){jQuery('.gradient-preview').css({'background':'-moz-linear-gradient(-45deg, '+ui.color.toString()+' 0%, '+jQuery('#niteoCS_gradient_two').val()+' 100%)','background':'-webkit-linear-gradient(-45deg, '+ui.color.toString()+' 0%, '+jQuery('#niteoCS_gradient_two').val()+' 100%)','background':'linear-gradient(135deg, '+ui.color.toString()+' 0%, '+jQuery('#niteoCS_gradient_two').val()+' 100%)'})}});jQuery('#niteoCS_gradient_two').wpColorPicker({change:function(event,ui){jQuery('.gradient-preview').css({'background':'-moz-linear-gradient(-45deg, '+jQuery('#niteoCS_gradient_one').val()+' 0%, '+ui.color.toString()+' 100%)','background':'-webkit-linear-gradient(-45deg, '+jQuery('#niteoCS_gradient_one').val()+' 0%, '+ui.color.toString()+' 100%)','background':'linear-gradient(135deg, '+jQuery('#niteoCS_gradient_one').val()+' 0%, '+ui.color.toString()+' 100%)'})}});jQuery('select[name^="niteoCS_banner_pattern"]').on('change',function(){var pattern=jQuery('select[name^="niteoCS_banner_pattern"] option:selected').val();if(pattern!='custom'){var pattern_url=jQuery(this).data('url');jQuery('#add-pattern').css('display','none');jQuery('.pattern-wrapper').css('background-image','url(\''+pattern_url+pattern+'.png\')')}else{var pattern_url=jQuery('#niteoCS_banner_pattern_custom').val();jQuery('#add-pattern').css('display','block');jQuery('.pattern-wrapper').css('background-image','url(\''+pattern_url+'\')')}});if(jQuery('#niteoCS_subscribe').prop('checked')==!0){jQuery('.subscribe').css('display','block')}
18
+ jQuery('#niteoCS_subscribe').change(function(){if(jQuery(this)[0].checked){jQuery('.subscribe').css('display','block')}else{jQuery('.subscribe').css('display','none')}});jQuery('#csoptions input[name="niteoCS_subscribe_type"]').change(function(){if(jQuery('#csoptions input[name="niteoCS_subscribe_type"]:checked').val()==0){jQuery('#subscribe-disabled').css('display','block');jQuery('#subscribe-3rdparty').css('display','none');jQuery('#subscribe-niteo').css('display','none')}else if(jQuery('#csoptions input[name="niteoCS_subscribe_type"]:checked').val()==1){jQuery('#subscribe-disabled').css('display','none');jQuery('#subscribe-3rdparty').css('display','block');jQuery('#subscribe-niteo').css('display','none')}else{jQuery('#subscribe-disabled').css('display','none');jQuery('#subscribe-3rdparty').css('display','none');jQuery('#subscribe-niteo').css('display','block')}});jQuery('.heading-animation').on('change',function(){heading_anim=jQuery('.heading-animation option:selected').val();jQuery('#heading-example').removeClass().addClass('animated '+heading_anim)});jQuery('.content-animation').on('change',function(){heading_anim=jQuery('.content-animation option:selected').val();jQuery('#content-example').removeClass().addClass('animated '+heading_anim)});var update_social=function(name,key,val){var socialmedia=$('#niteoCS_socialmedia').attr('value');socialmedia=$.parseJSON(socialmedia);$.each(socialmedia,function(i,ele){if(ele.name==name){ele[key]=val}});$('#niteoCS_socialmedia').attr('value',JSON.stringify(socialmedia))};var $sortableList=$('.social-inputs');var sortEventHandler=function(event,ui){var inputs=$sortableList.find('input[type="text"]');var order=ui.item.index();inputs.each(function(i,ele){var name=$(ele).data('name');update_social(name,'order',i)})};$sortableList.sortable({stop:sortEventHandler});$sortableList.on('sortchange',sortEventHandler);(function($){$.fn.toggleDisabled=function(){return this.each(function(){var $this=$(this);var active;var name=$this.data('name');if($this.attr('disabled')){$this.prop('disabled',!1);active='1'}else{$this.prop('disabled',!0);active='0'}
19
+ update_social(name,'active',active)})}})(jQuery);jQuery('.social-inputs input[type="text"]').focusout(function(){var name=jQuery(this).data('name');var socialurl=jQuery(this).attr('value');update_social(name,'url',socialurl)});jQuery('.social-inputs input[type="checkbox"]').click(function(e){var $this=$(this).siblings('input[type="text"]');$this.toggleDisabled()});jQuery('.social-media i').click(function(){var name=jQuery(this).data('name');jQuery(this).toggleClass('active');jQuery('.social-inputs li.'+name).toggleClass('active');jQuery('.social-inputs li.'+name+' input').trigger('change');if(jQuery(this).hasClass('active')){update_social(name,'hidden','0')}else{update_social(name,'hidden','1')}
20
+ if(jQuery('.social-media i.active').length){jQuery('.social-inputs .label').css('display','block')}else{jQuery('.social-inputs .label').css('display','none')}});if(jQuery('.social-media i.active').length){jQuery('.social-inputs .label').css('display','block')}
21
+ jQuery('.view-release').click(function(e){e.preventDefault();$this=jQuery(this);var release_url=$this.attr('href');jQuery.get(release_url,function(release){$this.closest('.notice').find('.release-note .notes').remove();$this.closest('.notice').find('.release-note').append('<div class="notes">'+release+'</div>')}).fail(function(){$this.closest('.notice').find('.release-note p').remove();$this.closest('.notice').find('.release-note').append('<p>There was an error loading release notes. Please try again later.</p>')})});jQuery('.update-theme').click(function(e){e.preventDefault();var $this=$(this),$parent=$this.parents('.notice'),security=$this.data('security'),slug=$this.data('slug'),type=$this.data('type'),themeName=$parent.find('.theme-name').text(),remoteUrl=jQuery(this).data('remote_url');update={'name':slug,'tmp_name':'','type':type,'url':remoteUrl+'?action=download&slug='+slug,}
22
+ var data={action:'cmp_theme_update_install',security:security,file:update};$parent.find('.message').html('<i class="fa fa-cog fa-spin fa-1x fa-fw"></i><span class="sr-only">Updating heme...</span><span> working hard on updating Theme...</span>');$.post(ajaxurl,data,function(response){if(response=='success'){setTimeout(function(){$parent.removeClass('notice-warning').addClass('notice-success');$parent.find('.message').html('<span> '+themeName+' Theme was updated sucessfully! </span><i class="fa fa-smile-o" aria-hidden="true"></i>')},1500)}else{response=response.slice(0,-1);var error=$('p',$(response)).text();$parent.removeClass('notice-warning').addClass('notice-error');$parent.find('.message').html('<i class="fa fa-frown-o" aria-hidden="true"></i><span> '+error+'</span>')}})});jQuery('.theme-select').click(function(){jQuery(this).parent().find('input[name="select_theme"]').prop("checked",!0).trigger('change');jQuery('.theme-select').removeClass('selected');jQuery(this).parent().find('.theme-select').addClass('selected')});jQuery('.theme-update.button').one('click',function(e){e.preventDefault();var $this=$(this),$wrapper=$this.closest('.theme-wrapper'),security=$wrapper.data('security'),slug=$wrapper.data('slug'),type=$wrapper.data('type'),remoteUrl=$wrapper.data('remote_url');var update={'name':slug,'tmp_name':'','type':type,'url':remoteUrl+'?action=download&slug='+slug,}
23
+ var data={action:'cmp_theme_update_install',security:security,file:update};$this.html('<i class="fa fa-cog fa-spin fa-1x fa-fw"></i><span>Updating..</span>');$.post(ajaxurl,data,function(response){if(response=='success'){setTimeout(function(){$this.html('<i class="fa fa-smile-o" aria-hidden="true"></i><span>Updated!</span>');setTimeout(function(){$this.fadeOut()},1500)},1500)}else{response=response.slice(0,-1);$this.html('<i class="fa fa-frown-o" aria-hidden="true"></i><span>Update Failed!</span>')}})});jQuery('.theme-details').click(function(){var $this=$(this),$wrapper=$this.closest('.theme-wrapper'),slug=$wrapper.data('slug'),version=$wrapper.data('version'),remoteUrl=$wrapper.data('remote_url'),type=$wrapper.data('type'),purchased=$wrapper.data('purchased'),freebie=$wrapper.data('freebie'),noticeHtml='',security=jQuery('.update-theme').data('security'),i=0;var data={action:'niteo_themeinfo',security:jQuery('.theme-wrapper').data('security'),theme_slug:jQuery(this).parents('.theme-wrapper').data('slug'),};$.post(ajaxurl,data,function(response){var buttonDisabled='';var buyButton='';var versionInfo='';var noticeHtml='';response=jQuery.parseJSON(response);if(response.result=='true'){jQuery('body').addClass('modal-open');if(purchased=='1'&&type=='premium'){versionInfo='<span class="theme-version">Version: '+version+'</span>';if(jQuery('.update-theme').length){var newVer=jQuery('.update-theme').data('new_ver');noticeHtml='<div class="notice notice-warning notice-alt notice-large"><h3 class="notice-title">Update Available</h3><p class="message"><strong>There is a new version of '+response.name+' theme available. <a href="'+remoteUrl+'readme/'+slug+'-readme.php" class="view-release">View update '+newVer+' notes</a> or <a href="'+window.location.href+'&action=update-cmp-theme&theme='+slug+'&type='+type+'" class="update-theme" data-type="'+type+'" data-security="'+security+'" data-slug="'+slug+'" data-remote_url="'+remoteUrl+'">Update now.</a></strong></p><div class="release-note"></div></div>'}else{noticeHtml='<div class="notice notice-success notice-alt notice-large"><p>Theme is up to date.</p></div>'}}
24
+ if(purchased!='1'&&type=='premium'){var buttonDisabled='disabled ';var buyURL=$wrapper.find('a').attr('href');if(!freebie){var buyButton='<button type="button" class="theme-purchase button hide"><a href="'+buyURL+'" target="_blank"><i class="fa fa-cart-arrow-down" aria-hidden="true"></i>Buy</a></button>'}else if(freebie){var buyButton='<button type="button" class="theme-purchase button hide"><a href="'+buyURL+'" target="_blank"><i class="fa fa-download" aria-hidden="true"></i>FREE Download</a></button>'}}
25
+ var screenshots=response.screenshots;var arrows='';if(Object.keys(screenshots).length>1){arrows='<div class="screenshots-nav"><div class="left"><i class="fa fa-chevron-left" aria-hidden="true"></i></div><div class="right"><i class="fa fa-chevron-right" aria-hidden="true"></i></div></div>'}
26
+ var html=$(['<div class="theme-backdrop">',' <div class="theme-wrap">',' <div class="theme-header">',' <button class="close dashicons dashicons-no"><span class="screen-reader-text">Close details dialog</span></button>',' </div>',' <div class="theme-about">',' <div class="theme-screenshots">',' <div class="screenshot" style="background-image:url(\''+screenshots['0']+'\')">'+arrows+'</div>',' </div>',' <div class="theme-info">',' <h2 class="theme-name">'+response.name+versionInfo+'</h2>',' <p class="theme-author">By <a href="'+response.author_homepage+'" target="_blank">'+response.author+'</a></p>',noticeHtml,' <div class="theme-description">'+response.description+'</div>',buyButton,' </div>',' </div>',' <div class="theme-actions">',' <button type="submit" '+buttonDisabled+'class="button activate" name="Submit" aria-label="Select '+response.name+'">Activate</button>',' <a href="http://cmp.niteothemes.com/?cmp_preview=true&selector=true&theme='+slug+'&utm_source=cmp&utm_medium=referral&utm_campaign='+slug+'" class="button cmp-preview" target="_blank" aria-label="Preview '+response.name+'">Live Preview</a>',' </div>',' </div>','</div>',].join("\n"));jQuery('.theme-overlay.cmp').append(html);jQuery('.theme-overlay.cmp .view-release').click(function(e){e.preventDefault();$this=jQuery(this);var release_url=$this.attr('href');jQuery.get(release_url,function(release){$this.closest('.notice').find('.release-note .notes').remove();$this.closest('.notice').find('.release-note').append('<div class="notes">'+release+'</div>')}).fail(function(){$this.closest('.notice').find('.release-note p').remove();$this.closest('.notice').find('.release-note').append('<p>There was an error loading release notes. Please try again later.</p>')})});jQuery('.theme-overlay.cmp .close').click(function(e){e.preventDefault();jQuery('body').removeClass('modal-open');jQuery('.theme-overlay.cmp .theme-backdrop').fadeOut('fast')});jQuery('.theme-overlay.cmp .activate').click(function(e){e.preventDefault();jQuery('input[name="select_theme"]').each(function(){if(jQuery(this).val()==slug){jQuery(this).prop('checked',!0);jQuery('.theme-select').removeClass('selected');jQuery(this).parent().addClass('selected')}});jQuery('#csoptions').submit()});jQuery('.screenshots-nav .right').click(function(){i++;if(i==Object.keys(screenshots).length){i=0}
27
+ if((i in screenshots)){jQuery('.screenshot').css('background-image','url(\''+screenshots[i]+'\')')}});jQuery('.screenshots-nav .left').click(function(){i--;if(i<0){i=Object.keys(screenshots).length-1}
28
+ if((i in screenshots)){jQuery('.screenshot').css('background-image','url(\''+screenshots[i]+'\')')}})}})});jQuery('#csoptions input[name="niteoCS_subscribe_type"]').trigger('change');media_upload_button('logo',!1,'image');media_upload_button('favicon',!1,'image');media_upload_button('banner',!0,'image');media_upload_button('pattern',!1,'image');media_upload_button('video-thumb',!1,'image');media_upload_button('video',!1,'video');$('#niteoCS_overlay_opacity').on('input',function(){$(this).trigger('change')});jQuery('#niteoCS_overlay_opacity').change(function(){if(this.value==0){jQuery('#current-opacity').html(': transparent')}else{jQuery('#current-opacity').html(': '+this.value)}});function ucwords(str){return(str+'').replace(/^([a-z])|\s+([a-z])/g,function($1){return $1.toUpperCase()})}
29
+ function strtolower(str){return(str+'').toLowerCase()}
30
+ function media_upload_button(name,multiple,type){var $container=jQuery('.'+name+'-wrapper');var $add_button=jQuery('#add-'+name);var $delete_button=jQuery('#delete-'+name);var image;var imgID='';var title=name.replace('-',' ');title=title[0].toUpperCase()+title.slice(1);if(jQuery('#niteoCS-'+name+'-id').val()!=''){$delete_button.css('display','block')}
31
+ $add_button.click(function(e){e.preventDefault();if(media_uploader){media_uploader.open();return}
32
+ var media_uploader=wp.media({title:'Select '+title,button:{text:'Insert '+title},multiple:multiple,library:{type:[type]},}).on('select',function(){var attachment=media_uploader.state().get('selection').toJSON();if(attachment.length>0){$container.empty();jQuery(attachment).each(function(i){if(attachment[i].sizes&&attachment[i].sizes.large){image=attachment[i].sizes.large.url}else{image=attachment[i].url}
33
+ var comma=i===0?'':',';imgID+=(comma+attachment[i].id);if(name=='pattern'){$container.css('background-image','url(\''+image+'\')')}else if(name=='video'){$container.append('<video width="600" height="400" controls><source src="'+image+'" type="video/mp4">Your browser does not support the video tag.</video>')}else{$container.append('<img src="'+image+'" alt="" style="max-width:588px"/>')}});$delete_button.css('display','block')}
34
+ jQuery('#niteoCS-'+name+'-id').val(imgID).trigger('change')}).open();if(name=='pattern'){$container.css('background-image','url(\''+image+'\')')}});$delete_button.click(function(e){jQuery(this).css('display','none');$container.empty();jQuery('#niteoCS-'+name+'-id').val('');jQuery('#niteoCS-'+name+'-id').trigger('change')})}})
languages/coming-soon-default.mo CHANGED
Binary file
languages/coming-soon-default.po CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: cmp\n"
4
- "POT-Creation-Date: 2017-11-24 19:27+0100\n"
5
- "PO-Revision-Date: 2017-11-24 19:27+0100\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "Language: en\n"
@@ -395,15 +395,14 @@ msgstr ""
395
 
396
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/construct/construct-settings.php:37
397
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/hardwork/hardwork-settings.php:52
398
- #: cmp-premium-themes/eclipse/eclipse-settings.php:45
399
- #: cmp-premium-themes/fifty/fifty-settings.php:71
400
  #: cmp-premium-themes/frame/frame-settings.php:48
401
  #: cmp-premium-themes/hardwork_premium/hardwork_premium-settings.php:36
402
  msgid "Customize Colors"
403
  msgstr ""
404
 
405
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/construct/construct-settings.php:40
406
- #: cmp-premium-themes/eclipse/eclipse-settings.php:48
407
  #: cmp-premium-themes/frame/frame-settings.php:51
408
  msgid "Active Color"
409
  msgstr ""
@@ -414,19 +413,18 @@ msgstr ""
414
 
415
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/construct/construct-settings.php:49
416
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/hardwork/hardwork-settings.php:56
417
- #: cmp-premium-themes/eclipse/eclipse-settings.php:58
418
- #: cmp-premium-themes/fifty/fifty-settings.php:75
419
  #: cmp-premium-themes/frame/frame-settings.php:61
420
  #: cmp-premium-themes/hardwork_premium/hardwork_premium-settings.php:40
421
  msgid "Font Color"
422
  msgstr ""
423
 
424
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/construct/construct-settings.php:57
 
425
  msgid "Background Color"
426
  msgstr ""
427
 
428
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/hardwork/hardwork-settings.php:64
429
- #: cmp-premium-themes/eclipse/eclipse-settings.php:67
430
  #: cmp-premium-themes/frame/frame-settings.php:80
431
  #: cmp-premium-themes/hardwork_premium/hardwork_premium-settings.php:48
432
  msgid "Overlay Color"
@@ -437,50 +435,17 @@ msgid "Enable Overlay Color"
437
  msgstr ""
438
 
439
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/hardwork/hardwork-settings.php:73
440
- #: cmp-premium-themes/eclipse/eclipse-settings.php:73
441
  #: cmp-premium-themes/frame/frame-settings.php:86
442
  #: cmp-premium-themes/hardwork_premium/hardwork_premium-settings.php:53
443
  msgid "Overlay Opacity"
444
  msgstr ""
445
 
446
- #: cmp-premium-themes/eclipse/eclipse-settings.php:82
447
- #: cmp-premium-themes/fifty/fifty-settings.php:64
448
- #: cmp-premium-themes/fifty/fifty-settings.php:108
449
  #: cmp-premium-themes/frame/frame-settings.php:94
450
  #: cmp-premium-themes/hardwork_premium/hardwork_premium-settings.php:62
451
  msgid "Save All Changes"
452
  msgstr ""
453
 
454
- #: cmp-premium-themes/fifty/fifty-settings.php:41
455
- msgid "Layout"
456
- msgstr ""
457
-
458
- #: cmp-premium-themes/fifty/fifty-settings.php:45
459
- msgid "Select Layout"
460
- msgstr ""
461
-
462
- #: cmp-premium-themes/fifty/fifty-settings.php:48
463
- #: cmp-premium-themes/fifty/fifty-settings.php:49
464
- msgid "Vertical Layout"
465
- msgstr ""
466
-
467
- #: cmp-premium-themes/fifty/fifty-settings.php:53
468
- #: cmp-premium-themes/fifty/fifty-settings.php:54
469
- msgid "Skewed Layout"
470
- msgstr ""
471
-
472
- #: cmp-premium-themes/fifty/fifty-settings.php:84
473
- msgid "Content Background Color"
474
- msgstr ""
475
-
476
- #: cmp-premium-themes/fifty/fifty-settings.php:89
477
- msgid "Background opacity"
478
- msgstr ""
479
-
480
- #: cmp-premium-themes/fifty/fifty-settings.php:96
481
- msgid "Active Color (button)"
482
- msgstr ""
483
-
484
  #: cmp-premium-themes/fifty/fifty-social_settings.php:20
485
  msgid "Social Icons Location"
486
  msgstr ""
@@ -493,19 +458,19 @@ msgstr ""
493
  msgid "Footer (small icons)"
494
  msgstr ""
495
 
496
- #: cmp-premium-themes/fifty/fifty-theme.php:258
497
- #: cmp-premium-themes/fifty/fifty-theme.php:270
498
- #: cmp-premium-themes/hardwork_premium/hardwork_premium-theme.php:160
499
- #: cmp-premium-themes/hardwork_premium/hardwork_premium-theme.php:172
500
  msgid ""
501
  "To Display Graphic Media please upgrade CMP Plugin to latest version. You "
502
  "can download latest version on "
503
  msgstr ""
504
 
505
- #: cmp-premium-themes/fifty/fifty-theme.php:258
506
- #: cmp-premium-themes/fifty/fifty-theme.php:270
507
- #: cmp-premium-themes/hardwork_premium/hardwork_premium-theme.php:160
508
- #: cmp-premium-themes/hardwork_premium/hardwork_premium-theme.php:172
509
  msgid ""
510
  "or you can use automatic plugin update in WP-Admin > Plugins > CMP - Coming "
511
  "Soon & Maintenance Plugin > Update Now."
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: cmp\n"
4
+ "POT-Creation-Date: 2017-09-28 22:25+0200\n"
5
+ "PO-Revision-Date: 2017-09-28 22:25+0200\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "Language: en\n"
395
 
396
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/construct/construct-settings.php:37
397
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/hardwork/hardwork-settings.php:52
398
+ #: cmp-premium-themes/fifty/fifty-settings.php:33
 
399
  #: cmp-premium-themes/frame/frame-settings.php:48
400
  #: cmp-premium-themes/hardwork_premium/hardwork_premium-settings.php:36
401
  msgid "Customize Colors"
402
  msgstr ""
403
 
404
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/construct/construct-settings.php:40
405
+ #: cmp-premium-themes/fifty/fifty-settings.php:55
406
  #: cmp-premium-themes/frame/frame-settings.php:51
407
  msgid "Active Color"
408
  msgstr ""
413
 
414
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/construct/construct-settings.php:49
415
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/hardwork/hardwork-settings.php:56
416
+ #: cmp-premium-themes/fifty/fifty-settings.php:37
 
417
  #: cmp-premium-themes/frame/frame-settings.php:61
418
  #: cmp-premium-themes/hardwork_premium/hardwork_premium-settings.php:40
419
  msgid "Font Color"
420
  msgstr ""
421
 
422
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/construct/construct-settings.php:57
423
+ #: cmp-premium-themes/fifty/fifty-settings.php:46
424
  msgid "Background Color"
425
  msgstr ""
426
 
427
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/hardwork/hardwork-settings.php:64
 
428
  #: cmp-premium-themes/frame/frame-settings.php:80
429
  #: cmp-premium-themes/hardwork_premium/hardwork_premium-settings.php:48
430
  msgid "Overlay Color"
435
  msgstr ""
436
 
437
  #: cmp-coming-soon-maintenance/tags/1.4.0/themes/hardwork/hardwork-settings.php:73
 
438
  #: cmp-premium-themes/frame/frame-settings.php:86
439
  #: cmp-premium-themes/hardwork_premium/hardwork_premium-settings.php:53
440
  msgid "Overlay Opacity"
441
  msgstr ""
442
 
443
+ #: cmp-premium-themes/fifty/fifty-settings.php:65
 
 
444
  #: cmp-premium-themes/frame/frame-settings.php:94
445
  #: cmp-premium-themes/hardwork_premium/hardwork_premium-settings.php:62
446
  msgid "Save All Changes"
447
  msgstr ""
448
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
  #: cmp-premium-themes/fifty/fifty-social_settings.php:20
450
  msgid "Social Icons Location"
451
  msgstr ""
458
  msgid "Footer (small icons)"
459
  msgstr ""
460
 
461
+ #: cmp-premium-themes/fifty/fifty-theme.php:194
462
+ #: cmp-premium-themes/fifty/fifty-theme.php:206
463
+ #: cmp-premium-themes/hardwork_premium/hardwork_premium-theme.php:138
464
+ #: cmp-premium-themes/hardwork_premium/hardwork_premium-theme.php:150
465
  msgid ""
466
  "To Display Graphic Media please upgrade CMP Plugin to latest version. You "
467
  "can download latest version on "
468
  msgstr ""
469
 
470
+ #: cmp-premium-themes/fifty/fifty-theme.php:194
471
+ #: cmp-premium-themes/fifty/fifty-theme.php:206
472
+ #: cmp-premium-themes/hardwork_premium/hardwork_premium-theme.php:138
473
+ #: cmp-premium-themes/hardwork_premium/hardwork_premium-theme.php:150
474
  msgid ""
475
  "or you can use automatic plugin update in WP-Admin > Plugins > CMP - Coming "
476
  "Soon & Maintenance Plugin > Update Now."
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: 2.0
7
  Author: NiteoThemes
8
  Author URI: https://www.niteothemes.com
9
  Text Domain: cmp-coming-soon-maintenance
@@ -17,7 +17,7 @@ class niteo_cmp {
17
  public function __construct() {
18
  $this->author = 'NiteoThemes';
19
  $this->author_homepage = 'https://niteothemes.com';
20
- $this->version = '2.0';
21
  $this->dev = false;
22
  $this->plugins_dir_path = plugin_dir_path( __DIR__ );
23
  if ( $this->plugins_dir_path == './') {
@@ -47,7 +47,7 @@ class niteo_cmp {
47
  public function cmp() {
48
  $this->__construct();
49
  }
50
-
51
  public function cmp_adminInit() {
52
  wp_register_style( 'cmp-style', plugins_url('/css/cmp-settings-style'.$this->minified.'.css', __FILE__),'',$this->version);
53
  wp_enqueue_style('cmp-style');
@@ -201,8 +201,8 @@ class niteo_cmp {
201
  }
202
  }
203
 
204
- // Render CMP Theme if is activated
205
- if ( $this->cmp_status() == 1 || $this->cmp_status() == 2 ) {
206
 
207
  // check if user logged in
208
  if ( !is_user_logged_in() ) {
@@ -254,9 +254,10 @@ class niteo_cmp {
254
  }
255
  }
256
 
257
- // if CMP in redirect mode
258
- if ( $this->cmp_status() == 3 && get_option('niteoCS_URL_redirect') == 0 && !is_user_logged_in() ) {
259
  $redirect_url = get_option('niteoCS_URL_redirect');
 
260
  // redirect to URL
261
  if ( $redirect_url != '') {
262
  header('Location: '.esc_url( $redirect_url ));
@@ -742,6 +743,29 @@ class niteo_cmp {
742
  load_plugin_textdomain( 'cmp-coming-soon-maintenance', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
743
  }
744
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
745
  // unsplash api
746
  public function niteo_unsplash( $params ) {
747
  $ajax = false;
@@ -766,12 +790,12 @@ class niteo_cmp {
766
 
767
  array_key_exists ('feed', $params) ? $feed = $params['feed'] : $feed = '';
768
  array_key_exists ('url', $params) ? $url = $params['url'] : $url = '';
769
- array_key_exists ('cat', $params) ? $cat = $params['cat'] : $cat = '';
770
  array_key_exists ('custom_str', $params) ? $custom_str = $params['custom_str'] : $custom_str = '';
771
-
772
- $sig = 'sig='.rand(10000,99999);
773
 
774
  switch ( $feed ) {
 
775
  case '0':
776
  $id = '';
777
  // check if $query contains unsplash.com url
@@ -787,26 +811,29 @@ class niteo_cmp {
787
 
788
  $pathFragments = explode('/', $parts['path']);
789
  $id = end($pathFragments);
790
-
791
  }
 
792
  // $query is ID
793
  } else {
794
  $id = $url;
795
  }
796
 
797
- $unsplash_img = 'https://source.unsplash.com/'.$id.'/WIDTHxHEIGHT/?';
 
798
  break;
799
 
 
800
  case '1':
801
- if ($custom_str != '') {
802
- $custom_str = ',' .$custom_str . '&';
803
- } else {
804
- $custom_str = '&';
805
  }
806
-
807
- $unsplash_img = 'https://source.unsplash.com/WIDTHxHEIGHT/?'.$cat.$custom_str.$sig;
 
808
  break;
809
 
 
810
  case '2':
811
  if ( is_numeric( $url ) ) {
812
  $collection = $url;
@@ -815,33 +842,40 @@ class niteo_cmp {
815
  $collection = str_replace('-', '', $collection );
816
  }
817
 
818
- $unsplash_img = 'https://source.unsplash.com/collection/'.$collection.'/WIDTHxHEIGHT/?'.$sig;
 
819
  break;
820
 
 
821
  case '3':
822
- if ( $cat == '0' || $cat == '') {
823
- $featured = 'random';
 
 
824
  } else {
825
- $featured = 'featured';
826
  }
827
 
828
- $url = str_replace(' ', ',', $url);
829
-
830
 
831
- if ( $url !== '' ) {
832
- $url = $url . '&';
833
  }
834
 
835
- $unsplash_img = 'https://source.unsplash.com/'.$featured.'/WIDTHxHEIGHT/?'.$url.$sig;
 
836
  break;
837
 
838
  default:
839
- $unsplash_img = 'https://source.unsplash.com/featured/WIDTHxHEIGHT/?'.$sig;
840
  break;
841
  }
842
 
 
 
843
  if ( $ajax === true ) {
844
- echo $unsplash_img;
845
  wp_die();
846
 
847
  } else {
@@ -861,54 +895,83 @@ class niteo_cmp {
861
  }
862
 
863
  // save subscribe function
864
- public function niteo_subscribe( $email ) {
 
 
865
  $response = '';
 
 
 
 
 
 
 
 
866
 
867
- // validate email address
868
- if ( is_email( $email ) ) {
869
- $timestamp = time();
870
- $ip_address = sanitize_text_field($_SERVER['REMOTE_ADDR']);
871
- $subscribe_list = get_option('niteoCS_subscribers_list');
872
-
873
- if ( get_option('niteoCS_translation') ) {
874
- $translation = json_decode( get_option('niteoCS_translation'), true );
875
- $response1 = $translation[7]['translation'];
876
- $response2 = $translation[5]['translation'];
877
- $response3 = $translation[6]['translation'];
878
-
879
- } else {
880
- $response1 = 'Thank you, your sign-up request was successful!';
881
- $response2 = 'This email address has already been on our subscriber list.';
882
- $response3 = 'Please insert valid email.';
883
- }
884
-
885
- // if no subscribe list created, create first item and insert it into DB
886
- if ( !$subscribe_list ) {
887
- $subscribe_list = array();
888
- $new_email = array('id' => '0', 'timestamp' => $timestamp, 'email' => $email, 'ip_address' => $ip_address);
889
- array_push( $subscribe_list, $new_email );
890
- update_option( 'niteoCS_subscribers_list', $subscribe_list );
891
- $response = $response1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
892
 
893
- } else {
894
- // check if email don`t already exists
895
- if ( !$this->niteo_in_array_r( $email, $subscribe_list, true ) ) {
896
- $count = count($subscribe_list);
897
- $new_email = array('id' => $count, 'timestamp' => $timestamp, 'email' => $email, 'ip_address' => $ip_address);
898
- array_push( $subscribe_list, $new_email );
899
- update_option('niteoCS_subscribers_list', $subscribe_list);
900
- $response = $response1;
901
- // if it exists return failed response
902
  } else {
903
- $response = $response2;
904
- }
905
  }
 
 
 
 
 
 
 
906
 
907
  } else {
908
- $response = $response3;
909
  }
910
-
911
- return $response;
912
  }
913
 
914
  public function niteo_export_csv() {
@@ -1164,6 +1227,7 @@ class niteo_cmp {
1164
  }
1165
 
1166
 
 
1167
  public function cmp_google_variant_title( $variant ) {
1168
 
1169
  switch( $variant ) {
@@ -1231,6 +1295,38 @@ class niteo_cmp {
1231
  break;
1232
  }
1233
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1234
  }
1235
 
1236
 
@@ -1248,7 +1344,8 @@ add_action( 'wp_ajax_niteo_unsplash', array($cmpPlugin, 'niteo_unsplash') );
1248
  add_action( 'wp_ajax_niteo_export_csv', array($cmpPlugin, 'niteo_export_csv') );
1249
  add_action( 'wp_ajax_cmp_theme_update_install', array($cmpPlugin, 'cmp_theme_update_install') );
1250
  add_action( 'wp_ajax_cmp_toggle_activation', array($cmpPlugin, 'cmp_toggle_activation') );
1251
-
 
1252
 
1253
 
1254
  add_action('plugins_loaded', array($cmpPlugin, 'cmp_textDomain') );
@@ -1263,6 +1360,8 @@ register_activation_hook(__FILE__, array($cmpPlugin, 'cmp_activate'));
1263
  register_deactivation_hook(__FILE__, array($cmpPlugin, 'cmp_deactivate'));
1264
  register_uninstall_hook(__FILE__, 'cmp_plugin_delete');
1265
 
 
 
1266
  add_filter( 'style_loader_src', array($cmpPlugin,'sdt_remove_ver_css_js'), 9999, 2 );
1267
  add_filter( 'script_loader_src', array($cmpPlugin,'sdt_remove_ver_css_js'), 9999, 2 );
1268
 
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: 2.1
7
  Author: NiteoThemes
8
  Author URI: https://www.niteothemes.com
9
  Text Domain: cmp-coming-soon-maintenance
17
  public function __construct() {
18
  $this->author = 'NiteoThemes';
19
  $this->author_homepage = 'https://niteothemes.com';
20
+ $this->version = '2.1';
21
  $this->dev = false;
22
  $this->plugins_dir_path = plugin_dir_path( __DIR__ );
23
  if ( $this->plugins_dir_path == './') {
47
  public function cmp() {
48
  $this->__construct();
49
  }
50
+
51
  public function cmp_adminInit() {
52
  wp_register_style( 'cmp-style', plugins_url('/css/cmp-settings-style'.$this->minified.'.css', __FILE__),'',$this->version);
53
  wp_enqueue_style('cmp-style');
201
  }
202
  }
203
 
204
+ // Render CMP Theme mode if is activated
205
+ if ( $this->cmp_status() == 1 || $this->cmp_status() == 2 || ( $this->cmp_status() == 3 && get_option('niteoCS_redirect_time') != 0 ) ) {
206
 
207
  // check if user logged in
208
  if ( !is_user_logged_in() ) {
254
  }
255
  }
256
 
257
+ // if CMP in redirect mode with 0 timeouthtel
258
+ if ( $this->cmp_status() == 3 && get_option('niteoCS_redirect_time') == 0 && !is_user_logged_in() ) {
259
  $redirect_url = get_option('niteoCS_URL_redirect');
260
+
261
  // redirect to URL
262
  if ( $redirect_url != '') {
263
  header('Location: '.esc_url( $redirect_url ));
743
  load_plugin_textdomain( 'cmp-coming-soon-maintenance', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
744
  }
745
 
746
+ public function cmp_unsplash_api ( $query ) {
747
+
748
+ $api_url = 'https://api.unsplash.com/'.$query.'&client_id=41f043163758cf2e898e8a868bc142c20bc3f5966e7abac4779ee684088092ab' ;
749
+ // var_dump($api_url);
750
+ if ( function_exists( 'wp_remote_get' ) ) {
751
+
752
+ $response = wp_remote_get( $api_url );
753
+
754
+ if ( isset($response['body']) ) {
755
+
756
+ $body = $response['body'];
757
+ $data = array( 'response' => $response['response']['code'], 'body' => $body );
758
+ } else {
759
+ $data = array( 'response' => $response['response']['code'], 'body' => $response['response']['message'] );
760
+ }
761
+
762
+ } else {
763
+ $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.' );
764
+ }
765
+
766
+ return $data;
767
+ }
768
+
769
  // unsplash api
770
  public function niteo_unsplash( $params ) {
771
  $ajax = false;
790
 
791
  array_key_exists ('feed', $params) ? $feed = $params['feed'] : $feed = '';
792
  array_key_exists ('url', $params) ? $url = $params['url'] : $url = '';
793
+ array_key_exists ('feat', $params) ? $feat = $params['feat'] : $feat = '';
794
  array_key_exists ('custom_str', $params) ? $custom_str = $params['custom_str'] : $custom_str = '';
795
+ array_key_exists ('count', $params) ? $count = $params['count'] : $count = '1';
 
796
 
797
  switch ( $feed ) {
798
+ // specific unsplash photo by url/id
799
  case '0':
800
  $id = '';
801
  // check if $query contains unsplash.com url
811
 
812
  $pathFragments = explode('/', $parts['path']);
813
  $id = end($pathFragments);
 
814
  }
815
+
816
  // $query is ID
817
  } else {
818
  $id = $url;
819
  }
820
 
821
+ // prepare query for single image
822
+ $api_query = 'photos/'.$id.'?';
823
  break;
824
 
825
+ // random from user
826
  case '1':
827
+
828
+ if ( $custom_str[0] == '@' ) {
829
+ $custom_str = substr($custom_str, 1);
 
830
  }
831
+
832
+ // prepare query for random photo from collection
833
+ $api_query = 'photos/random/?username='.$custom_str.'&count='.$count;
834
  break;
835
 
836
+ // random from collection
837
  case '2':
838
  if ( is_numeric( $url ) ) {
839
  $collection = $url;
842
  $collection = str_replace('-', '', $collection );
843
  }
844
 
845
+ // prepare query for random photo from collection
846
+ $api_query = 'photos/random/?collections='.$collection.'&count='.$count;
847
  break;
848
 
849
+ // random photo
850
  case '3':
851
+
852
+ // featured
853
+ if ( $feat == '0' || $feat == '') {
854
+ $featured = 'false';
855
  } else {
856
+ $featured = 'true';
857
  }
858
 
859
+ // category
860
+ $search = str_replace(' ', ',', $url);
861
 
862
+ if ( $search !== '' ) {
863
+ $search = 'query='.$search.'&';
864
  }
865
 
866
+ // prepare query for random photo
867
+ $api_query = 'photos/random/?orientation=landscape&featured='.$featured.'&'.$search.'count='.$count;
868
  break;
869
 
870
  default:
871
+ $api_query = 'photos/random/?orientation=landscape&count='.$count;
872
  break;
873
  }
874
 
875
+ $unsplash_img = $this->cmp_unsplash_api( $api_query );
876
+
877
  if ( $ajax === true ) {
878
+ echo json_encode($unsplash_img);
879
  wp_die();
880
 
881
  } else {
895
  }
896
 
897
  // save subscribe function
898
+ // $check must be true, to avoid duplicated requests after update to 2.1
899
+ public function niteo_subscribe( $check ) {
900
+
901
  $response = '';
902
+ $response_invalid = '';
903
+ $ajax = false;
904
+
905
+ // check for ajax request
906
+ if ( isset( $_POST['check'] ) && $_POST['check'] == true ) {
907
+ $check = true;
908
+ $ajax = true;
909
+ }
910
 
911
+ if ( $check === true ) :
912
+
913
+ if ( $_SERVER['REQUEST_METHOD'] == 'POST'
914
+ && isset( $_POST['form_honeypot'] )
915
+ && $_POST['form_honeypot'] === ''
916
+ && isset( $_POST['EMAIL'] )
917
+ && is_email( $_POST['EMAIL'] ) )
918
+ {
919
+
920
+ $email = $_POST['EMAIL'];
921
+ $timestamp = time();
922
+ $ip_address = sanitize_text_field($_SERVER['REMOTE_ADDR']);
923
+ $subscribe_list = get_option('niteoCS_subscribers_list');
924
+
925
+ if ( get_option('niteoCS_translation') ) {
926
+ $translation = json_decode( get_option('niteoCS_translation'), true );
927
+ $response_ok = $translation[7]['translation'];
928
+ $response_duplicate = $translation[5]['translation'];
929
+ $response_invalid = $translation[6]['translation'];
930
+
931
+ } else {
932
+ $response_ok = 'Thank you, your sign-up request was successful!';
933
+ $response_duplicate = 'This Email address has already been on our subscriber list.';
934
+ $response_invalid = 'Please insert valid Email address.';
935
+ }
936
+
937
+ // if no subscribe list created, create first item and insert it into DB
938
+ if ( !$subscribe_list ) {
939
+ $subscribe_list = array();
940
+ $new_email = array('id' => '0', 'timestamp' => $timestamp, 'email' => $email, 'ip_address' => $ip_address);
941
+ array_push( $subscribe_list, $new_email );
942
+ update_option( 'niteoCS_subscribers_list', $subscribe_list );
943
+ $response = $response_ok;
944
+
945
+ } else {
946
+ // check if email don`t already exists
947
+ if ( !$this->niteo_in_array_r( $email, $subscribe_list, true ) ) {
948
+ $count = count($subscribe_list);
949
+ $new_email = array('id' => $count, 'timestamp' => $timestamp, 'email' => $email, 'ip_address' => $ip_address);
950
+ array_push( $subscribe_list, $new_email );
951
+ update_option('niteoCS_subscribers_list', $subscribe_list);
952
+ $response = $response_ok;
953
+ // if it exists return failed response
954
+ } else {
955
+ $response = $response_duplicate;
956
+ }
957
+ }
958
+
959
 
 
 
 
 
 
 
 
 
 
960
  } else {
961
+ $response = $response_invalid;
 
962
  }
963
+
964
+
965
+ endif; // $check !== true
966
+
967
+ if ( $ajax === true ) {
968
+ echo $response;
969
+ wp_die();
970
 
971
  } else {
972
+ return $response;
973
  }
974
+
 
975
  }
976
 
977
  public function niteo_export_csv() {
1227
  }
1228
 
1229
 
1230
+
1231
  public function cmp_google_variant_title( $variant ) {
1232
 
1233
  switch( $variant ) {
1295
  break;
1296
  }
1297
  }
1298
+
1299
+ public function cmp_plugin_update(\WP_Upgrader $upgrader, array $hook_extra) {
1300
+ if (is_array($hook_extra) && array_key_exists('action', $hook_extra) && array_key_exists('type', $hook_extra) && array_key_exists('plugins', $hook_extra)) {
1301
+ if ($hook_extra['action'] == 'update' && $hook_extra['type'] == 'plugin' && is_array($hook_extra['plugins']) && !empty($hook_extra['plugins'])) {
1302
+ $this_plugin = plugin_basename(__FILE__);
1303
+ foreach ($hook_extra['plugins'] as $key => $plugin) {
1304
+ if ($this_plugin == $plugin) {
1305
+ $this_plugin_updated = true;
1306
+ break;
1307
+ }
1308
+ }// endforeach;
1309
+ unset($key, $plugin, $this_plugin);
1310
+ if (isset($this_plugin_updated) && $this_plugin_updated === true) {
1311
+ // migrate postery
1312
+ if ( get_option('niteoCS_theme') == 'postery' && !in_array('postery', $this->premium_installed) ) {
1313
+
1314
+ WP_Filesystem();
1315
+
1316
+ $source_path = plugin_dir_path( __FILE__ ) . 'themes/postery.zip';
1317
+ $destination_path = $this->plugins_dir_path . 'cmp-premium-themes/';
1318
+
1319
+ // create new theme DIR
1320
+ if ( wp_mkdir_p( $destination_path ) ) {
1321
+ // Unzip FILE into that DIR
1322
+ $unzipfile = unzip_file( $source_path, $destination_path);
1323
+
1324
+ }
1325
+ }
1326
+ }// endif; $this_plugin_updated
1327
+ }// endif update plugin and plugins not empty.
1328
+ }// endif; $hook_extra
1329
+ }// updatePlugin
1330
  }
1331
 
1332
 
1344
  add_action( 'wp_ajax_niteo_export_csv', array($cmpPlugin, 'niteo_export_csv') );
1345
  add_action( 'wp_ajax_cmp_theme_update_install', array($cmpPlugin, 'cmp_theme_update_install') );
1346
  add_action( 'wp_ajax_cmp_toggle_activation', array($cmpPlugin, 'cmp_toggle_activation') );
1347
+ add_action( 'wp_ajax_nopriv_niteo_subscribe', array($cmpPlugin, 'niteo_subscribe') );
1348
+ add_action( 'wp_ajax_niteo_subscribe', array($cmpPlugin, 'niteo_subscribe') );
1349
 
1350
 
1351
  add_action('plugins_loaded', array($cmpPlugin, 'cmp_textDomain') );
1360
  register_deactivation_hook(__FILE__, array($cmpPlugin, 'cmp_deactivate'));
1361
  register_uninstall_hook(__FILE__, 'cmp_plugin_delete');
1362
 
1363
+ add_action('upgrader_process_complete', array($cmpPlugin, 'cmp_plugin_update'), 10, 2);
1364
+
1365
  add_filter( 'style_loader_src', array($cmpPlugin,'sdt_remove_ver_css_js'), 9999, 2 );
1366
  add_filter( 'script_loader_src', array($cmpPlugin,'sdt_remove_ver_css_js'), 9999, 2 );
1367
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=KV2JF
4
  Tags: under construction, construction page, maintenance mode, landing page, launch page, launching, security, coming soon, customizable, offline, offline page, unavailable, free, unsplash, subscribe form
5
  Requires at least: 3.0
6
  Tested up to: 4.9
7
- Stable tag: 2.0
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -54,7 +54,7 @@ CMP brings premium features for free, no PRO versions! It is very user friendly
54
  9. CMP - Theme Details
55
  10. CMP - Admin screen
56
  11. CMP - Admin screen
57
- 12. CMP - Admin screene
58
 
59
 
60
 
@@ -109,6 +109,13 @@ CMP brings premium features for free, no PRO versions! It is very user friendly
109
 
110
 
111
  == Changelog ==
 
 
 
 
 
 
 
112
  <h4>2.0</h4>
113
  <ul>
114
  <li>New free CMP theme Eclipse available for download with beautiful Counter, extended Footer and Welcome hero screen animation. Check it out <a href="https://niteothemes.com/?filter=freebies">CMP Freebies</a></li>
4
  Tags: under construction, construction page, maintenance mode, landing page, launch page, launching, security, coming soon, customizable, offline, offline page, unavailable, free, unsplash, subscribe form
5
  Requires at least: 3.0
6
  Tested up to: 4.9
7
+ Stable tag: 2.1
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
54
  9. CMP - Theme Details
55
  10. CMP - Admin screen
56
  11. CMP - Admin screen
57
+ 12. CMP - Admin screen
58
 
59
 
60
 
109
 
110
 
111
  == Changelog ==
112
+ <h4>2.1</h4>
113
+ <ul>
114
+ <li>Completely rewritten Unsplash API to avoid duplicated cached images when using Image sliders.</li>
115
+ <li>CMP Subscriber form AJAX submission to avoid Website reload for better user experience.</li>
116
+ <li>Resolved bug when CMP page was set to Redirect mode but the website was sometimes not redirected to custom URL after set TimeOut.</li>
117
+ </ul>
118
+
119
  <h4>2.0</h4>
120
  <ul>
121
  <li>New free CMP theme Eclipse available for download with beautiful Counter, extended Footer and Welcome hero screen animation. Check it out <a href="https://niteothemes.com/?filter=freebies">CMP Freebies</a></li>
themes/construct/construct-theme.php CHANGED
@@ -1,13 +1,3 @@
1
- <?php
2
- if ( $_SERVER['REQUEST_METHOD'] == 'POST'
3
- && isset( $_POST['form_honeypot'] )
4
- && $_POST['form_honeypot'] === ''
5
- && isset( $_POST['EMAIL'] )
6
- && is_email( $_POST['EMAIL'] ) ) {
7
- $subscribe_response = $this->niteo_subscribe( $_POST['EMAIL'] );
8
- }
9
- ?>
10
-
11
  <!DOCTYPE html>
12
 
13
  <html <?php language_attributes(); ?>>
 
 
 
 
 
 
 
 
 
 
1
  <!DOCTYPE html>
2
 
3
  <html <?php language_attributes(); ?>>
themes/countdown/countdown-theme.php CHANGED
@@ -1,12 +1,3 @@
1
- <?php
2
- if ( $_SERVER['REQUEST_METHOD'] == 'POST'
3
- && isset( $_POST['form_honeypot'] )
4
- && $_POST['form_honeypot'] === ''
5
- && isset( $_POST['EMAIL'] )
6
- && is_email( $_POST['EMAIL'] ) ) {
7
- $subscribe_response = $this->niteo_subscribe( $_POST['EMAIL'] );
8
- }
9
- ?>
10
  <!DOCTYPE html>
11
 
12
  <html <?php language_attributes(); ?>>
 
 
 
 
 
 
 
 
 
1
  <!DOCTYPE html>
2
 
3
  <html <?php language_attributes(); ?>>
themes/hardwork/hardwork-theme.php CHANGED
@@ -128,6 +128,8 @@
128
  <div id="background-wrapper">
129
 
130
  <?php
 
 
131
  if ( method_exists ( $html, 'cmp_background' ) ) {
132
  echo $html->cmp_background( $niteoCS_background, $themeslug );
133
  }
@@ -137,7 +139,8 @@
137
 
138
  <section class="section section-body">
139
  <?php
140
- // display logo
 
141
  if ( method_exists ( $html, 'cmp_logo' ) ) {
142
  echo $html->cmp_logo( $themeslug );
143
  }
128
  <div id="background-wrapper">
129
 
130
  <?php
131
+
132
+
133
  if ( method_exists ( $html, 'cmp_background' ) ) {
134
  echo $html->cmp_background( $niteoCS_background, $themeslug );
135
  }
139
 
140
  <section class="section section-body">
141
  <?php
142
+
143
+ // display logo
144
  if ( method_exists ( $html, 'cmp_logo' ) ) {
145
  echo $html->cmp_logo( $themeslug );
146
  }
themes/postery.zip ADDED
Binary file
themes/postery/postery-theme.php CHANGED
@@ -1,12 +1,3 @@
1
- <?php
2
- if ( $_SERVER['REQUEST_METHOD'] == 'POST'
3
- && isset( $_POST['form_honeypot'] )
4
- && $_POST['form_honeypot'] === ''
5
- && isset( $_POST['EMAIL'] )
6
- && is_email( $_POST['EMAIL'] ) ) {
7
- $subscribe_response = $this->niteo_subscribe( $_POST['EMAIL'] );
8
- }
9
- ?>
10
  <!DOCTYPE html>
11
 
12
  <html <?php language_attributes(); ?>>
 
 
 
 
 
 
 
 
 
1
  <!DOCTYPE html>
2
 
3
  <html <?php language_attributes(); ?>>