| @@ -13,9 +13,9 @@ | ||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 16 | 16 | |
| 17 | -//FixIn: 10.1.1.2 | |
| 17 | +// FixIn: 10.1.1.2. | |
| 18 | 18 | |
| 19 | 19 | // ===================================================================================================================== |
| 20 | 20 | // == Nonce functions == |
| 21 | 21 | // ===================================================================================================================== |
| @@ -45,12 +45,12 @@ | ||
| 45 | 45 | * |
| 46 | 46 | * @return bool|void |
| 47 | 47 | */ |
| 48 | 48 | function wpbc_check_nonce_in_admin_panel( $action_check = 'wpbc_ajax_admin_nonce' ){ |
| 49 | - | |
| 49 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 50 | 50 | $nonce = ( isset($_REQUEST['wpbc_nonce']) ) ? $_REQUEST['wpbc_nonce'] : ''; |
| 51 | 51 | |
| 52 | - if ( '' === $nonce ) return false; // Its was request from some other plugin //FixIn: 7.2.1.10 | |
| 52 | + if ( '' === $nonce ) return false; // Its was request from some other plugin // FixIn: 7.2.1.10. | |
| 53 | 53 | |
| 54 | 54 | if ( ! wp_verify_nonce( $nonce, $action_check ) ) { // This nonce is not valid. |
| 55 | 55 | ?> |
| 56 | 56 | <script type="text/javascript"> |
| @@ -58,20 +58,20 @@ | ||
| 58 | 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 | 59 | |
| 60 | 60 | echo '<strong>' . esc_js( __( 'Error' , 'booking') ) . '!</strong> '; |
| 61 | 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>"); | |
| 62 | + /* translators: 1: ... */ | |
| 63 | + echo esc_js( sprintf( __( 'Probably nonce for this page has been expired. Please %1$sreload the page%2$s.', 'booking' ), "<a href='javascript:void(0)' onclick='javascript:location.reload();'>", "</a>" ) ); | |
| 64 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.MissingTranslatorsComment | |
| 65 | + echo '<br/>' . sprintf( esc_js( __( 'Please check more here %s', 'booking' ) ), "<a href='https://wpbookingcalendar.com/faq/request-do-not-pass-security-check/?update=" . esc_attr( WP_BK_VERSION_NUM ) . '&ver=' . wpbc_get_version_type__and_mu() . "'>FAQ</a>" ); // FixIn: 8.8.3.6. | |
| 64 | 66 | |
| 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 | 67 | ?></div></div>" ); |
| 70 | 68 | } else if (jQuery(".ajax_respond_insert").length > 0 ){ |
| 71 | 69 | 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 | |
| 70 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.MissingTranslatorsComment | |
| 71 | + printf( __( '%1$sError!%2$s Request do not pass security check! Please refresh the page and try one more time.', 'booking' ), '<strong>', '</strong>' ); | |
| 72 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.MissingTranslatorsComment | |
| 73 | + echo '<br/>' . sprintf( __( 'Please check more here %s', 'booking' ), 'https://wpbookingcalendar.com/faq/request-do-not-pass-security-check/?update=' . esc_attr( WP_BK_VERSION_NUM ) . '&ver=' . wpbc_get_version_type__and_mu() ); // FixIn: 8.8.3.6. | |
| 74 | 74 | ?></div></div>" ); |
| 75 | 75 | } |
| 76 | 76 | if ( jQuery( "#ajax_message" ).length ){ |
| 77 | 77 | jQuery( "#ajax_message" ).slideUp(); |
| @@ -79,9 +79,9 @@ | ||
| 79 | 79 | </script> |
| 80 | 80 | <?php |
| 81 | 81 | die; |
| 82 | 82 | } |
| 83 | - return true; //FixIn: 7.2.1.10 | |
| 83 | + return true; // FixIn: 7.2.1.10. | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | |
| 87 | 87 | // --------------------------------------------------------------------------------------------------------------------- |
| @@ -95,25 +95,25 @@ | ||
| 95 | 95 | |
| 96 | 96 | function wpbc_do_not_cache() { |
| 97 | 97 | |
| 98 | 98 | if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
| 99 | - define( 'DONOTCACHEPAGE', true ); | |
| 99 | + define( 'DONOTCACHEPAGE', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound | |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | if ( ! defined( 'DONOTCACHEDB' ) ) { |
| 103 | - define( 'DONOTCACHEDB', true ); | |
| 103 | + define( 'DONOTCACHEDB', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | if ( ! defined( 'DONOTMINIFY' ) ) { |
| 107 | - define( 'DONOTMINIFY', true ); | |
| 107 | + define( 'DONOTMINIFY', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound | |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | if ( ! defined( 'DONOTCDN' ) ) { |
| 111 | - define( 'DONOTCDN', true ); | |
| 111 | + define( 'DONOTCDN', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | if ( ! defined( 'DONOTCACHEOBJECT' ) ) { |
| 115 | - define( 'DONOTCACHEOBJECT', true ); | |
| 115 | + define( 'DONOTCACHEOBJECT', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound | |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Set the headers to prevent caching for the different browsers. |
| 119 | 119 | nocache_headers(); |
| @@ -125,9 +125,9 @@ | ||
| 125 | 125 | // Exclude from Minify and caching from different CACHE Plugins |
| 126 | 126 | // ===================================================================================================================== |
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | - * Add exclusion of minify JS files in 'WP-Optimize' plugin //FixIn: 10.1.3.3 | |
| 129 | + * Add exclusion of minify JS files in 'WP-Optimize' plugin // FixIn: 10.1.3.3. | |
| 130 | 130 | * |
| 131 | 131 | * Otherwise default rules: |
| 132 | 132 | * *plugins/booking* |
| 133 | 133 | * *jquery/jquery.min.js |
| @@ -146,5 +146,72 @@ | ||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | return $excluded_filter_arr; |
| 149 | 149 | } |
| 150 | -add_filter( 'wp-optimize-minify-default-exclusions', 'wpbc_exclude_for_wp_optimize', 10, 1 ); | |
| 150 | +add_filter( 'wp-optimize-minify-default-exclusions', 'wpbc_exclude_for_wp_optimize', 10, 1 ); | |
| 151 | + | |
| 152 | +// FixIn: 10.14.4.2. (loader made cache-proof) | |
| 153 | +function wpbc_get_exclude_scripts_arr_for_wp_rocket() { | |
| 154 | + | |
| 155 | + $plugin_path = wpbc_make_link_relative( WPBC_PLUGIN_URL ); | |
| 156 | + | |
| 157 | + $exclusions = array(); | |
| 158 | + // Exclude jQuery | |
| 159 | + $exclusions[] = '/jquery(-migrate)?-?([0-9.]+)?(.min|.slim|.slim.min)?.js(\?(.*))?( |\'|"|>)'; | |
| 160 | + | |
| 161 | + // Exclude plugin JS files | |
| 162 | + $exclusions[] = $plugin_path . '/(.*)'; | |
| 163 | + | |
| 164 | + /* | |
| 165 | + $exclusions[] = '/wp-content/plugins/booking(.*)/_dist/all/_out/wpbc_all.js'; | |
| 166 | + $exclusions[] = '/wp-content/plugins/booking(.*)/js/datepick/jquery.datepick.wpbc.9.0.js'; | |
| 167 | + $exclusions[] = '/wp-content/plugins/booking(.*)/js/wpbc_time-selector.js'; | |
| 168 | + $exclusions[] = '/wp-content/plugins/booking(.*)/vendors/_custom/tippy.js'; | |
| 169 | + $exclusions[] = '/wp-content/plugins/booking(.*)/vendors/_custom/popper/popper.js'; | |
| 170 | + $exclusions[] = '/wp-content/plugins/booking(.*)/inc/js/biz_m.js'; | |
| 171 | + */ | |
| 172 | + | |
| 173 | + // Exclude some important plugin JS vars | |
| 174 | + $exclusions[] = 'wpbc_init__head'; | |
| 175 | + $exclusions[] = 'wpbc_url_ajax'; | |
| 176 | + $exclusions[] = 'booking_max_monthes_in_calendar'; | |
| 177 | + $exclusions[] = 'wpbc_define_tippy_popover'; | |
| 178 | + $exclusions[] = 'flex_tl_table_loading'; | |
| 179 | + | |
| 180 | + $exclusions[] = '(.*)_wpbc.(.*)'; | |
| 181 | + $exclusions[] = 'moveOptionalElementsToGarbage'; | |
| 182 | + $exclusions[] = ' wpbc_(.*)'; | |
| 183 | + | |
| 184 | + | |
| 185 | + // Old way to exclude all | |
| 186 | + $exclusions[] = '/wp-content/plugins/booking(.*)/(.*)'; | |
| 187 | + $exclusions[] = '(.*)wpbc(.*)'; | |
| 188 | + | |
| 189 | + return $exclusions; | |
| 190 | +} | |
| 191 | + | |
| 192 | +/** | |
| 193 | + * Exclude JS scripts from Delay JS in the WP Rocket plugin | |
| 194 | + * | |
| 195 | + * @param $exclusions | |
| 196 | + * | |
| 197 | + * @return mixed | |
| 198 | + */ | |
| 199 | +function wpbc_exclude_from_delay_for_wp_rocket( $other_exclusions ) { | |
| 200 | + // return $exclusions; | |
| 201 | + $wpbc_exclusions = wpbc_get_exclude_scripts_arr_for_wp_rocket(); | |
| 202 | + | |
| 203 | + $exclusions = array_merge( $other_exclusions, $wpbc_exclusions ); | |
| 204 | + | |
| 205 | + return $exclusions; | |
| 206 | +} | |
| 207 | +add_filter( 'rocket_delay_js_exclusions', 'wpbc_exclude_from_delay_for_wp_rocket' ); | |
| 208 | + | |
| 209 | +/** | |
| 210 | + * Don't defer our plugin scripts | |
| 211 | + */ | |
| 212 | +add_filter( 'rocket_defer_js_exclusions', 'wpbc_exclude_from_delay_for_wp_rocket' ); | |
| 213 | + | |
| 214 | +/** | |
| 215 | + * If WP Rocket is deferring inline JS, exclude our initializer by a unique key | |
| 216 | + */ | |
| 217 | +add_filter( 'rocket_defer_inline_exclusions', 'wpbc_exclude_from_delay_for_wp_rocket' ); | |