PluginProbe
Booking Calendar / 10.1.3
Booking Calendar v10.1.3
11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 All 203 releases
booking / includes / _functions / nonce_func.php

nonce_func.php in Booking Calendar 10.1.3, at includes/_functions/nonce_func.php

150 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.0
4 * @package Booking Calendar
5 * @subpackage Nonce functions - excluding from front-end
6 * @category Functions
7 *
8 * @author wpdevelop
9 * @link https://wpbookingcalendar.com/
10 * @email info@wpbookingcalendar.com
11 *
12 * @modified 2024-06-14
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
17 //FixIn: 10.1.1.2
18
19 // =====================================================================================================================
20 // == Nonce functions ==
21 // =====================================================================================================================
22
23 /**
24 * Is use nonce fields at Front-Edn side in king forms
25 * If we do not use nonce, then it can prevent issues on websites with cache plugins regarding these Errors: Forbidden (403) Probably nonce for this page has been expired.
26 * or Error: Request do not pass security check! Please refresh the page and try one more time. Please check more here https://wpbookingcalendar.com/faq/request-do-not-pass-security-check/
27 * Find more information at these pages: https://konstantin.blog/2012/nonces-on-the-front-end-is-a-bad-idea/
28 * https://contactform7.com/2017/08/18/contact-form-7-49/
29 * https://developer.wordpress.org/apis/security/nonces/
30 *
31 * @return bool
32 */
33 function wpbc_is_use_nonce_at_front_end() {
34 return( 'On' === get_bk_option( 'booking_is_nonce_at_front_end' ) );
35 }
36
37 // ---------------------------------------------------------------------------------------------------------------------
38 // S u p p o r t f u n c t i o n s f o r A j a x ///////////////
39 // ---------------------------------------------------------------------------------------------------------------------
40
41 /**
42 * Verify the nonce in Admin Panel - during Ajax request
43 *
44 * @param $action_check
45 *
46 * @return bool|void
47 */
48 function wpbc_check_nonce_in_admin_panel( $action_check = 'wpbc_ajax_admin_nonce' ){
49
50 $nonce = ( isset($_REQUEST['wpbc_nonce']) ) ? $_REQUEST['wpbc_nonce'] : '';
51
52 if ( '' === $nonce ) return false; // Its was request from some other plugin //FixIn: 7.2.1.10
53
54 if ( ! wp_verify_nonce( $nonce, $action_check ) ) { // This nonce is not valid.
55 ?>
56 <script type="text/javascript">
57 if (jQuery("#ajax_respond").length > 0 ){
58 jQuery( "#ajax_respond" ).after( "<div class='wpdevelop'><div style='margin: 0 0 40px;' class='wpbc-general-settings-notice wpbc-settings-notice notice-error 0alert 0alert-warning 0alert-danger'><?php
59
60 echo '<strong>' . esc_js( __( 'Error' , 'booking') ) . '!</strong> ';
61
62 echo sprintf( esc_js( __( 'Probably nonce for this page has been expired. Please %sreload the page%s.', 'booking' ) )
63 ,"<a href='javascript:void(0)' onclick='javascript:location.reload();'>", "</a>");
64
65 echo '<br/>' . sprintf( esc_js( __( 'Please check more here %s', 'booking' ) )
66 , "<a href='https://wpbookingcalendar.com/faq/request-do-not-pass-security-check/?update=" . WP_BK_VERSION_NUM . '&ver=' . wpbc_get_version_type__and_mu(). "'>FAQ</a>"
67 ); //FixIn: 8.8.3.6
68
69 ?></div></div>" );
70 } else if (jQuery(".ajax_respond_insert").length > 0 ){
71 jQuery( ".ajax_respond_insert" ).after( "<div class='wpdevelop'><div class='alert alert-warning alert-danger'><?php
72 printf( __( '%sError!%s Request do not pass security check! Please refresh the page and try one more time.', 'booking' ), '<strong>', '</strong>' );
73 echo '<br/>' . sprintf( __( 'Please check more here %s', 'booking' ), 'https://wpbookingcalendar.com/faq/request-do-not-pass-security-check/?update=' . WP_BK_VERSION_NUM . '&ver=' . wpbc_get_version_type__and_mu() ); //FixIn: 8.8.3.6
74 ?></div></div>" );
75 }
76 if ( jQuery( "#ajax_message" ).length ){
77 jQuery( "#ajax_message" ).slideUp();
78 }
79 </script>
80 <?php
81 die;
82 }
83 return true; //FixIn: 7.2.1.10
84 }
85
86
87 // ---------------------------------------------------------------------------------------------------------------------
88 // For test only, where Nonce time can be adjusted
89 // ---------------------------------------------------------------------------------------------------------------------
90 // add_filter( 'nonce_life', 'wpbc_nonce_life_test' );
91 //function wpbc_nonce_life_test( $lifespan ) {
92 // return 60; //4 * HOUR_IN_SECONDS;
93 //}
94
95
96 function wpbc_do_not_cache() {
97
98 if ( ! defined( 'DONOTCACHEPAGE' ) ) {
99 define( 'DONOTCACHEPAGE', true );
100 }
101
102 if ( ! defined( 'DONOTCACHEDB' ) ) {
103 define( 'DONOTCACHEDB', true );
104 }
105
106 if ( ! defined( 'DONOTMINIFY' ) ) {
107 define( 'DONOTMINIFY', true );
108 }
109
110 if ( ! defined( 'DONOTCDN' ) ) {
111 define( 'DONOTCDN', true );
112 }
113
114 if ( ! defined( 'DONOTCACHEOBJECT' ) ) {
115 define( 'DONOTCACHEOBJECT', true );
116 }
117
118 // Set the headers to prevent caching for the different browsers.
119 nocache_headers();
120 }
121 //wpbc_do_not_cache();
122
123
124 // =====================================================================================================================
125 // Exclude from Minify and caching from different CACHE Plugins
126 // =====================================================================================================================
127
128 /**
129 * Add exclusion of minify JS files in 'WP-Optimize' plugin //FixIn: 10.1.3.3
130 *
131 * Otherwise default rules:
132 * *plugins/booking*
133 * *jquery/jquery.min.js
134 * *jquery/jquery-migrate.min.js
135 *
136 * @param $excluded_filter_arr
137 *
138 * @return mixed
139 */
140 function wpbc_exclude_for_wp_optimize( $excluded_filter_arr ) {
141
142 if ( is_array( $excluded_filter_arr ) ) {
143 $excluded_filter_arr[] = '*/plugins/booking*';
144 $excluded_filter_arr[] = '*/jquery/jquery.min.js';
145 $excluded_filter_arr[] = '*/jquery/jquery-migrate.min.js';
146 }
147
148 return $excluded_filter_arr;
149 }
150 add_filter( 'wp-optimize-minify-default-exclusions', 'wpbc_exclude_for_wp_optimize', 10, 1 );