Under Construction - Version 2.20

Version Description

  • 2017/06/12
  • new theme - Internet of Things
  • added support for Siteground caching plugin
  • we've crossed the 80k users mark on June 7th
Download this release

Release Info

Developer WebFactory
Plugin Icon 128x128 Under Construction
Version 2.20
Comparing to
See all releases

Code changes from version 2.15 to 2.20

images/thumbnails/iot.png ADDED
Binary file
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: WebFactory, UnderConstructionPage
3
  Tags: maintenance mode, maintenance page, coming soon page, landing page, under construction
4
  Requires at least: 4.0
5
- Tested up to: 4.7
6
- Stable tag: 2.15
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -92,15 +92,22 @@ Or if needed, upload manually;
92
  20. Ambulance theme
93
  21. Laptop theme
94
  22. Puzzles theme contributed by <a href="https://twitter.com/EdelHaut">Ralf Biester</a>
95
- 23. Main settings
96
- 24. Design settings
97
- 25. Content settings
98
- 26. Access settings
99
- 27. Support
 
100
 
101
 
102
  == Changelog ==
103
 
 
 
 
 
 
 
104
  = 2.15 =
105
  * 2017/05/29
106
  * new theme - Puzzles contributed by <a href="https://twitter.com/EdelHaut">Ralf Biester</a>
2
  Contributors: WebFactory, UnderConstructionPage
3
  Tags: maintenance mode, maintenance page, coming soon page, landing page, under construction
4
  Requires at least: 4.0
5
+ Tested up to: 4.8
6
+ Stable tag: 2.20
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
92
  20. Ambulance theme
93
  21. Laptop theme
94
  22. Puzzles theme contributed by <a href="https://twitter.com/EdelHaut">Ralf Biester</a>
95
+ 23. Internet of Things
96
+ 24. Main settings
97
+ 25. Design settings
98
+ 26. Content settings
99
+ 27. Access settings
100
+ 28. Support
101
 
102
 
103
  == Changelog ==
104
 
105
+ = 2.20 =
106
+ * 2017/06/12
107
+ * new theme - Internet of Things
108
+ * added support for Siteground caching plugin
109
+ * we've crossed the 80k users mark on June 7th
110
+
111
  = 2.15 =
112
  * 2017/05/29
113
  * new theme - Puzzles contributed by <a href="https://twitter.com/EdelHaut">Ralf Biester</a>
themes/iot/index.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * UnderConstructionPage
4
+ * Internet of Things theme
5
+ * (c) Web factory Ltd, 2015 - 2017
6
+ */
7
+
8
+
9
+ // this is an include only WP file
10
+ if (!defined('ABSPATH')) {
11
+ die;
12
+ }
13
+ ?>
14
+ <!DOCTYPE html>
15
+ <html lang="en">
16
+ <head>
17
+ <meta charset="utf-8">
18
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
19
+ <meta name="viewport" content="width=device-width, initial-scale=1">
20
+ <title>[title]</title>
21
+ <meta name="description" content="[description]" />
22
+ <meta name="generator" content="[generator]">
23
+ <link rel="stylesheet" href="[theme-url-common]css/bootstrap.min.css?v=[version]" type="text/css">
24
+ <link rel="stylesheet" href="[theme-url]style.css?v=[version]" type="text/css">
25
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,900">
26
+ [head]
27
+ </head>
28
+
29
+ <body>
30
+ <div class="container">
31
+ <div class="row">
32
+ <div class="col-xs-12 col-md-12 col-lg-12">
33
+ <h1>[heading1]</h1>
34
+ </div>
35
+ </div>
36
+ </div>
37
+
38
+ <div id="hero-image">
39
+ <img src="[theme-url]iot.png" alt="The Internet of Things" title="The Internet of Things">
40
+ </div>
41
+ <div class="container">
42
+
43
+ <div class="row">
44
+ <div class="col-xs-12 col-md-8 col-md-offset-2 col-lg-offset-2 col-lg-8">
45
+ <p class="content">[content]</p>
46
+ </div>
47
+ </div>
48
+
49
+ <div class="row" id="social">
50
+ <div class="col-xs-12 col-md-12 col-lg-12">
51
+ [social-icons]
52
+ </div>
53
+ </div>
54
+
55
+ </div>
56
+ [footer]
57
+ </body>
58
+ </html>
themes/iot/iot.png ADDED
Binary file
themes/iot/style.css ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * UnderConstructionPage
3
+ * Internet of Things theme CSS
4
+ * (c) Web factory Ltd, 2015 - 2017
5
+ */
6
+
7
+
8
+ html {
9
+ height: 100%;
10
+ padding: 0;
11
+ margin: 0;
12
+ }
13
+
14
+ body {
15
+ font-weight: 400;
16
+ font-size: 14px;
17
+ line-height: 120%;
18
+ color: #3d3c3e;
19
+ background: #cd1f1f;
20
+ padding: 0;
21
+ margin: 0;
22
+ background-repeat: repeat;
23
+ background-attachment: fixed;
24
+ }
25
+
26
+ #hero-image {
27
+ text-align: center;
28
+ margin: 20px auto 40px auto;
29
+ box-shadow: inset 0px -3px 0px #3f3e40;
30
+ }
31
+
32
+ #hero-image img {
33
+ max-width: 80%;
34
+ }
35
+
36
+ h1 {
37
+ font-size: 34px;
38
+ color: #3d3c3e;
39
+ font-family: "Roboto", sans-serif;
40
+ font-weight: 900;
41
+ margin: 60px 0 30px 0;
42
+ text-align: center;
43
+ }
44
+
45
+ .content {
46
+ text-align: center;
47
+ font-family: "Helvetica", "Arial", sans-serif;
48
+ }
49
+
50
+ #social {
51
+ text-align: center;
52
+ margin-top: 30px;
53
+ }
54
+
55
+ #social a i {
56
+ color: #3d3c3e;
57
+ margin: 10px;
58
+ box-sizing: content-box;
59
+ }
60
+
61
+ #social a:hover i {
62
+ color: #d65454;
63
+ }
64
+
65
+ @media(max-width:767px){
66
+ h1 {
67
+ font-size: 30px;
68
+ margin: 10px 0 30px 0;
69
+ }
70
+ #hero-image img {
71
+ max-width: 95%;
72
+ }
73
+ #hero-image {
74
+ box-shadow: inset 0px -1px 0px #3f3e40;
75
+ }
76
+ }
under-construction.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin URI: https://underconstructionpage.com/
5
  Description: Hide your site behind a great looking under construction page while you do maintenance work.
6
  Author: Web factory Ltd
7
- Version: 2.15
8
  Author URI: http://www.webfactoryltd.com/
9
  Text Domain: under-construction-page
10
  Domain Path: lang
@@ -45,27 +45,27 @@ class UCP {
45
  static $version = 0;
46
  static $licensing_servers = array('https://license1.underconstructionpage.com/', 'https://license2.underconstructionpage.com/');
47
 
48
-
49
  // get plugin version from header
50
  static function get_plugin_version() {
51
  $plugin_data = get_file_data(__FILE__, array('version' => 'Version'), 'plugin');
52
  self::$version = $plugin_data['version'];
53
-
54
  return $plugin_data['version'];
55
  } // get_plugin_version
56
-
57
-
58
- // hook things up
59
  static function init() {
60
  // check if minimal required WP version is present
61
  if (false === self::check_wp_version(4.0)) {
62
  return false;
63
  }
64
-
65
  if (is_admin()) {
66
  // if the plugin was updated from ver < 1.20 upgrade settings array
67
  self::maybe_upgrade();
68
-
69
  // add UCP menu to admin tools menu group
70
  add_action('admin_menu', array(__CLASS__, 'admin_menu'));
71
 
@@ -80,10 +80,10 @@ class UCP {
80
  // manages admin header notifications
81
  add_action('admin_notices', array(__CLASS__, 'admin_notices'));
82
  add_action('admin_action_ucp_dismiss_notice', array(__CLASS__, 'dismiss_notice'));
83
-
84
  // enqueue admin scripts
85
  add_action('admin_enqueue_scripts', array(__CLASS__, 'admin_enqueue_scripts'));
86
-
87
  // AJAX endpoints
88
  add_action('wp_ajax_ucp_dismiss_pointer', array(__CLASS__, 'dismiss_pointer_ajax'));
89
  add_action('wp_ajax_ucp_dismiss_survey', array(__CLASS__, 'dismiss_survey_ajax'));
@@ -91,7 +91,7 @@ class UCP {
91
  } else {
92
  // main plugin logic
93
  add_action('wp', array(__CLASS__, 'display_construction_page'), 0, 1);
94
-
95
  // show under construction notice on login form
96
  add_filter('login_message', array(__CLASS__, 'login_message'));
97
 
@@ -106,49 +106,49 @@ class UCP {
106
  add_action('wp_before_admin_bar_render', array(__CLASS__, 'admin_bar_notice'));
107
  } // init
108
 
109
-
110
  // check if user has the minimal WP version required by UCP
111
  static function check_wp_version($min_version) {
112
  if (!version_compare(get_bloginfo('version'), $min_version, '>=')) {
113
  add_action('admin_notices', array(__CLASS__, 'notice_min_wp_version'));
114
  return false;
115
  } else {
116
- return true;
117
  }
118
  } // check_wp_version
119
-
120
-
121
  // display error message if WP version is too low
122
  static function notice_min_wp_version() {
123
  echo '<div class="error"><p>' . sprintf(__('UnderConstruction plugin <b>requires WordPress version 4.0</b> or higher to function properly. You are using WordPress version %s. Please <a href="%s">update it</a>.', 'under-construction-page'), get_bloginfo('version'), admin_url('update-core.php')) . '</p></div>';
124
  } // notice_min_wp_version_error
125
-
126
-
127
  // some things have to be loaded earlier
128
  static function plugins_loaded() {
129
  self::get_plugin_version();
130
-
131
  load_plugin_textdomain('under-construction-page');
132
  } // plugins_loaded
133
-
134
-
135
  // activate doesn't get fired on upgrades so we have to compensate
136
  public static function maybe_upgrade() {
137
  $meta = self::get_meta();
138
  $options = self::get_options();
139
-
140
  // added in v1.70 to rename roles to whitelisted_roles
141
  if (isset($options['roles'])) {
142
  $options['whitelisted_roles'] = $options['roles'];
143
  unset($options['roles']);
144
  update_option(UCP_OPTIONS_KEY, $options);
145
  }
146
-
147
  // check if we need to convert options from the old format to new, or maybe it is already done
148
  if (isset($meta['options_ver']) && $meta['options_ver'] == self::$version) {
149
  return;
150
- }
151
-
152
  if (get_option('set_size') || get_option('set_tweet') || get_option('set_fb') || get_option('set_font') || get_option('set_msg') || get_option('set_opt') || get_option('set_admin')) {
153
  // convert old options to new
154
  $options['status'] = (get_option('set_opt') === 'Yes')? '1': '0';
@@ -157,7 +157,7 @@ class UCP {
157
  $options['social_facebook'] = trim(get_option('set_fb'));
158
  $options['social_twitter'] = trim(get_option('set_tweet'));
159
  update_option(UCP_OPTIONS_KEY, $options);
160
-
161
  delete_option('set_size');
162
  delete_option('set_tweet');
163
  delete_option('set_fb');
@@ -165,16 +165,16 @@ class UCP {
165
  delete_option('set_msg');
166
  delete_option('set_opt');
167
  delete_option('set_admin');
168
-
169
  self::reset_pointers();
170
  }
171
 
172
- // we update only once
173
  $meta['options_ver'] = self::$version;
174
  update_option(UCP_META_KEY, $meta);
175
  } // maybe_upgrade
176
-
177
-
178
  // get plugin's options
179
  static function get_options() {
180
  $options = get_option(UCP_OPTIONS_KEY, array());
@@ -186,8 +186,8 @@ class UCP {
186
 
187
  return $options;
188
  } // get_options
189
-
190
-
191
  // get plugin's meta data
192
  static function get_meta() {
193
  $meta = get_option(UCP_META_KEY, array());
@@ -200,12 +200,12 @@ class UCP {
200
 
201
  return $meta;
202
  } // get_meta
203
-
204
 
205
  // fetch and display the construction page if it's enabled or preview requested
206
  static function display_construction_page() {
207
  $options = self::get_options();
208
-
209
  // some URLs have to be accessible at all times
210
  if ($_SERVER['REQUEST_URI'] == '/wp-admin' ||
211
  $_SERVER['REQUEST_URI'] == '/feed/' ||
@@ -217,8 +217,8 @@ class UCP {
217
  $_SERVER['REQUEST_URI'] == '/wp-login.php') {
218
  return true;
219
  }
220
-
221
- if (true == self::is_construction_mode_enabled(false)
222
  || (is_user_logged_in() && isset($_GET['ucp_preview']))) {
223
  header(self::wp_get_server_protocol() . ' 503 Service Unavailable');
224
  echo self::get_template($options['theme']);
@@ -226,18 +226,18 @@ class UCP {
226
  }
227
  } // display_construction_page
228
 
229
-
230
  // keeping compatibility with WP < v4.4
231
  static function wp_get_server_protocol() {
232
  $protocol = $_SERVER['SERVER_PROTOCOL'];
233
  if (!in_array($protocol, array('HTTP/1.1', 'HTTP/2', 'HTTP/2.0'))) {
234
  $protocol = 'HTTP/1.0';
235
  }
236
-
237
  return $protocol;
238
  } // wp_get_server_protocol
239
-
240
-
241
  // disables feed if necessary
242
  static function disable_feed() {
243
  if (true == self::is_construction_mode_enabled(false)) {
@@ -246,12 +246,12 @@ class UCP {
246
  }
247
  } // disable_feed
248
 
249
-
250
  // enqueue CSS and JS scripts in admin
251
  static function admin_enqueue_scripts($hook) {
252
  $surveys = get_option(UCP_SURVEYS_KEY);
253
  $meta = self::get_meta();
254
-
255
  // survey is shown min 5 min after install
256
  // no survey at the moment
257
  if (false && empty($surveys['designs']) && current_time('timestamp') - $meta['first_install'] > 300) {
@@ -259,7 +259,7 @@ class UCP {
259
  } else {
260
  $open_survey = false;
261
  }
262
-
263
  $js_localize = array('undocumented_error' => __('An undocumented error has occured. Please refresh the page and try again.', 'under-construction-page'),
264
  'plugin_name' => __('UnderConstructionPage', 'under-construction-page'),
265
  'settings_url' => admin_url('options-general.php?page=ucp'),
@@ -268,12 +268,12 @@ class UCP {
268
  'nonce_dismiss_survey' => wp_create_nonce('ucp_dismiss_survey'),
269
  'nonce_submit_survey' => wp_create_nonce('ucp_submit_survey'),
270
  'deactivate_confirmation' => __('Are you sure you want to deactivate UnderConstruction plugin?' . "\n" . 'If you are removing it because of a problem please contact our support. They will be more than happy to help.', 'under-construction-page'));
271
-
272
  if ('settings_page_ucp' == $hook) {
273
  wp_enqueue_style('wp-jquery-ui-dialog');
274
  wp_enqueue_style('ucp-select2', UCP_PLUGIN_URL . 'css/select2.min.css', array(), self::$version);
275
  wp_enqueue_style('ucp-admin', UCP_PLUGIN_URL . 'css/ucp-admin.css', array(), self::$version);
276
-
277
  wp_enqueue_script('jquery-ui-tabs');
278
  wp_enqueue_script('jquery-ui-dialog');
279
  wp_enqueue_script('ucp-jquery-plugins', UCP_PLUGIN_URL . 'js/ucp-jquery-plugins.js', array('jquery'), self::$version, true);
@@ -281,12 +281,12 @@ class UCP {
281
  wp_enqueue_script('ucp-admin', UCP_PLUGIN_URL . 'js/ucp-admin.js', array('jquery'), self::$version, true);
282
  wp_localize_script('ucp-admin', 'ucp', $js_localize);
283
  }
284
-
285
  if ('plugins.php' == $hook) {
286
  wp_enqueue_script('ucp-admin-plugins', UCP_PLUGIN_URL . 'js/ucp-admin-plugins.js', array('jquery'), self::$version, true);
287
  wp_localize_script('ucp-admin-plugins', 'ucp', $js_localize);
288
  }
289
-
290
  $pointers = get_option(UCP_POINTERS_KEY);
291
  if ($pointers && 'settings_page_ucp' != $hook) {
292
  $pointers['_nonce_dismiss_pointer'] = wp_create_nonce('ucp_dismiss_pointer');
@@ -297,12 +297,12 @@ class UCP {
297
  wp_localize_script('jquery', 'ucp', $js_localize);
298
  }
299
  } // admin_enqueue_scripts
300
-
301
-
302
  // permanently dismiss a pointer
303
  static function dismiss_pointer_ajax() {
304
  check_ajax_referer('ucp_dismiss_pointer');
305
-
306
  $pointers = get_option(UCP_POINTERS_KEY);
307
  $pointer = trim($_POST['pointer']);
308
 
@@ -312,41 +312,41 @@ class UCP {
312
 
313
  unset($pointers[$pointer]);
314
  update_option(UCP_POINTERS_KEY, $pointers);
315
-
316
  wp_send_json_success();
317
  } // dismiss_pointer_ajax
318
-
319
-
320
  // permanently dismiss a survey
321
  static function dismiss_survey_ajax() {
322
  check_ajax_referer('ucp_dismiss_survey');
323
-
324
  $surveys = get_option(UCP_SURVEYS_KEY, array());
325
  $survey = trim($_POST['survey']);
326
 
327
  $surveys[$survey] = -1;
328
  update_option(UCP_SURVEYS_KEY, $surveys);
329
-
330
  wp_send_json_success();
331
  } // dismiss_survey_ajax
332
-
333
-
334
  // submit survey
335
  static function submit_survey_ajax() {
336
  check_ajax_referer('ucp_submit_survey');
337
 
338
- $options = self::get_options();
339
  $meta = self::get_meta();
340
  $surveys = get_option(UCP_SURVEYS_KEY);
341
-
342
  $vars = wp_parse_args($_POST, array('survey' => '', 'answers' => '', 'custom_answer' => '', 'emailme' => ''));
343
  $vars['answers'] = trim($vars['answers'], ',');
344
  $vars['custom_answer'] = trim(strip_tags($vars['custom_answer']));
345
-
346
  if (empty($vars['survey']) || empty($vars['answers'])) {
347
  wp_send_json_error();
348
  }
349
-
350
  $request_params = array('sslverify' => false, 'timeout' => 15, 'redirection' => 2);
351
  $request_args = array('action' => 'submit_survey',
352
  'survey' => $vars['survey'],
@@ -360,57 +360,57 @@ class UCP {
360
 
361
  $url = add_query_arg($request_args, self::$licensing_servers[0]);
362
  $response = wp_remote_get(esc_url_raw($url), $request_params);
363
-
364
  if (is_wp_error($response) || !wp_remote_retrieve_body($response)) {
365
  $url = add_query_arg($request_args, self::$licensing_servers[1]);
366
  $response = wp_remote_get(esc_url_raw($url), $request_params);
367
  }
368
-
369
  $surveys[$vars['survey']] = current_time('timestamp');
370
  update_option(UCP_SURVEYS_KEY, $surveys);
371
-
372
  wp_send_json_success();
373
  } // submit_survey_ajax
374
-
375
-
376
  static function encode_email($email) {
377
  $len = strlen($email);
378
  $out = '';
379
-
380
  for ($i = 0; $i < $len; $i++) {
381
  $out .= '&#'. ord($email[$i]) . ';';
382
  }
383
-
384
  return $out;
385
  } // encode_email
386
-
387
-
388
  // parse shortcode alike variables
389
  static function parse_vars($string) {
390
  $org_string = $string;
391
-
392
- $vars = array('site-title' => get_bloginfo('name'),
393
- 'site-tagline' => get_bloginfo('description'),
394
- 'site-description' => get_bloginfo('description'),
395
- 'site-url' => trailingslashit(get_home_url()),
396
  'wp-url' => trailingslashit(get_site_url()),
397
  'site-login-url' => get_site_url() . '/wp-login.php');
398
-
399
  foreach ($vars as $var_name => $var_value) {
400
  $var_name = '[' . $var_name . ']';
401
  $string = str_ireplace($var_name, $var_value, $string);
402
  }
403
-
404
  $string = apply_filters('ucp_parse_vars', $string, $org_string, $vars);
405
-
406
  return $string;
407
  } // parse_vars
408
-
409
-
410
  // generate HTML from social icons
411
  static function generate_social_icons($options, $template_id) {
412
  $out = '';
413
-
414
  if (!empty($options['social_facebook'])) {
415
  $out .= '<a title="Facebook" href="' . $options['social_facebook'] . '" target="_blank"><i class="fa fa-facebook-square fa-3x"></i></a>';
416
  }
@@ -456,19 +456,19 @@ class UCP {
456
  if (!empty($options['social_phone'])) {
457
  $out .= '<a title="Phone" href="tel:' . $options['social_phone'] . '"><i class="fa fa-phone-square fa-3x"></i></a>';
458
  }
459
-
460
  return $out;
461
  } // generate_social_icons
462
-
463
-
464
  // shortcode for inserting things in header
465
  static function generate_head($options, $template_id) {
466
  $out = '';
467
-
468
  $out .= '<link rel="stylesheet" href="' . trailingslashit(UCP_PLUGIN_URL . 'themes') . 'css/common.css?v=' . self::$version . '" type="text/css">' . "\n";
469
-
470
  $out .= '<link rel="stylesheet" href="https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css" integrity="sha384-dNpIIXE8U05kAbPhy3G1cz+yZmTzA6CY8Vg/u2L9xRnHjJiAK76m2BIEaSEV+/aU" crossorigin="anonymous">';
471
-
472
  if (!empty($options['ga_tracking_id'])) {
473
  $out .= "
474
  <script>
@@ -480,21 +480,21 @@ class UCP {
480
  ga('send', 'pageview');
481
  </script>";
482
  }
483
-
484
  if (!empty($options['custom_css'])) {
485
  $out .= "\n" . '<style type="text/css">' . $options['custom_css'] . '</style>';
486
  }
487
-
488
  $out = apply_filters('ucp_head', $out, $options, $template_id);
489
-
490
  return trim($out);
491
  } // generate_head
492
-
493
-
494
  // shortcode for inserting things in footer
495
  static function generate_footer($options, $template_id) {
496
  $out = '';
497
-
498
  if ($options['linkback'] == '1') {
499
  $tmp = md5(get_site_url());
500
  if ($tmp[0] < '4') {
@@ -507,7 +507,7 @@ class UCP {
507
  $out .= '<p id="linkback">Create free <a href="https://underconstructionpage.com/" target="_blank">maintenance mode pages for WordPress</a>.</p>';
508
  }
509
  }
510
-
511
  if ($options['login_button'] == '1') {
512
  if (is_user_logged_in()) {
513
  $out .= '<div id="login-button" class="loggedin">';
@@ -518,13 +518,13 @@ class UCP {
518
  }
519
  $out .= '</div>';
520
  }
521
-
522
  $out = apply_filters('ucp_footer', $out, $options, $template_id);
523
-
524
  return $out;
525
  } // generate_footer
526
-
527
-
528
  // returnes parsed template
529
  static function get_template($template_id) {
530
  $vars = array();
@@ -543,29 +543,29 @@ class UCP {
543
  $vars['social-icons'] = self::generate_social_icons($options, $template_id);
544
  $vars['head'] = self::generate_head($options, $template_id);
545
  $vars['footer'] = self::generate_footer($options, $template_id);
546
-
547
  $vars = apply_filters('ucp_get_template_vars', $vars, $template_id, $options);
548
-
549
  ob_start();
550
  require UCP_PLUGIN_DIR . 'themes/' . $template_id . '/index.php';
551
  $template = ob_get_clean();
552
-
553
  foreach ($vars as $var_name => $var_value) {
554
  $var_name = '[' . $var_name . ']';
555
  $template = str_ireplace($var_name, $var_value, $template);
556
  }
557
-
558
  $template = apply_filters('ucp_get_template', $template, $vars, $options);
559
-
560
  return $template;
561
  } // get_template
562
 
563
-
564
  // checks if construction mode is enabled for the current visitor
565
  static function is_construction_mode_enabled($settings_only = false) {
566
  $options = self::get_options();
567
  $current_user = wp_get_current_user();
568
-
569
  // just to be on the safe side
570
  if (defined('DOING_CRON') && DOING_CRON) {
571
  return false;
@@ -573,7 +573,7 @@ class UCP {
573
  if (defined('DOING_AJAX') && DOING_AJAX) {
574
  return false;
575
  }
576
-
577
  // just check if it's generally enabled
578
  if ($settings_only) {
579
  if ($options['status']) {
@@ -599,7 +599,7 @@ class UCP {
599
  }
600
  } // is_construction_mode_enabled
601
 
602
-
603
  // check if user has the specified role
604
  static function user_has_role($roles) {
605
  $current_user = wp_get_current_user();
@@ -613,12 +613,12 @@ class UCP {
613
  return in_array($user_role, $roles);
614
  } // user_has_role
615
 
616
-
617
  // displays various notices in admin header
618
  static function admin_notices() {
619
  $notices = get_option(UCP_NOTICES_KEY);
620
  $meta = self::get_meta();
621
-
622
  if (empty($notices['dismiss_rate']) &&
623
  (current_time('timestamp') - $meta['first_install']) > (DAY_IN_SECONDS * 2)) {
624
  $rate_url = 'https://wordpress.org/support/plugin/under-construction-page/reviews/?rate=5#new-post';
@@ -628,24 +628,24 @@ class UCP {
628
 
629
  echo '<br><a target="_blank" href="' . esc_url($rate_url) . '" style="vertical-align: baseline; margin-top: 15px;" class="button-primary">' . __('Help make the plugin better by rating it', 'under-construction-page') . '</a>';
630
  echo '&nbsp;&nbsp;&nbsp;&nbsp;<a href="' . esc_url($dismiss_url) . '">' . __('I\'ve already rated the plugin', 'under-construction-page') . '</a>';
631
- echo '</p></div>';
632
  }
633
  } // notices
634
-
635
-
636
  // handle dismiss button for notices
637
  static function dismiss_notice() {
638
  if (empty($_GET['notice'])) {
639
  wp_redirect(admin_url());
640
  exit;
641
  }
642
-
643
  $notices = get_option(UCP_NOTICES_KEY, array());
644
-
645
  if ($_GET['notice'] == 'rate') {
646
  $notices['dismiss_rate'] = true;
647
  }
648
-
649
  update_option(UCP_NOTICES_KEY, $notices);
650
 
651
  if (!empty($_GET['redirect'])) {
@@ -657,11 +657,11 @@ class UCP {
657
  exit;
658
  } // dismiss_notice
659
 
660
-
661
  // add admin bar notice when construction is enabled
662
  static function admin_bar_notice() {
663
  global $wp_admin_bar;
664
-
665
  // only show to admins
666
  if (!current_user_can('administrator')) {
667
  return;
@@ -674,7 +674,7 @@ class UCP {
674
  $title = '<img style="height: 17px; margin-bottom: -4px; padding-right: 3px;" src="' . UCP_PLUGIN_URL . '/images/ucp_icon_disabled.png" alt="' . __('Under construction mode is disabled', 'under-construction-page') . '" title="' . __('Under construction mode is disabled', 'under-construction-page') . '"> <span class="ab-label">' . __('Under construction mode is', 'under-construction-page') . ' <strong style="font-weight: bold;">' . __('disabled', 'under-construction-page') . '</strong></span>';
675
  $class = 'ucp-disabled';
676
  }
677
-
678
  $wp_admin_bar->add_menu(array(
679
  'parent' => '',
680
  'id' => 'construction-mode',
@@ -683,18 +683,18 @@ class UCP {
683
  'meta' => array('class' => $class)
684
  ));
685
  } // admin_bar_notice
686
-
687
-
688
  // show under construction notice on WP login form
689
  static function login_message($message) {
690
  if (self::is_construction_mode_enabled(true)) {
691
  $message .= '<div class="message">' . __('Under construction mode is <b>enabled</b>.', 'under-construction-page') . '</div>';
692
  }
693
-
694
  return $message;
695
  } // login_notice
696
 
697
-
698
  // add settings link to plugins page
699
  static function plugin_action_links($links) {
700
  $settings_link = '<a href="' . admin_url('options-general.php?page=ucp') . '" title="' . __('UnderConstruction Settings', 'under-construction-page') . '">' . __('Settings', 'under-construction-page') . '</a>';
@@ -702,8 +702,8 @@ class UCP {
702
 
703
  return $links;
704
  } // plugin_action_links
705
-
706
-
707
  // add links to plugin's description in plugins table
708
  static function plugin_meta_links($links, $file) {
709
  $support_link = '<a target="_blank" href="https://wordpress.org/support/plugin/under-construction-page" title="' . __('Get help', 'under-construction-page') . '">' . __('Support', 'under-construction-page') . '</a>';
@@ -714,20 +714,20 @@ class UCP {
714
 
715
  return $links;
716
  } // plugin_meta_links
717
-
718
 
719
  // create the admin menu item
720
  static function admin_menu() {
721
  add_options_page('UnderConstruction', 'UnderConstruction', 'manage_options', 'ucp', array(__CLASS__, 'main_page'));
722
  } // admin_menu
723
 
724
-
725
  // all settings are saved in one option
726
  static function register_settings() {
727
  register_setting(UCP_OPTIONS_KEY, UCP_OPTIONS_KEY, array(__CLASS__, 'sanitize_settings'));
728
  } // register_settings
729
 
730
-
731
  // set default settings
732
  static function default_options() {
733
  $defaults = array('status' => '0',
@@ -762,7 +762,7 @@ class UCP {
762
 
763
  return $defaults;
764
  } // default_options
765
-
766
 
767
  // sanitize settings on save
768
  static function sanitize_settings($options) {
@@ -800,11 +800,11 @@ class UCP {
800
  break;
801
  } // switch
802
  } // foreach
803
-
804
  $options['whitelisted_roles'] = empty($options['whitelisted_roles'])? array(): $options['whitelisted_roles'];
805
  $options['whitelisted_users'] = empty($options['whitelisted_users'])? array(): $options['whitelisted_users'];
806
  $options = self::check_var_isset($options, array('status' => 0, 'linkback' => 0, 'login_button' => 0));
807
-
808
  if (!empty($options['ga_tracking_id']) && preg_match('/^UA-\d{3,}-\d{1,3}$/', $options['ga_tracking_id']) === 0) {
809
  add_settings_error('ucp', 'ga_tracking_id', __('Please enter a valid Google Analytics Tracking ID, or leave empty to disable tracking.', 'under-construction-page'));
810
  }
@@ -812,25 +812,28 @@ class UCP {
812
  // empty cache in 3rd party plugins
813
  if ($options != $old_options) {
814
  if (function_exists('w3tc_pgcache_flush')) {
815
- w3tc_pgcache_flush();
816
- }
817
  if (function_exists('wp_cache_clean_cache')) {
818
  global $file_prefix;
819
- wp_cache_clean_cache($file_prefix);
820
  }
821
  if (function_exists('wp_cache_clear_cache')) {
822
  wp_cache_clear_cache();
823
  }
824
  if (class_exists('Endurance_Page_Cache')) {
825
  $epc = new Endurance_Page_Cache;
826
- $epc->purge_all();
 
 
 
827
  }
828
  }
829
-
830
  return array_merge($old_options, $options);
831
  } // sanitize_settings
832
-
833
-
834
  // checkbox helper function
835
  static function checked($value, $current, $echo = false) {
836
  $out = '';
@@ -849,8 +852,8 @@ class UCP {
849
  return $out;
850
  }
851
  } // checked
852
-
853
-
854
  // helper function for saving options, mostly checkboxes
855
  static function check_var_isset($values, $variables) {
856
  foreach ($variables as $key => $value) {
@@ -858,11 +861,11 @@ class UCP {
858
  $values[$key] = $value;
859
  }
860
  }
861
-
862
  return $values;
863
  } // check_var_isset
864
-
865
-
866
  // helper function for creating dropdowns
867
  static function create_select_options($options, $selected = null, $output = true) {
868
  $out = "\n";
@@ -889,12 +892,12 @@ class UCP {
889
  return $out;
890
  }
891
  } // create_select_options
892
-
893
-
894
  static function tab_main() {
895
  $options = self::get_options();
896
  $default_options = self::default_options();
897
-
898
  echo '<table class="form-table">';
899
 
900
  echo '<tr valign="top">
@@ -906,33 +909,33 @@ class UCP {
906
  <span class="onoffswitch-switch"></span>
907
  </label>
908
  </div>';
909
-
910
  echo '<p class="description">By enabling construction mode all users (<a class="change_tab" data-tab="3" href="#whitelisted-roles">except selected ones</a>) will not be able to access the site\'s content. They will only see the under construction page.</p>';
911
  echo '</td></tr>';
912
-
913
  echo '<tr valign="top">
914
  <th scope="row"><label for="end_date">' . __('End Date &amp; Time', 'under-construction-page') . '</label></th>
915
  <td><input id="end_date" type="text" class="datepicker" name="' . UCP_OPTIONS_KEY . '[end_date]" value="' . esc_attr($options['end_date']) . '" placeholder="yyyy-mm-dd hh:mm"><span title="' . __('Open date & time picker', 'under-construction-page') . '" alt="' . __('Open date & time picker', 'under-construction-page') . '" class="show-datepicker dashicons dashicons-calendar-alt"></span> <span title="Clear date & time" alt="' . __('Clear date & time', 'under-construction-page') . '" class="clear-datepicker dashicons dashicons-no"></span>';
916
  echo '<p class="description">If enabled, construction mode will automatically stop showing on the selected date.<br>
917
  This option will not "auto-enable" construction mode. Status has to be set to "On".</p>';
918
  echo '</td></tr>';
919
-
920
  echo '<tr valign="top">
921
  <th scope="row"><label for="ga_tracking_id">' . __('Google Analytics Tracking ID', 'under-construction-page') . '</label></th>
922
  <td><input id="ga_tracking_id" type="text" class="code" name="' . UCP_OPTIONS_KEY . '[ga_tracking_id]" value="' . esc_attr($options['ga_tracking_id']) . '" placeholder="UA-xxxxxx-xx">';
923
  echo '<p class="description">Enter the unique tracking ID found in your GA tracking profile settings to track visits to the page.<br>Leave blank to disable tracking.</p>';
924
  echo '</td></tr>';
925
-
926
  echo '</table>';
927
  } // tab_main
928
-
929
-
930
  static function tab_content() {
931
  $options = self::get_options();
932
  $default_options = self::default_options();
933
-
934
  echo '<table class="form-table">';
935
-
936
  echo '<tr valign="top">
937
  <th scope="row"><label for="title">Title</label></th>
938
  <td><input type="text" id="title" class="regular-text" name="' . UCP_OPTIONS_KEY . '[title]" value="' . esc_attr($options['title']) . '" />';
@@ -952,7 +955,7 @@ class UCP {
952
  <td><input id="description" type="text" class="large-text" name="' . UCP_OPTIONS_KEY . '[description]" value="' . esc_attr($options['description']) . '" />';
953
  echo '<p class="description">Description meta tag (see above for available <a href="#title">shortcodes</a>). Default: ' . $default_options['description'] . '</p>';
954
  echo '</td></tr>';
955
-
956
  echo '<tr valign="top">
957
  <th scope="row"><label for="heading1">Headline</label></th>
958
  <td><input id="heading1" type="text" class="large-text" name="' . UCP_OPTIONS_KEY . '[heading1]" value="' . esc_attr($options['heading1']) . '" />';
@@ -965,7 +968,7 @@ class UCP {
965
  wp_editor($options['content'], 'content', array('tabfocus_elements' => 'insert-media-button,save-post', 'editor_height' => 250, 'resize' => 1, 'textarea_name' => UCP_OPTIONS_KEY . '[content]', 'drag_drop_upload' => 1));
966
  echo '<p class="description">All HTML elements are allowed. Shortcodes are not parsed except <a href="#title">UC template ones</a>. Default: ' . $default_options['content'] . '</p>';
967
  echo '</td></tr>';
968
-
969
  echo '<tr valign="top" id="login_button_wrap">
970
  <th scope="row"><label for="login_button">Login Button</label></th>
971
  <td><div class="onoffswitch">
@@ -977,7 +980,7 @@ class UCP {
977
  </div>';
978
  echo '<p class="description">Show a descrete link to the login form, or WP admin if you\'re logged in, in the lower right corner of the page.</p>';
979
  echo '</td></tr>';
980
-
981
  echo '<tr valign="top">
982
  <th scope="row"><label for="linkback">Show Some Love</label></th>
983
  <td><div class="onoffswitch">
@@ -989,113 +992,113 @@ class UCP {
989
  </div>';
990
  echo '<p class="description">Please help others learn about this free plugin by placing a small link in the footer. Thank you very much!</p>';
991
  echo '</td></tr>';
992
-
993
-
994
  echo '</table>';
995
-
996
  echo '<h2 class="title">Social &amp; Contact Icons</h2>';
997
-
998
  echo '<table class="form-table">';
999
  echo '<tr valign="top">
1000
  <th scope="row"><label for="social_facebook">Facebook Page</label></th>
1001
  <td><input id="social_facebook" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_facebook]" value="' . esc_attr($options['social_facebook']) . '" placeholder="Facebook business or personal page URL">';
1002
  echo '<p class="description">Complete URL, with http prefix, to Facebook page.</p>';
1003
  echo '</td></tr>';
1004
-
1005
  echo '<tr valign="top">
1006
  <th scope="row"><label for="social_twitter">Twitter Profile</label></th>
1007
  <td><input id="social_twitter" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_twitter]" value="' . esc_attr($options['social_twitter']) . '" placeholder="Twitter profile URL">';
1008
  echo '<p class="description">Complete URL, with http prefix, to Twitter profile page.</p>';
1009
  echo '</td></tr>';
1010
-
1011
  echo '<tr valign="top">
1012
  <th scope="row"><label for="social_google">Google Page</label></th>
1013
  <td><input id="social_google" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_google]" value="' . esc_attr($options['social_google']) . '" placeholder="Google+ page URL">';
1014
  echo '<p class="description">Complete URL, with http prefix, to Google+ page.</p>';
1015
  echo '</td></tr>';
1016
-
1017
  echo '<tr valign="top">
1018
  <th scope="row"><label for="social_linkedin">LinkedIn Profile</label></th>
1019
  <td><input id="social_linkedin" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_linkedin]" value="' . esc_attr($options['social_linkedin']) . '" placeholder="LinkedIn profile page URL">';
1020
  echo '<p class="description">Complete URL, with http prefix, to LinkedIn profile page.</p>';
1021
  echo '</td></tr>';
1022
-
1023
  echo '<tr valign="top">
1024
  <th scope="row"><label for="social_youtube">YouTube Profile Page or Video</label></th>
1025
  <td><input id="social_youtube" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_youtube]" value="' . esc_attr($options['social_youtube']) . '" placeholder="YouTube page or video URL">';
1026
  echo '<p class="description">Complete URL, with http prefix, to YouTube page or video.</p>';
1027
  echo '</td></tr>';
1028
-
1029
  echo '<tr valign="top">
1030
  <th scope="row"><label for="social_vimeo">Vimeo Profile Page or Video</label></th>
1031
  <td><input id="social_vimeo" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_vimeo]" value="' . esc_attr($options['social_vimeo']) . '" placeholder="Vimeo page or video URL">';
1032
  echo '<p class="description">Complete URL, with http prefix, to Vimeo page or video.</p>';
1033
  echo '</td></tr>';
1034
-
1035
  echo '<tr valign="top">
1036
  <th scope="row"><label for="social_pinterest">Pinterest Profile</label></th>
1037
  <td><input id="social_pinterest" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_pinterest]" value="' . esc_attr($options['social_pinterest']) . '" placeholder="Pinterest profile URL">';
1038
  echo '<p class="description">Complete URL, with http prefix, to Pinterest profile.</p>';
1039
  echo '</td></tr>';
1040
-
1041
  echo '<tr valign="top">
1042
  <th scope="row"><label for="social_dribbble">Dribbble Profile</label></th>
1043
  <td><input id="social_dribbble" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_dribbble]" value="' . esc_attr($options['social_dribbble']) . '" placeholder="Dribbble profile URL">';
1044
  echo '<p class="description">Complete URL, with http prefix, to Dribbble profile.</p>';
1045
  echo '</td></tr>';
1046
-
1047
  echo '<tr valign="top">
1048
  <th scope="row"><label for="social_behance">Behance Profile</label></th>
1049
  <td><input id="social_behance" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_behance]" value="' . esc_attr($options['social_behance']) . '" placeholder="Behance profile URL">';
1050
  echo '<p class="description">Complete URL, with http prefix, to Behance profile.</p>';
1051
  echo '</td></tr>';
1052
-
1053
  echo '<tr valign="top">
1054
  <th scope="row"><label for="social_instagram">Instagram Profile</label></th>
1055
  <td><input id="social_instagram" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_instagram]" value="' . esc_attr($options['social_instagram']) . '" placeholder="Instagram profile URL">';
1056
  echo '<p class="description">Complete URL, with http prefix, to Instagram profile.</p>';
1057
  echo '</td></tr>';
1058
-
1059
  echo '<tr valign="top">
1060
  <th scope="row"><label for="social_tumblr">Tumblr Blog</label></th>
1061
  <td><input id="social_tumblr" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_tumblr]" value="' . esc_attr($options['social_tumblr']) . '" placeholder="Tumblr blog URL">';
1062
  echo '<p class="description">Complete URL, with http prefix, to Tumblr blog.</p>';
1063
  echo '</td></tr>';
1064
-
1065
  echo '<tr valign="top">
1066
  <th scope="row"><label for="social_skype">Skype Username</label></th>
1067
  <td><input id="social_skype" type="text" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_skype]" value="' . esc_attr($options['social_skype']) . '" placeholder="Skype username / account name">';
1068
  echo '<p class="description">Skype username / account name.</p>';
1069
  echo '</td></tr>';
1070
-
1071
  echo '<tr valign="top">
1072
  <th scope="row"><label for="social_whatsapp">WhatsApp Phone Number</label></th>
1073
  <td><input id="social_whatsapp" type="text" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_whatsapp]" value="' . esc_attr($options['social_whatsapp']) . '" placeholder="+1-123-456-789">';
1074
  echo '<p class="description">WhatsApp phone number in full international format.</p>';
1075
  echo '</td></tr>';
1076
-
1077
  echo '<tr valign="top">
1078
  <th scope="row"><label for="social_email">Email Address</label></th>
1079
  <td><input id="social_email" type="email" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_email]" value="' . esc_attr($options['social_email']) . '" placeholder="name@domain.com">';
1080
  echo '<p class="description">Email will be encoded on the page to protect it from email address harvesters.</p>';
1081
  echo '</td></tr>';
1082
-
1083
  echo '<tr valign="top">
1084
  <th scope="row"><label for="social_phone">Phone Number</label></th>
1085
  <td><input id="social_phone" type="tel" class="regular-text" name="' . UCP_OPTIONS_KEY . '[social_phone]" value="' . esc_attr($options['social_phone']) . '" placeholder="+1-123-456-789">';
1086
  echo '<p class="description">Complete phone number in international format.</p>';
1087
  echo '</td></tr>';
1088
-
1089
  echo '</table>';
1090
  } // tab_content
1091
-
1092
-
1093
  static function tab_design() {
1094
  $options = self::get_options();
1095
  $default_options = self::default_options();
1096
-
1097
  $img_path = UCP_PLUGIN_URL . 'images/thumbnails/';
1098
-
1099
  $themes = array('mad_designer' => __('Mad Designer', 'under-construction-page'),
1100
  'plain_text' => __('Plain Text', 'under-construction-page'),
1101
  'under_construction' => __('Under Construction', 'under-construction-page'),
@@ -1117,15 +1120,16 @@ class UCP {
1117
  'light_bulb' => __('Light Bulb', 'under-construction-page'),
1118
  'ambulance' => __('Ambulance', 'under-construction-page'),
1119
  'laptop' => __('Laptop', 'under-construction-page'),
1120
- 'puzzles' => __('Puzzles', 'under-construction-page'));
 
1121
  $themes = apply_filters('ucp_themes', $themes);
1122
-
1123
  echo '<table class="form-table">';
1124
  echo '<tr valign="top">
1125
  <th scope="row">' . __('Theme', 'under-construction-page') . '</th>
1126
  <td>';
1127
  echo '<input type="hidden" id="theme_id" name="' . UCP_OPTIONS_KEY . '[theme]" value="' . $options['theme'] . '">';
1128
-
1129
  foreach ($themes as $theme_id => $theme_name) {
1130
  if ($theme_id === $options['theme']) {
1131
  $class = ' active';
@@ -1134,7 +1138,7 @@ class UCP {
1134
  }
1135
  echo '<div class="ucp-thumb' . $class . '" data-theme-id="' . $theme_id . '"><img src="' . $img_path . $theme_id . '.png" alt="' . $theme_name . '" title="' . $theme_name . '" /><span>' . $theme_name . '</span></div>';
1136
  }
1137
-
1138
  $tmp = md5(get_site_url());
1139
  if ($tmp[0] < '6') {
1140
  $tweet = 'I need more themes for the free Under Construction #wordpress plugin. When are they coming out? @webfactoryltd';
@@ -1146,11 +1150,11 @@ class UCP {
1146
  $tweet = 'When will you make more themes for the free Under Construction Page plugin for #wordpress? @webfactoryltd';
1147
  $url = 'https://underconstructionpage.com/';
1148
  }
1149
-
1150
  echo '<div class="ucp-thumb-special"><a href="https://twitter.com/intent/tweet?url=' . $url . '&text=' . urlencode($tweet) . '" target="_blank"><img src="' . $img_path . 'more_coming_soon.png" alt="Need more themes?" title="Need more themes?" /></a><br />Click for More Themes</div>';
1151
-
1152
  echo '</td></tr>';
1153
-
1154
  echo '<tr valign="top">
1155
  <th scope="row"><label for="custom_css">' . __('Custom CSS', 'under-construction-page') . '</label></th>
1156
  <td>';
@@ -1158,76 +1162,76 @@ class UCP {
1158
  echo '<p class="description">&lt;style&gt; tags will be added automatically. Do not include them in your code.<br>
1159
  For RTL languages support add: <code>body { direction: rtl; }</code></p>';
1160
  echo '</td></tr>';
1161
-
1162
  echo '</table>';
1163
  } // tab_design
1164
-
1165
-
1166
  // markup & logic for access tab
1167
  static function tab_access() {
1168
  $options = self::get_options();
1169
  $default_options = self::default_options();
1170
  $roles = $users = array();
1171
-
1172
  $tmp_roles = get_editable_roles();
1173
  foreach ($tmp_roles as $tmp_role => $details) {
1174
  $name = translate_user_role($details['name']);
1175
  $roles[] = array('val' => $tmp_role, 'label' => $name);
1176
  }
1177
-
1178
  $tmp_users = get_users(array('fields' => array('id', 'display_name')));
1179
  foreach ($tmp_users as $user) {
1180
  $users[] = array('val' => $user->id, 'label' => $user->display_name);
1181
  }
1182
-
1183
  echo '<table class="form-table">';
1184
-
1185
  echo '<tr valign="top" id="whitelisted-roles">
1186
  <th scope="row">' . __('Whitelisted User Roles', 'under-construction-page') . '</th>
1187
  <td>';
1188
-
1189
  foreach ($roles as $tmp_role) {
1190
  echo '<input name="' . UCP_OPTIONS_KEY . '[whitelisted_roles][]" id="roles-' . $tmp_role['val'] . '" ' . self::checked($tmp_role['val'], $options['whitelisted_roles'], false) . ' value="' . $tmp_role['val'] . '" type="checkbox" /> <label for="roles-' . $tmp_role['val'] . '">' . $tmp_role['label'] . '</label><br />';
1191
  }
1192
  echo '<p class="description">Selected user roles will <b>not</b> be affected by the under construction mode and will always see the "normal" site. Default: administrator.</p>';
1193
  echo '</td></tr>';
1194
-
1195
  echo '<tr valign="top">
1196
  <th scope="row"><label for="whitelisted_users">' . __('Whitelisted Users', 'under-construction-page') . '</label></th>
1197
  <td><select id="whitelisted_users" class="select2" style="width: 50%; max-width: 300px;" name="' . UCP_OPTIONS_KEY . '[whitelisted_users][]" multiple>';
1198
  self::create_select_options($users, $options['whitelisted_users'], true);
1199
-
1200
  echo '</select><p class="description">Selected users (when logged in) will <b>not</b> be affected by the under construction mode and will always see the "normal" site.</p>';
1201
  echo '</td></tr>';
1202
-
1203
  echo '</table>';
1204
  } // tab_access
1205
-
1206
 
1207
  // support tab - FAQ and links
1208
  static function tab_support() {
1209
  echo '<h2>' . __('FAQ', 'under-construction-page') . '</h2>';
1210
-
1211
  echo '<p><b>How can I work on my site while construction mode is enabled?</b><br>Make sure your user role (probably admin) is selected under <a class="change_tab" data-tab="3" href="#whitelisted-roles">Access - Whitelisted User Roles</a> and open the site while logged in.</p>';
1212
-
1213
  echo '<p><b>How can I log in / access WordPress admin after construction mode has been enabled?</b><br>Enable the <a class="change_tab" data-tab="2" href="#login_button_wrap">Login Button</a> option under Content, and a login link will be shown in the lower right corner of the under construction page.</p>';
1214
-
1215
  echo '<p><b>How do I add my logo to the page?</b><br>Head over to <a class="change_tab" data-tab="2" href="#content_wrap">Content</a> and click "Add Media". Upload/select the logo, position it as you see fit and add other content.</p>';
1216
-
1217
  echo '<p><b>I\'ve made changes to UCP, but they are not visible. What do I do?</b><br>Click "Save Changes" one more time. Open your site and force refresh browser cache (Ctrl or Shift + F5). If that doesn\'t help it means you have a caching plugin installed. Purge/delete cache in that plugin or disable it.</p>';
1218
-
1219
  echo '<p><b>How can I get more designs? Where do I download them?</b><br>We update the plugin every 7-10 days and each update comes with at least one new theme/design. There is no other way of getting more designs nor a place to download them.</p>';
1220
-
1221
  echo '<p><b>How can I edit designs?</b><br>There is an option to add <a class="change_tab" data-tab="1" href="#custom_css">custom CSS</a>. If you want more than that you will have to edit the source files located in <code>/under-construction-page/themes/</code>.</p>';
1222
-
1223
  echo '<p><b>I have disabled UCP but the under construction page is still visible. How do I remove it?</b><br>Open your site and force refresh browser cache (Ctrl or Shift + F5). If that doesn\'t help it means you have a caching plugin installed. Purge/delete cache in that plugin or disable it.<br>If that fails too contact your hosting provider and ask to empty the site cache for you.</p>';
1224
-
1225
  echo '<h2><br>How to get support?</h2>';
1226
-
1227
  echo '<p>We do our very best to keep <span class="ucp-logo">UnderConstructionPage</span> bug free and compatible with all plugins and themes. If you run into a problem head over to the <a target="_blank" href="http://wordpress.org/support/plugin/under-construction-page">official support forum</a>, open a new thread, and we\'ll help you ASAP.</p>';
1228
  } // tab_support
1229
-
1230
-
1231
  // output the whole options page
1232
  static function main_page() {
1233
  if (!current_user_can('manage_options')) {
@@ -1243,7 +1247,7 @@ class UCP {
1243
  unset($pointers['welcome']);
1244
  update_option(UCP_POINTERS_KEY, $pointers);
1245
  }
1246
-
1247
  echo '<div class="wrap">
1248
  <h1 class="ucp-logo"><img src="' . UCP_PLUGIN_URL . '/images/ucp_logo.png" alt="UnderConstructionPage" title="UnderConstructionPage">UnderConstructionPage</h1>';
1249
 
@@ -1261,89 +1265,89 @@ class UCP {
1261
  echo '<div id="ucp_tabs" class="ui-tabs" style="display: none;">';
1262
  echo '<ul>';
1263
  foreach ($tabs as $tab) {
1264
- if(!empty($tab['label'])){
1265
  echo '<li><a href="#' . $tab['id'] . '" class="' . $tab['class'] . '"><span class="icon"><span class="dashicons ' . $tab['icon'] . '"></span></span><span class="label">' . $tab['label'] . '</span></a></li>';
1266
  }
1267
  }
1268
  echo '</ul>';
1269
-
1270
  foreach ($tabs as $tab) {
1271
  if(is_callable($tab['callback'])) {
1272
  echo '<div style="display: none;" id="' . $tab['id'] . '">';
1273
  call_user_func($tab['callback']);
1274
  echo '</div>';
1275
- }
1276
  } // foreach
1277
 
1278
  echo '</div>'; // ucp_tabs
1279
-
1280
  echo '<p class="submit">';
1281
  echo get_submit_button(__('Save Changes', 'under-construction-page'), 'primary large', 'submit', false);
1282
  echo ' &nbsp; &nbsp; <a id="ucp_preview" href="' . get_home_url() . '/?ucp_preview" class="button button-large button-secondary" target="_blank">' . __('Preview', 'under-construction-page') . '</a>';
1283
  echo '</p>';
1284
-
1285
  echo '</form>'; // ucp_tabs
1286
  echo '</div>'; // wrap
1287
-
1288
  echo '<div id="features-survey-dialog" style="display: none;" title="Please help us make UCP better"><span class="ui-helper-hidden-accessible"><input type="text"/></span>';
1289
  echo '<p>We strive to add new feature to <span class="ucp-logo">UnderConstructionPage</span> every week and want to make them as usefull as possible. <b>What designs should we continue to add to UCP?</b></p>';
1290
-
1291
  $questions = array();
1292
  $questions[] = '<div class="question-wrapper" data-value="current-designs">' .
1293
  '<img src="' . UCP_PLUGIN_URL . 'images/thumbnails/rocket.png" alt="Designs similar to ones we already have" title="Designs similar to ones we already have">' .
1294
  '<div class="question"><b>Designs similar to ones we already have</b></div>' .
1295
  '</div>';
1296
-
1297
  $questions[] = '<div class="question-wrapper" data-value="photo-designs">' .
1298
  '<img src="' . UCP_PLUGIN_URL .'images/survey-designs-photo.png" alt="Serious looking designs based on photographs" title="Serious looking designs based on photographs">' .
1299
  '<div class="question"><b>"Serious" looking designs based on photos</b></div>' .
1300
  '</div>';
1301
-
1302
  $questions[] = '<div class="question-wrapper" data-value="plain-designs">' .
1303
  '<img src="' . UCP_PLUGIN_URL . 'images/thumbnails/plain_text.png" alt="Plain, no thrills designs based on typography" title="Plain, no thrills designs based on typography">' .
1304
  '<div class="question"><b>Plain, no thrills designs based on typography</b></div>' .
1305
  '</div>';
1306
-
1307
  $questions[] = '<div class="question-wrapper" data-value="theme-designs">' .
1308
  '<span class="dashicons big dashicons-media-document"></span>'.
1309
  '<div class="question"><b>Use theme design / pick any existing page</b></div>' .
1310
  '</div>';
1311
-
1312
  shuffle($questions);
1313
  echo implode(' ', $questions);
1314
-
1315
  $current_user = wp_get_current_user();
1316
  echo '<div class="footer">';
1317
  echo '<input id="emailme" type="checkbox" value="' . $current_user->user_email . '"> <label for="emailme">Email me on ' . $current_user->user_email . ' when new designs are added</label><br>';
1318
  echo '<a data-survey="designs-survey" class="submit-survey button-primary button button-large" href="#">Add those new designs ASAP!</a>';
1319
  echo '<a href="#" class="dismiss-survey" data-survey="designs-survey"><small><i>Close this survey and never show it again</i></small></a>';
1320
  echo '</div>';
1321
-
1322
  echo '</div>';
1323
  } // options_page
1324
-
1325
-
1326
  // reset all pointers to default state - visible
1327
  static function reset_pointers() {
1328
  $pointers = array();
1329
  $pointers['welcome'] = array('target' => '#menu-settings', 'edge' => 'left', 'align' => 'right', 'content' => 'Thank you for installing the <b style="font-weight: 800; font-variant: small-caps;">UnderConstructionPage</b> plugin! Please open <a href="' . admin_url('options-general.php?page=ucp'). '">Settings - UnderConstruction</a> to create a beautiful under construction page.');
1330
-
1331
  update_option(UCP_POINTERS_KEY, $pointers);
1332
  } // reset_pointers
1333
-
1334
-
1335
  // reset pointers on activation
1336
  static function activate() {
1337
  self::reset_pointers();
1338
  } // activate
1339
-
1340
  // clean up on deactivation
1341
  static function deactivate() {
1342
  delete_option(UCP_POINTERS_KEY);
1343
  delete_option(UCP_NOTICES_KEY);
1344
  } // deactivate
1345
-
1346
-
1347
  // clean up on uninstall
1348
  static function uninstall() {
1349
  delete_option(UCP_OPTIONS_KEY);
4
  Plugin URI: https://underconstructionpage.com/
5
  Description: Hide your site behind a great looking under construction page while you do maintenance work.
6
  Author: Web factory Ltd
7
+ Version: 2.20
8
  Author URI: http://www.webfactoryltd.com/
9
  Text Domain: under-construction-page
10
  Domain Path: lang
45
  static $version = 0;
46
  static $licensing_servers = array('https://license1.underconstructionpage.com/', 'https://license2.underconstructionpage.com/');
47
 
48
+
49
  // get plugin version from header
50
  static function get_plugin_version() {
51
  $plugin_data = get_file_data(__FILE__, array('version' => 'Version'), 'plugin');
52
  self::$version = $plugin_data['version'];
53
+
54
  return $plugin_data['version'];
55
  } // get_plugin_version
56
+
57
+
58
+ // hook things up
59
  static function init() {
60
  // check if minimal required WP version is present
61
  if (false === self::check_wp_version(4.0)) {
62
  return false;
63
  }
64
+
65
  if (is_admin()) {
66
  // if the plugin was updated from ver < 1.20 upgrade settings array
67
  self::maybe_upgrade();
68
+
69
  // add UCP menu to admin tools menu group
70
  add_action('admin_menu', array(__CLASS__, 'admin_menu'));
71
 
80
  // manages admin header notifications
81
  add_action('admin_notices', array(__CLASS__, 'admin_notices'));
82
  add_action('admin_action_ucp_dismiss_notice', array(__CLASS__, 'dismiss_notice'));
83
+
84
  // enqueue admin scripts
85
  add_action('admin_enqueue_scripts', array(__CLASS__, 'admin_enqueue_scripts'));
86
+
87
  // AJAX endpoints
88
  add_action('wp_ajax_ucp_dismiss_pointer', array(__CLASS__, 'dismiss_pointer_ajax'));
89
  add_action('wp_ajax_ucp_dismiss_survey', array(__CLASS__, 'dismiss_survey_ajax'));
91
  } else {
92
  // main plugin logic
93
  add_action('wp', array(__CLASS__, 'display_construction_page'), 0, 1);
94
+
95
  // show under construction notice on login form
96
  add_filter('login_message', array(__CLASS__, 'login_message'));
97
 
106
  add_action('wp_before_admin_bar_render', array(__CLASS__, 'admin_bar_notice'));
107
  } // init
108
 
109
+
110
  // check if user has the minimal WP version required by UCP
111
  static function check_wp_version($min_version) {
112
  if (!version_compare(get_bloginfo('version'), $min_version, '>=')) {
113
  add_action('admin_notices', array(__CLASS__, 'notice_min_wp_version'));
114
  return false;
115
  } else {
116
+ return true;
117
  }
118
  } // check_wp_version
119
+
120
+
121
  // display error message if WP version is too low
122
  static function notice_min_wp_version() {
123
  echo '<div class="error"><p>' . sprintf(__('UnderConstruction plugin <b>requires WordPress version 4.0</b> or higher to function properly. You are using WordPress version %s. Please <a href="%s">update it</a>.', 'under-construction-page'), get_bloginfo('version'), admin_url('update-core.php')) . '</p></div>';
124
  } // notice_min_wp_version_error
125
+
126
+
127
  // some things have to be loaded earlier
128
  static function plugins_loaded() {
129
  self::get_plugin_version();
130
+
131
  load_plugin_textdomain('under-construction-page');
132
  } // plugins_loaded
133
+
134
+
135
  // activate doesn't get fired on upgrades so we have to compensate
136
  public static function maybe_upgrade() {
137
  $meta = self::get_meta();
138
  $options = self::get_options();
139
+
140
  // added in v1.70 to rename roles to whitelisted_roles
141
  if (isset($options['roles'])) {
142
  $options['whitelisted_roles'] = $options['roles'];
143
  unset($options['roles']);
144
  update_option(UCP_OPTIONS_KEY, $options);
145
  }
146
+
147
  // check if we need to convert options from the old format to new, or maybe it is already done
148
  if (isset($meta['options_ver']) && $meta['options_ver'] == self::$version) {
149
  return;
150
+ }
151
+
152
  if (get_option('set_size') || get_option('set_tweet') || get_option('set_fb') || get_option('set_font') || get_option('set_msg') || get_option('set_opt') || get_option('set_admin')) {
153
  // convert old options to new
154
  $options['status'] = (get_option('set_opt') === 'Yes')? '1': '0';
157
  $options['social_facebook'] = trim(get_option('set_fb'));
158
  $options['social_twitter'] = trim(get_option('set_tweet'));
159
  update_option(UCP_OPTIONS_KEY, $options);
160
+
161
  delete_option('set_size');
162
  delete_option('set_tweet');
163
  delete_option('set_fb');
165
  delete_option('set_msg');
166
  delete_option('set_opt');
167
  delete_option('set_admin');
168
+
169
  self::reset_pointers();
170
  }
171
 
172
+ // we update only once
173
  $meta['options_ver'] = self::$version;
174
  update_option(UCP_META_KEY, $meta);
175
  } // maybe_upgrade
176
+
177
+
178
  // get plugin's options
179
  static function get_options() {
180
  $options = get_option(UCP_OPTIONS_KEY, array());
186
 
187
  return $options;
188
  } // get_options
189
+
190
+
191
  // get plugin's meta data
192
  static function get_meta() {
193
  $meta = get_option(UCP_META_KEY, array());
200
 
201
  return $meta;
202
  } // get_meta
203
+
204
 
205
  // fetch and display the construction page if it's enabled or preview requested
206
  static function display_construction_page() {
207
  $options = self::get_options();
208
+
209
  // some URLs have to be accessible at all times
210
  if ($_SERVER['REQUEST_URI'] == '/wp-admin' ||
211
  $_SERVER['REQUEST_URI'] == '/feed/' ||
217
  $_SERVER['REQUEST_URI'] == '/wp-login.php') {
218
  return true;
219
  }
220
+
221
+ if (true == self::is_construction_mode_enabled(false)
222
  || (is_user_logged_in() && isset($_GET['ucp_preview']))) {
223
  header(self::wp_get_server_protocol() . ' 503 Service Unavailable');
224
  echo self::get_template($options['theme']);
226
  }
227
  } // display_construction_page
228
 
229
+
230
  // keeping compatibility with WP < v4.4
231
  static function wp_get_server_protocol() {
232
  $protocol = $_SERVER['SERVER_PROTOCOL'];
233
  if (!in_array($protocol, array('HTTP/1.1', 'HTTP/2', 'HTTP/2.0'))) {
234
  $protocol = 'HTTP/1.0';
235
  }
236
+
237
  return $protocol;
238
  } // wp_get_server_protocol
239
+
240
+
241
  // disables feed if necessary
242
  static function disable_feed() {
243
  if (true == self::is_construction_mode_enabled(false)) {
246
  }
247
  } // disable_feed
248
 
249
+
250
  // enqueue CSS and JS scripts in admin
251
  static function admin_enqueue_scripts($hook) {
252
  $surveys = get_option(UCP_SURVEYS_KEY);
253
  $meta = self::get_meta();
254
+
255
  // survey is shown min 5 min after install
256
  // no survey at the moment
257
  if (false && empty($surveys['designs']) && current_time('timestamp') - $meta['first_install'] > 300) {
259
  } else {
260
  $open_survey = false;
261
  }
262
+
263
  $js_localize = array('undocumented_error' => __('An undocumented error has occured. Please refresh the page and try again.', 'under-construction-page'),
264
  'plugin_name' => __('UnderConstructionPage', 'under-construction-page'),
265
  'settings_url' => admin_url('options-general.php?page=ucp'),
268
  'nonce_dismiss_survey' => wp_create_nonce('ucp_dismiss_survey'),
269
  'nonce_submit_survey' => wp_create_nonce('ucp_submit_survey'),
270
  'deactivate_confirmation' => __('Are you sure you want to deactivate UnderConstruction plugin?' . "\n" . 'If you are removing it because of a problem please contact our support. They will be more than happy to help.', 'under-construction-page'));
271
+
272
  if ('settings_page_ucp' == $hook) {
273
  wp_enqueue_style('wp-jquery-ui-dialog');
274
  wp_enqueue_style('ucp-select2', UCP_PLUGIN_URL . 'css/select2.min.css', array(), self::$version);
275
  wp_enqueue_style('ucp-admin', UCP_PLUGIN_URL . 'css/ucp-admin.css', array(), self::$version);
276
+
277
  wp_enqueue_script('jquery-ui-tabs');
278
  wp_enqueue_script('jquery-ui-dialog');
279
  wp_enqueue_script('ucp-jquery-plugins', UCP_PLUGIN_URL . 'js/ucp-jquery-plugins.js', array('jquery'), self::$version, true);
281
  wp_enqueue_script('ucp-admin', UCP_PLUGIN_URL . 'js/ucp-admin.js', array('jquery'), self::$version, true);
282
  wp_localize_script('ucp-admin', 'ucp', $js_localize);
283
  }
284
+
285
  if ('plugins.php' == $hook) {
286
  wp_enqueue_script('ucp-admin-plugins', UCP_PLUGIN_URL . 'js/ucp-admin-plugins.js', array('jquery'), self::$version, true);
287
  wp_localize_script('ucp-admin-plugins', 'ucp', $js_localize);
288
  }
289
+
290
  $pointers = get_option(UCP_POINTERS_KEY);
291
  if ($pointers && 'settings_page_ucp' != $hook) {
292
  $pointers['_nonce_dismiss_pointer'] = wp_create_nonce('ucp_dismiss_pointer');
297
  wp_localize_script('jquery', 'ucp', $js_localize);
298
  }
299
  } // admin_enqueue_scripts
300
+
301
+
302
  // permanently dismiss a pointer
303
  static function dismiss_pointer_ajax() {
304
  check_ajax_referer('ucp_dismiss_pointer');
305
+
306
  $pointers = get_option(UCP_POINTERS_KEY);
307
  $pointer = trim($_POST['pointer']);
308
 
312
 
313
  unset($pointers[$pointer]);
314
  update_option(UCP_POINTERS_KEY, $pointers);
315
+
316
  wp_send_json_success();
317
  } // dismiss_pointer_ajax
318
+
319
+
320
  // permanently dismiss a survey
321
  static function dismiss_survey_ajax() {
322
  check_ajax_referer('ucp_dismiss_survey');
323
+
324
  $surveys = get_option(UCP_SURVEYS_KEY, array());
325
  $survey = trim($_POST['survey']);
326
 
327
  $surveys[$survey] = -1;
328
  update_option(UCP_SURVEYS_KEY, $surveys);
329
+
330
  wp_send_json_success();
331
  } // dismiss_survey_ajax
332
+
333
+
334
  // submit survey
335
  static function submit_survey_ajax() {
336
  check_ajax_referer('ucp_submit_survey');
337
 
338
+ $options = self::get_options();
339
  $meta = self::get_meta();
340
  $surveys = get_option(UCP_SURVEYS_KEY);
341
+
342
  $vars = wp_parse_args($_POST, array('survey' => '', 'answers' => '', 'custom_answer' => '', 'emailme' => ''));
343
  $vars['answers'] = trim($vars['answers'], ',');
344
  $vars['custom_answer'] = trim(strip_tags($vars['custom_answer']));
345
+
346
  if (empty($vars['survey']) || empty($vars['answers'])) {
347
  wp_send_json_error();
348
  }
349
+
350
  $request_params = array('sslverify' => false, 'timeout' => 15, 'redirection' => 2);
351
  $request_args = array('action' => 'submit_survey',
352
  'survey' => $vars['survey'],
360
 
361
  $url = add_query_arg($request_args, self::$licensing_servers[0]);
362
  $response = wp_remote_get(esc_url_raw($url), $request_params);
363
+
364
  if (is_wp_error($response) || !wp_remote_retrieve_body($response)) {
365
  $url = add_query_arg($request_args, self::$licensing_servers[1]);
366
  $response = wp_remote_get(esc_url_raw($url), $request_params);
367
  }
368
+
369
  $surveys[$vars['survey']] = current_time('timestamp');
370
  update_option(UCP_SURVEYS_KEY, $surveys);
371
+
372
  wp_send_json_success();
373
  } // submit_survey_ajax
374
+
375
+
376
  static function encode_email($email) {
377
  $len = strlen($email);
378
  $out = '';
379
+
380
  for ($i = 0; $i < $len; $i++) {
381
  $out .= '&#'. ord($email[$i]) . ';';
382
  }
383
+
384
  return $out;
385
  } // encode_email
386
+
387
+
388
  // parse shortcode alike variables
389
  static function parse_vars($string) {
390
  $org_string = $string;
391
+
392
+ $vars = array('site-title' => get_bloginfo('name'),
393
+ 'site-tagline' => get_bloginfo('description'),
394
+ 'site-description' => get_bloginfo('description'),
395
+ 'site-url' => trailingslashit(get_home_url()),
396
  'wp-url' => trailingslashit(get_site_url()),
397
  'site-login-url' => get_site_url() . '/wp-login.php');
398
+
399
  foreach ($vars as $var_name => $var_value) {
400
  $var_name = '[' . $var_name . ']';
401
  $string = str_ireplace($var_name, $var_value, $string);
402
  }
403
+
404
  $string = apply_filters('ucp_parse_vars', $string, $org_string, $vars);
405
+
406
  return $string;
407
  } // parse_vars
408
+
409
+
410
  // generate HTML from social icons
411
  static function generate_social_icons($options, $template_id) {
412
  $out = '';
413
+
414
  if (!empty($options['social_facebook'])) {
415
  $out .= '<a title="Facebook" href="' . $options['social_facebook'] . '" target="_blank"><i class="fa fa-facebook-square fa-3x"></i></a>';
416
  }
456
  if (!empty($options['social_phone'])) {
457
  $out .= '<a title="Phone" href="tel:' . $options['social_phone'] . '"><i class="fa fa-phone-square fa-3x"></i></a>';
458
  }
459
+
460
  return $out;
461
  } // generate_social_icons
462
+
463
+
464
  // shortcode for inserting things in header
465
  static function generate_head($options, $template_id) {
466
  $out = '';
467
+
468
  $out .= '<link rel="stylesheet" href="' . trailingslashit(UCP_PLUGIN_URL . 'themes') . 'css/common.css?v=' . self::$version . '" type="text/css">' . "\n";
469
+
470
  $out .= '<link rel="stylesheet" href="https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css" integrity="sha384-dNpIIXE8U05kAbPhy3G1cz+yZmTzA6CY8Vg/u2L9xRnHjJiAK76m2BIEaSEV+/aU" crossorigin="anonymous">';
471
+
472
  if (!empty($options['ga_tracking_id'])) {
473
  $out .= "
474
  <script>
480
  ga('send', 'pageview');
481
  </script>";
482
  }
483
+
484
  if (!empty($options['custom_css'])) {
485
  $out .= "\n" . '<style type="text/css">' . $options['custom_css'] . '</style>';
486
  }
487
+
488
  $out = apply_filters('ucp_head', $out, $options, $template_id);
489
+
490
  return trim($out);
491
  } // generate_head
492
+
493
+
494
  // shortcode for inserting things in footer
495
  static function generate_footer($options, $template_id) {
496
  $out = '';
497
+
498
  if ($options['linkback'] == '1') {
499
  $tmp = md5(get_site_url());
500
  if ($tmp[0] < '4') {
507
  $out .= '<p id="linkback">Create free <a href="https://underconstructionpage.com/" target="_blank">maintenance mode pages for WordPress</a>.</p>';
508
  }
509
  }
510
+
511
  if ($options['login_button'] == '1') {
512
  if (is_user_logged_in()) {
513
  $out .= '<div id="login-button" class="loggedin">';
518
  }
519
  $out .= '</div>';
520
  }
521
+
522
  $out = apply_filters('ucp_footer', $out, $options, $template_id);
523
+
524
  return $out;
525
  } // generate_footer
526
+
527
+
528
  // returnes parsed template
529
  static function get_template($template_id) {
530
  $vars = array();
543
  $vars['social-icons'] = self::generate_social_icons($options, $template_id);
544
  $vars['head'] = self::generate_head($options, $template_id);
545
  $vars['footer'] = self::generate_footer($options, $template_id);
546
+
547
  $vars = apply_filters('ucp_get_template_vars', $vars, $template_id, $options);
548
+
549
  ob_start();
550
  require UCP_PLUGIN_DIR . 'themes/' . $template_id . '/index.php';
551
  $template = ob_get_clean();
552
+
553
  foreach ($vars as $var_name => $var_value) {
554
  $var_name = '[' . $var_name . ']';
555
  $template = str_ireplace($var_name, $var_value, $template);
556
  }
557
+
558
  $template = apply_filters('ucp_get_template', $template, $vars, $options);
559
+
560
  return $template;
561
  } // get_template
562
 
563
+
564
  // checks if construction mode is enabled for the current visitor
565
  static function is_construction_mode_enabled($settings_only = false) {
566
  $options = self::get_options();
567
  $current_user = wp_get_current_user();
568
+
569
  // just to be on the safe side
570
  if (defined('DOING_CRON') && DOING_CRON) {
571
  return false;
573
  if (defined('DOING_AJAX') && DOING_AJAX) {
574
  return false;
575
  }
576
+
577
  // just check if it's generally enabled
578
  if ($settings_only) {
579
  if ($options['status']) {
599
  }
600
  } // is_construction_mode_enabled
601
 
602
+
603
  // check if user has the specified role
604
  static function user_has_role($roles) {
605
  $current_user = wp_get_current_user();
613
  return in_array($user_role, $roles);
614
  } // user_has_role
615
 
616
+
617
  // displays various notices in admin header
618
  static function admin_notices() {
619
  $notices = get_option(UCP_NOTICES_KEY);
620
  $meta = self::get_meta();
621
+
622
  if (empty($notices['dismiss_rate']) &&
623
  (current_time('timestamp') - $meta['first_install']) > (DAY_IN_SECONDS * 2)) {
624
  $rate_url = 'https://wordpress.org/support/plugin/under-construction-page/reviews/?rate=5#new-post';
628
 
629
  echo '<br><a target="_blank" href="' . esc_url($rate_url) . '" style="vertical-align: baseline; margin-top: 15px;" class="button-primary">' . __('Help make the plugin better by rating it', 'under-construction-page') . '</a>';
630
  echo '&nbsp;&nbsp;&nbsp;&nbsp;<a href="' . esc_url($dismiss_url) . '">' . __('I\'ve already rated the plugin', 'under-construction-page') . '</a>';
631
+ echo '</p></div>';
632
  }
633
  } // notices
634
+
635
+
636
  // handle dismiss button for notices
637
  static function dismiss_notice() {
638
  if (empty($_GET['notice'])) {
639
  wp_redirect(admin_url());
640
  exit;
641
  }
642
+
643
  $notices = get_option(UCP_NOTICES_KEY, array());
644
+
645
  if ($_GET['notice'] == 'rate') {
646
  $notices['dismiss_rate'] = true;
647
  }
648
+
649
  update_option(UCP_NOTICES_KEY, $notices);
650
 
651
  if (!empty($_GET['redirect'])) {
657
  exit;
658
  } // dismiss_notice
659
 
660
+
661
  // add admin bar notice when construction is enabled
662
  static function admin_bar_notice() {
663
  global $wp_admin_bar;
664
+
665
  // only show to admins
666
  if (!current_user_can('administrator')) {
667
  return;
674
  $title = '<img style="height: 17px; margin-bottom: -4px; padding-right: 3px;" src="' . UCP_PLUGIN_URL . '/images/ucp_icon_disabled.png" alt="' . __('Under construction mode is disabled', 'under-construction-page') . '" title="' . __('Under construction mode is disabled', 'under-construction-page') . '"> <span class="ab-label">' . __('Under construction mode is', 'under-construction-page') . ' <strong style="font-weight: bold;">' . __('disabled', 'under-construction-page') . '</strong></span>';
675
  $class = 'ucp-disabled';
676
  }
677
+
678
  $wp_admin_bar->add_menu(array(
679
  'parent' => '',
680
  'id' => 'construction-mode',
683
  'meta' => array('class' => $class)
684
  ));
685
  } // admin_bar_notice
686
+
687
+
688
  // show under construction notice on WP login form
689
  static function login_message($message) {
690
  if (self::is_construction_mode_enabled(true)) {
691
  $message .= '<div class="message">' . __('Under construction mode is <b>enabled</b>.', 'under-construction-page') . '</div>';
692
  }
693
+
694
  return $message;
695
  } // login_notice
696
 
697
+
698
  // add settings link to plugins page
699
  static function plugin_action_links($links) {
700
  $settings_link = '<a href="' . admin_url('options-general.php?page=ucp') . '" title="' . __('UnderConstruction Settings', 'under-construction-page') . '">' . __('Settings', 'under-construction-page') . '</a>';
702
 
703
  return $links;
704
  } // plugin_action_links
705
+
706
+
707
  // add links to plugin's description in plugins table
708
  static function plugin_meta_links($links, $file) {
709
  $support_link = '<a target="_blank" href="https://wordpress.org/support/plugin/under-construction-page" title="' . __('Get help', 'under-construction-page') . '">' . __('Support', 'under-construction-page') . '</a>';
714
 
715
  return $links;
716
  } // plugin_meta_links
717
+
718
 
719
  // create the admin menu item
720
  static function admin_menu() {
721
  add_options_page('UnderConstruction', 'UnderConstruction', 'manage_options', 'ucp', array(__CLASS__, 'main_page'));
722
  } // admin_menu
723
 
724
+
725
  // all settings are saved in one option
726
  static function register_settings() {
727
  register_setting(UCP_OPTIONS_KEY, UCP_OPTIONS_KEY, array(__CLASS__, 'sanitize_settings'));
728
  } // register_settings
729
 
730
+
731
  // set default settings
732
  static function default_options() {
733
  $defaults = array('status' => '0',
762
 
763
  return $defaults;
764
  } // default_options
765
+
766
 
767
  // sanitize settings on save
768
  static function sanitize_settings($options) {
800
  break;
801
  } // switch
802
  } // foreach
803
+
804
  $options['whitelisted_roles'] = empty($options['whitelisted_roles'])? array(): $options['whitelisted_roles'];
805
  $options['whitelisted_users'] = empty($options['whitelisted_users'])? array(): $options['whitelisted_users'];
806
  $options = self::check_var_isset($options, array('status' => 0, 'linkback' => 0, 'login_button' => 0));
807
+
808
  if (!empty($options['ga_tracking_id']) && preg_match('/^UA-\d{3,}-\d{1,3}$/', $options['ga_tracking_id']) === 0) {
809
  add_settings_error('ucp', 'ga_tracking_id', __('Please enter a valid Google Analytics Tracking ID, or leave empty to disable tracking.', 'under-construction-page'));
810
  }
812
  // empty cache in 3rd party plugins
813
  if ($options != $old_options) {
814
  if (function_exists('w3tc_pgcache_flush')) {
815
+ w3tc_pgcache_flush();
816
+ }
817
  if (function_exists('wp_cache_clean_cache')) {
818
  global $file_prefix;
819
+ wp_cache_clean_cache($file_prefix);
820
  }
821
  if (function_exists('wp_cache_clear_cache')) {
822
  wp_cache_clear_cache();
823
  }
824
  if (class_exists('Endurance_Page_Cache')) {
825
  $epc = new Endurance_Page_Cache;
826
+ $epc->purge_all();
827
+ }
828
+ if (class_exists('SG_CachePress_Supercacher') && method_exists('SG_CachePress_Supercacher', 'purge_cache')) {
829
+ SG_CachePress_Supercacher::purge_cache(true);
830
  }
831
  }
832
+
833
  return array_merge($old_options, $options);
834
  } // sanitize_settings
835
+
836
+
837
  // checkbox helper function
838
  static function checked($value, $current, $echo = false) {
839
  $out = '';
852
  return $out;
853
  }
854
  } // checked
855
+
856
+
857
  // helper function for saving options, mostly checkboxes
858
  static function check_var_isset($values, $variables) {
859
  foreach ($variables as $key => $value) {
861
  $values[$key] = $value;
862
  }
863
  }
864
+
865
  return $values;
866
  } // check_var_isset
867
+
868
+
869
  // helper function for creating dropdowns
870
  static function create_select_options($options, $selected = null, $output = true) {
871
  $out = "\n";
892
  return $out;
893
  }
894
  } // create_select_options
895
+
896
+
897
  static function tab_main() {
898
  $options = self::get_options();
899
  $default_options = self::default_options();
900
+
901
  echo '<table class="form-table">';
902
 
903
  echo '<tr valign="top">
909
  <span class="onoffswitch-switch"></span>
910
  </label>
911
  </div>';
912
+
913
  echo '<p class="description">By enabling construction mode all users (<a class="change_tab" data-tab="3" href="#whitelisted-roles">except selected ones</a>) will not be able to access the site\'s content. They will only see the under construction page.</p>';
914
  echo '</td></tr>';
915
+
916
  echo '<tr valign="top">
917
  <th scope="row"><label for="end_date">' . __('End Date &amp; Time', 'under-construction-page') . '</label></th>
918
  <td><input id="end_date" type="text" class="datepicker" name="' . UCP_OPTIONS_KEY . '[end_date]" value="' . esc_attr($options['end_date']) . '" placeholder="yyyy-mm-dd hh:mm"><span title="' . __('Open date & time picker', 'under-construction-page') . '" alt="' . __('Open date & time picker', 'under-construction-page') . '" class="show-datepicker dashicons dashicons-calendar-alt"></span> <span title="Clear date & time" alt="' . __('Clear date & time', 'under-construction-page') . '" class="clear-datepicker dashicons dashicons-no"></span>';
919
  echo '<p class="description">If enabled, construction mode will automatically stop showing on the selected date.<br>
920
  This option will not "auto-enable" construction mode. Status has to be set to "On".</p>';
921
  echo '</td></tr>';
922
+
923
  echo '<tr valign="top">
924
  <th scope="row"><label for="ga_tracking_id">' . __('Google Analytics Tracking ID', 'under-construction-page') . '</label></th>
925
  <td><input id="ga_tracking_id" type="text" class="code" name="' . UCP_OPTIONS_KEY . '[ga_tracking_id]" value="' . esc_attr($options['ga_tracking_id']) . '" placeholder="UA-xxxxxx-xx">';
926
  echo '<p class="description">Enter the unique tracking ID found in your GA tracking profile settings to track visits to the page.<br>Leave blank to disable tracking.</p>';
927
  echo '</td></tr>';
928
+
929
  echo '</table>';
930
  } // tab_main
931
+
932
+
933
  static function tab_content() {
934
  $options = self::get_options();
935
  $default_options = self::default_options();
936
+
937
  echo '<table class="form-table">';
938
+
939
  echo '<tr valign="top">
940
  <th scope="row"><label for="title">Title</label></th>
941
  <td><input type="text" id="title" class="regular-text" name="' . UCP_OPTIONS_KEY . '[title]" value="' . esc_attr($options['title']) . '" />';
955
  <td><input id="description" type="text" class="large-text" name="' . UCP_OPTIONS_KEY . '[description]" value="' . esc_attr($options['description']) . '" />';
956
  echo '<p class="description">Description meta tag (see above for available <a href="#title">shortcodes</a>). Default: ' . $default_options['description'] . '</p>';
957
  echo '</td></tr>';
958
+
959
  echo '<tr valign="top">
960
  <th scope="row"><label for="heading1">Headline</label></th>
961
  <td><input id="heading1" type="text" class="large-text" name="' . UCP_OPTIONS_KEY . '[heading1]" value="' . esc_attr($options['heading1']) . '" />';
968
  wp_editor($options['content'], 'content', array('tabfocus_elements' => 'insert-media-button,save-post', 'editor_height' => 250, 'resize' => 1, 'textarea_name' => UCP_OPTIONS_KEY . '[content]', 'drag_drop_upload' => 1));
969
  echo '<p class="description">All HTML elements are allowed. Shortcodes are not parsed except <a href="#title">UC template ones</a>. Default: ' . $default_options['content'] . '</p>';
970
  echo '</td></tr>';
971
+
972
  echo '<tr valign="top" id="login_button_wrap">
973
  <th scope="row"><label for="login_button">Login Button</label></th>
974
  <td><div class="onoffswitch">
980
  </div>';
981
  echo '<p class="description">Show a descrete link to the login form, or WP admin if you\'re logged in, in the lower right corner of the page.</p>';
982
  echo '</td></tr>';
983
+
984
  echo '<tr valign="top">
985
  <th scope="row"><label for="linkback">Show Some Love</label></th>
986
  <td><div class="onoffswitch">
992
  </div>';
993
  echo '<p class="description">Please help others learn about this free plugin by placing a small link in the footer. Thank you very much!</p>';
994
  echo '</td></tr>';
995
+
996
+
997
  echo '</table>';
998
+
999
  echo '<h2 class="title">Social &amp; Contact Icons</h2>';
1000
+
1001
  echo '<table class="form-table">';
1002
  echo '<tr valign="top">
1003
  <th scope="row"><label for="social_facebook">Facebook Page</label></th>
1004
  <td><input id="social_facebook" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_facebook]" value="' . esc_attr($options['social_facebook']) . '" placeholder="Facebook business or personal page URL">';
1005
  echo '<p class="description">Complete URL, with http prefix, to Facebook page.</p>';
1006
  echo '</td></tr>';
1007
+
1008
  echo '<tr valign="top">
1009
  <th scope="row"><label for="social_twitter">Twitter Profile</label></th>
1010
  <td><input id="social_twitter" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_twitter]" value="' . esc_attr($options['social_twitter']) . '" placeholder="Twitter profile URL">';
1011
  echo '<p class="description">Complete URL, with http prefix, to Twitter profile page.</p>';
1012
  echo '</td></tr>';
1013
+
1014
  echo '<tr valign="top">
1015
  <th scope="row"><label for="social_google">Google Page</label></th>
1016
  <td><input id="social_google" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_google]" value="' . esc_attr($options['social_google']) . '" placeholder="Google+ page URL">';
1017
  echo '<p class="description">Complete URL, with http prefix, to Google+ page.</p>';
1018
  echo '</td></tr>';
1019
+
1020
  echo '<tr valign="top">
1021
  <th scope="row"><label for="social_linkedin">LinkedIn Profile</label></th>
1022
  <td><input id="social_linkedin" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_linkedin]" value="' . esc_attr($options['social_linkedin']) . '" placeholder="LinkedIn profile page URL">';
1023
  echo '<p class="description">Complete URL, with http prefix, to LinkedIn profile page.</p>';
1024
  echo '</td></tr>';
1025
+
1026
  echo '<tr valign="top">
1027
  <th scope="row"><label for="social_youtube">YouTube Profile Page or Video</label></th>
1028
  <td><input id="social_youtube" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_youtube]" value="' . esc_attr($options['social_youtube']) . '" placeholder="YouTube page or video URL">';
1029
  echo '<p class="description">Complete URL, with http prefix, to YouTube page or video.</p>';
1030
  echo '</td></tr>';
1031
+
1032
  echo '<tr valign="top">
1033
  <th scope="row"><label for="social_vimeo">Vimeo Profile Page or Video</label></th>
1034
  <td><input id="social_vimeo" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_vimeo]" value="' . esc_attr($options['social_vimeo']) . '" placeholder="Vimeo page or video URL">';
1035
  echo '<p class="description">Complete URL, with http prefix, to Vimeo page or video.</p>';
1036
  echo '</td></tr>';
1037
+
1038
  echo '<tr valign="top">
1039
  <th scope="row"><label for="social_pinterest">Pinterest Profile</label></th>
1040
  <td><input id="social_pinterest" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_pinterest]" value="' . esc_attr($options['social_pinterest']) . '" placeholder="Pinterest profile URL">';
1041
  echo '<p class="description">Complete URL, with http prefix, to Pinterest profile.</p>';
1042
  echo '</td></tr>';
1043
+
1044
  echo '<tr valign="top">
1045
  <th scope="row"><label for="social_dribbble">Dribbble Profile</label></th>
1046
  <td><input id="social_dribbble" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_dribbble]" value="' . esc_attr($options['social_dribbble']) . '" placeholder="Dribbble profile URL">';
1047
  echo '<p class="description">Complete URL, with http prefix, to Dribbble profile.</p>';
1048
  echo '</td></tr>';
1049
+
1050
  echo '<tr valign="top">
1051
  <th scope="row"><label for="social_behance">Behance Profile</label></th>
1052
  <td><input id="social_behance" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_behance]" value="' . esc_attr($options['social_behance']) . '" placeholder="Behance profile URL">';
1053
  echo '<p class="description">Complete URL, with http prefix, to Behance profile.</p>';
1054
  echo '</td></tr>';
1055
+
1056
  echo '<tr valign="top">
1057
  <th scope="row"><label for="social_instagram">Instagram Profile</label></th>
1058
  <td><input id="social_instagram" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_instagram]" value="' . esc_attr($options['social_instagram']) . '" placeholder="Instagram profile URL">';
1059
  echo '<p class="description">Complete URL, with http prefix, to Instagram profile.</p>';
1060
  echo '</td></tr>';
1061
+
1062
  echo '<tr valign="top">
1063
  <th scope="row"><label for="social_tumblr">Tumblr Blog</label></th>
1064
  <td><input id="social_tumblr" type="url" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_tumblr]" value="' . esc_attr($options['social_tumblr']) . '" placeholder="Tumblr blog URL">';
1065
  echo '<p class="description">Complete URL, with http prefix, to Tumblr blog.</p>';
1066
  echo '</td></tr>';
1067
+
1068
  echo '<tr valign="top">
1069
  <th scope="row"><label for="social_skype">Skype Username</label></th>
1070
  <td><input id="social_skype" type="text" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_skype]" value="' . esc_attr($options['social_skype']) . '" placeholder="Skype username / account name">';
1071
  echo '<p class="description">Skype username / account name.</p>';
1072
  echo '</td></tr>';
1073
+
1074
  echo '<tr valign="top">
1075
  <th scope="row"><label for="social_whatsapp">WhatsApp Phone Number</label></th>
1076
  <td><input id="social_whatsapp" type="text" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_whatsapp]" value="' . esc_attr($options['social_whatsapp']) . '" placeholder="+1-123-456-789">';
1077
  echo '<p class="description">WhatsApp phone number in full international format.</p>';
1078
  echo '</td></tr>';
1079
+
1080
  echo '<tr valign="top">
1081
  <th scope="row"><label for="social_email">Email Address</label></th>
1082
  <td><input id="social_email" type="email" class="regular-text code" name="' . UCP_OPTIONS_KEY . '[social_email]" value="' . esc_attr($options['social_email']) . '" placeholder="name@domain.com">';
1083
  echo '<p class="description">Email will be encoded on the page to protect it from email address harvesters.</p>';
1084
  echo '</td></tr>';
1085
+
1086
  echo '<tr valign="top">
1087
  <th scope="row"><label for="social_phone">Phone Number</label></th>
1088
  <td><input id="social_phone" type="tel" class="regular-text" name="' . UCP_OPTIONS_KEY . '[social_phone]" value="' . esc_attr($options['social_phone']) . '" placeholder="+1-123-456-789">';
1089
  echo '<p class="description">Complete phone number in international format.</p>';
1090
  echo '</td></tr>';
1091
+
1092
  echo '</table>';
1093
  } // tab_content
1094
+
1095
+
1096
  static function tab_design() {
1097
  $options = self::get_options();
1098
  $default_options = self::default_options();
1099
+
1100
  $img_path = UCP_PLUGIN_URL . 'images/thumbnails/';
1101
+
1102
  $themes = array('mad_designer' => __('Mad Designer', 'under-construction-page'),
1103
  'plain_text' => __('Plain Text', 'under-construction-page'),
1104
  'under_construction' => __('Under Construction', 'under-construction-page'),
1120
  'light_bulb' => __('Light Bulb', 'under-construction-page'),
1121
  'ambulance' => __('Ambulance', 'under-construction-page'),
1122
  'laptop' => __('Laptop', 'under-construction-page'),
1123
+ 'puzzles' => __('Puzzles', 'under-construction-page'),
1124
+ 'iot' => __('Internet of Things', 'under-construction-page'));
1125
  $themes = apply_filters('ucp_themes', $themes);
1126
+
1127
  echo '<table class="form-table">';
1128
  echo '<tr valign="top">
1129
  <th scope="row">' . __('Theme', 'under-construction-page') . '</th>
1130
  <td>';
1131
  echo '<input type="hidden" id="theme_id" name="' . UCP_OPTIONS_KEY . '[theme]" value="' . $options['theme'] . '">';
1132
+
1133
  foreach ($themes as $theme_id => $theme_name) {
1134
  if ($theme_id === $options['theme']) {
1135
  $class = ' active';
1138
  }
1139
  echo '<div class="ucp-thumb' . $class . '" data-theme-id="' . $theme_id . '"><img src="' . $img_path . $theme_id . '.png" alt="' . $theme_name . '" title="' . $theme_name . '" /><span>' . $theme_name . '</span></div>';
1140
  }
1141
+
1142
  $tmp = md5(get_site_url());
1143
  if ($tmp[0] < '6') {
1144
  $tweet = 'I need more themes for the free Under Construction #wordpress plugin. When are they coming out? @webfactoryltd';
1150
  $tweet = 'When will you make more themes for the free Under Construction Page plugin for #wordpress? @webfactoryltd';
1151
  $url = 'https://underconstructionpage.com/';
1152
  }
1153
+
1154
  echo '<div class="ucp-thumb-special"><a href="https://twitter.com/intent/tweet?url=' . $url . '&text=' . urlencode($tweet) . '" target="_blank"><img src="' . $img_path . 'more_coming_soon.png" alt="Need more themes?" title="Need more themes?" /></a><br />Click for More Themes</div>';
1155
+
1156
  echo '</td></tr>';
1157
+
1158
  echo '<tr valign="top">
1159
  <th scope="row"><label for="custom_css">' . __('Custom CSS', 'under-construction-page') . '</label></th>
1160
  <td>';
1162
  echo '<p class="description">&lt;style&gt; tags will be added automatically. Do not include them in your code.<br>
1163
  For RTL languages support add: <code>body { direction: rtl; }</code></p>';
1164
  echo '</td></tr>';
1165
+
1166
  echo '</table>';
1167
  } // tab_design
1168
+
1169
+
1170
  // markup & logic for access tab
1171
  static function tab_access() {
1172
  $options = self::get_options();
1173
  $default_options = self::default_options();
1174
  $roles = $users = array();
1175
+
1176
  $tmp_roles = get_editable_roles();
1177
  foreach ($tmp_roles as $tmp_role => $details) {
1178
  $name = translate_user_role($details['name']);
1179
  $roles[] = array('val' => $tmp_role, 'label' => $name);
1180
  }
1181
+
1182
  $tmp_users = get_users(array('fields' => array('id', 'display_name')));
1183
  foreach ($tmp_users as $user) {
1184
  $users[] = array('val' => $user->id, 'label' => $user->display_name);
1185
  }
1186
+
1187
  echo '<table class="form-table">';
1188
+
1189
  echo '<tr valign="top" id="whitelisted-roles">
1190
  <th scope="row">' . __('Whitelisted User Roles', 'under-construction-page') . '</th>
1191
  <td>';
1192
+
1193
  foreach ($roles as $tmp_role) {
1194
  echo '<input name="' . UCP_OPTIONS_KEY . '[whitelisted_roles][]" id="roles-' . $tmp_role['val'] . '" ' . self::checked($tmp_role['val'], $options['whitelisted_roles'], false) . ' value="' . $tmp_role['val'] . '" type="checkbox" /> <label for="roles-' . $tmp_role['val'] . '">' . $tmp_role['label'] . '</label><br />';
1195
  }
1196
  echo '<p class="description">Selected user roles will <b>not</b> be affected by the under construction mode and will always see the "normal" site. Default: administrator.</p>';
1197
  echo '</td></tr>';
1198
+
1199
  echo '<tr valign="top">
1200
  <th scope="row"><label for="whitelisted_users">' . __('Whitelisted Users', 'under-construction-page') . '</label></th>
1201
  <td><select id="whitelisted_users" class="select2" style="width: 50%; max-width: 300px;" name="' . UCP_OPTIONS_KEY . '[whitelisted_users][]" multiple>';
1202
  self::create_select_options($users, $options['whitelisted_users'], true);
1203
+
1204
  echo '</select><p class="description">Selected users (when logged in) will <b>not</b> be affected by the under construction mode and will always see the "normal" site.</p>';
1205
  echo '</td></tr>';
1206
+
1207
  echo '</table>';
1208
  } // tab_access
1209
+
1210
 
1211
  // support tab - FAQ and links
1212
  static function tab_support() {
1213
  echo '<h2>' . __('FAQ', 'under-construction-page') . '</h2>';
1214
+
1215
  echo '<p><b>How can I work on my site while construction mode is enabled?</b><br>Make sure your user role (probably admin) is selected under <a class="change_tab" data-tab="3" href="#whitelisted-roles">Access - Whitelisted User Roles</a> and open the site while logged in.</p>';
1216
+
1217
  echo '<p><b>How can I log in / access WordPress admin after construction mode has been enabled?</b><br>Enable the <a class="change_tab" data-tab="2" href="#login_button_wrap">Login Button</a> option under Content, and a login link will be shown in the lower right corner of the under construction page.</p>';
1218
+
1219
  echo '<p><b>How do I add my logo to the page?</b><br>Head over to <a class="change_tab" data-tab="2" href="#content_wrap">Content</a> and click "Add Media". Upload/select the logo, position it as you see fit and add other content.</p>';
1220
+
1221
  echo '<p><b>I\'ve made changes to UCP, but they are not visible. What do I do?</b><br>Click "Save Changes" one more time. Open your site and force refresh browser cache (Ctrl or Shift + F5). If that doesn\'t help it means you have a caching plugin installed. Purge/delete cache in that plugin or disable it.</p>';
1222
+
1223
  echo '<p><b>How can I get more designs? Where do I download them?</b><br>We update the plugin every 7-10 days and each update comes with at least one new theme/design. There is no other way of getting more designs nor a place to download them.</p>';
1224
+
1225
  echo '<p><b>How can I edit designs?</b><br>There is an option to add <a class="change_tab" data-tab="1" href="#custom_css">custom CSS</a>. If you want more than that you will have to edit the source files located in <code>/under-construction-page/themes/</code>.</p>';
1226
+
1227
  echo '<p><b>I have disabled UCP but the under construction page is still visible. How do I remove it?</b><br>Open your site and force refresh browser cache (Ctrl or Shift + F5). If that doesn\'t help it means you have a caching plugin installed. Purge/delete cache in that plugin or disable it.<br>If that fails too contact your hosting provider and ask to empty the site cache for you.</p>';
1228
+
1229
  echo '<h2><br>How to get support?</h2>';
1230
+
1231
  echo '<p>We do our very best to keep <span class="ucp-logo">UnderConstructionPage</span> bug free and compatible with all plugins and themes. If you run into a problem head over to the <a target="_blank" href="http://wordpress.org/support/plugin/under-construction-page">official support forum</a>, open a new thread, and we\'ll help you ASAP.</p>';
1232
  } // tab_support
1233
+
1234
+
1235
  // output the whole options page
1236
  static function main_page() {
1237
  if (!current_user_can('manage_options')) {
1247
  unset($pointers['welcome']);
1248
  update_option(UCP_POINTERS_KEY, $pointers);
1249
  }
1250
+
1251
  echo '<div class="wrap">
1252
  <h1 class="ucp-logo"><img src="' . UCP_PLUGIN_URL . '/images/ucp_logo.png" alt="UnderConstructionPage" title="UnderConstructionPage">UnderConstructionPage</h1>';
1253
 
1265
  echo '<div id="ucp_tabs" class="ui-tabs" style="display: none;">';
1266
  echo '<ul>';
1267
  foreach ($tabs as $tab) {
1268
+ if(!empty($tab['label'])){
1269
  echo '<li><a href="#' . $tab['id'] . '" class="' . $tab['class'] . '"><span class="icon"><span class="dashicons ' . $tab['icon'] . '"></span></span><span class="label">' . $tab['label'] . '</span></a></li>';
1270
  }
1271
  }
1272
  echo '</ul>';
1273
+
1274
  foreach ($tabs as $tab) {
1275
  if(is_callable($tab['callback'])) {
1276
  echo '<div style="display: none;" id="' . $tab['id'] . '">';
1277
  call_user_func($tab['callback']);
1278
  echo '</div>';
1279
+ }
1280
  } // foreach
1281
 
1282
  echo '</div>'; // ucp_tabs
1283
+
1284
  echo '<p class="submit">';
1285
  echo get_submit_button(__('Save Changes', 'under-construction-page'), 'primary large', 'submit', false);
1286
  echo ' &nbsp; &nbsp; <a id="ucp_preview" href="' . get_home_url() . '/?ucp_preview" class="button button-large button-secondary" target="_blank">' . __('Preview', 'under-construction-page') . '</a>';
1287
  echo '</p>';
1288
+
1289
  echo '</form>'; // ucp_tabs
1290
  echo '</div>'; // wrap
1291
+
1292
  echo '<div id="features-survey-dialog" style="display: none;" title="Please help us make UCP better"><span class="ui-helper-hidden-accessible"><input type="text"/></span>';
1293
  echo '<p>We strive to add new feature to <span class="ucp-logo">UnderConstructionPage</span> every week and want to make them as usefull as possible. <b>What designs should we continue to add to UCP?</b></p>';
1294
+
1295
  $questions = array();
1296
  $questions[] = '<div class="question-wrapper" data-value="current-designs">' .
1297
  '<img src="' . UCP_PLUGIN_URL . 'images/thumbnails/rocket.png" alt="Designs similar to ones we already have" title="Designs similar to ones we already have">' .
1298
  '<div class="question"><b>Designs similar to ones we already have</b></div>' .
1299
  '</div>';
1300
+
1301
  $questions[] = '<div class="question-wrapper" data-value="photo-designs">' .
1302
  '<img src="' . UCP_PLUGIN_URL .'images/survey-designs-photo.png" alt="Serious looking designs based on photographs" title="Serious looking designs based on photographs">' .
1303
  '<div class="question"><b>"Serious" looking designs based on photos</b></div>' .
1304
  '</div>';
1305
+
1306
  $questions[] = '<div class="question-wrapper" data-value="plain-designs">' .
1307
  '<img src="' . UCP_PLUGIN_URL . 'images/thumbnails/plain_text.png" alt="Plain, no thrills designs based on typography" title="Plain, no thrills designs based on typography">' .
1308
  '<div class="question"><b>Plain, no thrills designs based on typography</b></div>' .
1309
  '</div>';
1310
+
1311
  $questions[] = '<div class="question-wrapper" data-value="theme-designs">' .
1312
  '<span class="dashicons big dashicons-media-document"></span>'.
1313
  '<div class="question"><b>Use theme design / pick any existing page</b></div>' .
1314
  '</div>';
1315
+
1316
  shuffle($questions);
1317
  echo implode(' ', $questions);
1318
+
1319
  $current_user = wp_get_current_user();
1320
  echo '<div class="footer">';
1321
  echo '<input id="emailme" type="checkbox" value="' . $current_user->user_email . '"> <label for="emailme">Email me on ' . $current_user->user_email . ' when new designs are added</label><br>';
1322
  echo '<a data-survey="designs-survey" class="submit-survey button-primary button button-large" href="#">Add those new designs ASAP!</a>';
1323
  echo '<a href="#" class="dismiss-survey" data-survey="designs-survey"><small><i>Close this survey and never show it again</i></small></a>';
1324
  echo '</div>';
1325
+
1326
  echo '</div>';
1327
  } // options_page
1328
+
1329
+
1330
  // reset all pointers to default state - visible
1331
  static function reset_pointers() {
1332
  $pointers = array();
1333
  $pointers['welcome'] = array('target' => '#menu-settings', 'edge' => 'left', 'align' => 'right', 'content' => 'Thank you for installing the <b style="font-weight: 800; font-variant: small-caps;">UnderConstructionPage</b> plugin! Please open <a href="' . admin_url('options-general.php?page=ucp'). '">Settings - UnderConstruction</a> to create a beautiful under construction page.');
1334
+
1335
  update_option(UCP_POINTERS_KEY, $pointers);
1336
  } // reset_pointers
1337
+
1338
+
1339
  // reset pointers on activation
1340
  static function activate() {
1341
  self::reset_pointers();
1342
  } // activate
1343
+
1344
  // clean up on deactivation
1345
  static function deactivate() {
1346
  delete_option(UCP_POINTERS_KEY);
1347
  delete_option(UCP_NOTICES_KEY);
1348
  } // deactivate
1349
+
1350
+
1351
  // clean up on uninstall
1352
  static function uninstall() {
1353
  delete_option(UCP_OPTIONS_KEY);