gf_yst_referer_session

The Gravity Forms Directory & Addons gf yst referer session function.

Description

gf_yst_referer_session(); 

Usage

  1. if ( !function_exists( 'gf_yst_referer_session' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'gravity-forms-directory-addons/gravity-forms-referrer.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = gf_yst_referer_session(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/gravity-forms-referrer.php  
  1. function gf_yst_referer_session() { 
  2. $baseurl = get_bloginfo('url'); 
  3. if ( !isset($_SESSION) ) { 
  4. session_start(); 
  5. if ( !isset($_SESSION['gf_yst_pages']) || !is_array($_SESSION['gf_yst_pages']) ) { 
  6. $_SESSION['gf_yst_pages'] = array(); 
  7. if ( !isset($_SESSION['gf_yst_referer']) || !is_array($_SESSION['gf_yst_referer']) ) { 
  8. $_SESSION['gf_yst_referer'] = array(); 
  9.  
  10. // With the ajax submission option, every time someone submitted a form, admin-ajax.php would show as a visited page. 
  11. // This should prevent that. 
  12. if(isset($_SERVER['HTTP_REFERER']) && preg_match('/admin\-ajax\.php/ism', $_SERVER['HTTP_REFERER'], $matches)) { return; } 
  13.  
  14. if (!isset($_SERVER['HTTP_REFERER']) || (strpos($_SERVER['HTTP_REFERER'], $baseurl) === false) && ! (in_array($_SERVER['HTTP_REFERER'], $_SESSION['gf_yst_referer'])) ) { 
  15. if (! isset($_SERVER['HTTP_REFERER'])) { 
  16. $_SESSION['gf_yst_referer'][] = "Type-in or bookmark"; 
  17. } else { 
  18. $_SESSION['gf_yst_referer'][] = $_SERVER['HTTP_REFERER']; 
  19. if (end($_SESSION['gf_yst_pages']) != "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']) { 
  20. $_SESSION['gf_yst_pages'][] = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; 
  21. return;