title: In jquery use php variable to execute the jquery
body: <p>I am loading some jquery within a Wordpress page, the jquery works as I want it to but now I need to have that jquery only fire if a php variable exists.</p>
  
  <p>In php I would just do:</p>
  
  <pre><code>if( $foo ) {
      do this;
  }
  </code></pre>
  
  <p>In Wordpress I am enqueuing the a file bla.js that contains this:</p>
  
  <pre><code>jQuery(document).ready(function($){
      $('#someID.some-class &gt; a').append('&lt;div class="caption"&gt;&lt;/div&gt;');
      $(".caption").text("Add this text");
  });
  </code></pre>
  
  <p>I am confused as how to add the php check if $foo exits. There seems to be several approaches but all I end up doing is producing an unexpected token error.</p>