Guest User

Untitled

a guest
Nov 19th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. function site_referral_check() {
  2.  
  3. if (!is_admin()){
  4.  
  5. $allowed_host = 'google.com'; // not actual production site
  6. $theurl = $_SERVER['HTTP_REFERER'];
  7. $host = parse_url($theurl, PHP_URL_HOST);
  8.  
  9. //add console variable for debugging. how I know when $host is blank
  10. $javascript_ouput = "<script>console.log('Debug Info: " .$host. "');
  11. </script>";
  12.  
  13. echo $javascript_ouput;
  14.  
  15. //echo "The allowed host: ".$allowed_host; exit;
  16. if ( !isset($_COOKIE["site-referral"])) {
  17.  
  18.  
  19. if ($host == $allowed_host) {
  20.  
  21. setcookie( "site-referral", "site-referral", time() + 1800, COOKIEPATH, COOKIE_DOMAIN);
  22. }
  23.  
  24. if (!$host == $allowed_host) {
  25.  
  26. //Redirect
  27. wp_redirect('http://google.com' ); exit;
  28. }
  29.  
  30.  
  31.  
  32. }
  33.  
  34.  
  35. }
Add Comment
Please, Sign In to add comment