PluginProbe
Loading Page with Loading Screen / 1.1.11
Loading Page with Loading Screen v1.1.11
1.2.8 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.1.0 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 1.1.20 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 All 46 releases
loading-page / loading-page.php

loading-page.php in Loading Page with Loading Screen 1.1.11, at loading-page.php

1,156 lines 57.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 Plugin Name: Loading Page
4 Plugin URI: http://wordpress.dwbooster.com/content-tools/loading-page
5 Description: Loading Page plugin performs a pre-loading of images on your website and displays a loading progress screen with percentage of completion. Once everything is loaded, the screen disappears.
6 Version: 1.1.11
7 Author: CodePeople
8 Author URI: http://wordpress.dwbooster.com/content-tools/loading-page
9 License: GPLv2
10 Text Domain: loading-page
11 */
12
13 require_once 'banner.php';
14 $codepeople_promote_banner_plugins['codepeople-loading-page'] = array(
15 'plugin_name' => 'Loading Page',
16 'plugin_url' => 'https://wordpress.org/support/plugin/loading-page/reviews/#new-post',
17 );
18
19 // CONST.
20 define( 'LOADING_PAGE_PLUGIN_DIR', dirname( __FILE__ ) );
21 define( 'LOADING_PAGE_PLUGIN_URL', plugins_url( '', __FILE__ ) );
22 define( 'LOADING_PAGE_TD', 'loading-page' );
23
24 // Feedback system.
25 require_once 'feedback/cp-feedback.php';
26 new CP_FEEDBACK( plugin_basename( dirname( __FILE__ ) ), __FILE__, 'https://wordpress.dwbooster.com/contact-us' );
27
28 require LOADING_PAGE_PLUGIN_DIR . '/includes/admin_functions.php';
29
30 add_filter( 'option_sbp_settings', 'loading_page_troubleshoot' );
31 if ( ! function_exists( 'loading_page_troubleshoot' ) ) {
32 /**
33 * Troubleshoot
34 *
35 * @param array $option checks values entered by third-party plugins.
36 */
37 function loading_page_troubleshoot( $option ) {
38 if ( ! is_admin() ) {
39 // Solves a conflict caused by the "Speed Booster Pack" plugin.
40 if ( is_array( $option ) && isset( $option['jquery_to_footer'] ) ) {
41 unset( $option['jquery_to_footer'] );
42 }
43 if ( is_array( $option ) && isset( $option['defer_parsing'] ) ) {
44 unset( $option['defer_parsing'] );
45 }
46 }
47 return $option;
48 } // End loading_page_troubleshoot.
49 }
50
51 /**
52 * Plugin activation
53 */
54 register_activation_hook( __FILE__, 'loading_page_install' );
55 if ( ! function_exists( 'loading_page_install' ) ) {
56 /**
57 * Default options
58 */
59 function _loading_page_options() {
60 $loading_page_options = get_option( 'loading_page_options', array() );
61 if ( ! empty( $loading_page_options ) ) {
62 return;
63 }
64
65 // Set the default options here.
66 $loading_page_options = array(
67 'foregroundColor' => '#000000',
68 'backgroundColor' => '#ffffff',
69 'enabled_loading_screen' => true,
70 'close_btn' => true,
71 'remove_in_on_load' => false,
72 'loading_screen' => 'logo',
73 'lp_loading_screen_display_in' => 'all',
74 'once_per_session' => 'always',
75 'lp_loading_screen_display_in_pages' => '',
76 'lp_loading_screen_display_post_types' => '',
77 'lp_loading_screen_exclude_from_pages' => '',
78 'lp_loading_screen_exclude_from_post_types' => '',
79 'lp_loading_screen_exclude_from_urls' => array(),
80 'displayPercent' => true,
81 'backgroundImage' => '',
82 'backgroundImageRepeat' => 'repeat',
83 'fullscreen' => 0,
84 'pageEffect' => 'none',
85 'deepSearch' => true,
86 'modifyDisplayRule' => false,
87 // For the logo screen.
88 'lp_ls' => array( 'logo' => array( 'image' => plugins_url( 'loading-screens/logo/images/05.svg', __FILE__ ) ) ),
89 );
90
91 update_option( 'loading_page_options', $loading_page_options );
92 }
93
94 /**
95 * Install
96 *
97 * @param boolean $networkwide indicates if it is a multisite WordPress installation.
98 */
99 function loading_page_install( $networkwide ) {
100 global $wpdb;
101
102 if ( function_exists( 'is_multisite' ) && is_multisite() ) {
103 if ( $networkwide ) {
104 $old_blog = $wpdb->blogid;
105 // Get all blog ids.
106 $blogids = get_sites( array( 'fields' => 'ids' ) );
107 foreach ( $blogids as $blog_id ) {
108 switch_to_blog( $blog_id );
109 _loading_page_options();
110 }
111 switch_to_blog( $old_blog );
112 return;
113 }
114 }
115 _loading_page_options();
116 } // End loading_page_install.
117 } // End plugin activation.
118
119 /**
120 * Patch to solve the conflict with the previous version that was using animated gifs.
121 */
122 function loading_page_gifs_replacement_patch() {
123 $opt = get_option( 'loading_page_options', array() );
124 if (
125 ! empty( $opt ) &&
126 ! empty( $opt['lp_ls'] ) &&
127 ! empty( $opt['lp_ls']['logo'] ) &&
128 ! empty( $opt['lp_ls']['logo']['image'] )
129 ) {
130 $path = $opt['lp_ls']['logo']['image'];
131 // Only to solve an issue with the previous version of the plugin when where used .gif.
132 $path = preg_replace( '/\/loading\-screens\/logo\/gifs\/(\d+)\.gif/i', '/loading-screens/logo/images/$1.svg', $path );
133 $opt['lp_ls']['logo']['image'] = $path;
134 update_option( 'loading_page_options', $opt );
135 }
136 }
137
138 /**
139 * Replaces the animated gifts
140 *
141 * @param object $upgrader_object unused parameter.
142 * @param array $options plugins identifiers.
143 */
144 function loading_page_upgrade_completed_gifs_patch( $upgrader_object, $options ) {
145 $our_plugin = plugin_basename( __FILE__ );
146 if ( 'update' === $options['action'] && 'plugin' === $options['type'] && isset( $options['plugins'] ) ) {
147 foreach ( $options['plugins'] as $plugin ) {
148 if ( $plugin === $our_plugin ) {
149 loading_page_gifs_replacement_patch();
150 }
151 }
152 }
153 }
154 add_action( 'upgrader_process_complete', 'loading_page_upgrade_completed_gifs_patch', 10, 2 );
155 /**
156 * Calls the gifs replacement patch
157 *
158 * @param string $plugin plugin name.
159 * @param boolean $network_activation plugins activate into a WordPress multisite installation.
160 */
161 function loading_page_activated_gifs_patch( $plugin, $network_activation ) {
162 if ( plugin_basename( __FILE__ ) === $plugin ) {
163 loading_page_gifs_replacement_patch();
164 }
165 }
166 add_action( 'activated_plugin', 'loading_page_activated_gifs_patch', 10, 2 );
167
168 /**
169 * A new blog has been created in a multisite WordPress
170 */
171 add_action( 'wpmu_new_blog', 'loading_page_new_blog', 10, 6 );
172 /**
173 * New blog creation
174 *
175 * @param integer $blog_id blog id.
176 * @param integer $user_id user id.
177 * @param string $domain blog domain.
178 * @param string $path blog path.
179 * @param integer $site_id site id.
180 * @param array $meta metadata.
181 */
182 function loading_page_new_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
183 global $wpdb;
184 $file = basename( __FILE__ );
185 $dir = basename( dirname( __FILE__ ) );
186 if ( is_plugin_active_for_network( $dir . '/' . $file ) ) {
187 $current_blog = $wpdb->blogid;
188 switch_to_blog( $blog_id );
189 _loading_page_options();
190 switch_to_blog( $current_blog );
191 }
192 } // End loading_page_new_blog.
193
194 // Redirecting the user to the settings page of the plugin.
195 add_action( 'activated_plugin', 'loading_page_redirect_to_settings', 10, 2 );
196 if ( ! function_exists( 'loading_page_redirect_to_settings' ) ) {
197 /**
198 * Redirects the user to the settings page
199 *
200 * @param string $plugin plugin name.
201 * @param boolean $network_activation multisite activation.
202 */
203 function loading_page_redirect_to_settings( $plugin, $network_activation ) {
204 if (
205 empty( $_REQUEST['_ajax_nonce'] ) &&
206 plugin_basename( __FILE__ ) === $plugin &&
207 ( ! isset( $_POST['action'] ) || 'activate-selected' !== $_POST['action'] ) && // phpcs:ignore WordPress.Security.NonceVerification
208 ( ! isset( $_POST['action2'] ) || 'activate-selected' !== $_POST['action2'] ) // phpcs:ignore WordPress.Security.NonceVerification
209 ) {
210 wp_safe_redirect( admin_url( 'options-general.php?page=loading-page.php' ) );
211 remove_all_actions( 'shutdown' );
212 exit;
213 }
214 }
215 }
216
217 if ( ! function_exists( 'loading_page_get_settings' ) ) {
218 function loading_page_get_settings() {
219 global $wp, $_loading_page_settings_global_var;
220 if ( empty( $_loading_page_settings_global_var ) ) {
221 $current_url = home_url( add_query_arg( array(), $wp->request ) );
222 $_loading_page_settings_global_var = apply_filters( 'loading_page_settings', get_option( 'loading_page_options', [] ), $current_url );
223 }
224 return $_loading_page_settings_global_var;
225 } // End loading_page_get_settings
226 }
227
228 /*
229 * Plugin initializing
230 */
231 add_action( 'init', 'loading_page_init' );
232 if ( ! function_exists( 'loading_page_init' ) ) {
233 /**
234 * Enqueuen script if loading page is enabled
235 */
236 function loading_page_init() {
237 if ( ! is_admin() && empty( $_REQUEST['elementor-preview'] ) ) {
238
239 $op = loading_page_get_settings();
240
241 if ( ! empty( $op ) && is_array( $op ) && ! empty( $op['enabled_loading_screen'] ) ) {
242 if (
243 ! defined( 'DOING_AJAX' ) &&
244 ! empty( $op['once_per_session'] ) &&
245 'always' != $op['once_per_session'] &&
246 session_id() == '' &&
247 ! headers_sent()
248 ) {
249 @session_start();
250 }
251
252 add_action( 'wp_enqueue_scripts', 'loading_page_enqueue_scripts', 1 );
253 }
254 }
255 } // End loading_page_init.
256 }
257
258 /*
259 * Admin initionalizing
260 */
261 add_action( 'admin_init', 'loading_page_admin_init' );
262 if ( ! function_exists( 'loading_page_admin_init' ) ) {
263 /**
264 * Initialize the plugin admin
265 */
266 function loading_page_admin_init() {
267 // Load the associated text domain.
268 load_plugin_textdomain( 'loading-page', false, LOADING_PAGE_PLUGIN_DIR . '/languages/' );
269
270 // Set plugin links.
271 $plugin = plugin_basename( __FILE__ );
272 add_filter( 'plugin_action_links_' . $plugin, 'loading_page_links' );
273
274 // Load resources.
275 add_action( 'admin_enqueue_scripts', 'loading_page_admin_resources' );
276 } // End loading_page_admin_init.
277 }
278
279 if ( ! function_exists( 'loading_page_links' ) ) {
280 /**
281 * Set plugins section links
282 *
283 * @param array $links links array.
284 */
285 function loading_page_links( $links ) {
286 // Custom link.
287 $custom_link = '<a href="http://wordpress.dwbooster.com/contact-us" target="_blank">' . __( 'Request custom changes', 'loading-page' ) . '</a>';
288 array_unshift( $links, $custom_link );
289
290 // Settings link.
291 $settings_link = '<a href="options-general.php?page=loading-page.php">' . __( 'Settings', 'loading-page' ) . '</a>';
292 array_unshift( $links, $settings_link );
293
294 return $links;
295 } // End loading_page_links.
296 }
297
298 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'loading_page_customization_link' );
299 if ( ! function_exists( 'loading_page_customization_link' ) ) {
300 /**
301 * Redirects the user to the WordPress forum
302 *
303 * @param array $links links array.
304 */
305 function loading_page_customization_link( $links ) {
306 array_unshift( $links, '<a href="https://wordpress.org/support/plugin/loading-page/#new-post" target="_blank">' . __( 'Help', 'loading-page' ) . '</a>' );
307 return $links;
308 }
309 }
310
311 // Set the settings menu option.
312 add_action( 'admin_menu', 'loading_page_settings_menu' );
313 if ( ! function_exists( 'loading_page_settings_menu' ) ) {
314 /**
315 * WordPress menu option
316 */
317 function loading_page_settings_menu() {
318 /**
319 * Add to admin_menu
320 * - The capability has been modified, from "edit_posts" to "manage_options"
321 * - Now only the administrators can now edit the "Loading Page" settings.
322 */
323 add_options_page( 'Loading Page', 'Loading Page', 'manage_options', 'loading-page.php', 'loading_page_settings_page' );
324 } // End loading_page_settings_menu.
325 }
326
327 if ( ! function_exists( 'loading_page_add_code_block' ) ) {
328 /**
329 * Embed the code block on page
330 */
331 function loading_page_add_code_block() {
332 $codeblock = '';
333 $op = loading_page_get_settings();
334 if ( ! empty( $op ) && ! empty( $op['codeBlock'] ) ) {
335 $codeblock = '<div id="loading_page_codeBlock">' . $op['codeBlock'] . '</div>';
336 }
337 return $codeblock;
338 }
339 }
340
341 if ( ! function_exists( 'loading_page_admin_resources' ) ) {
342 /**
343 * Enqueue admin resources
344 *
345 * @param string $hook hook name.
346 */
347 function loading_page_admin_resources( $hook ) {
348 if ( strpos( $hook, 'loading-page' ) !== false ) {
349 wp_enqueue_media();
350 wp_enqueue_style( 'farbtastic' );
351 wp_enqueue_script( 'farbtastic' );
352 wp_enqueue_style( 'thickbox' );
353 wp_enqueue_script( 'thickbox' );
354
355 wp_enqueue_script( 'lp-admin-script', LOADING_PAGE_PLUGIN_URL . '/js/loading-page-admin.js', array( 'jquery', 'thickbox', 'farbtastic' ), 'free-1.1.11', true );
356 }
357 } // End loading_page_admin_resources.
358 }
359
360 if ( ! function_exists( 'loading_page_loading_screen' ) ) {
361 /**
362 * Deciding to include the loading screen
363 */
364 function loading_page_loading_screen() {
365 global $post;
366
367 $is_bot = function () {
368 if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
369 $system = sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) );
370 if ( ! empty( $system ) ) {
371 return preg_match( '/(Googlebot)|(Baiduspider)|(ia_archiver)|(R6_FeedFetcher)|(NetcraftSurveyAgent)|(Sogou web spider)|(bingbot)|(Yahoo\! Slurp)|(facebookexternalhit)|(PrintfulBot)|(msnbot)|(Twitterbot)|(UnwindFetchor)|(urlresolver)/i', $system );
372 }
373 }
374
375 return false;
376 };
377
378 $op = loading_page_get_settings();
379 $loading_screen = 0;
380
381 if ( $is_bot() ) {
382 return $loading_screen;
383 }
384
385 if (
386 ! empty( $op['enabled_loading_screen'] )
387 ) {
388 global $wp;
389 $current_url = home_url( add_query_arg( array(), $wp->request ) );
390 $_permalink = md5( $current_url );
391
392 if (
393 empty( $op['lp_loading_screen_devices'] ) ||
394 'both' == $op['lp_loading_screen_devices'] ||
395 ( 'desktop' == $op['lp_loading_screen_devices'] && ! wp_is_mobile() ) ||
396 ( 'mobile' == $op['lp_loading_screen_devices'] && wp_is_mobile() )
397 ) {
398 if ( ! empty( $op['once_per_session'] ) && 'always' != $op['once_per_session'] ) {
399 if(
400 ! empty( $_SESSION['loading_page_once_per_session'] ) &&
401 (
402 'site' == $op['once_per_session'] ||
403 (
404 'page' == $op['once_per_session'] &&
405 is_array( $_SESSION['loading_page_once_per_session'] ) &&
406 ! empty( $_SESSION['loading_page_once_per_session'][ $_permalink ] )
407 )
408 )
409 ) {
410 return $loading_screen;
411 }
412
413 if ( empty( $_SESSION['loading_page_once_per_session'] ) || ! is_array( $_SESSION['loading_page_once_per_session'] ) ) {
414 $_SESSION['loading_page_once_per_session'] = array();
415 }
416 $_SESSION['loading_page_once_per_session'][ $_permalink ] = 1;
417 }
418
419 $pages = ( ! empty( $op['lp_loading_screen_display_in_pages'] ) ) ? $op['lp_loading_screen_display_in_pages'] : '';
420 $pages = str_replace( ' ', '', $pages );
421 $pages = explode( ',', $pages );
422
423 $post_types = ( ! empty( $op['lp_loading_screen_display_post_types'] ) ) ? $op['lp_loading_screen_display_post_types'] : '';
424 $post_types = str_replace( ' ', '', $post_types );
425 $post_types = explode( ',', $post_types );
426
427 $exclude_pages = ( ! empty( $op['lp_loading_screen_exclude_from_pages'] ) ) ? $op['lp_loading_screen_exclude_from_pages'] : '';
428 $exclude_pages = str_replace( ' ', '', $exclude_pages );
429 $exclude_pages = explode( ',', $exclude_pages );
430
431 $exclude_post_types = ( ! empty( $op['lp_loading_screen_exclude_from_post_types'] ) ) ? $op['lp_loading_screen_exclude_from_post_types'] : '';
432 $exclude_post_types = str_replace( ' ', '', $exclude_post_types );
433 $exclude_post_types = explode( ',', $exclude_post_types );
434
435 $exclude_pages_urls = ( ! empty( $op['lp_loading_screen_exclude_from_urls'] ) ) ? $op['lp_loading_screen_exclude_from_urls'] : array();
436
437 $exclude_elementor_maintenance = ( defined( 'ELEMENTOR_VERSION' ) &&
438 ! empty( $op['lp_loading_screen_exclude_from_elementor_maintenance'] ) &&
439 '' !== get_option( 'elementor_maintenance_mode_mode', '' )
440 ) ? true : false;
441
442 if (
443 ! $exclude_elementor_maintenance &&
444 ( empty( $op['lp_loading_screen_display_in'] ) ||
445 'all' === $op['lp_loading_screen_display_in'] ||
446 ( 'home' === $op['lp_loading_screen_display_in'] && ( is_home() || is_front_page() ) ) ||
447 ( 'pages' === $op['lp_loading_screen_display_in'] && is_singular() && isset( $post ) && in_array( $post->ID, $pages ) ) ||
448 ( 'post_type' === $op['lp_loading_screen_display_in'] && is_singular() && isset( $post ) && in_array( $post->post_type, $post_types, true ) )
449 ) &&
450 ( empty( $post ) ||
451 empty( $post->ID ) ||
452 (
453 ( empty( $exclude_pages ) ||
454 ! in_array( $post->ID, $exclude_pages )
455 )
456 &&
457 ( empty( $exclude_post_types ) ||
458 ! in_array( $post->post_type, $exclude_post_types, true )
459 )
460 )
461 )
462 ) {
463 if ( ! empty( $exclude_pages_urls ) ) {
464 $protocol = ( ( ! empty( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] ) || ( isset( $_SERVER['SERVER_PORT'] ) && 443 === $_SERVER['SERVER_PORT'] ) ) ? 'https://' : 'http://';
465 $current_url = esc_url_raw( $protocol . ( isset( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : '' ) . ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '' ) );
466 foreach ( $exclude_pages_urls as $exclude_page_url ) {
467 $exclude_page_url = preg_quote( $exclude_page_url, '/' );
468 $exclude_page_url = str_replace( '\*', '.*', $exclude_page_url );
469 if ( preg_match( '/' . $exclude_page_url . '/i', $current_url ) ) {
470 return;
471 }
472 }
473 }
474 add_filter( 'body_class', function( $classes ){ $classes[] = 'lp_loading_screen_body'; return $classes; } );
475 $loading_screen = 1;
476 add_action( 'wp_head', 'loading_page_replace_the_header', 99 );
477 add_filter( 'autoptimize_filter_js_dontmove', 'loading_page_autoptimize_exclude', 10, 1 );
478 }
479 }
480 }
481 return $loading_screen;
482 }
483 }
484
485 if ( ! function_exists( 'loading_page_autoptimize_exclude' ) ) {
486 /**
487 * Excluding the plugin resources from Autoptimize
488 *
489 * @param array $to_exclude to exclude URLs.
490 */
491 function loading_page_autoptimize_exclude( $to_exclude ) {
492 $to_exclude[] = 'loading-page.min.js';
493 $to_exclude[] = '/loading-screens/';
494 return $to_exclude;
495 }
496 }
497
498 if ( ! function_exists( 'loading_page_replace_the_header' ) ) {
499 /**
500 * Including styles in the page header section
501 */
502 function loading_page_replace_the_header() {
503 $opt = loading_page_get_settings();
504 if ( empty( $opt ) || empty( $opt['modifyDisplayRule'] ) ) {
505 echo '<style id="loading-page-inline-style">body{visibility:hidden;}</style><noscript><style>body{visibility:visible;}</style></noscript>';
506 } else {
507 echo '<style id="loading-page-inline-style">body{display:none;}</style><noscript><style>body{display:block;}</style></noscript>';
508 }
509
510 if (
511 ! empty( $opt ) &&
512 ! empty( $opt['lp_ls'] ) &&
513 ! empty( $opt['lp_ls']['logo'] ) &&
514 ! empty( $opt['lp_ls']['logo']['image'] )
515 ) {
516 $path = $opt['lp_ls']['logo']['image'];
517 echo '<link rel="preload" href="' . esc_attr( $path ) . '" as="image" type="image/svg+xml">';
518 }
519 } // End loading_page_replace_the_header.
520 }
521
522 if ( ! function_exists( 'loading_page_hex2rgb' ) ) {
523 /**
524 * Transform colors code
525 *
526 * @param array/string $colour color code.
527 */
528 function loading_page_hex2rgb( $colour ) {
529 if ( '#' === $colour[0] ) {
530 $colour = substr( $colour, 1 );
531 }
532 if ( 6 === strlen( $colour ) ) {
533 list($r, $g, $b) = array( $colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5] );
534 } elseif ( 3 === strlen( $colour ) ) {
535 list($r, $g, $b) = array( $colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2] );
536 } else {
537 return $colour;
538 }
539 $r = hexdec( $r );
540 $g = hexdec( $g );
541 $b = hexdec( $b );
542 return 'rgba(' . $r . ',' . $g . ',' . $b . ',.8)';
543 }
544 }
545
546 if ( ! function_exists( 'loading_page_enqueue_scripts' ) ) {
547 /**
548 * Enqueue public scripts
549 */
550 function loading_page_enqueue_scripts() {
551 global $post;
552
553 $op = loading_page_get_settings();
554 $loading_screen = loading_page_loading_screen();
555 if ( $loading_screen && ! empty( $op['from_trigger'] ) ) {
556 wp_enqueue_script( 'codepeople-loading-page-link-script', LOADING_PAGE_PLUGIN_URL . '/js/links.min.js', array( 'jquery' ), 'free-1.1.11', false );
557 }
558
559 if ( $loading_screen ) {
560 $loading_page_settings = array(
561 'loadingScreen' => $loading_screen,
562 'closeBtn' => ( ! isset( $op['close_btn'] ) || $op['close_btn'] ) ? true : false,
563 'removeInOnLoad' => ( ! empty( $op['remove_in_on_load'] ) ) ? $op['remove_in_on_load'] : false,
564 'codeblock' => loading_page_add_code_block(),
565 'backgroundColor' => ( ! isset( $op['transparency'] ) || $op['transparency'] ) ? loading_page_hex2rgb( $op['backgroundColor'] ) : $op['backgroundColor'],
566 'foregroundColor' => $op['foregroundColor'],
567 'backgroundImage' => $op['backgroundImage'],
568 'additionalSeconds' => ( ! empty( $op['additionalSeconds'] ) ) ? $op['additionalSeconds'] : 0,
569 'pageEffect' => $op['pageEffect'],
570 'backgroundRepeat' => $op['backgroundImageRepeat'],
571 'fullscreen' => ( ( ! empty( $op['fullscreen'] ) ) ? 1 : 0 ),
572 'graphic' => $op['loading_screen'],
573 'text' => ( ( ! empty( $op['displayPercent'] ) ) ? $op['displayPercent'] : 0 ),
574 'lp_ls' => ( ( ! empty( $op['lp_ls'] ) ) ? $op['lp_ls'] : 0 ),
575 'screen_size' => ( ( ! empty( $op['screen_size'] ) ) ? $op['screen_size'] : 'all' ),
576 'screen_width' => ( ( ! empty( $op['screen_width'] ) ) ? $op['screen_width'] : 0 ),
577 'deepSearch' => ( ( empty( $op['deepSearch'] ) ) ? 0 : 1 ),
578 'modifyDisplayRule' => ( ( empty( $op['modifyDisplayRule'] ) ) ? 0 : 1 ),
579 'triggerLinkScreenNeverClose' => empty( $op['triggerLinkScreenNeverClose'] ) ? 0 : 1,
580 'triggerLinkScreenCloseAfter' => ! empty( $op['triggerLinkScreenCloseAfter'] ) ? intval( $op['triggerLinkScreenCloseAfter'] ) : 4,
581 );
582
583 $required = array( 'jquery' );
584 wp_enqueue_script( 'jquery' );
585 wp_enqueue_style( 'codepeople-loading-page-style', LOADING_PAGE_PLUGIN_URL . '/css/loading-page.css', array(), 'free-1.1.11', false );
586 wp_enqueue_style( 'codepeople-loading-page-style-effect', LOADING_PAGE_PLUGIN_URL . '/css/loading-page' . ( ( 'none' !== $op['pageEffect'] ) ? '-' . $op['pageEffect'] : '' ) . '.css', array(), 'free-1.1.11', false );
587
588 $s = loading_page_get_screen( $op['loading_screen'] );
589 if ( $s ) {
590 if ( ! empty( $s['style'] ) ) {
591 wp_enqueue_style( 'codepeople-loading-page-style-' . $s['id'], $s['style'], array(), 'free-1.1.11', false );
592 }
593
594 if ( ! empty( $s['script'] ) ) {
595 wp_enqueue_script( 'codepeople-loading-page-script-' . $s['id'], $s['script'], array( 'jquery' ), 'free-1.1.11', false );
596 $required[] = 'codepeople-loading-page-script-' . $s['id'];
597 }
598 }
599 wp_enqueue_script( 'codepeople-loading-page-script', LOADING_PAGE_PLUGIN_URL . '/js/loading-page.min.js', $required, 'free-1.1.11', false );
600 if ( function_exists( 'wp_add_inline_script' ) ) {
601 wp_add_inline_script( 'codepeople-loading-page-script', 'loading_page_settings=' . wp_json_encode( $loading_page_settings ) . ';', 'before' );
602 } else {
603 wp_localize_script( 'codepeople-loading-page-script', 'loading_page_settings', $loading_page_settings );
604 }
605 }
606 } // End loading_page_enqueue_scripts.
607 }
608
609 if ( ! function_exists( 'loading_page_sanitize_array' ) ) {
610 /**
611 * Sanitize mutilevel array
612 *
613 * @param array/string $array values to sanitize.
614 */
615 function loading_page_sanitize_array( $array ) {
616 if ( is_array( $array ) ) {
617 foreach ( $array as $key => $value ) {
618 if ( is_array( $value ) ) {
619 $array[ $key ] = loading_page_sanitize_array( $value );
620 } else {
621 $array[ $key ] = sanitize_text_field( wp_unslash( $value ) );
622 }
623 }
624 return $array;
625 } else {
626 return sanitize_text_field( wp_unslash( $array ) );
627 }
628 } // End loading_page_sanitize_array.
629 }
630
631 if ( ! function_exists( 'loading_page_settings_page' ) ) {
632 /**
633 * Plugin settings page
634 */
635 function loading_page_settings_page() {
636 if ( isset( $_POST['loading_page_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['loading_page_nonce'] ) ), __FILE__ ) ) {
637
638 $allowed_tags = wp_kses_allowed_html( 'post' );
639
640 $allowed_tags['source'] = array(
641 'src' => true,
642 'type' => true
643 );
644
645 if ( current_user_can( 'manage_options' ) ) {
646 $allowed_tags['script'] = true;
647 $allowed_tags['style'] = true;
648 $allowed_tags['link'] = true;
649 }
650
651 $additional_seconds = isset( $_POST['lp_additionalSeconds'] ) && is_numeric( $_POST['lp_additionalSeconds'] ) ? intval( $_POST['lp_additionalSeconds'] ) : 0;
652 $code_block = isset( $_POST['lp_codeBlock'] ) ? wp_kses( wp_unslash( $_POST['lp_codeBlock'] ), $allowed_tags ) : '';
653
654 $lp_loading_screen_exclude_from_urls = isset( $_POST['lp_loading_screen_exclude_from_urls'] ) ? sanitize_textarea_field( wp_unslash( $_POST['lp_loading_screen_exclude_from_urls'] ) ) : '';
655 $lp_loading_screen_exclude_from_urls = explode( "\n", $lp_loading_screen_exclude_from_urls );
656 foreach ( $lp_loading_screen_exclude_from_urls as $key => $url ) {
657 $url = trim( $url );
658 if ( '' === $url ) {
659 unset( $lp_loading_screen_exclude_from_urls[ $key ] );
660 } else {
661 $lp_loading_screen_exclude_from_urls[ $key ] = $url;
662 }
663 }
664
665 $lp_screen_width = '';
666 if ( ! empty( $_POST['lp_screen_width'] ) ) {
667 $lp_screen_width = preg_replace( '/[^\\d\\.]/', '', sanitize_text_field( wp_unslash( $_POST['lp_screen_width'] ) ) );
668 }
669
670 // Set the default options here.
671 $loading_page_options = array(
672 'foregroundColor' => ( ! empty( $_POST['lp_foregroundColor'] ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_foregroundColor'] ) ) : '#FFFFFF',
673 'backgroundColor' => ( ! empty( $_POST['lp_backgroundColor'] ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_backgroundColor'] ) ) : '#000000',
674 'transparency' => ( ! empty( $_POST['lp_backgroundTransparency'] ) ) ? true : false,
675 'backgroundImage' => isset( $_POST['lp_backgroundImage'] ) ? esc_url_raw( wp_unslash( $_POST['lp_backgroundImage'] ) ) : '',
676 'backgroundImageRepeat' => ( isset( $_POST['lp_backgroundRepeat'] ) && in_array( $_POST['lp_backgroundRepeat'], array( 'repeat', 'no-repeat' ), true ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_backgroundRepeat'] ) ) : 'repeat',
677 'additionalSeconds' => $additional_seconds,
678 'codeBlock' => wp_unslash( $code_block ),
679 'fullscreen' => ( isset( $_POST['lp_fullscreen'] ) ) ? 1 : 0,
680 'enabled_loading_screen' => ( isset( $_POST['lp_enabled_loading_screen'] ) ) ? true : false,
681 'from_trigger' => ( isset( $_POST['lp_from_trigger'] ) ) ? true : false,
682 'close_btn' => ( isset( $_POST['lp_close_btn'] ) ) ? true : false,
683 'remove_in_on_load' => ( isset( $_POST['lp_remove_in_on_load'] ) ) ? true : false,
684 'screen_size' => ( isset( $_POST['lp_screen_size'] ) && in_array( $_POST['lp_screen_size'], array( 'all', 'greater', 'lesser' ), true ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_screen_size'] ) ) : 'all',
685 'screen_width' => is_numeric( $lp_screen_width ) ? $lp_screen_width : '',
686 'lp_loading_screen_display_in' => ( isset( $_POST['lp_loading_screen_display_in'] ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_loading_screen_display_in'] ) ) : 'all',
687 'once_per_session' => ( ! isset( $_POST['once_per_session'] ) ||
688 ! in_array( $_POST['once_per_session'], array( 'always', 'site', 'page' ), true )
689 ) ? 'always' : sanitize_text_field( wp_unslash( $_POST['once_per_session'] ) ),
690 'lp_loading_screen_display_in_pages' => isset( $_POST['lp_loading_screen_display_in_pages'] ) ? sanitize_text_field( wp_unslash( $_POST['lp_loading_screen_display_in_pages'] ) ) : '',
691 'lp_loading_screen_display_post_types' => isset( $_POST['lp_loading_screen_display_post_types'] ) ? sanitize_text_field( wp_unslash( $_POST['lp_loading_screen_display_post_types'] ) ) : '',
692 'lp_loading_screen_devices' => isset( $_POST['lp_loading_screen_devices'] ) && in_array( $_POST['lp_loading_screen_devices'], array( 'desktop', 'mobile', 'both' ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_loading_screen_devices'] ) ) : 'both',
693 'lp_loading_screen_exclude_from_pages' => isset( $_POST['lp_loading_screen_exclude_from_pages'] ) ? sanitize_text_field( wp_unslash( $_POST['lp_loading_screen_exclude_from_pages'] ) ) : '',
694 'lp_loading_screen_exclude_from_post_types' => isset( $_POST['lp_loading_screen_exclude_from_post_types'] ) ? sanitize_text_field( wp_unslash( $_POST['lp_loading_screen_exclude_from_post_types'] ) ) : '',
695 'lp_loading_screen_exclude_from_urls' => $lp_loading_screen_exclude_from_urls,
696 'lp_loading_screen_exclude_from_elementor_maintenance' => ( isset( $_POST['lp_loading_screen_exclude_from_elementor_maintenance'] ) ) ? true : false,
697 'deepSearch' => ( isset( $_POST['lp_deactivateDeepSearch'] ) ) ? false : true,
698 'modifyDisplayRule' => ( isset( $_POST['lp_modifyDisplayRule'] ) ) ? true : false,
699 'loading_screen' => isset( $_POST['lp_loading_screen'] ) ? sanitize_text_field( wp_unslash( $_POST['lp_loading_screen'] ) ) : '',
700 'displayPercent' => ( isset( $_POST['lp_displayPercent'] ) ) ? true : false,
701 'pageEffect' => isset( $_POST['lp_pageEffect'] ) ? sanitize_text_field( wp_unslash( $_POST['lp_pageEffect'] ) ) : '',
702 'triggerLinkScreenNeverClose' => isset( $_POST['lp_triggerLinkScreenNeverClose'] ) ? true : false,
703 'triggerLinkScreenCloseAfter' => isset( $_POST['lp_triggerLinkScreenCloseAfter'] ) && is_numeric( $_POST['lp_triggerLinkScreenCloseAfter'] ) ? intval( $_POST['lp_triggerLinkScreenCloseAfter'] ) : '',
704 );
705
706 if ( isset( $_POST['lp_ls'] ) ) {
707 $loading_page_options['lp_ls'] = loading_page_sanitize_array( $_POST['lp_ls'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
708 }
709
710 update_option( 'loading_page_video_tutorial', ( ! empty( $_POST['loading_page_video_tutorial'] ) && 'collapsed' === $_POST['loading_page_video_tutorial'] ) ? 'collapsed' : 'expanded' );
711
712 if ( update_option( 'loading_page_options', $loading_page_options ) ) {
713 print '<div class="updated">' . esc_html( __( 'The Loading Page has been stored successfully', 'loading-page' ) ) . '</div>';
714 } else {
715 print '<div class="error">' . esc_html( __( 'The Loading Page settings could not be stored', 'loading-page' ) ) . '</div>';
716 }
717 }
718
719 $loading_page_options = get_option( 'loading_page_options', [] );
720
721 $loading_page_video_tutorial = get_option( 'loading_page_video_tutorial', 'expanded' );
722 $loading_page_video_tutorial_open_close = ( 'expanded' === $loading_page_video_tutorial ) ? 'X' : '+';
723 $loading_page_video_tutorial_status = ( 'collapsed' === $loading_page_video_tutorial ) ? 'lp-video-collapsed' : '';
724
725 ?>
726 <style>
727 .lp-video-container {
728 overflow: hidden;
729 position: relative;
730 width: 100%;
731 }
732
733 .lp-video-container::after {
734 padding-top: 56.25%;
735 display: block;
736 content: '';
737 }
738
739 .lp-video-container iframe {
740 position: absolute;
741 top: 0;
742 left: 0;
743 width: 100%;
744 height: 100%;
745 }
746
747 .lp-video-collapsed {
748 display: none;
749 }
750 </style>
751 <div class="wrap">
752 <form method="post">
753 <input type="hidden" name="loading_page_nonce" value="<?php print( esc_attr( wp_create_nonce( __FILE__ ) ) ); ?>" />
754 <h2><?php esc_html_e( 'Loading Page Settings', 'loading-page' ); ?></h2>
755 <div class="postbox">
756 <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Video Tutorial', 'loading-page' ); ?></span><a href="javascript:void(0);" onclick="loading_page_collapse_expand_video_tutorial(this);" style="float:right;font-size:1.3em;text-decoration:none;"><?php print esc_html( $loading_page_video_tutorial_open_close ); ?></a></h3>
757 <div class="inside lp-video-tutorial <?php echo esc_attr( $loading_page_video_tutorial_status ); ?>" style="position:relative;">
758 <input type="hidden" name="loading_page_video_tutorial" value="<?php echo esc_attr( $loading_page_video_tutorial ); ?>" />
759 <div class="lp-video-container">
760 <iframe title="<?php esc_attr_e( 'Video tutorial', 'loading-page' ); ?>" src="https://www.youtube.com/embed/5x_LtjoCFUY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
761 </div>
762 </div>
763 </div>
764 <div class="postbox">
765 <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Loading Screen', 'loading-page' ); ?></span></h3>
766 <div class="inside">
767 <p style="border:1px solid #E6DB55;margin-bottom:10px;padding:5px;background-color: #FFFFE0;">If you want test the premium version of Loading Page go to the following links:<br /> <a href="https://demos.dwbooster.com/loading-page/wp-login.php" target="_blank">Administration area: Click to access the administration area demo</a><br />
768 <a href="https://demos.dwbooster.com/loading-page/" target="_blank">Public page: Click to access the Loading Page</a><br />
769 <a href="https://wordpress.org/support/plugin/loading-page/#new-post" target="_blank">If you need additional help</a>
770 </p>
771 <p>
772 <?php
773 esc_html_e(
774 'Displays a loading screen until the webpage is ready, the screen shows the loading percent.',
775 'loading-page'
776 );
777 ?>
778 </p>
779 <table class="form-table">
780 <tr>
781 <th><?php esc_html_e( 'Enable loading screen', 'loading-page' ); ?></th>
782 <td><input aria-label="<?php esc_attr_e( 'Enable loading screen', 'loading-page' ); ?>" type="checkbox" name="lp_enabled_loading_screen" <?php echo ( ( ! empty( $loading_page_options['enabled_loading_screen'] ) ) ? 'CHECKED' : '' ); ?> /></td>
783 </tr>
784 <tr>
785 <th style="border-top:2px dashed green;border-left:2px dashed green;border-bottom:2px dashed green;padding-left:10px;"><?php esc_html_e( 'Show loading screen when clicking on link', 'loading-page' ); ?></th>
786 <td style="border-top:2px dashed green;border-right:2px dashed green;border-bottom:2px dashed green;padding-left:10px;"><input aria-label="<?php esc_attr_e( 'Show loading screen when clicking on link', 'loading-page' ); ?>" type="checkbox" name="lp_from_trigger" <?php print ! empty( $loading_page_options['from_trigger'] ) ? 'CHECKED' : ''; ?> /> <i style="color:green;"><?php esc_html_e( 'Display the loading screen as soon as the link on the current page is clicked, and not only when the next page is loaded.', 'loading-page' ); ?></i></td>
787 </tr>
788 <tr>
789 <th><?php esc_html_e( 'Display a close screen button', 'loading-page' ); ?></th>
790 <td><input aria-label="<?php esc_attr_e( 'Display a close screen button', 'loading-page' ); ?>" type="checkbox" name="lp_close_btn" <?php echo ( ( ! isset( $loading_page_options['close_btn'] ) || $loading_page_options['close_btn'] ) ? 'CHECKED' : '' ); ?> /></td>
791 </tr>
792 <tr>
793 <th><?php esc_html_e( 'Hide the loading screen in the window onload event', 'loading-page' ); ?></th>
794 <td><input aria-label="<?php esc_attr_e( 'Hide the loading screen in the onload event', 'loading-page' ); ?>" type="checkbox" name="lp_remove_in_on_load" <?php echo ( ( ! empty( $loading_page_options['remove_in_on_load'] ) ) ? 'CHECKED' : '' ); ?> /> <i><?php esc_html_e( 'Hides the loading screen in the onload event of window - or - as soon as possible', 'loading-page' ); ?></i></td>
795 </tr>
796 <tr>
797 <th><?php esc_html_e( 'Display the loading screen on', 'loading-page' ); ?></th>
798 <td>
799 <select aria-label="<?php esc_attr_e( 'Screen size', 'loading-page' ); ?>" name="lp_screen_size" style="float:left;">
800 <option value="all"
801 <?php
802 if (
803 isset( $loading_page_options['screen_size'] ) &&
804 'all' === $loading_page_options['screen_size']
805 ) {
806 print 'SELECTED';
807 }
808 ?>
809 ><?php esc_html_e( 'All Screens', 'loading-page' ); ?></option>
810 <option value="greater"
811 <?php
812 if (
813 isset( $loading_page_options['screen_size'] ) &&
814 'greater' === $loading_page_options['screen_size']
815 ) {
816 print 'SELECTED';
817 }
818 ?>
819 ><?php esc_html_e( 'Greater Than', 'loading-page' ); ?></option>
820 <option value="lesser"
821 <?php
822 if (
823 isset( $loading_page_options['screen_size'] ) &&
824 'lesser' === $loading_page_options['screen_size']
825 ) {
826 print 'SELECTED';
827 }
828 ?>
829 ><?php esc_html_e( 'Lesser Than', 'loading-page' ); ?></option>
830 </select>
831 <div id="lp_width_container" style="float:left; padding-left:10px;
832 <?php
833 if ( ! isset( $loading_page_options['screen_size'] ) || 'all' === $loading_page_options['screen_size'] ) {
834 echo 'display:none;';
835 } else {
836 echo 'display:block;';
837 }
838 ?>
839 ">
840 <?php esc_html_e( 'Width', 'loading-page' ); ?>:
841 <input aria-label="<?php esc_attr_e( 'Screen width', 'loading-page' ); ?>" type="text" name="lp_screen_width" value="<?php
842 if ( isset( $loading_page_options['screen_width'] ) ) {
843 echo esc_attr( $loading_page_options['screen_width'] );
844 }
845 ?>" /> px
846 </div>
847 <script>
848 jQuery('[name="lp_screen_size"]').on('change',function() {
849 jQuery('#lp_width_container')[(this.value == 'all') ? 'hide' : 'show']();
850 })
851 </script>
852 </td>
853 </tr>
854 <tr>
855 <th><?php esc_html_e( 'Display the loading screen', 'loading-page' ); ?></th>
856 <td>
857 <?php
858 if (
859 ! isset( $loading_page_options['once_per_session'] ) ||
860 false === $loading_page_options['once_per_session']
861 ) {
862 $loading_page_options['once_per_session'] = 'always';
863 } elseif ( true === $loading_page_options['once_per_session'] ) {
864 $loading_page_options['once_per_session'] = 'site';
865 }
866 ?>
867 <input aria-label="<?php esc_attr_e( 'Always', 'loading-page' ); ?>" type="radio" value="always" name="once_per_session" <?php echo ( ( 'always' === $loading_page_options['once_per_session'] ) ? 'CHECKED' : '' ); ?> /> <span><?php esc_html_e( 'always', 'loading-page' ); ?></span><br />
868 <input aria-label="<?php esc_attr_e( 'Once per session', 'loading-page' ); ?>" type="radio" value="site" name="once_per_session" <?php echo ( ( 'site' === $loading_page_options['once_per_session'] ) ? 'CHECKED' : '' ); ?> /> <span><?php esc_html_e( 'once per session', 'loading-page' ); ?></span><br />
869 <input aria-label="<?php esc_attr_e( 'Once per page', 'loading-page' ); ?>" type="radio" value="page" name="once_per_session" <?php echo ( ( 'page' === $loading_page_options['once_per_session'] ) ? 'CHECKED' : '' ); ?> /> <span><?php esc_html_e( 'once per page', 'loading-page' ); ?></span>
870
871 </td>
872 </tr>
873 <tr>
874 <th><?php esc_html_e( 'Display loading screen in', 'loading-page' ); ?></th>
875 <td>
876 <div><input aria-label="<?php esc_attr_e( 'Homepage', 'loading-page' ); ?>" type="radio" name="lp_loading_screen_display_in" value="home" <?php echo ( ( isset( $loading_page_options['lp_loading_screen_display_in'] ) && 'home' === $loading_page_options['lp_loading_screen_display_in'] ) ? 'CHECKED' : '' ); ?> /> <?php esc_html_e( 'homepage only', 'loading-page' ); ?></div>
877
878 <div><input aria-label="<?php esc_attr_e( 'All pages', 'loading-page' ); ?>" type="radio" name="lp_loading_screen_display_in" value="all" <?php echo ( ( isset( $loading_page_options['lp_loading_screen_display_in'] ) && 'all' === $loading_page_options['lp_loading_screen_display_in'] ) ? 'CHECKED' : '' ); ?> /> <?php esc_html_e( 'all pages', 'loading-page' ); ?></div>
879
880 <div><input aria-label="<?php esc_attr_e( 'Specific pages', 'loading-page' ); ?>" type="radio" name="lp_loading_screen_display_in" value="pages" <?php echo ( ( isset( $loading_page_options['lp_loading_screen_display_in'] ) && 'pages' === $loading_page_options['lp_loading_screen_display_in'] ) ? 'CHECKED' : '' ); ?> /> <?php esc_html_e( 'specific pages', 'loading-page' ); ?>
881 <input aria-label="<?php esc_attr_e( 'Pages/posts ids', 'loading-page' ); ?>" type="text" name="lp_loading_screen_display_in_pages" value="<?php
882 if ( ! empty( $loading_page_options['lp_loading_screen_display_in_pages'] ) ) {
883 print esc_attr( $loading_page_options['lp_loading_screen_display_in_pages'] );}
884 ?>" style="width:100%;margin:10px; 0 10px 20px;">
885 <i><?php esc_html_e( 'Type one, or more post/pages IDs, separated by commas ","', 'loading-page' ); ?></i>
886 </div>
887
888 <div><input aria-label="<?php esc_attr_e( 'specific post types', 'loading-page' ); ?>" type="radio" name="lp_loading_screen_display_in" value="post_type" <?php echo ( ( isset( $loading_page_options['lp_loading_screen_display_in'] ) && 'post_type' === $loading_page_options['lp_loading_screen_display_in'] ) ? 'CHECKED' : '' ); ?> /> <?php esc_html_e( 'specific post types', 'loading-page' ); ?>
889 <input aria-label="<?php esc_attr_e( 'Post types', 'loading-page' ); ?>" type="text" name="lp_loading_screen_display_post_types" value="<?php
890 if ( ! empty( $loading_page_options['lp_loading_screen_display_post_types'] ) ) {
891 print esc_attr( $loading_page_options['lp_loading_screen_display_post_types'] );}
892 ?>" style="width:100%;margin:10px; 0 10px 20px;">
893 <i><?php esc_html_e( 'Type one or more post types, separated by commas ","', 'loading-page' ); ?></i>
894 </div>
895 </td>
896 </tr>
897 <tr>
898 <th><?php esc_html_e( 'Devices', 'loading-page' ); ?></th>
899 <td>
900 <label><input aria-label="<?php esc_attr_e( 'Display the loading screen only on the desktop', 'loading-page' ); ?>" type="radio" name="lp_loading_screen_devices" value="desktop" <?php
901 if ( ! empty( $loading_page_options['lp_loading_screen_devices'] ) && 'desktop' == $loading_page_options['lp_loading_screen_devices'] ) {
902 print 'CHECKED';}
903 ?>> <?php esc_html_e( 'Display the loading screen only on desktops', 'loading-page' ); ?></label><br>
904 <label><input aria-label="<?php esc_attr_e( 'Display the loading screen only on mobiles', 'loading-page' ); ?>" type="radio" name="lp_loading_screen_devices" value="mobile" <?php
905 if ( ! empty( $loading_page_options['lp_loading_screen_devices'] ) && 'mobile' == $loading_page_options['lp_loading_screen_devices'] ) {
906 print 'CHECKED';}
907 ?>> <?php esc_html_e( 'Display the loading screen only on mobiles', 'loading-page' ); ?></label><br>
908 <label><input aria-label="<?php esc_attr_e( 'Display the loading screen on both desktops and mobiles', 'loading-page' ); ?>" type="radio" name="lp_loading_screen_devices" value="both" <?php
909 if ( empty( $loading_page_options['lp_loading_screen_devices'] ) || 'both' == $loading_page_options['lp_loading_screen_devices'] ) {
910 print 'CHECKED';}
911 ?>> <?php esc_html_e( 'Display the loading screen on both desktops and mobiles', 'loading-page' ); ?></label><br>
912 </td>
913 </tr>
914 <tr>
915 <td colspan="2">
916 <hr />
917 </td>
918 </tr>
919 <tr>
920 <th><?php esc_html_e( 'Exclude loading screen from', 'loading-page' ); ?></th>
921 <td><input aria-label="<?php esc_attr_e( 'Pages/posts ids separated by comma', 'loading-page' ); ?>" type="text" name="lp_loading_screen_exclude_from_pages" value="<?php
922 if ( ! empty( $loading_page_options['lp_loading_screen_exclude_from_pages'] ) ) {
923 print esc_attr( $loading_page_options['lp_loading_screen_exclude_from_pages'] );}
924 ?>"> <i><?php esc_html_e( 'Type one, or more post/pages IDs, separated by commas ","', 'loading-page' ); ?></i></td>
925 </tr>
926 <tr>
927 <th><?php esc_html_e( 'Exclude loading screen from post types', 'loading-page' ); ?></th>
928 <td><input aria-label="<?php esc_attr_e( 'Post types separated by comma', 'loading-page' ); ?>" type="text" name="lp_loading_screen_exclude_from_post_types" value="<?php
929 if ( ! empty( $loading_page_options['lp_loading_screen_exclude_from_post_types'] ) ) {
930 print esc_attr( $loading_page_options['lp_loading_screen_exclude_from_post_types'] );}
931 ?>"> <i><?php esc_html_e( 'Type one, or more post/pages types, separated by commas ","', 'loading-page' ); ?></i></td>
932 </tr>
933 <tr>
934 <th><?php esc_html_e( 'Exclude loading screen from pages with the URL', 'loading-page' ); ?></th>
935 <td><textarea aria-label="<?php esc_attr_e( 'URLs of the pages to exclude', 'loading-page' ); ?>" name="lp_loading_screen_exclude_from_urls" style="width:100%" rows="6"><?php
936 print esc_textarea(
937 ( ! empty( $loading_page_options['lp_loading_screen_exclude_from_urls'] ) )
938 ? implode( "\n", $loading_page_options['lp_loading_screen_exclude_from_urls'] ) : ''
939 );
940 ?></textarea>
941 <i>Enter an URL per row (use the * symbol as wildcard)</i>
942 </td>
943 </tr>
944 <tr>
945 <th colspan="2">
946 <?php esc_html_e( 'Exclude the loading screen if Elementor Maintenance or Coming Soon modes are enabled', 'loading-page' ); ?>
947 <input aria-label="<?php esc_attr_e( 'Disable the loading screen from Coming Soon or Maintenance modes', 'loading-page' ); ?>" type="checkbox" name="lp_loading_screen_exclude_from_elementor_maintenance" <?php echo ( ( ! empty( $loading_page_options['lp_loading_screen_exclude_from_elementor_maintenance'] ) ) ? 'CHECKED' : '' ); ?> />
948 </th>
949 </tr>
950 <tr>
951 <td colspan="2">
952 <hr />
953 </td>
954 </tr>
955 <tr>
956 <?php $loading_screens = loading_page_get_screen_list(); ?>
957 <th><?php esc_html_e( 'Select the loading screen', 'loading-page' ); ?></th>
958 <td>
959 <select aria-label="<?php esc_attr_e( 'Loading screen', 'loading-page' ); ?>" name="lp_loading_screen">
960 <?php
961 foreach ( $loading_screens as $screen ) {
962 print '<option value="' . esc_attr( $screen['id'] ) . '" ' . ( ( isset( $loading_page_options['loading_screen'] ) && $loading_page_options['loading_screen'] === $screen['id'] ) ? 'SELECTED' : '' ) . ' title="' . ( ( ! empty( $screen['tips'] ) ) ? esc_attr( $screen['tips'] ) : '' ) . '" >' . esc_html( $screen['name'] ) . '</option>';
963 }
964 ?>
965 </select>
966 <span style="color:#FF0000;">
967 The free version of the plugin includes the "Bar Screen" and "Logo Screen", however, if they are not sufficient to your website, the commercial version of the plugin includes other loading screens: <a href="http://wordpress.dwbooster.com/content-tools/loading-page" target="_blank">CLICK HERE</a>
968 </span>
969 </td>
970 </tr>
971 <?php
972 foreach ( $loading_screens as $screen ) {
973 if ( ! empty( $screen['adminsection'] ) ) {
974 include_once $screen['adminsection'];
975 }
976 if ( ! empty( $screen['adminscript'] ) ) {
977 wp_enqueue_script( $screen['adminscript'], $screen['adminscript'], array(), 'free-1.1.11', true );
978 }
979 }
980 ?>
981 <tr>
982 <th><?php esc_html_e( 'Select background color', 'loading-page' ); ?></th>
983 <td>
984 <input aria-label="<?php esc_attr_e( 'Background color', 'loading-page' ); ?>" type="text" name="lp_backgroundColor" id="lp_backgroundColor" value="<?php
985 if ( isset( $loading_page_options['backgroundColor'] ) ) {
986 print( esc_attr( $loading_page_options['backgroundColor'] ) );}
987 ?>" />
988 <input aria-label="<?php esc_attr_e( 'Apply transparency', 'loading-page' ); ?>" type="checkbox" name="lp_backgroundTransparency" <?php print ( ! isset( $loading_page_options['transparency'] ) || $loading_page_options['transparency'] ) ? 'CHECKED' : ''; ?> /><?php esc_html_e( 'Apply transparency', 'loading-page' ); ?>
989 <div id="lp_backgroundColor_picker"></div>
990 </td>
991 </tr>
992 <tr>
993 <th><?php esc_html_e( 'Select image as background', 'loading-page' ); ?></th>
994 <td>
995 <input aria-label="<?php esc_attr_e( 'Background image', 'loading-page' ); ?>" type="text" name="lp_backgroundImage" id="lp_backgroundImage" value="<?php
996 if ( isset( $loading_page_options['backgroundImage'] ) ) {
997 print( esc_attr( $loading_page_options['backgroundImage'] ) );}
998 ?>" />
999 <input type="button" value="Browse" onclick="loading_page_selected_image('lp_backgroundImage');" />
1000 <select aria-label="<?php esc_attr_e( 'Background position', 'loading-page' ); ?>" id="lp_backgroundRepeat" name="lp_backgroundRepeat">
1001 <option value="repeat"
1002 <?php
1003 if ( isset( $loading_page_options['backgroundImageRepeat'] ) && 'repeat' === $loading_page_options['backgroundImageRepeat'] ) {
1004 echo 'SELECTED';}
1005 ?>
1006 >Tile</option>
1007 <option value="no-repeat"
1008 <?php
1009 if ( isset( $loading_page_options['backgroundImageRepeat'] ) && 'no-repeat' === $loading_page_options['backgroundImageRepeat'] ) {
1010 echo 'SELECTED';}
1011 ?>
1012 >Center</option>
1013 </select>
1014
1015 </td>
1016 </tr>
1017 <tr>
1018 <th><?php esc_html_e( 'Display image in fullscreen', 'loading-page' ); ?></th>
1019 <td>
1020 <input aria-label="<?php esc_attr_e( 'Fullscreen', 'loading-page' ); ?>" type="checkbox" name="lp_fullscreen" id="lp_fullscreen" <?php echo ( ( isset( $loading_page_options['fullscreen'] ) && $loading_page_options['fullscreen'] ) ? 'CHECKED' : '' ); ?> />
1021 <i><?php esc_html_e( '(The fullscreen attribute can fail in some browsers)', 'loading-page' ); ?></i>
1022 </td>
1023 </tr>
1024 <tr>
1025 <th><?php esc_html_e( 'Select foreground color', 'loading-page' ); ?></th>
1026 <td><input aria-label="<?php esc_attr_e( 'Foreground color', 'loading-page' ); ?>" type="text" name="lp_foregroundColor" id="lp_foregroundColor" value="<?php
1027 if ( isset( $loading_page_options['foregroundColor'] ) ) {
1028 print( esc_attr( $loading_page_options['foregroundColor'] ) );}
1029 ?>" />
1030 <div id="lp_foregroundColor_picker"></div>
1031 </td>
1032 </tr>
1033 <tr>
1034 <th><?php esc_html_e( 'Additional seconds', 'loading-page' ); ?></th>
1035 <td>
1036 <input aria-label="<?php esc_attr_e( 'Additional seconds', 'loading-page' ); ?>" type="text" name="lp_additionalSeconds" id="lp_additionalSeconds" value="<?php
1037 if ( isset( $loading_page_options['additionalSeconds'] ) ) {
1038 print( esc_attr( $loading_page_options['additionalSeconds'] ) );}
1039 ?>" />
1040 <i><?php esc_html_e( 'Show the loading screen some few seconds after loading the page', 'loading-page' ); ?></i>
1041 </td>
1042 </tr>
1043 <tr>
1044 <th><?php esc_html_e( 'Include an ad, or your own block of code', 'loading-page' ); ?></th>
1045 <td>
1046 <textarea aria-label="<?php esc_attr_e( 'Ad or block of code', 'loading-page' ); ?>" name="lp_codeBlock" id="lp_codeBlock" rows="6" style="width:80%;"><?php
1047 if ( isset( $loading_page_options['codeBlock'] ) ) {
1048 print( esc_textarea( $loading_page_options['codeBlock'] ) );}
1049 ?></textarea>
1050 <p><i><b><?php esc_html_e( 'Trick', 'loading-page' ); ?></b>:
1051 <?php esc_html_e( 'As the block of code you can insert a pair of &lt;style&gt;&lt;/style&gt; tags to customize the appearance of loading screen. For example: for changing the font-family of the loading text: <b>&lt;style&gt;.lp-screen-text{font-family:Georgia !important;}&lt;/style&gt;</b>', 'loading-page' ); ?></i></p>
1052 </td>
1053 </tr>
1054 <tr>
1055 <th><?php esc_html_e( 'Apply the effect on page', 'loading-page' ); ?></th>
1056 <td>
1057 <select aria-label="<?php esc_attr_e( 'Animation effect', 'loading-page' ); ?>" name="lp_pageEffect">
1058 <?php
1059 $page_effects = array( 'none', 'rotateInLeft' );
1060
1061 foreach ( $page_effects as $value ) {
1062 print '<option value="' . esc_attr( $value ) . '" ' . ( ( isset( $loading_page_options['pageEffect'] ) && $loading_page_options['pageEffect'] === $value ) ? 'SELECTED' : '' ) . '>' . esc_html( $value ) . '</option>';
1063 }
1064 ?>
1065
1066 </select>
1067 <div style="color:#FF0000;">The premium version of plugin add the following effects: collapseIn, risingFromBottom, expandIn, fadeIn, fallFromTop, rotateInLeft, rotateInRight, rotateInRightWithoutToKeyframe, slideInSkew, tumbleIn, whirlIn</div>
1068 </td>
1069 </tr>
1070 <tr>
1071 <th><?php esc_html_e( 'Display loading percent', 'loading-page' ); ?></th>
1072 <td><input aria-label="<?php esc_attr_e( 'Display loading percent', 'loading-page' ); ?>" type="checkbox" name="lp_displayPercent" <?php echo ( ( ! empty( $loading_page_options['displayPercent'] ) ) ? 'CHECKED' : '' ); ?> /></td>
1073 </tr>
1074 </table>
1075 <div style="border: 1px solid #DADADA; padding:10px;">
1076 <h3><?php esc_html_e( 'Troubleshoot Area - Loading Screen', 'loading-page' ); ?></h3>
1077 <table class="form-table">
1078 <tr>
1079 <th><?php esc_html_e( 'Disable the search in deep', 'loading-page' ); ?></th>
1080 <td>
1081 <input aria-label="<?php esc_attr_e( 'Disable search in deep', 'loading-page' ); ?>" type="checkbox" name="lp_deactivateDeepSearch" <?php echo ( ( empty( $loading_page_options['deepSearch'] ) ) ? 'CHECKED' : '' ); ?> /> <i><?php esc_html_e( 'If the loading screen stops in some percentage, tick the checkbox', 'loading-page' ); ?></i>
1082 </td>
1083 </tr>
1084 <tr>
1085 <th><?php esc_html_e( 'The pages\' background is visible', 'loading-page' ); ?></th>
1086 <td>
1087 <input aria-label="<?php esc_attr_e( 'Tick if page visible', 'loading-page' ); ?>" type="checkbox" name="lp_modifyDisplayRule" <?php echo ( ( ! empty( $loading_page_options['modifyDisplayRule'] ) ) ? 'CHECKED' : '' ); ?> /> <i><?php esc_html_e( 'If website\'s background is visible before the loading screen, tick the checkbox', 'loading-page' ); ?></i>
1088 </td>
1089 </tr>
1090 <tr>
1091 <td colspan="2" style="padding-left:0;">
1092 <?php esc_html_e( 'You have ticked the box "show loading screen on link click", but the loading screen disappears too quickly, before loading the content of the next page.', 'loading-page' ); ?><br /><br />
1093 <input aria-label="<?php esc_attr_e( 'Loading screen disappear too quickly', 'loading-page' ); ?>" type="checkbox" name="lp_triggerLinkScreenNeverClose" <?php echo ( ( ! empty( $loading_page_options['triggerLinkScreenNeverClose'] ) ) ? 'CHECKED' : '' ); ?>/> <?php esc_html_e( 'Do not hide the loading screen', 'loading-page' ); ?>&nbsp;
1094 <?php esc_html_e( '- or close after ', 'loading-page' ); ?>&nbsp;
1095 <input type="number" name="lp_triggerLinkScreenCloseAfter" aria-label="<?php esc_attr_e( 'Close after X seconds', 'loading-page' ); ?>" value="<?php print esc_attr( isset( $loading_page_options['triggerLinkScreenCloseAfter'] ) ? $loading_page_options['triggerLinkScreenCloseAfter'] : 4 ); ?>" />&nbsp;
1096 <?php esc_html_e( 'seconds', 'loading-page' ); ?>
1097 </td>
1098 </tr>
1099 </table>
1100 </div>
1101 </div>
1102 </div>
1103 <div class="postbox">
1104 <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Lazy Loading', 'loading-page' ); ?></span></h3>
1105 <div class="inside">
1106 <p>
1107 <?php
1108 esc_html_e(
1109 'To load only the images visible in the viewport to improve the loading rate of your website and reduce the bandwidth consumption.',
1110 'loading-page'
1111 );
1112 ?>
1113 </p>
1114 <p>
1115 <span style="color:#FF0000;">
1116 The lazy loading of images is available only in the commercial version of plugin <a href="http://wordpress.dwbooster.com/content-tools/loading-page" target="_blank">CLICK HERE</a>
1117 </span>
1118 </p>
1119 <p><img alt="<?php esc_attr_e( 'Lazy loading chart', 'loading-page' ); ?>" src="<?php print( esc_attr( LOADING_PAGE_PLUGIN_URL . '/images/consumption_graph.png' ) ); ?>" style="max-width:100%;" /></p>
1120 <table class="form-table">
1121 <tr>
1122 <th><?php esc_html_e( 'Enable lazy loading', 'loading-page' ); ?></th>
1123 <td><input aria-label="<?php esc_attr_e( 'Enable lazy loading', 'loading-page' ); ?>" type="checkbox" DISABLED /></td>
1124 </tr>
1125 <tr>
1126 <th><?php esc_html_e( 'Select the image to load by default', 'loading-page' ); ?></th>
1127 <td>
1128 <input aria-label="<?php esc_attr_e( 'Image to load by default', 'loading-page' ); ?>" type="text" DISABLED /><input type="button" value="Browse" DISABLED />
1129 </td>
1130 </tr>
1131 <tr>
1132 <th><?php esc_html_e( 'Exclude lazy loading from', 'loading-page' ); ?></th>
1133 <td><input aria-label="<?php esc_attr_e( 'Pages/posts ids separated by comma', 'loading-page' ); ?>" type="text" DISABLED /> <i><?php esc_html_e( 'Type one, or more post/pages IDs, separated by commas ","', 'loading-page' ); ?></i></td>
1134 </tr>
1135 </table>
1136 <div style="border: 1px solid #DADADA; padding:10px;">
1137 <h3><?php esc_html_e( 'Troubleshoot Area - Lazy Loading', 'loading-page' ); ?></h3>
1138 <table class="form-table">
1139 <tr>
1140 <th><?php esc_html_e( 'Exclude images whose tag includes the class or attribute', 'loading-page' ); ?></th>
1141 <td>
1142 <input aria-label="<?php esc_attr_e( 'Class or attributes names', 'loading-page' ); ?>" type="text" style="width:100%;" disabled /><br />
1143 <p><i><?php esc_html_e( 'Don\'t apply the lazy loading to the images with the classes or attributes (separated by commas ",")', 'loading-page' ); ?></i></p>
1144 </td>
1145 </tr>
1146 </table>
1147 </div>
1148 </div>
1149 </div>
1150 <div><input type="submit" value="Update Settings" class="button-primary" /></div>
1151 </form>
1152 </div>
1153 <?php
1154 } // End loading_page_settings_page.
1155 }
1156