title: Passing Shortcode $atts from PHP to Javascript using wp_localize_script
body: <p>I want to use Wordpress' <code>wp_localize_script</code> in order to pass shortcode <code>$atts</code> available to a javascript script. </p>
  
  <p>It seems that <code>wp_localize_script</code> will only work in the same function where I <code>wp_enqueue_script</code> the referenced script. </p>
  
  <p>I access the shortcode <code>$atts</code> in a different function. </p>
  
  <pre><code>function csf_enqueue () {
  
  //other enqueued scripts
  
  wp_enqueue_script( 'csf_script_jquery', plugins_url( 'js/path/to/file', __FILE__ ), array ( 'jquery', 'jquery-ui-core') );
  
      $myvars = array('value' =&gt; 'one');
      wp_localize_script('csf_map_script_jquery', 'myVars', $myvars);
  }
  </code></pre>
  
  <p>I want to replace <code>$myvars</code> with the shortcodes' <code>$atts</code>.</p>
  
  <p>I add the shortcode as follows; </p>
  
  <pre><code>add_shortcode("csf_map", "csf_shortcode_ajax_frontend");
  </code></pre>
  
  <p>In <code>csf_shortcode_ajax_frontend()</code>, I access the shortcodes <code>$atts</code>.</p>
  
  <pre><code>function csf_shortcode_ajax_frontend( $atts, $content = null ) {
  
        $atts = shortcode_atts( array ( 
        'width'=&gt; 600,
        'height'=&gt; 400,
        'myinfo' =&gt; 'blah'
        ), $atts );  
  
  //continues
  }
  </code></pre>
  
  <p>How do I access the shortcode <code>$atts</code> in the function containing <code>wp_localize_script</code>, when wp_localize_script has (?) to contain the  <code>wp_enequeue_script</code> line?</p>