title: Render wordpress shortcode within page content
body: <p>I have written a wordpress plugin. It is a collection of shortcodes which fetch, parse and render data from an API.
  I am now currently writing a theme to support this plugin. I'm noticing that Wordpress seperates shortcode content from editor content and renders them seperately. 
  Here is an illustration of my issue:
  Editing a Page or a Post in the admin panel:</p>
  
  <pre><code>&lt;div class="row"&gt;
     &lt;div class="col-lg-12"&gt;
       &lt;p&gt;HERE&lt;/p&gt;
       [PluginShortcode_1]
     &lt;/div&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>Let's say that PluginShortcode_1 generates the following html:</p>
  
  <pre><code>&lt;h1&gt;This is the output of PluginShortcode_1&lt;/h1&gt;
    &lt;p&gt;Got Here!&lt;/p&gt;
  </code></pre>
  
  <p>I would like to expect the output to be:</p>
  
  <pre><code>&lt;div class="row"&gt;
     &lt;div class="col-lg-12"&gt;
       &lt;p&gt;HERE&lt;/p&gt;
       &lt;h1&gt;This is the output of PluginShortcode_1&lt;/h1&gt;
          &lt;p&gt;Got Here!&lt;/p&gt;
     &lt;/div&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>But rather, the following is sent to the browser:</p>
  
  <pre><code>&lt;h1&gt;This is the output of PluginShortcode_1&lt;/h1&gt;
    &lt;p&gt;Got Here!&lt;/p&gt;
  &lt;div class="row"&gt;
     &lt;div class="col-lg-12"&gt;
       &lt;p&gt;HERE&lt;/p&gt;
     &lt;/div&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>Apparently wordpress does the following:</p>
  
  <ol>
  <li>Parse and render shortcode content</li>
  <li>Render post content</li>
  </ol>
  
  <p>I've seen references to <a href="http://codex.wordpress.org/Function_Reference/do_shortcode" rel="nofollow" title="do_shortcode&#40;&#41;">do_shortcode()</a> But my plugin defines many shortcodes and would not explicitly know in the template.php which shortcode or shortcodes are on the page without parsing the content beforehand, selecting all of the shortcodes and applying the filters.</p>
  
  <p>UPDATE:</p>
  
  <p>The shortcode functions are within a set of classes which handle all of the rendering. Most of the shortcode content is store seperately in a "view" script which renders the content.</p>
  
  <p>The example above would be invoked in the following way:</p>
  
  <p>shortcodes.ini - a list of shortcodes and their associated functions:</p>
  
  <pre><code>[shortcode_values]
  PluginShortcode_1 = shortcodeOne
  AnotherShortcode  = anotherShortcode
  </code></pre>
  
  <p>Shortcodes.php - container for shortcode functions and invocation:</p>
  
  <pre><code>public function __construct() {
    $ini_array = parse_ini_file(__DIR__. '/shortcodes.ini', true);
    $this-&gt;codeLib = $ini_array['shortcode_values'];
    foreach ($this-&gt;codeLib as $codeTag =&gt; $codeMethod) {
      add_shortcode($codeTag, array(&amp;$this, $codeMethod));
    }
  }
  
  public function shortcodeOne() {
    require_once(__DIR__ . 'views/shortcodeOneView.php');
  }
  </code></pre>
  
  <p>views/shortcodeOneView.php</p>
  
  <pre><code>&lt;?php
  ?&gt;
    &lt;h1&gt;This is the output of PluginShortcode_1&lt;/h1&gt;
      &lt;p&gt;Got here!&lt;/p&gt;
  </code></pre>
  
  <p>Where the shortcode function would actually be responsible for fetching data, setting variables which would be exposed to the view.</p>
  
  <p>UPDATE 
    To complicate matters further, since this plugin makes API requests, I restrict it to only be invoked if the post content actually contains a shortcode.</p>
  
  <p>In the plugin initialization script, I have the following:</p>
  
  <p>class myPlugin.php:</p>
  
  <pre><code>public function __construct() {
    . . .
    add_filter('the_posts', array(&amp;$this, 'isShortcodeRequest'));
    . . .
  }
  
  public function isShortcodeRequest($posts) {
      if (empty($posts)) { return $posts; }
      foreach ($posts as $post) {
        if (stripos($post-&gt;post_content, '[PluginShortcode') !== false) {
          $shortcodes = new Shortcodes();
          break;
        }
      }
      return $posts;
    }
  </code></pre>
  
  <p>My concern is that this filter may be responsible for hijacking the output. . .(?)</p>