PluginProbe
Loading Page with Loading Screen / 1.1.20
Loading Page with Loading Screen v1.1.20
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.20, at loading-page.php

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