<?php
/*
 * This file is part of WPCore project.
 *
 * (c) Louis-Michel Raynauld <louismichel@pweb.ca>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace WPCore;

/**
 * WP shortcode
 *
 * @author Louis-Michel Raynauld <louismichel@pweb.ca>
 */
class WPshortcode extends WPaction
{
  protected $slug;
  protected $view;

  public function __construct($shortcode, View $view)
  {
    $this->slug = $shortcode;
    $this->view = $view;

    parent::__construct('init');
  }

  public function action()
  {
    add_shortcode( $this->slug, array($this,'callback') );
  }

  public function callback()
  {
    return $this->view->getContent();
  }
}

<?php
/*
 * This file is part of WPCore project.
 *
 * (c) Louis-Michel Raynauld <louismichel@pweb.ca>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace WPCore;

/**
 * WP shortcode
 *
 * @author Louis-Michel Raynauld <louismichel@pweb.ca>
 */
abstract class WPshortcode implements WPhook
{

  protected $slug;

  public function __construct($shortcode)
  {
    $this->slug = $shortcode;
  }

  public function register()
  {
    add_shortcode( $this->slug, array($this,'callback') );
  }

  public function remove()
  {
    remove_shortcode($this->slug);
  }

  abstract public function callback();

}
--- 
+++ 
@@ -15,26 +15,26 @@
  *
  * @author Louis-Michel Raynauld <louismichel@pweb.ca>
  */
-abstract class WPshortcode implements WPhook
+class WPshortcode extends WPaction
 {
+  protected $slug;
+  protected $view;
 
-  protected $slug;
-
-  public function __construct($shortcode)
+  public function __construct($shortcode, View $view)
   {
     $this->slug = $shortcode;
+    $this->view = $view;
+
+    parent::__construct('init');
   }
 
-  public function register()
+  public function action()
   {
     add_shortcode( $this->slug, array($this,'callback') );
   }
 
-  public function remove()
+  public function callback()
   {
-    remove_shortcode($this->slug);
+    return $this->view->getContent();
   }
-
-  abstract public function callback();
-
 }
Improve shortcode support using view and WPaction
