borlabs

Borlabs Cookie für einzelne Seiten aktivieren

Apr 11th, 2024 (edited)
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. add_action('after_setup_theme', function () {
  2.     // Define the URLs where Borlabs Cookie should be loaded
  3.     $urlList = [
  4.         '/pathA/',
  5.         '/pathB/onlySubPath/',
  6.         '/kontakt/',
  7.     ];
  8.  
  9.     if (!class_exists('\Borlabs\Cookie\Container\ApplicationContainer')) {
  10.         return;
  11.     }
  12.    
  13.     $shouldRemoveAction = true;
  14.  
  15.     foreach ($urlList as $url) {
  16.         if (strpos($_SERVER['REQUEST_URI'], $url) !== false) {
  17.             $shouldRemoveAction = false;
  18.             break;
  19.         }
  20.     }
  21.    
  22.     if ($shouldRemoveAction) {
  23.         return;
  24.     }
  25.  
  26.     $container = \Borlabs\Cookie\Container\ApplicationContainer::get();
  27.     remove_action('init', [$container->get(\Borlabs\Cookie\System\WordPressFrontendDriver\WordPressFrontendInit::class), 'register']);
  28. });
Add Comment
Please, Sign In to add comment