PluginProbe
Loading Page with Loading Screen / 1.1.9
Loading Page with Loading Screen v1.1.9
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.9, at loading-page.php

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