/** * Render the shortcode. * * @param array $atts The shortcode provided attributes. * @param string $content The shortcode enclosed content. * @return string */ public function render($atts = array(), $content = '') { if (empty($this->_template)) { wp_die('Empty template path.'); } self::$instance_number++; if (empty($atts)) { $atts = array(); } $this->_userData['attributes'] = thb_array_asum($this->_defaultData['attributes'], $atts); $loopArgs = thb_array_asum($this->_defaultData['loop'], $this->resolveAliases($this->_userData['attributes'])); if ($this->_dynamicLoopFunction) { $loopArgs += call_user_func($this->_dynamicLoopFunction); } foreach ($atts as $att) { if (in_array($att, $this->_classAttributes)) { $this->setUserClass($att); } } if (isset($atts['class']) && !empty($atts['class'])) { $this->setUserClass($atts['class']); } $this->_data['class'] = array_merge($this->_defaultData['class'], $this->_userData['class']); $this->_data['content'] = $content; $this->_data['items'] = array(); if ($this->_loopable) { $this->_data['items'] = get_posts($loopArgs); } $template_data = $this->_userData['attributes'] + $this->_data + $loopArgs; if (!empty($this->_module)) { $shortcode_output = thb_return_module_template_part($this->_module, $this->_template, $template_data); } else { $output = new THB_TemplateLoader($this->_template, $template_data); $shortcode_output = $output->render(true); } $this->reset(); return $shortcode_output; }
function thb_get_module_template_part($module, $path, $data = array()) { echo thb_return_module_template_part($module, $path, $data); }