/**
  * @param array $args
  * @param array $instance
  */
 function widget($args, $instance)
 {
     $shortcode = '';
     if ($this->childShortcode) {
         $shortcode .= '[' . $this->shortcode->getShortcodeName();
         if (isset($instance['parent'])) {
             $shortcode .= ' ' . $this->buildParams($instance['parent']);
         }
         $shortcode .= ']';
     }
     $s = $this->childShortcode ? $this->childShortcode : $this->shortcode;
     if (isset($instance['parent'])) {
         unset($instance['parent']);
     }
     if (!$this->childShortcode) {
         $instance = array('child' => $instance);
     }
     foreach ($instance['child'] as $e) {
         $c = isset($e['content']) ? $e['content'] : null;
         $shortcode .= '[' . $s->getShortcodeName() . $this->buildParams($e) . ']';
         if ($c !== null) {
             $shortcode .= $c . '[/' . $s->getShortcodeName() . ']';
         }
     }
     if ($this->childShortcode) {
         $shortcode .= '[/' . $this->shortcode->getShortcodeName() . ']';
     }
     echo $args['before_widget'];
     echo do_shortcode($shortcode);
     echo $args['after_widget'];
 }
 /**
  * Registers new shortcode
  * @param ctShortcode $shortcode
  */
 public static function register($shortcode)
 {
     self::$shortcodes[$shortcode->getGroupName()][$shortcode->getShortcodeName()] = $shortcode;
     self::$groups[$shortcode->getShortcodeName()] = $shortcode->getGroupName();
     self::$shortcodeNames[] = $shortcode->getShortcodeName();
 }
 /**
  * Creates debug pages
  * @param int $parentId
  * @param ctShortcode $code
  * @param string $result
  * @return int|\WP_Error
  */
 protected function createPage($parentId, $code, $result, $title = '')
 {
     $title = "Shortcode '" . ($code ? $code->getShortcodeName() : $title) . "'";
     $post = array('post_content' => $result, 'post_name' => $title, 'post_title' => $title, 'post_type' => "page", 'post_status' => 'publish', 'post_parent' => $parentId);
     return wp_insert_post($post);
 }