PluginProbe
Loading Page with Loading Screen / 1.1.17
Loading Page with Loading Screen v1.1.17
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.17, at loading-page.php

1,204 lines 60.4 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.17
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.17', 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 ) {
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 return 'rgba(' . $r . ',' . $g . ',' . $b . ',.8)';
553 }
554 }
555
556 if ( ! function_exists( 'loading_page_enqueue_scripts' ) ) {
557 /**
558 * Enqueue public scripts
559 */
560 function loading_page_enqueue_scripts() {
561 global $post;
562
563 $op = loading_page_get_settings();
564 $loading_screen = loading_page_loading_screen();
565 if ( $loading_screen && ! empty( $op['from_trigger'] ) ) {
566 wp_enqueue_script( 'codepeople-loading-page-link-script', LOADING_PAGE_PLUGIN_URL . '/js/links.min.js', array( 'jquery' ), 'free-1.1.17', false );
567 }
568
569 if ( $loading_screen ) {
570 $loading_page_settings = array(
571 'loadingScreen' => $loading_screen,
572 'closeBtn' => ( ! isset( $op['close_btn'] ) || $op['close_btn'] ) ? true : false,
573 'removeInOnLoad' => ( ! empty( $op['remove_in_on_load'] ) ) ? $op['remove_in_on_load'] : false,
574 'codeblock' => loading_page_add_code_block(),
575 'backgroundColor' => ( ! isset( $op['transparency'] ) || $op['transparency'] ) ? loading_page_hex2rgb( $op['backgroundColor'] ) : $op['backgroundColor'],
576 'foregroundColor' => $op['foregroundColor'],
577 'backgroundImage' => $op['backgroundImage'],
578 'additionalSeconds' => ( ! empty( $op['additionalSeconds'] ) ) ? $op['additionalSeconds'] : 0,
579 'pageEffect' => $op['pageEffect'],
580 'backgroundRepeat' => $op['backgroundImageRepeat'],
581 'fullscreen' => ( ( ! empty( $op['fullscreen'] ) ) ? 1 : 0 ),
582 'graphic' => $op['loading_screen'],
583 'text' => ( ( ! empty( $op['displayPercent'] ) ) ? $op['displayPercent'] : 0 ),
584 'lp_ls' => ( ( ! empty( $op['lp_ls'] ) ) ? $op['lp_ls'] : 0 ),
585 'screen_size' => ( ( ! empty( $op['screen_size'] ) ) ? $op['screen_size'] : 'all' ),
586 'screen_width' => ( ( ! empty( $op['screen_width'] ) ) ? $op['screen_width'] : 0 ),
587 'deepSearch' => ( ( empty( $op['deepSearch'] ) ) ? 0 : 1 ),
588 'modifyDisplayRule' => ( ( empty( $op['modifyDisplayRule'] ) ) ? 0 : 1 ),
589 'triggerLinkScreenNeverClose' => empty( $op['triggerLinkScreenNeverClose'] ) ? 0 : 1,
590 'triggerLinkScreenCloseAfter' => ! empty( $op['triggerLinkScreenCloseAfter'] ) ? intval( $op['triggerLinkScreenCloseAfter'] ) : 4,
591 );
592
593 $required = array( 'jquery' );
594 wp_enqueue_script( 'jquery' );
595 wp_enqueue_style( 'codepeople-loading-page-style', LOADING_PAGE_PLUGIN_URL . '/css/loading-page.css', array(), 'free-1.1.17', false );
596 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.17', false );
597
598 $s = loading_page_get_screen( $op['loading_screen'] );
599 if ( $s ) {
600 if ( ! empty( $s['style'] ) ) {
601 wp_enqueue_style( 'codepeople-loading-page-style-' . $s['id'], $s['style'], array(), 'free-1.1.17', false );
602 }
603
604 if ( ! empty( $s['script'] ) ) {
605 wp_enqueue_script( 'codepeople-loading-page-script-' . $s['id'], $s['script'], array( 'jquery' ), 'free-1.1.17', false );
606 $required[] = 'codepeople-loading-page-script-' . $s['id'];
607 }
608 }
609 wp_enqueue_script( 'codepeople-loading-page-script', LOADING_PAGE_PLUGIN_URL . '/js/loading-page.min.js', $required, 'free-1.1.17', false );
610 if ( function_exists( 'wp_add_inline_script' ) ) {
611 wp_add_inline_script( 'codepeople-loading-page-script', 'loading_page_settings=' . wp_json_encode( $loading_page_settings ) . ';', 'before' );
612 } else {
613 wp_localize_script( 'codepeople-loading-page-script', 'loading_page_settings', $loading_page_settings );
614 }
615 }
616 } // End loading_page_enqueue_scripts.
617 }
618
619 if ( ! function_exists( 'loading_page_sanitize_array' ) ) {
620 /**
621 * Sanitize mutilevel array
622 *
623 * @param array/string $array values to sanitize.
624 */
625 function loading_page_sanitize_array( $array ) {
626 if ( is_array( $array ) ) {
627 foreach ( $array as $key => $value ) {
628 if ( is_array( $value ) ) {
629 $array[ $key ] = loading_page_sanitize_array( $value );
630 } else {
631 $array[ $key ] = sanitize_text_field( wp_unslash( $value ) );
632 }
633 }
634 return $array;
635 } else {
636 return sanitize_text_field( wp_unslash( $array ) );
637 }
638 } // End loading_page_sanitize_array.
639 }
640
641 if ( ! function_exists( 'loading_page_settings_page' ) ) {
642 /**
643 * Plugin settings page
644 */
645 function loading_page_settings_page() {
646 if ( isset( $_POST['loading_page_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['loading_page_nonce'] ) ), __FILE__ ) ) {
647
648 $allowed_tags = wp_kses_allowed_html( 'post' );
649
650 $allowed_tags['source'] = array(
651 'src' => true,
652 'type' => true
653 );
654
655 if ( current_user_can( 'manage_options' ) ) {
656 $allowed_tags['script'] = true;
657 $allowed_tags['style'] = true;
658 $allowed_tags['link'] = true;
659 }
660
661 $additional_seconds = isset( $_POST['lp_additionalSeconds'] ) && is_numeric( $_POST['lp_additionalSeconds'] ) ? intval( $_POST['lp_additionalSeconds'] ) : 0;
662 $code_block = isset( $_POST['lp_codeBlock'] ) ? wp_kses( wp_unslash( $_POST['lp_codeBlock'] ), $allowed_tags ) : '';
663
664 $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'] ) ) : '';
665 $lp_loading_screen_exclude_from_urls = explode( "\n", $lp_loading_screen_exclude_from_urls );
666 foreach ( $lp_loading_screen_exclude_from_urls as $key => $url ) {
667 $url = trim( $url );
668 if ( '' === $url ) {
669 unset( $lp_loading_screen_exclude_from_urls[ $key ] );
670 } else {
671 $lp_loading_screen_exclude_from_urls[ $key ] = $url;
672 }
673 }
674
675 $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'] ) ) : '';
676 $lp_loading_screen_include_from_urls = explode( "\n", $lp_loading_screen_include_from_urls );
677 foreach ( $lp_loading_screen_include_from_urls as $key => $url ) {
678 $url = trim( $url );
679 if ( '' === $url ) {
680 unset( $lp_loading_screen_include_from_urls[ $key ] );
681 } else {
682 $lp_loading_screen_include_from_urls[ $key ] = $url;
683 }
684 }
685
686 $lp_screen_width = '';
687 if ( ! empty( $_POST['lp_screen_width'] ) ) {
688 $lp_screen_width = preg_replace( '/[^\\d\\.]/', '', sanitize_text_field( wp_unslash( $_POST['lp_screen_width'] ) ) );
689 }
690
691 // Set the default options here.
692 $loading_page_options = array(
693 'foregroundColor' => ( ! empty( $_POST['lp_foregroundColor'] ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_foregroundColor'] ) ) : '#FFFFFF',
694 'backgroundColor' => ( ! empty( $_POST['lp_backgroundColor'] ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_backgroundColor'] ) ) : '#000000',
695 'transparency' => ( ! empty( $_POST['lp_backgroundTransparency'] ) ) ? true : false,
696 'backgroundImage' => isset( $_POST['lp_backgroundImage'] ) ? esc_url_raw( wp_unslash( $_POST['lp_backgroundImage'] ) ) : '',
697 'backgroundImageRepeat' => ( isset( $_POST['lp_backgroundRepeat'] ) && in_array( $_POST['lp_backgroundRepeat'], array( 'repeat', 'no-repeat' ), true ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_backgroundRepeat'] ) ) : 'repeat',
698 'additionalSeconds' => $additional_seconds,
699 'codeBlock' => wp_unslash( $code_block ),
700 'fullscreen' => ( isset( $_POST['lp_fullscreen'] ) ) ? 1 : 0,
701 'enabled_loading_screen' => ( isset( $_POST['lp_enabled_loading_screen'] ) ) ? true : false,
702 'from_trigger' => ( isset( $_POST['lp_from_trigger'] ) ) ? true : false,
703 'close_btn' => ( isset( $_POST['lp_close_btn'] ) ) ? true : false,
704 'remove_in_on_load' => ( isset( $_POST['lp_remove_in_on_load'] ) ) ? true : false,
705 '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',
706 'screen_width' => is_numeric( $lp_screen_width ) ? $lp_screen_width : '',
707 'lp_loading_screen_display_in' => ( isset( $_POST['lp_loading_screen_display_in'] ) ) ? sanitize_text_field( wp_unslash( $_POST['lp_loading_screen_display_in'] ) ) : 'all',
708 'once_per_session' => ( ! isset( $_POST['once_per_session'] ) ||
709 ! in_array( $_POST['once_per_session'], array( 'always', 'site', 'page' ), true )
710 ) ? 'always' : sanitize_text_field( wp_unslash( $_POST['once_per_session'] ) ),
711 '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'] ) ) : '',
712 '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'] ) ) : '',
713 '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',
714 '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'] ) ) : '',
715 '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'] ) ) : '',
716 'lp_loading_screen_include_from_urls' => $lp_loading_screen_include_from_urls,
717 'lp_loading_screen_exclude_from_urls' => $lp_loading_screen_exclude_from_urls,
718 'lp_loading_screen_exclude_from_elementor_maintenance' => ( isset( $_POST['lp_loading_screen_exclude_from_elementor_maintenance'] ) ) ? true : false,
719 'deepSearch' => ( isset( $_POST['lp_deactivateDeepSearch'] ) ) ? false : true,
720 'modifyDisplayRule' => ( isset( $_POST['lp_modifyDisplayRule'] ) ) ? true : false,
721 'loading_screen' => isset( $_POST['lp_loading_screen'] ) ? sanitize_text_field( wp_unslash( $_POST['lp_loading_screen'] ) ) : '',
722 'displayPercent' => ( isset( $_POST['lp_displayPercent'] ) ) ? true : false,
723 'pageEffect' => isset( $_POST['lp_pageEffect'] ) ? sanitize_text_field( wp_unslash( $_POST['lp_pageEffect'] ) ) : '',
724 'triggerLinkScreenNeverClose' => isset( $_POST['lp_triggerLinkScreenNeverClose'] ) ? true : false,
725 'triggerLinkScreenCloseAfter' => isset( $_POST['lp_triggerLinkScreenCloseAfter'] ) && is_numeric( $_POST['lp_triggerLinkScreenCloseAfter'] ) ? intval( $_POST['lp_triggerLinkScreenCloseAfter'] ) : '',
726 );
727
728 if ( isset( $_POST['lp_ls'] ) ) {
729 $loading_page_options['lp_ls'] = loading_page_sanitize_array( $_POST['lp_ls'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
730 }
731
732 update_option( 'loading_page_video_tutorial', ( ! empty( $_POST['loading_page_video_tutorial'] ) && 'collapsed' === $_POST['loading_page_video_tutorial'] ) ? 'collapsed' : 'expanded' );
733
734 if ( update_option( 'loading_page_options', $loading_page_options ) ) {
735 print '<div class="updated">' . esc_html__( 'The Loading Page has been stored successfully', 'loading-page' ) . '</div>';
736 } else {
737 print '<div class="error">' . esc_html__( 'The Loading Page settings could not be stored', 'loading-page' ) . '</div>';
738 }
739 }
740
741 $loading_page_options = get_option( 'loading_page_options', [] );
742
743 $loading_page_video_tutorial = get_option( 'loading_page_video_tutorial', 'expanded' );
744 $loading_page_video_tutorial_open_close = ( 'expanded' === $loading_page_video_tutorial ) ? 'X' : '+';
745 $loading_page_video_tutorial_status = ( 'collapsed' === $loading_page_video_tutorial ) ? 'lp-video-collapsed' : '';
746
747 ?>
748 <style>
749 .lp-video-container {
750 overflow: hidden;
751 position: relative;
752 width: 100%;
753 }
754
755 .lp-video-container::after {
756 padding-top: 56.25%;
757 display: block;
758 content: '';
759 }
760
761 .lp-video-container iframe {
762 position: absolute;
763 top: 0;
764 left: 0;
765 width: 100%;
766 height: 100%;
767 }
768
769 .lp-video-collapsed {
770 display: none;
771 }
772 .lp-upgrade-message{
773 border:3px solid #e5c012;
774 margin-top:10px;
775 margin-bottom:10px;
776 padding:10px;
777 display:block;
778 width:100%;
779 box-sizing:border-box;
780 font-weight:500;
781 }
782 </style>
783 <div class="wrap">
784 <form method="post">
785 <input type="hidden" name="loading_page_nonce" value="<?php print( esc_attr( wp_create_nonce( __FILE__ ) ) ); ?>" />
786 <h2><?php esc_html_e( 'Loading Page Settings', 'loading-page' ); ?></h2>
787 <div class="postbox">
788 <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>
789 <div class="inside lp-video-tutorial <?php echo esc_attr( $loading_page_video_tutorial_status ); ?>" style="position:relative;">
790 <input type="hidden" name="loading_page_video_tutorial" value="<?php echo esc_attr( $loading_page_video_tutorial ); ?>" />
791 <div class="lp-video-container">
792 <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>
793 </div>
794 </div>
795 </div>
796 <div class="postbox">
797 <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Loading Screen', 'loading-page' ); ?></span></h3>
798 <div class="inside">
799 <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 />
800 <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 />
801 <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>
802 </p>
803 <p>
804 <?php
805 esc_html_e(
806 'Displays a loading screen until the webpage is ready, the screen shows the loading percent.',
807 'loading-page'
808 );
809 ?>
810 </p>
811 <table class="form-table">
812 <tr>
813 <th><?php esc_html_e( 'Enable loading screen', 'loading-page' ); ?></th>
814 <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>
815 </tr>
816 <tr>
817 <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>
818 <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>
819 </tr>
820 <tr>
821 <th><?php esc_html_e( 'Display a close screen button', 'loading-page' ); ?></th>
822 <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>
823 </tr>
824 <tr>
825 <th><?php esc_html_e( 'Hide the loading screen in the window onload event', 'loading-page' ); ?></th>
826 <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>
827 </tr>
828 <tr>
829 <th><?php esc_html_e( 'Display the loading screen on', 'loading-page' ); ?></th>
830 <td>
831 <select aria-label="<?php esc_attr_e( 'Screen size', 'loading-page' ); ?>" name="lp_screen_size" style="float:left;">
832 <option value="all"
833 <?php
834 if (
835 isset( $loading_page_options['screen_size'] ) &&
836 'all' === $loading_page_options['screen_size']
837 ) {
838 print 'SELECTED';
839 }
840 ?>
841 ><?php esc_html_e( 'All Screens', 'loading-page' ); ?></option>
842 <option value="greater"
843 <?php
844 if (
845 isset( $loading_page_options['screen_size'] ) &&
846 'greater' === $loading_page_options['screen_size']
847 ) {
848 print 'SELECTED';
849 }
850 ?>
851 ><?php esc_html_e( 'Greater Than', 'loading-page' ); ?></option>
852 <option value="lesser"
853 <?php
854 if (
855 isset( $loading_page_options['screen_size'] ) &&
856 'lesser' === $loading_page_options['screen_size']
857 ) {
858 print 'SELECTED';
859 }
860 ?>
861 ><?php esc_html_e( 'Lesser Than', 'loading-page' ); ?></option>
862 </select>
863 <div id="lp_width_container" style="float:left; padding-left:10px;
864 <?php
865 if ( ! isset( $loading_page_options['screen_size'] ) || 'all' === $loading_page_options['screen_size'] ) {
866 echo 'display:none;';
867 } else {
868 echo 'display:block;';
869 }
870 ?>
871 ">
872 <?php esc_html_e( 'Width', 'loading-page' ); ?>:
873 <input aria-label="<?php esc_attr_e( 'Screen width', 'loading-page' ); ?>" type="text" name="lp_screen_width" value="<?php
874 if ( isset( $loading_page_options['screen_width'] ) ) {
875 echo esc_attr( $loading_page_options['screen_width'] );
876 }
877 ?>" /> px
878 </div>
879 <script>
880 jQuery('[name="lp_screen_size"]').on('change',function() {
881 jQuery('#lp_width_container')[(this.value == 'all') ? 'hide' : 'show']();
882 })
883 </script>
884 </td>
885 </tr>
886 <tr>
887 <th><?php esc_html_e( 'Display the loading screen', 'loading-page' ); ?></th>
888 <td>
889 <?php
890 if (
891 ! isset( $loading_page_options['once_per_session'] ) ||
892 false === $loading_page_options['once_per_session']
893 ) {
894 $loading_page_options['once_per_session'] = 'always';
895 } elseif ( true === $loading_page_options['once_per_session'] ) {
896 $loading_page_options['once_per_session'] = 'site';
897 }
898 ?>
899 <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 />
900 <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 />
901 <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>
902
903 </td>
904 </tr>
905 <tr>
906 <th><?php esc_html_e( 'Display loading screen in', 'loading-page' ); ?></th>
907 <td>
908 <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>
909
910 <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' ); ?>
911
912 <div style="margin-left:20px;margin-top:10px;">
913 <?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' ); ?>
914 <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
915 print esc_textarea(
916 ( ! empty( $loading_page_options['lp_loading_screen_include_from_urls'] ) )
917 ? implode( "\n", $loading_page_options['lp_loading_screen_include_from_urls'] ) : ''
918 );
919 ?></textarea>
920 <i><?php esc_html_e( 'Enter a URL per row (use the * symbol as wildcard)', 'loading-page' ); ?></i>
921 </div>
922 </div>
923
924 <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' ); ?>
925 <div style="margin-left:20px;margin-top:10px;">
926 <input aria-label="<?php esc_attr_e( 'Pages/posts ids', 'loading-page' ); ?>" type="text" name="lp_loading_screen_display_in_pages" value="<?php
927 if ( ! empty( $loading_page_options['lp_loading_screen_display_in_pages'] ) ) {
928 print esc_attr( $loading_page_options['lp_loading_screen_display_in_pages'] );}
929 ?>" style="width:100%;">
930 <i><?php esc_html_e( 'Type one, or more post/pages IDs, separated by commas ","', 'loading-page' ); ?></i>
931 </div>
932 </div>
933
934 <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' ); ?>
935 <div style="margin-left:20px;margin-top:10px;">
936 <input aria-label="<?php esc_attr_e( 'Post types', 'loading-page' ); ?>" type="text" name="lp_loading_screen_display_post_types" value="<?php
937 if ( ! empty( $loading_page_options['lp_loading_screen_display_post_types'] ) ) {
938 print esc_attr( $loading_page_options['lp_loading_screen_display_post_types'] );}
939 ?>" style="width:100%;">
940 <i><?php esc_html_e( 'Type one or more post types, separated by commas ","', 'loading-page' ); ?></i>
941 </div>
942 </div>
943 </td>
944 </tr>
945 <tr>
946 <th><?php esc_html_e( 'Devices', 'loading-page' ); ?></th>
947 <td>
948 <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
949 if ( ! empty( $loading_page_options['lp_loading_screen_devices'] ) && 'desktop' == $loading_page_options['lp_loading_screen_devices'] ) {
950 print 'CHECKED';}
951 ?>> <?php esc_html_e( 'Display the loading screen only on desktops', 'loading-page' ); ?></label><br>
952 <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
953 if ( ! empty( $loading_page_options['lp_loading_screen_devices'] ) && 'mobile' == $loading_page_options['lp_loading_screen_devices'] ) {
954 print 'CHECKED';}
955 ?>> <?php esc_html_e( 'Display the loading screen only on mobiles', 'loading-page' ); ?></label><br>
956 <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
957 if ( empty( $loading_page_options['lp_loading_screen_devices'] ) || 'both' == $loading_page_options['lp_loading_screen_devices'] ) {
958 print 'CHECKED';}
959 ?>> <?php esc_html_e( 'Display the loading screen on both desktops and mobiles', 'loading-page' ); ?></label><br>
960 </td>
961 </tr>
962 <tr>
963 <td colspan="2">
964 <hr />
965 </td>
966 </tr>
967 <tr>
968 <th><?php esc_html_e( 'Exclude loading screen from', 'loading-page' ); ?></th>
969 <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
970 if ( ! empty( $loading_page_options['lp_loading_screen_exclude_from_pages'] ) ) {
971 print esc_attr( $loading_page_options['lp_loading_screen_exclude_from_pages'] );}
972 ?>"> <i><?php esc_html_e( 'Type one, or more post/pages IDs, separated by commas ","', 'loading-page' ); ?></i></td>
973 </tr>
974 <tr>
975 <th><?php esc_html_e( 'Exclude loading screen from post types', 'loading-page' ); ?></th>
976 <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
977 if ( ! empty( $loading_page_options['lp_loading_screen_exclude_from_post_types'] ) ) {
978 print esc_attr( $loading_page_options['lp_loading_screen_exclude_from_post_types'] );}
979 ?>"> <i><?php esc_html_e( 'Type one, or more post/pages types, separated by commas ","', 'loading-page' ); ?></i></td>
980 </tr>
981 <tr>
982 <th><?php esc_html_e( 'Exclude loading screen from pages with the URL', 'loading-page' ); ?></th>
983 <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
984 print esc_textarea(
985 ( ! empty( $loading_page_options['lp_loading_screen_exclude_from_urls'] ) )
986 ? implode( "\n", $loading_page_options['lp_loading_screen_exclude_from_urls'] ) : ''
987 );
988 ?></textarea>
989 <i><?php esc_html_e( 'Enter a URL per row (use the * symbol as wildcard)', 'loading-page' ); ?></i>
990 </td>
991 </tr>
992 <tr>
993 <th colspan="2">
994 <?php esc_html_e( 'Exclude the loading screen if Elementor Maintenance or Coming Soon modes are enabled', 'loading-page' ); ?>
995 <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' : '' ); ?> />
996 </th>
997 </tr>
998 <tr>
999 <td colspan="2">
1000 <hr />
1001 </td>
1002 </tr>
1003 <tr>
1004 <?php $loading_screens = loading_page_get_screen_list(); ?>
1005 <th><?php esc_html_e( 'Select the loading screen', 'loading-page' ); ?></th>
1006 <td>
1007 <select aria-label="<?php esc_attr_e( 'Loading screen', 'loading-page' ); ?>" name="lp_loading_screen">
1008 <?php
1009 foreach ( $loading_screens as $screen ) {
1010 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>';
1011 }
1012 ?>
1013 </select>
1014 <span class="lp-upgrade-message">
1015 <?php
1016 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' );
1017 ?> <a href="http://wordpress.dwbooster.com/content-tools/loading-page" target="_blank"><?php esc_html_e( 'CLICK HERE', 'loading-page' ); ?></a>
1018 </span>
1019 </td>
1020 </tr>
1021 <?php
1022 foreach ( $loading_screens as $screen ) {
1023 if ( ! empty( $screen['adminsection'] ) ) {
1024 include_once $screen['adminsection'];
1025 }
1026 if ( ! empty( $screen['adminscript'] ) ) {
1027 wp_enqueue_script( $screen['adminscript'], $screen['adminscript'], array(), 'free-1.1.17', true );
1028 }
1029 }
1030 ?>
1031 <tr>
1032 <th><?php esc_html_e( 'Select foreground color', 'loading-page' ); ?></th>
1033 <td><input aria-label="<?php esc_attr_e( 'Foreground color', 'loading-page' ); ?>" type="text" name="lp_foregroundColor" id="lp_foregroundColor" value="<?php
1034 if ( isset( $loading_page_options['foregroundColor'] ) ) {
1035 print( esc_attr( $loading_page_options['foregroundColor'] ) );}
1036 ?>" />
1037 <div id="lp_foregroundColor_picker"></div>
1038 </td>
1039 </tr>
1040 <tr>
1041 <th><?php esc_html_e( 'Select background color', 'loading-page' ); ?></th>
1042 <td>
1043 <input aria-label="<?php esc_attr_e( 'Background color', 'loading-page' ); ?>" type="text" name="lp_backgroundColor" id="lp_backgroundColor" value="<?php
1044 if ( isset( $loading_page_options['backgroundColor'] ) ) {
1045 print( esc_attr( $loading_page_options['backgroundColor'] ) );}
1046 ?>" />
1047 <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' ); ?>
1048 <div id="lp_backgroundColor_picker"></div>
1049 </td>
1050 </tr>
1051 <tr>
1052 <th><?php esc_html_e( 'Select image as background', 'loading-page' ); ?></th>
1053 <td>
1054 <input aria-label="<?php esc_attr_e( 'Background image', 'loading-page' ); ?>" type="text" name="lp_backgroundImage" id="lp_backgroundImage" value="<?php
1055 if ( isset( $loading_page_options['backgroundImage'] ) ) {
1056 print( esc_attr( $loading_page_options['backgroundImage'] ) );}
1057 ?>" />
1058 <input type="button" value="Browse" onclick="loading_page_selected_image('lp_backgroundImage');" />
1059 <select aria-label="<?php esc_attr_e( 'Background position', 'loading-page' ); ?>" id="lp_backgroundRepeat" name="lp_backgroundRepeat">
1060 <option value="repeat"
1061 <?php
1062 if ( isset( $loading_page_options['backgroundImageRepeat'] ) && 'repeat' === $loading_page_options['backgroundImageRepeat'] ) {
1063 echo 'SELECTED';}
1064 ?>
1065 >Tile</option>
1066 <option value="no-repeat"
1067 <?php
1068 if ( isset( $loading_page_options['backgroundImageRepeat'] ) && 'no-repeat' === $loading_page_options['backgroundImageRepeat'] ) {
1069 echo 'SELECTED';}
1070 ?>
1071 >Center</option>
1072 </select>
1073
1074 </td>
1075 </tr>
1076 <tr>
1077 <th><?php esc_html_e( 'Display image in fullscreen', 'loading-page' ); ?></th>
1078 <td>
1079 <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' : '' ); ?> />
1080 <i><?php esc_html_e( '(The fullscreen attribute can fail in some browsers)', 'loading-page' ); ?></i>
1081 </td>
1082 </tr>
1083 <tr>
1084 <th><?php esc_html_e( 'Additional seconds', 'loading-page' ); ?></th>
1085 <td>
1086 <input aria-label="<?php esc_attr_e( 'Additional seconds', 'loading-page' ); ?>" type="text" name="lp_additionalSeconds" id="lp_additionalSeconds" value="<?php
1087 if ( isset( $loading_page_options['additionalSeconds'] ) ) {
1088 print( esc_attr( $loading_page_options['additionalSeconds'] ) );}
1089 ?>" />
1090 <i><?php esc_html_e( 'Show the loading screen some few seconds after loading the page', 'loading-page' ); ?></i>
1091 </td>
1092 </tr>
1093 <tr>
1094 <th><?php esc_html_e( 'Include an ad, or your own block of code', 'loading-page' ); ?></th>
1095 <td>
1096 <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
1097 if ( isset( $loading_page_options['codeBlock'] ) ) {
1098 print( esc_textarea( $loading_page_options['codeBlock'] ) );}
1099 ?></textarea>
1100 <p><i><b><?php esc_html_e( 'Trick', 'loading-page' ); ?></b>:
1101 <?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>
1102 </td>
1103 </tr>
1104 <tr>
1105 <th><?php esc_html_e( 'Apply the effect on page', 'loading-page' ); ?></th>
1106 <td>
1107 <select aria-label="<?php esc_attr_e( 'Animation effect', 'loading-page' ); ?>" name="lp_pageEffect">
1108 <?php
1109 $page_effects = array( 'none', 'rotateInLeft' );
1110
1111 foreach ( $page_effects as $value ) {
1112 print '<option value="' . esc_attr( $value ) . '" ' . ( ( isset( $loading_page_options['pageEffect'] ) && $loading_page_options['pageEffect'] === $value ) ? 'SELECTED' : '' ) . '>' . esc_html( $value ) . '</option>';
1113 }
1114 ?>
1115
1116 </select>
1117 <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>
1118 </td>
1119 </tr>
1120 <tr>
1121 <th><?php esc_html_e( 'Display loading percent', 'loading-page' ); ?></th>
1122 <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>
1123 </tr>
1124 </table>
1125 <div style="border: 1px solid #DADADA; padding:10px;">
1126 <h3><?php esc_html_e( 'Troubleshoot Area - Loading Screen', 'loading-page' ); ?></h3>
1127 <table class="form-table">
1128 <tr>
1129 <th><?php esc_html_e( 'Disable the search in deep', 'loading-page' ); ?></th>
1130 <td>
1131 <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>
1132 </td>
1133 </tr>
1134 <tr>
1135 <th><?php esc_html_e( 'The pages\' background is visible', 'loading-page' ); ?></th>
1136 <td>
1137 <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>
1138 </td>
1139 </tr>
1140 <tr>
1141 <td colspan="2" style="padding-left:0;">
1142 <?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 />
1143 <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;
1144 <?php esc_html_e( '- or close after ', 'loading-page' ); ?>&nbsp;
1145 <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;
1146 <?php esc_html_e( 'seconds', 'loading-page' ); ?>
1147 </td>
1148 </tr>
1149 </table>
1150 </div>
1151 </div>
1152 </div>
1153 <div class="postbox">
1154 <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Lazy Loading', 'loading-page' ); ?></span></h3>
1155 <div class="inside">
1156 <p>
1157 <?php
1158 esc_html_e(
1159 'To load only the images visible in the viewport to improve the loading rate of your website and reduce the bandwidth consumption.',
1160 'loading-page'
1161 );
1162 ?>
1163 </p>
1164 <p class="lp-upgrade-message">
1165 <?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>
1166 </p>
1167 <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>
1168 <table class="form-table">
1169 <tr>
1170 <th><?php esc_html_e( 'Enable lazy loading', 'loading-page' ); ?></th>
1171 <td><input aria-label="<?php esc_attr_e( 'Enable lazy loading', 'loading-page' ); ?>" type="checkbox" DISABLED /></td>
1172 </tr>
1173 <tr>
1174 <th><?php esc_html_e( 'Select the image to load by default', 'loading-page' ); ?></th>
1175 <td>
1176 <input aria-label="<?php esc_attr_e( 'Image to load by default', 'loading-page' ); ?>" type="text" DISABLED /><input type="button" value="Browse" DISABLED />
1177 </td>
1178 </tr>
1179 <tr>
1180 <th><?php esc_html_e( 'Exclude lazy loading from', 'loading-page' ); ?></th>
1181 <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>
1182 </tr>
1183 </table>
1184 <div style="border: 1px solid #DADADA; padding:10px;">
1185 <h3><?php esc_html_e( 'Troubleshoot Area - Lazy Loading', 'loading-page' ); ?></h3>
1186 <table class="form-table">
1187 <tr>
1188 <th><?php esc_html_e( 'Exclude images whose tag includes the class or attribute', 'loading-page' ); ?></th>
1189 <td>
1190 <input aria-label="<?php esc_attr_e( 'Class or attributes names', 'loading-page' ); ?>" type="text" style="width:100%;" disabled /><br />
1191 <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>
1192 </td>
1193 </tr>
1194 </table>
1195 </div>
1196 </div>
1197 </div>
1198 <div><input type="submit" value="Update Settings" class="button-primary" /></div>
1199 </form>
1200 </div>
1201 <?php
1202 } // End loading_page_settings_page.
1203 }
1204