Advertisement
swte

Untitled

Apr 19th, 2018
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. add_filter('swift_performance_cache_folder_prefix', 'swift_gdpr_cookie_prefix');
  2. add_action('swift_performance_prebuild_cache_hit', 'swift_gdpr_cookie_prebuild'));
  3.  
  4. function swift_gdpr_cookie_prefix(){
  5.     return (isset($_COOKIES['wp-gdpr-cookie']) && $_COOKIES['wp-gdpr-cookie'] == 'Y' ? 'accepted' : '');
  6. }
  7.  
  8.  
  9. function swift_gdpr_cookie_prebuild($permalink){
  10.       // Add country code to prebuild header
  11.       add_filter('swift_performance_prebuild_headers', function($headers){
  12.             $headers['Cookie'] = 'wp-gdpr-cookie=Y';
  13.             return $headers;
  14.       });
  15.  
  16.       // Add country code to mobile prebuild header
  17.       add_filter('swift_performance_mobile_prebuild_headers', function($headers){
  18.             $headers['Cookie'] = 'wp-gdpr-cookie=Y';
  19.             return $headers;
  20.       });
  21.  
  22.       Swift_Performance::prebuild_cache_hit($permalink);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement