Beispiel #1
0
 /**
  * Registers Shortcode and its function
  * 
  * @param  array  $attrs   Attributes from user input
  * @param  string $content Content on shortcodes with opening and closing tags
  * @param  string $tag     Shortcode tag
  * @return void
  */
 public function __registerShortcode($attrs, $content = null, $tag)
 {
     // Clear attributes
     $this->attributes->clear();
     // Set default attributes
     $this->attributes->setList($this->default_attributes->getAll());
     // Remove quotes from attributes
     if ($attrs) {
         if (is_array($attrs)) {
             foreach ($attrs as $key => $attr) {
                 $attrs[$key] = static::__cleanAttrValue($attr);
             }
         } elseif (is_string($attrs)) {
             $attrs = static::__cleanAttrValue($attrs);
         }
         $this->attributes->setList($attrs);
     }
     ob_start();
     // Execute shortcode function
     call_user_func_array($this->function, array($this->attributes, $content, $tag));
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }