title: Wordpress - make variables available for all theme files (without Globals)
body: <p>I'm developing a Wordpress theme and I'm trying to store some of my variables in a function to re-use it among my theme files, without writing the same variables hundreds of time and without make them <strong>global</strong>. I've read that's a bad practice. </p>
  
  <p>For now I'm using <code>add_action</code> but <strong>without results</strong>. Having in my <code>functions.php</code></p>
  
  <pre><code>add_action( 'run_pms_variables', 'pms_variables_function' );
  function pms_variables_function ($uid ) {
      $the_group_uid = isset($_COOKIE["v_group_id"]) &amp;&amp; !empty($_COOKIE["v_group_id"]) ? trim(strip_tags($_COOKIE["v_group_id"])) : "";       
      $session_detail = vpb_get_the_user_detail($uid);
      $session_username = strlen($session_detail[0]) &gt; 40 ? ucfirst(substr($session_detail[0],0,40)) : ucfirst($session_detail[0]);
      $session_uid = $session_detail[1];
      $session_email = $session_detail[2];
      $session_photo = $session_detail[3];
      $session_country = $session_detail[4];
      //$session_usernames = explode(' ', $session_detail[0]);
      $session_firstname = get_user_meta($uid,'first_name', true );
      $session_lastname = get_user_meta($uid,'last_name', true );
  }
  </code></pre>
  
  <p>and using eventually in my files like:</p>
  
  <pre><code>do_action('run_pms_variables', $uid );
  </code></pre>
  
  <p>I mean, can you address me to the right method? Thanks.</p>