Passing values into Wordpress shortcode
<p>I'm trying to write a Wordpress shortcode in php. I'm having trouble passing values from the shortcode to the rendered content though.</p>

<pre><code>function tweet($atts) {

extract( shortcode_atts( array(
                'id'            =&gt; '',
                'width'         =&gt; '520',
                'height'        =&gt; '600',
                'theme'         =&gt; 'light',
                'link_color'    =&gt; '#333333',
                'border_color'  =&gt; '#e8e8e8',
                'header'        =&gt; 'true',
                'footer'        =&gt; 'true',
                'border'        =&gt; 'true',
                'scrollbar'     =&gt; 'true',
                'transparent'   =&gt; 'false',
                'tweet_limit'   =&gt; '10',
        ), $atts ) );



return '&lt;a class="twitter-timeline"  
data-widget-id="&lt;?php echo $this-&gt;id; ?&gt;"
width="&lt;?php echo $this-&gt;width; ?&gt;"
height="&lt;?php echo $this-&gt;height; ?&gt;"
data-theme="&lt;?php echo $this-&gt;theme; ?&gt;" 
data-link-color="&lt;?php echo $this-&gt;linkColor; ?&gt;"
data-border-color=&lt;?php echo $this-&gt;borderColor; ?&gt;
data-chrome="&lt;?php echo $this-&gt;chrome; ?&gt;"
data-tweet-limit="&lt;?php echo $this-&gt;tweetLimit; ?&gt;"
lang="&lt;?php echo $this-&gt;lang; ?&gt;"&gt;&lt;/a&gt;';
}
add_shortcode('twitter', 'tweet');
</code></pre>

<p>If I hard code values into fields like, <code>data-widget-id</code>, then it will work. However, if I just write <code>[twitter id="707980844590342144"]</code> the value doesn't get passed in.</p>

<p>It seems like something along these lines might be the solution, but I haven't been able to get it working so far:</p>

<pre><code>        $this-&gt;id           = $id;
        $this-&gt;width        = $width;
        $this-&gt;height       = $height;
        $this-&gt;theme        = $theme;
        $this-&gt;linkColor    = $link_color;
        $this-&gt;borderColor  = $border_color;
        $this-&gt;tweetLimit   = $tweet_limit;
        $this-&gt;chrome       = "";
        $this-&gt;chrome       .= ( $header == 'false')        ? 'noheader ' : '';
        $this-&gt;chrome       .= ( $footer == 'false')        ? 'nofooter ' : '';
        $this-&gt;chrome       .= ( $borders == 'false')       ? 'noborders ' : '';
        $this-&gt;chrome       .= ( $scrollbar == 'false')     ? 'noscrollbar ' : '';
        $this-&gt;chrome       .= ( $transparent == 'true')    ? 'transparent ' : '';
</code></pre>