| @@ -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(); |
| @@ -148,20 +148,14 @@ | ||
| 148 | 148 | return $excluded_filter_arr; |
| 149 | 149 | } |
| 150 | 150 | add_filter( 'wp-optimize-minify-default-exclusions', 'wpbc_exclude_for_wp_optimize', 10, 1 ); |
| 151 | 151 | |
| 152 | +// FixIn: 10.14.4.2. (loader made cache-proof) | |
| 153 | +function wpbc_get_exclude_scripts_arr_for_wp_rocket() { | |
| 152 | 154 | |
| 153 | -/** | |
| 154 | - * Exclude JS scripts from Delay JS in the WP Rocket plugin | |
| 155 | - * | |
| 156 | - * @param $exclusions | |
| 157 | - * | |
| 158 | - * @return mixed | |
| 159 | - */ | |
| 160 | -function wpbc_exclude_from_delay_for_wp_rocket( $exclusions ) { | |
| 161 | - | |
| 162 | 155 | $plugin_path = wpbc_make_link_relative( WPBC_PLUGIN_URL ); |
| 163 | 156 | |
| 157 | + $exclusions = array(); | |
| 164 | 158 | // Exclude jQuery |
| 165 | 159 | $exclusions[] = '/jquery(-migrate)?-?([0-9.]+)?(.min|.slim|.slim.min)?.js(\?(.*))?( |\'|"|>)'; |
| 166 | 160 | |
| 167 | 161 | // Exclude plugin JS files |
| @@ -170,10 +164,10 @@ | ||
| 170 | 164 | /* |
| 171 | 165 | $exclusions[] = '/wp-content/plugins/booking(.*)/_dist/all/_out/wpbc_all.js'; |
| 172 | 166 | $exclusions[] = '/wp-content/plugins/booking(.*)/js/datepick/jquery.datepick.wpbc.9.0.js'; |
| 173 | 167 | $exclusions[] = '/wp-content/plugins/booking(.*)/js/wpbc_time-selector.js'; |
| 174 | - $exclusions[] = '/wp-content/plugins/booking(.*)/assets/libs/tippy.js'; | |
| 175 | - $exclusions[] = '/wp-content/plugins/booking(.*)/assets/libs/popper/popper.js'; | |
| 168 | + $exclusions[] = '/wp-content/plugins/booking(.*)/vendors/_custom/tippy.js'; | |
| 169 | + $exclusions[] = '/wp-content/plugins/booking(.*)/vendors/_custom/popper/popper.js'; | |
| 176 | 170 | $exclusions[] = '/wp-content/plugins/booking(.*)/inc/js/biz_m.js'; |
| 177 | 171 | */ |
| 178 | 172 | |
| 179 | 173 | // Exclude some important plugin JS vars |
| @@ -188,11 +182,36 @@ | ||
| 188 | 182 | $exclusions[] = ' wpbc_(.*)'; |
| 189 | 183 | |
| 190 | 184 | |
| 191 | 185 | // Old way to exclude all |
| 192 | - // $exclusions[] = '/wp-content/plugins/booking(.*)/(.*)'; | |
| 193 | - // $exclusions[] = '(.*)wpbc(.*)'; | |
| 186 | + $exclusions[] = '/wp-content/plugins/booking(.*)/(.*)'; | |
| 187 | + $exclusions[] = '(.*)wpbc(.*)'; | |
| 194 | 188 | |
| 195 | 189 | return $exclusions; |
| 190 | +} | |
| 196 | 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; | |
| 197 | 206 | } |
| 198 | 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' ); | |