PluginProbe
Loading Page with Loading Screen / 1.1.1
Loading Page with Loading Screen v1.1.1
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.1, at loading-page.php

1,132 lines 56.7 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.1
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 plugin_basename( __FILE__ ) === $plugin &&
206 ( ! isset( $_POST['action'] ) || 'activate-selected' !== $_POST['action'] ) && // phpcs:ignore WordPress.Security.NonceVerification
207 ( ! isset( $_POST['action2'] ) || 'activate-selected' !== $_POST['action2'] ) // phpcs:ignore WordPress.Security.NonceVerification
208 ) {
209 wp_safe_redirect( admin_url( 'options-general.php?page=loading-page.php' ) );
210 exit;
211 }
212 }
213 }
214
215 if ( ! function_exists( 'loading_page_get_settings' ) ) {
216 function loading_page_get_settings() {
217 global $wp, $_loading_page_settings_global_var;
218 if ( empty( $_loading_page_settings_global_var ) ) {
219 $current_url = home_url( add_query_arg( array(), $wp->request ) );
220 $_loading_page_settings_global_var = apply_filters( 'loading_page_settings', get_option( 'loading_page_options', [] ), $current_url );
221 }
222 return $_loading_page_settings_global_var;
223 } // End loading_page_get_settings
224 }
225
226 /*
227 * Plugin initializing
228 */
229 add_action( 'init', 'loading_page_init' );
230 if ( ! function_exists( 'loading_page_init' ) ) {
231 /**
232 * Enqueuen script if loading page is enabled
233 */
234 function loading_page_init() {
235 if ( ! is_admin() && empty( $_REQUEST['elementor-preview'] ) ) {
236 if ( ! defined( 'DOING_AJAX' ) && '' === session_id() ) {
237 @session_start();
238 }
239
240 $op = loading_page_get_settings();
241
242 if ( ! empty( $op ) && is_array( $op ) && ! empty( $op['enabled_loading_screen'] ) ) {
243 add_action( 'wp_enqueue_scripts', 'loading_page_enqueue_scripts', 1 );
244 }
245 }
246 } // End loading_page_init.
247 }
248
249 /*
250 * Admin initionalizing
251 */
252 add_action( 'admin_init', 'loading_page_admin_init' );
253 if ( ! function_exists( 'loading_page_admin_init' ) ) {
254 /**
255 * Initialize the plugin admin
256 */
257 function loading_page_admin_init() {
258 // Load the associated text domain.
259 load_plugin_textdomain( 'loading-page', false, LOADING_PAGE_PLUGIN_DIR . '/languages/' );
260
261 // Set plugin links.
262 $plugin = plugin_basename( __FILE__ );
263 add_filter( 'plugin_action_links_' . $plugin, 'loading_page_links' );
264
265 // Load resources.
266 add_action( 'admin_enqueue_scripts', 'loading_page_admin_resources' );
267 } // End loading_page_admin_init.
268 }
269
270 if ( ! function_exists( 'loading_page_links' ) ) {
271 /**
272 * Set plugins section links
273 *
274 * @param array $links links array.
275 */
276 function loading_page_links( $links ) {
277 // Custom link.
278 $custom_link = '<a href="http://wordpress.dwbooster.com/contact-us" target="_blank">' . __( 'Request custom changes', 'loading-page' ) . '</a>';
279 array_unshift( $links, $custom_link );
280
281 // Settings link.
282 $settings_link = '<a href="options-general.php?page=loading-page.php">' . __( 'Settings', 'loading-page' ) . '</a>';
283 array_unshift( $links, $settings_link );
284
285 return $links;
286 } // End loading_page_links.
287 }
288
289 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'loading_page_customization_link' );
290 if ( ! function_exists( 'loading_page_customization_link' ) ) {
291 /**
292 * Redirects the user to the WordPress forum
293 *
294 * @param array $links links array.
295 */
296 function loading_page_customization_link( $links ) {
297 array_unshift( $links, '<a href="https://wordpress.org/support/plugin/loading-page/#new-post" target="_blank">' . __( 'Help', 'loading-page' ) . '</a>' );
298 return $links;
299 }
300 }
301
302 // Set the settings menu option.
303 add_action( 'admin_menu', 'loading_page_settings_menu' );
304 if ( ! function_exists( 'loading_page_settings_menu' ) ) {
305 /**
306 * WordPress menu option
307 */
308 function loading_page_settings_menu() {
309 /**
310 * Add to admin_menu
311 * - The capability has been modified, from "edit_posts" to "manage_options"
312 * - Now only the administrators can now edit the "Loading Page" settings.
313 */
314 add_options_page( 'Loading Page', 'Loading Page', 'manage_options', 'loading-page.php', 'loading_page_settings_page' );
315 } // End loading_page_settings_menu.
316 }
317
318 if ( ! function_exists( 'loading_page_add_code_block' ) ) {
319 /**
320 * Embed the code block on page
321 */
322 function loading_page_add_code_block() {
323 $codeblock = '';
324 $op = loading_page_get_settings();
325 if ( ! empty( $op ) && ! empty( $op['codeBlock'] ) ) {
326 $codeblock = '<div id="loading_page_codeBlock">' . $op['codeBlock'] . '</div>';
327 }
328 return $codeblock;
329 }
330 }
331
332 if ( ! function_exists( 'loading_page_admin_resources' ) ) {
333 /**
334 * Enqueue admin resources
335 *
336 * @param string $hook hook name.
337 */
338 function loading_page_admin_resources( $hook ) {
339 if ( strpos( $hook, 'loading-page' ) !== false ) {
340 wp_enqueue_media();
341 wp_enqueue_style( 'farbtastic' );
342 wp_enqueue_script( 'farbtastic' );
343 wp_enqueue_style( 'thickbox' );
344 wp_enqueue_script( 'thickbox' );
345
346 wp_enqueue_script( 'lp-admin-script', LOADING_PAGE_PLUGIN_URL . '/js/loading-page-admin.js', array( 'jquery', 'thickbox', 'farbtastic' ), 'free-1.1.1', true );
347 }
348 } // End loading_page_admin_resources.
349 }
350
351 if ( ! function_exists( 'loading_page_loading_screen' ) ) {
352 /**
353 * Deciding to include the loading screen
354 */
355 function loading_page_loading_screen() {
356 global $post;
357 $op = loading_page_get_settings();
358 $loading_screen = 0;
359 if (
360 ! isset( $_SERVER['HTTP_USER_AGENT'] ) ||
361 preg_match( '/bot|crawl|slurp|spider/i', sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) )
362 ) {
363 return $loading_screen;
364 }
365
366 if (
367 ! empty( $op['enabled_loading_screen'] )
368 ) {
369 global $wp;
370 $current_url = home_url( add_query_arg( array(), $wp->request ) );
371 $_permalink = md5( $current_url );
372
373 if (
374 (
375 empty( $op['lp_loading_screen_devices'] ) ||
376 'both' == $op['lp_loading_screen_devices'] ||
377 ( 'desktop' == $op['lp_loading_screen_devices'] && ! wp_is_mobile() ) ||
378 ( 'mobile' == $op['lp_loading_screen_devices'] && wp_is_mobile() )
379 ) &&
380 (
381 empty( $op['once_per_session'] ) ||
382 'always' === $op['once_per_session'] ||
383 empty( $_SESSION['loading_page_once_per_session'] ) ||
384 ( 'page' === $op['once_per_session'] &&
385 is_array( $_SESSION['loading_page_once_per_session'] ) &&
386 empty( $_SESSION['loading_page_once_per_session'][ $_permalink ] )
387 )
388 )
389 ) {
390 if ( empty( $_SESSION['loading_page_once_per_session'] ) || ! is_array( $_SESSION['loading_page_once_per_session'] ) ) {
391 $_SESSION['loading_page_once_per_session'] = array();
392 }
393 $_SESSION['loading_page_once_per_session'][ $_permalink ] = 1;
394
395 $pages = ( ! empty( $op['lp_loading_screen_display_in_pages'] ) ) ? $op['lp_loading_screen_display_in_pages'] : '';
396 $pages = str_replace( ' ', '', $pages );
397 $pages = explode( ',', $pages );
398
399 $post_types = ( ! empty( $op['lp_loading_screen_display_post_types'] ) ) ? $op['lp_loading_screen_display_post_types'] : '';
400 $post_types = str_replace( ' ', '', $post_types );
401 $post_types = explode( ',', $post_types );
402
403 $exclude_pages = ( ! empty( $op['lp_loading_screen_exclude_from_pages'] ) ) ? $op['lp_loading_screen_exclude_from_pages'] : '';
404 $exclude_pages = str_replace( ' ', '', $exclude_pages );
405 $exclude_pages = explode( ',', $exclude_pages );
406
407 $exclude_post_types = ( ! empty( $op['lp_loading_screen_exclude_from_post_types'] ) ) ? $op['lp_loading_screen_exclude_from_post_types'] : '';
408 $exclude_post_types = str_replace( ' ', '', $exclude_post_types );
409 $exclude_post_types = explode( ',', $exclude_post_types );
410
411 $exclude_pages_urls = ( ! empty( $op['lp_loading_screen_exclude_from_urls'] ) ) ? $op['lp_loading_screen_exclude_from_urls'] : array();
412
413 $exclude_elementor_maintenance = ( defined( 'ELEMENTOR_VERSION' ) &&
414 ! empty( $op['lp_loading_screen_exclude_from_elementor_maintenance'] ) &&
415 '' !== get_option( 'elementor_maintenance_mode_mode', '' )
416 ) ? true : false;
417
418 if (
419 ! $exclude_elementor_maintenance &&
420 ( empty( $op['lp_loading_screen_display_in'] ) ||
421 'all' === $op['lp_loading_screen_display_in'] ||
422 ( 'home' === $op['lp_loading_screen_display_in'] && ( is_home() || is_front_page() ) ) ||
423 ( 'pages' === $op['lp_loading_screen_display_in'] && is_singular() && isset( $post ) && in_array( $post->ID, $pages ) ) ||
424 ( 'post_type' === $op['lp_loading_screen_display_in'] && is_singular() && isset( $post ) && in_array( $post->post_type, $post_types, true ) )
425 ) &&
426 ( empty( $post ) ||
427 empty( $post->ID ) ||
428 (
429 ( empty( $exclude_pages ) ||
430 ! in_array( $post->ID, $exclude_pages )
431 )
432 &&
433 ( empty( $exclude_post_types ) ||
434 ! in_array( $post->post_type, $exclude_post_types, true )
435 )
436 )
437 )
438 ) {
439 if ( ! empty( $exclude_pages_urls ) ) {
440 $protocol = ( ( ! empty( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] ) || ( isset( $_SERVER['SERVER_PORT'] ) && 443 === $_SERVER['SERVER_PORT'] ) ) ? 'https://' : 'http://';
441 $current_url = esc_url_raw( $protocol . ( isset( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : '' ) . ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '' ) );
442 foreach ( $exclude_pages_urls as $exclude_page_url ) {
443 $exclude_page_url = preg_quote( $exclude_page_url, '/' );
444 $exclude_page_url = str_replace( '\*', '.*', $exclude_page_url );
445 if ( preg_match( '/' . $exclude_page_url . '/i', $current_url ) ) {
446 return;
447 }
448 }
449 }
450 add_filter( 'body_class', function( $classes ){ $classes[] = 'lp_loading_screen_body'; return $classes; } );
451 $loading_screen = 1;
452 add_action( 'wp_head', 'loading_page_replace_the_header', 99 );
453 add_filter( 'autoptimize_filter_js_dontmove', 'loading_page_autoptimize_exclude', 10, 1 );
454 }
455 }
456 }
457 return $loading_screen;
458 }
459 }
460
461 if ( ! function_exists( 'loading_page_autoptimize_exclude' ) ) {
462 /**
463 * Excluding the plugin resources from Autoptimize
464 *
465 * @param array $to_exclude to exclude URLs.
466 */
467 function loading_page_autoptimize_exclude( $to_exclude ) {
468 $to_exclude[] = 'loading-page.min.js';
469 $to_exclude[] = '/loading-screens/';
470 return $to_exclude;
471 }
472 }
473
474 if ( ! function_exists( 'loading_page_replace_the_header' ) ) {
475 /**
476 * Including styles in the page header section
477 */
478 function loading_page_replace_the_header() {
479 $opt = loading_page_get_settings();
480 if ( empty( $opt ) || empty( $opt['modifyDisplayRule'] ) ) {
481 echo '<style id="loading-page-inline-style">body{visibility:hidden;}</style><noscript><style>body{visibility:visible;}</style></noscript>';
482 } else {
483 echo '<style id="loading-page-inline-style">body{display:none;}</style><noscript><style>body{display:block;}</style></noscript>';
484 }
485
486 if (
487 ! empty( $opt ) &&
488 ! empty( $opt['lp_ls'] ) &&
489 ! empty( $opt['lp_ls']['logo'] ) &&
490 ! empty( $opt['lp_ls']['logo']['image'] )
491 ) {
492 $path = $opt['lp_ls']['logo']['image'];
493 echo '<link rel="preload" href="' . esc_attr( $path ) . '" as="image" type="image/svg+xml">';
494 }
495 } // End loading_page_replace_the_header.
496 }
497
498 if ( ! function_exists( 'loading_page_hex2rgb' ) ) {
499 /**
500 * Transform colors code
501 *
502 * @param array/string $colour color code.
503 */
504 function loading_page_hex2rgb( $colour ) {
505 if ( '#' === $colour[0] ) {
506 $colour = substr( $colour, 1 );
507 }
508 if ( 6 === strlen( $colour ) ) {
509 list($r, $g, $b) = array( $colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5] );
510 } elseif ( 3 === strlen( $colour ) ) {
511 list($r, $g, $b) = array( $colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2] );
512 } else {
513 return $colour;
514 }
515 $r = hexdec( $r );
516 $g = hexdec( $g );
517 $b = hexdec( $b );
518 return 'rgba(' . $r . ',' . $g . ',' . $b . ',.8)';
519 }
520 }
521
522 if ( ! function_exists( 'loading_page_enqueue_scripts' ) ) {
523 /**
524 * Enqueue public scripts
525 */
526 function loading_page_enqueue_scripts() {
527 global $post;
528
529 $op = loading_page_get_settings();
530 $loading_screen = loading_page_loading_screen();
531 if ( $loading_screen && ! empty( $op['from_trigger'] ) ) {
532 wp_enqueue_script( 'codepeople-loading-page-link-script', LOADING_PAGE_PLUGIN_URL . '/js/links.min.js', array( 'jquery' ), 'free-1.1.1', false );
533 }
534
535 if ( $loading_screen ) {
536 $loading_page_settings = array(
537 'loadingScreen' => $loading_screen,
538 'closeBtn' => ( ! isset( $op['close_btn'] ) || $op['close_btn'] ) ? true : false,
539 'removeInOnLoad' => ( ! empty( $op['remove_in_on_load'] ) ) ? $op['remove_in_on_load'] : false,
540 'codeblock' => loading_page_add_code_block(),
541 'backgroundColor' => ( ! isset( $op['transparency'] ) || $op['transparency'] ) ? loading_page_hex2rgb( $op['backgroundColor'] ) : $op['backgroundColor'],
542 'foregroundColor' => $op['foregroundColor'],
543 'backgroundImage' => $op['backgroundImage'],
544 'additionalSeconds' => ( ! empty( $op['additionalSeconds'] ) ) ? $op['additionalSeconds'] : 0,
545 'pageEffect' => $op['pageEffect'],
546 'backgroundRepeat' => $op['backgroundImageRepeat'],
547 'fullscreen' => ( ( ! empty( $op['fullscreen'] ) ) ? 1 : 0 ),
548 'graphic' => $op['loading_screen'],
549 'text' => ( ( ! empty( $op['displayPercent'] ) ) ? $op['displayPercent'] : 0 ),
550 'lp_ls' => ( ( ! empty( $op['lp_ls'] ) ) ? $op['lp_ls'] : 0 ),
551 'screen_size' => ( ( ! empty( $op['screen_size'] ) ) ? $op['screen_size'] : 'all' ),
552 'screen_width' => ( ( ! empty( $op['screen_width'] ) ) ? $op['screen_width'] : 0 ),
553 'deepSearch' => ( ( empty( $op['deepSearch'] ) ) ? 0 : 1 ),
554 'modifyDisplayRule' => ( ( empty( $op['modifyDisplayRule'] ) ) ? 0 : 1 ),
555 'triggerLinkScreenNeverClose' => empty( $op['triggerLinkScreenNeverClose'] ) ? 0 : 1,
556 'triggerLinkScreenCloseAfter' => ! empty( $op['triggerLinkScreenCloseAfter'] ) ? intval( $op['triggerLinkScreenCloseAfter'] ) : 4,
557 );
558
559 $required = array( 'jquery' );
560 wp_enqueue_script( 'jquery' );
561 wp_enqueue_style( 'codepeople-loading-page-style', LOADING_PAGE_PLUGIN_URL . '/css/loading-page.css', array(), 'free-1.1.1', false );
562 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.1', false );
563
564 $s = loading_page_get_screen( $op['loading_screen'] );
565 if ( $s ) {
566 if ( ! empty( $s['style'] ) ) {
567 wp_enqueue_style( 'codepeople-loading-page-style-' . $s['id'], $s['style'], array(), 'free-1.1.1', false );
568 }
569
570 if ( ! empty( $s['script'] ) ) {
571 wp_enqueue_script( 'codepeople-loading-page-script-' . $s['id'], $s['script'], array( 'jquery' ), 'free-1.1.1', false );
572 $required[] = 'codepeople-loading-page-script-' . $s['id'];
573 }
574 }
575 wp_enqueue_script( 'codepeople-loading-page-script', LOADING_PAGE_PLUGIN_URL . '/js/loading-page.min.js', $required, 'free-1.1.1', false );
576 if ( function_exists( 'wp_add_inline_script' ) ) {
577 wp_add_inline_script( 'codepeople-loading-page-script', 'loading_page_settings=' . wp_json_encode( $loading_page_settings ) . ';', 'before' );
578 } else {
579 wp_localize_script( 'codepeople-loading-page-script', 'loading_page_settings', $loading_page_settings );
580 }
581 }
582 } // End loading_page_enqueue_scripts.
583 }
584
585 if ( ! function_exists( 'loading_page_sanitize_array' ) ) {
586 /**
587 * Sanitize mutilevel array
588 *
589 * @param array/string $array values to sanitize.
590 */
591 function loading_page_sanitize_array( $array ) {
592 if ( is_array( $array ) ) {
593 foreach ( $array as $key => $value ) {
594 if ( is_array( $value ) ) {
595 $array[ $key ] = loading_page_sanitize_array( $value );
596 } else {
597 $array[ $key ] = sanitize_text_field( wp_unslash( $value ) );
598 }
599 }
600 return $array;
601 } else {
602 return sanitize_text_field( wp_unslash( $array ) );
603 }
604 } // End loading_page_sanitize_array.
605 }
606
607 if ( ! function_exists( 'loading_page_settings_page' ) ) {
608 /**
609 * Plugin settings page
610 */
611 function loading_page_settings_page() {
612 if ( isset( $_POST['loading_page_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['loading_page_nonce'] ) ), __FILE__ ) ) {
613
614 $allowed_tags = wp_kses_allowed_html( 'post' );
615
616 $allowed_tags['source'] = array(
617 'src' => true,
618 'type' => true
619 );
620
621 if ( current_user_can( 'manage_options' ) ) {
622 $allowed_tags['script'] = true;
623 $allowed_tags['style'] = true;
624 $allowed_tags['link'] = true;
625 }
626
627 $additional_seconds = isset( $_POST['lp_additionalSeconds'] ) && is_numeric( $_POST['lp_additionalSeconds'] ) ? intval( $_POST['lp_additionalSeconds'] ) : 0;
628 $code_block = isset( $_POST['lp_codeBlock'] ) ? wp_kses( wp_unslash( $_POST['lp_codeBlock'] ), $allowed_tags ) : '';
629
630 $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'] ) ) : '';
631 $lp_loading_screen_exclude_from_urls = explode( "\n", $lp_loading_screen_exclude_from_urls );
632 foreach ( $lp_loading_screen_exclude_from_urls as $key => $url ) {
633 $url = trim( $url );
634 if ( '' === $url ) {
635 unset( $lp_loading_screen_exclude_from_urls[ $key ] );
636 } else {
637 $lp_loading_screen_exclude_from_urls[ $key ] = $url;
638 }
639 }
640
641 $lp_screen_width = '';
642 if ( ! empty( $_POST['lp_screen_width'] ) ) {
643 $lp_screen_width = preg_replace( '/[^\\d\\.]/', '', sanitize_text_field( wp_unslash( $_POST['lp_screen_width'] ) ) );
644 }
645
646 // Set the default options here.
647 $loading_page_options = array(
648 'foregroundColor' => ( ! empty( $_POST['lp_foregroundColor'] ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_foregroundColor'] ) ) : '#FFFFFF',
649 'backgroundColor' => ( ! empty( $_POST['lp_backgroundColor'] ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_backgroundColor'] ) ) : '#000000',
650 'transparency' => ( ! empty( $_POST['lp_backgroundTransparency'] ) ) ? true : false,
651 'backgroundImage' => isset( $_POST['lp_backgroundImage'] ) ? esc_url_raw( wp_unslash( $_POST['lp_backgroundImage'] ) ) : '',
652 'backgroundImageRepeat' => ( isset( $_POST['lp_backgroundRepeat'] ) && in_array( $_POST['lp_backgroundRepeat'], array( 'repeat', 'no-repeat' ), true ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_backgroundRepeat'] ) ) : 'repeat',
653 'additionalSeconds' => $additional_seconds,
654 'codeBlock' => wp_unslash( $code_block ),
655 'fullscreen' => ( isset( $_POST['lp_fullscreen'] ) ) ? 1 : 0,
656 'enabled_loading_screen' => ( isset( $_POST['lp_enabled_loading_screen'] ) ) ? true : false,
657 'from_trigger' => ( isset( $_POST['lp_from_trigger'] ) ) ? true : false,
658 'close_btn' => ( isset( $_POST['lp_close_btn'] ) ) ? true : false,
659 'remove_in_on_load' => ( isset( $_POST['lp_remove_in_on_load'] ) ) ? true : false,
660 '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',
661 'screen_width' => is_numeric( $lp_screen_width ) ? $lp_screen_width : '',
662 'lp_loading_screen_display_in' => ( isset( $_POST['lp_loading_screen_display_in'] ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_loading_screen_display_in'] ) ) : 'all',
663 'once_per_session' => ( ! isset( $_POST['once_per_session'] ) ||
664 ! in_array( $_POST['once_per_session'], array( 'always', 'site', 'page' ), true )
665 ) ? 'always' : sanitize_text_field( wp_unslash( $_POST['once_per_session'] ) ),
666 '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'] ) ) : '',
667 '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'] ) ) : '',
668 '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',
669 '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'] ) ) : '',
670 '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'] ) ) : '',
671 'lp_loading_screen_exclude_from_urls' => $lp_loading_screen_exclude_from_urls,
672 'lp_loading_screen_exclude_from_elementor_maintenance' => ( isset( $_POST['lp_loading_screen_exclude_from_elementor_maintenance'] ) ) ? true : false,
673 'deepSearch' => ( isset( $_POST['lp_deactivateDeepSearch'] ) ) ? false : true,
674 'modifyDisplayRule' => ( isset( $_POST['lp_modifyDisplayRule'] ) ) ? true : false,
675 'loading_screen' => isset( $_POST['lp_loading_screen'] ) ? sanitize_text_field( wp_unslash( $_POST['lp_loading_screen'] ) ) : '',
676 'displayPercent' => ( isset( $_POST['lp_displayPercent'] ) ) ? true : false,
677 'pageEffect' => isset( $_POST['lp_pageEffect'] ) ? sanitize_text_field( wp_unslash( $_POST['lp_pageEffect'] ) ) : '',
678 'triggerLinkScreenNeverClose' => isset( $_POST['lp_triggerLinkScreenNeverClose'] ) ? true : false,
679 'triggerLinkScreenCloseAfter' => isset( $_POST['lp_triggerLinkScreenCloseAfter'] ) && is_numeric( $_POST['lp_triggerLinkScreenCloseAfter'] ) ? intval( $_POST['lp_triggerLinkScreenCloseAfter'] ) : '',
680 );
681
682 if ( isset( $_POST['lp_ls'] ) ) {
683 $loading_page_options['lp_ls'] = loading_page_sanitize_array( $_POST['lp_ls'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
684 }
685
686 update_option( 'loading_page_video_tutorial', ( ! empty( $_POST['loading_page_video_tutorial'] ) && 'collapsed' === $_POST['loading_page_video_tutorial'] ) ? 'collapsed' : 'expanded' );
687
688 if ( update_option( 'loading_page_options', $loading_page_options ) ) {
689 print '<div class="updated">' . esc_html( __( 'The Loading Page has been stored successfully', 'loading-page' ) ) . '</div>';
690 } else {
691 print '<div class="error">' . esc_html( __( 'The Loading Page settings could not be stored', 'loading-page' ) ) . '</div>';
692 }
693 }
694
695 $loading_page_options = get_option( 'loading_page_options', [] );
696
697 $loading_page_video_tutorial = get_option( 'loading_page_video_tutorial', 'expanded' );
698 $loading_page_video_tutorial_open_close = ( 'expanded' === $loading_page_video_tutorial ) ? 'X' : '+';
699 $loading_page_video_tutorial_status = ( 'collapsed' === $loading_page_video_tutorial ) ? 'lp-video-collapsed' : '';
700
701 ?>
702 <style>
703 .lp-video-container {
704 overflow: hidden;
705 position: relative;
706 width: 100%;
707 }
708
709 .lp-video-container::after {
710 padding-top: 56.25%;
711 display: block;
712 content: '';
713 }
714
715 .lp-video-container iframe {
716 position: absolute;
717 top: 0;
718 left: 0;
719 width: 100%;
720 height: 100%;
721 }
722
723 .lp-video-collapsed {
724 display: none;
725 }
726 </style>
727 <div class="wrap">
728 <form method="post">
729 <input type="hidden" name="loading_page_nonce" value="<?php print( esc_attr( wp_create_nonce( __FILE__ ) ) ); ?>" />
730 <h2><?php esc_html_e( 'Loading Page Settings', 'loading-page' ); ?></h2>
731 <div class="postbox">
732 <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>
733 <div class="inside lp-video-tutorial <?php echo esc_attr( $loading_page_video_tutorial_status ); ?>" style="position:relative;">
734 <input type="hidden" name="loading_page_video_tutorial" value="<?php echo esc_attr( $loading_page_video_tutorial ); ?>" />
735 <div class="lp-video-container">
736 <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>
737 </div>
738 </div>
739 </div>
740 <div class="postbox">
741 <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Loading Screen', 'loading-page' ); ?></span></h3>
742 <div class="inside">
743 <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 />
744 <a href="https://demos.dwbooster.com/loading-page/" target="_blank">Public page: Click to access the Loading Page</a><br />
745 <a href="https://wordpress.org/support/plugin/loading-page/#new-post" target="_blank">If you need additional help</a>
746 </p>
747 <p>
748 <?php
749 esc_html_e(
750 'Displays a loading screen until the webpage is ready, the screen shows the loading percent.',
751 'loading-page'
752 );
753 ?>
754 </p>
755 <table class="form-table">
756 <tr>
757 <th><?php esc_html_e( 'Enable loading screen', 'loading-page' ); ?></th>
758 <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>
759 </tr>
760 <tr>
761 <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>
762 <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>
763 </tr>
764 <tr>
765 <th><?php esc_html_e( 'Display a close screen button', 'loading-page' ); ?></th>
766 <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>
767 </tr>
768 <tr>
769 <th><?php esc_html_e( 'Hide the loading screen in the window onload event', 'loading-page' ); ?></th>
770 <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>
771 </tr>
772 <tr>
773 <th><?php esc_html_e( 'Display the loading screen on', 'loading-page' ); ?></th>
774 <td>
775 <select aria-label="<?php esc_attr_e( 'Screen size', 'loading-page' ); ?>" name="lp_screen_size" style="float:left;">
776 <option value="all"
777 <?php
778 if (
779 isset( $loading_page_options['screen_size'] ) &&
780 'all' === $loading_page_options['screen_size']
781 ) {
782 print 'SELECTED';
783 }
784 ?>
785 ><?php esc_html_e( 'All Screens', 'loading-page' ); ?></option>
786 <option value="greater"
787 <?php
788 if (
789 isset( $loading_page_options['screen_size'] ) &&
790 'greater' === $loading_page_options['screen_size']
791 ) {
792 print 'SELECTED';
793 }
794 ?>
795 ><?php esc_html_e( 'Greater Than', 'loading-page' ); ?></option>
796 <option value="lesser"
797 <?php
798 if (
799 isset( $loading_page_options['screen_size'] ) &&
800 'lesser' === $loading_page_options['screen_size']
801 ) {
802 print 'SELECTED';
803 }
804 ?>
805 ><?php esc_html_e( 'Lesser Than', 'loading-page' ); ?></option>
806 </select>
807 <div id="lp_width_container" style="float:left; padding-left:10px;
808 <?php
809 if ( ! isset( $loading_page_options['screen_size'] ) || 'all' === $loading_page_options['screen_size'] ) {
810 echo 'display:none;';
811 } else {
812 echo 'display:block;';
813 }
814 ?>
815 ">
816 <?php esc_html_e( 'Width', 'loading-page' ); ?>:
817 <input aria-label="<?php esc_attr_e( 'Screen width', 'loading-page' ); ?>" type="text" name="lp_screen_width" value="<?php
818 if ( isset( $loading_page_options['screen_width'] ) ) {
819 echo esc_attr( $loading_page_options['screen_width'] );
820 }
821 ?>" /> px
822 </div>
823 <script>
824 jQuery('[name="lp_screen_size"]').change(function() {
825 jQuery('#lp_width_container')[(this.value == 'all') ? 'hide' : 'show']();
826 })
827 </script>
828 </td>
829 </tr>
830 <tr>
831 <th><?php esc_html_e( 'Display the loading screen', 'loading-page' ); ?></th>
832 <td>
833 <?php
834 if (
835 ! isset( $loading_page_options['once_per_session'] ) ||
836 false === $loading_page_options['once_per_session']
837 ) {
838 $loading_page_options['once_per_session'] = 'always';
839 } elseif ( true === $loading_page_options['once_per_session'] ) {
840 $loading_page_options['once_per_session'] = 'site';
841 }
842 ?>
843 <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 />
844 <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 />
845 <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>
846
847 </td>
848 </tr>
849 <tr>
850 <th><?php esc_html_e( 'Display loading screen in', 'loading-page' ); ?></th>
851 <td>
852 <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>
853
854 <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>
855
856 <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' ); ?>
857 <input aria-label="<?php esc_attr_e( 'Pages/posts ids', 'loading-page' ); ?>" type="text" name="lp_loading_screen_display_in_pages" value="<?php
858 if ( ! empty( $loading_page_options['lp_loading_screen_display_in_pages'] ) ) {
859 print esc_attr( $loading_page_options['lp_loading_screen_display_in_pages'] );}
860 ?>" style="width:100%;margin:10px; 0 10px 20px;">
861 <i><?php esc_html_e( 'Type one, or more post/pages IDs, separated by commas ","', 'loading-page' ); ?></i>
862 </div>
863
864 <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' ); ?>
865 <input aria-label="<?php esc_attr_e( 'Post types', 'loading-page' ); ?>" type="text" name="lp_loading_screen_display_post_types" value="<?php
866 if ( ! empty( $loading_page_options['lp_loading_screen_display_post_types'] ) ) {
867 print esc_attr( $loading_page_options['lp_loading_screen_display_post_types'] );}
868 ?>" style="width:100%;margin:10px; 0 10px 20px;">
869 <i><?php esc_html_e( 'Type one or more post types, separated by commas ","', 'loading-page' ); ?></i>
870 </div>
871 </td>
872 </tr>
873 <tr>
874 <th><?php esc_html_e( 'Devices', 'loading-page' ); ?></th>
875 <td>
876 <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
877 if ( ! empty( $loading_page_options['lp_loading_screen_devices'] ) && 'desktop' == $loading_page_options['lp_loading_screen_devices'] ) {
878 print 'CHECKED';}
879 ?>> <?php esc_html_e( 'Display the loading screen only on desktops', 'loading-page' ); ?></label><br>
880 <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
881 if ( ! empty( $loading_page_options['lp_loading_screen_devices'] ) && 'mobile' == $loading_page_options['lp_loading_screen_devices'] ) {
882 print 'CHECKED';}
883 ?>> <?php esc_html_e( 'Display the loading screen only on mobiles', 'loading-page' ); ?></label><br>
884 <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
885 if ( empty( $loading_page_options['lp_loading_screen_devices'] ) || 'both' == $loading_page_options['lp_loading_screen_devices'] ) {
886 print 'CHECKED';}
887 ?>> <?php esc_html_e( 'Display the loading screen on both desktops and mobiles', 'loading-page' ); ?></label><br>
888 </td>
889 </tr>
890 <tr>
891 <td colspan="2">
892 <hr />
893 </td>
894 </tr>
895 <tr>
896 <th><?php esc_html_e( 'Exclude loading screen from', 'loading-page' ); ?></th>
897 <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
898 if ( ! empty( $loading_page_options['lp_loading_screen_exclude_from_pages'] ) ) {
899 print esc_attr( $loading_page_options['lp_loading_screen_exclude_from_pages'] );}
900 ?>"> <i><?php esc_html_e( 'Type one, or more post/pages IDs, separated by commas ","', 'loading-page' ); ?></i></td>
901 </tr>
902 <tr>
903 <th><?php esc_html_e( 'Exclude loading screen from post types', 'loading-page' ); ?></th>
904 <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
905 if ( ! empty( $loading_page_options['lp_loading_screen_exclude_from_post_types'] ) ) {
906 print esc_attr( $loading_page_options['lp_loading_screen_exclude_from_post_types'] );}
907 ?>"> <i><?php esc_html_e( 'Type one, or more post/pages types, separated by commas ","', 'loading-page' ); ?></i></td>
908 </tr>
909 <tr>
910 <th><?php esc_html_e( 'Exclude loading screen from pages with the URL', 'loading-page' ); ?></th>
911 <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
912 print esc_textarea(
913 ( ! empty( $loading_page_options['lp_loading_screen_exclude_from_urls'] ) )
914 ? implode( "\n", $loading_page_options['lp_loading_screen_exclude_from_urls'] ) : ''
915 );
916 ?></textarea>
917 <i>Enter an URL per row (use the * symbol as wildcard)</i>
918 </td>
919 </tr>
920 <tr>
921 <th colspan="2">
922 <?php esc_html_e( 'Exclude the loading screen if Elementor Maintenance or Coming Soon modes are enabled', 'loading-page' ); ?>
923 <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' : '' ); ?> />
924 </th>
925 </tr>
926 <tr>
927 <td colspan="2">
928 <hr />
929 </td>
930 </tr>
931 <tr>
932 <?php $loading_screens = loading_page_get_screen_list(); ?>
933 <th><?php esc_html_e( 'Select the loading screen', 'loading-page' ); ?></th>
934 <td>
935 <select aria-label="<?php esc_attr_e( 'Loading screen', 'loading-page' ); ?>" name="lp_loading_screen">
936 <?php
937 foreach ( $loading_screens as $screen ) {
938 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>';
939 }
940 ?>
941 </select>
942 <span style="color:#FF0000;">
943 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>
944 </span>
945 </td>
946 </tr>
947 <?php
948 foreach ( $loading_screens as $screen ) {
949 if ( ! empty( $screen['adminsection'] ) ) {
950 include_once $screen['adminsection'];
951 }
952 if ( ! empty( $screen['adminscript'] ) ) {
953 wp_enqueue_script( $screen['adminscript'], $screen['adminscript'], array(), 'free-1.1.1', true );
954 }
955 }
956 ?>
957 <tr>
958 <th><?php esc_html_e( 'Select background color', 'loading-page' ); ?></th>
959 <td>
960 <input aria-label="<?php esc_attr_e( 'Background color', 'loading-page' ); ?>" type="text" name="lp_backgroundColor" id="lp_backgroundColor" value="<?php
961 if ( isset( $loading_page_options['backgroundColor'] ) ) {
962 print( esc_attr( $loading_page_options['backgroundColor'] ) );}
963 ?>" />
964 <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' ); ?>
965 <div id="lp_backgroundColor_picker"></div>
966 </td>
967 </tr>
968 <tr>
969 <th><?php esc_html_e( 'Select image as background', 'loading-page' ); ?></th>
970 <td>
971 <input aria-label="<?php esc_attr_e( 'Background image', 'loading-page' ); ?>" type="text" name="lp_backgroundImage" id="lp_backgroundImage" value="<?php
972 if ( isset( $loading_page_options['backgroundImage'] ) ) {
973 print( esc_attr( $loading_page_options['backgroundImage'] ) );}
974 ?>" />
975 <input type="button" value="Browse" onclick="loading_page_selected_image('lp_backgroundImage');" />
976 <select aria-label="<?php esc_attr_e( 'Background position', 'loading-page' ); ?>" id="lp_backgroundRepeat" name="lp_backgroundRepeat">
977 <option value="repeat"
978 <?php
979 if ( isset( $loading_page_options['backgroundImageRepeat'] ) && 'repeat' === $loading_page_options['backgroundImageRepeat'] ) {
980 echo 'SELECTED';}
981 ?>
982 >Tile</option>
983 <option value="no-repeat"
984 <?php
985 if ( isset( $loading_page_options['backgroundImageRepeat'] ) && 'no-repeat' === $loading_page_options['backgroundImageRepeat'] ) {
986 echo 'SELECTED';}
987 ?>
988 >Center</option>
989 </select>
990
991 </td>
992 </tr>
993 <tr>
994 <th><?php esc_html_e( 'Display image in fullscreen', 'loading-page' ); ?></th>
995 <td>
996 <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' : '' ); ?> />
997 <i><?php esc_html_e( '(The fullscreen attribute can fail in some browsers)', 'loading-page' ); ?></i>
998 </td>
999 </tr>
1000 <tr>
1001 <th><?php esc_html_e( 'Select foreground color', 'loading-page' ); ?></th>
1002 <td><input aria-label="<?php esc_attr_e( 'Foreground color', 'loading-page' ); ?>" type="text" name="lp_foregroundColor" id="lp_foregroundColor" value="<?php
1003 if ( isset( $loading_page_options['foregroundColor'] ) ) {
1004 print( esc_attr( $loading_page_options['foregroundColor'] ) );}
1005 ?>" />
1006 <div id="lp_foregroundColor_picker"></div>
1007 </td>
1008 </tr>
1009 <tr>
1010 <th><?php esc_html_e( 'Additional seconds', 'loading-page' ); ?></th>
1011 <td>
1012 <input aria-label="<?php esc_attr_e( 'Additional seconds', 'loading-page' ); ?>" type="text" name="lp_additionalSeconds" id="lp_additionalSeconds" value="<?php
1013 if ( isset( $loading_page_options['additionalSeconds'] ) ) {
1014 print( esc_attr( $loading_page_options['additionalSeconds'] ) );}
1015 ?>" />
1016 <i><?php esc_html_e( 'Show the loading screen some few seconds after loading the page', 'loading-page' ); ?></i>
1017 </td>
1018 </tr>
1019 <tr>
1020 <th><?php esc_html_e( 'Include an ad, or your own block of code', 'loading-page' ); ?></th>
1021 <td>
1022 <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
1023 if ( isset( $loading_page_options['codeBlock'] ) ) {
1024 print( esc_textarea( $loading_page_options['codeBlock'] ) );}
1025 ?></textarea>
1026 <p><i><b><?php esc_html_e( 'Trick', 'loading-page' ); ?></b>:
1027 <?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>
1028 </td>
1029 </tr>
1030 <tr>
1031 <th><?php esc_html_e( 'Apply the effect on page', 'loading-page' ); ?></th>
1032 <td>
1033 <select aria-label="<?php esc_attr_e( 'Animation effect', 'loading-page' ); ?>" name="lp_pageEffect">
1034 <?php
1035 $page_effects = array( 'none', 'rotateInLeft' );
1036
1037 foreach ( $page_effects as $value ) {
1038 print '<option value="' . esc_attr( $value ) . '" ' . ( ( isset( $loading_page_options['pageEffect'] ) && $loading_page_options['pageEffect'] === $value ) ? 'SELECTED' : '' ) . '>' . esc_html( $value ) . '</option>';
1039 }
1040 ?>
1041
1042 </select>
1043 <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>
1044 </td>
1045 </tr>
1046 <tr>
1047 <th><?php esc_html_e( 'Display loading percent', 'loading-page' ); ?></th>
1048 <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>
1049 </tr>
1050 </table>
1051 <div style="border: 1px solid #DADADA; padding:10px;">
1052 <h3><?php esc_html_e( 'Troubleshoot Area - Loading Screen', 'loading-page' ); ?></h3>
1053 <table class="form-table">
1054 <tr>
1055 <th><?php esc_html_e( 'Disable the search in deep', 'loading-page' ); ?></th>
1056 <td>
1057 <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>
1058 </td>
1059 </tr>
1060 <tr>
1061 <th><?php esc_html_e( 'The pages\' background is visible', 'loading-page' ); ?></th>
1062 <td>
1063 <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>
1064 </td>
1065 </tr>
1066 <tr>
1067 <td colspan="2" style="padding-left:0;">
1068 <?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 />
1069 <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;
1070 <?php esc_html_e( '- or close after ', 'loading-page' ); ?>&nbsp;
1071 <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;
1072 <?php esc_html_e( 'seconds', 'loading-page' ); ?>
1073 </td>
1074 </tr>
1075 </table>
1076 </div>
1077 </div>
1078 </div>
1079 <div class="postbox">
1080 <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Lazy Loading', 'loading-page' ); ?></span></h3>
1081 <div class="inside">
1082 <p>
1083 <?php
1084 esc_html_e(
1085 'To load only the images visible in the viewport to improve the loading rate of your website and reduce the bandwidth consumption.',
1086 'loading-page'
1087 );
1088 ?>
1089 </p>
1090 <p>
1091 <span style="color:#FF0000;">
1092 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>
1093 </span>
1094 </p>
1095 <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>
1096 <table class="form-table">
1097 <tr>
1098 <th><?php esc_html_e( 'Enable lazy loading', 'loading-page' ); ?></th>
1099 <td><input aria-label="<?php esc_attr_e( 'Enable lazy loading', 'loading-page' ); ?>" type="checkbox" DISABLED /></td>
1100 </tr>
1101 <tr>
1102 <th><?php esc_html_e( 'Select the image to load by default', 'loading-page' ); ?></th>
1103 <td>
1104 <input aria-label="<?php esc_attr_e( 'Image to load by default', 'loading-page' ); ?>" type="text" DISABLED /><input type="button" value="Browse" DISABLED />
1105 </td>
1106 </tr>
1107 <tr>
1108 <th><?php esc_html_e( 'Exclude lazy loading from', 'loading-page' ); ?></th>
1109 <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>
1110 </tr>
1111 </table>
1112 <div style="border: 1px solid #DADADA; padding:10px;">
1113 <h3><?php esc_html_e( 'Troubleshoot Area - Lazy Loading', 'loading-page' ); ?></h3>
1114 <table class="form-table">
1115 <tr>
1116 <th><?php esc_html_e( 'Exclude images whose tag includes the class or attribute', 'loading-page' ); ?></th>
1117 <td>
1118 <input aria-label="<?php esc_attr_e( 'Class or attributes names', 'loading-page' ); ?>" type="text" style="width:100%;" disabled /><br />
1119 <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>
1120 </td>
1121 </tr>
1122 </table>
1123 </div>
1124 </div>
1125 </div>
1126 <div><input type="submit" value="Update Settings" class="button-primary" /></div>
1127 </form>
1128 </div>
1129 <?php
1130 } // End loading_page_settings_page.
1131 }
1132