/** * */ public function onAfterRender() { // Only process for frontend if (JFactory::getApplication()->isSite()) { require_once __DIR__ . '/core/bootstrap.php'; $template = JFactory::getApplication()->getTemplate(); $templateDir = JPATH_ROOT . '/templates/' . $template . '/html/plg_system_ztshortcodes'; ZtShortcodesPath::getInstance()->registerNamespace('Shortcodes', $templateDir); // Get body $html = JResponse::getBody(); $parser = ZtShortcodesParser::getInstance(); // Execute shortcodes $html = $parser->do_shortcode($html); // Set back to Joomla! JResponse::setBody($html); } }
* * @name Zt Shortcodes * @version 2.0.0 * @package Plugin * @subpackage System * @author ZooTemplate * @email support@zootemplate.com * @link http://www.zootemplate.com * @copyright Copyright (c) 2015 ZooTemplate * @license GPL v2 */ defined('_JEXEC') or die('Restricted access'); $joomlaRoot = realpath(__DIR__ . '/../../../../../../'); require_once $joomlaRoot . '/plugins/system/ztshortcodes/core/bootstrap.php'; // Groupping shortcodes $parser = ZtShortcodesParser::getInstance(); $list = $parser->getShortcodes(); ?> <html> <head> <?php $this->load('Shortcodes://html/admin/shortcodes.head.php'); ?> </head> <body> <div class="zt-shortcode-wrap"> <?php $this->load('Shortcodes://html/admin/shortcodes.list.php', array('list' => $list)); ?> <?php
/** * Regular Expression callable for do_shortcode() for calling shortcode hook. * @see get_shortcode_regex for details of the match array contents. * * @since 2.5.0 * @access private * @uses $shortcode_tags * * @param array $m Regular expression match array * @return mixed False on failure. */ public function do_shortcode_tag($m) { // Provide caching for same shortcodes $cacheId = ZtShortcodesHelperCommon::getCacheId($m); $cache = JFactory::getCache('ztshortcodes', ''); $html = $cache->get($cacheId); if ($html === false) { // allow [[foo]] syntax for escaping a tag if ($m[1] == '[' && $m[6] == ']') { return substr($m[0], 1, -1); } $tag = $m[2]; // Get attributes of this shortcode instance $attr = $this->shortcode_parse_atts($m[3]); // Callback for parent prepare $callback = $this->shortcode_tags[$tag]; // Do init for asked tag if (method_exists($callback[0], 'init')) { $attr = call_user_func(array($callback[0], 'init'), $attr, $tag); } // Shortcode data exists if (isset($this->_shortcodes[$tag])) { // Process for subTags if needed if (isset($this->_shortcodes[$tag]['subTag'])) { foreach ($this->_shortcodes[$tag]['subTag'] as $subTag => $subData) { $subParser = ZtShortcodesParser::getInstance(); $subData['attributes']['_parent'] = $attr; $subParser->add_shortcode($subTag, $subData); if (isset($m[5])) { $m[5] = $subParser->do_shortcode($m[5]); } } } // Have attributes than we merge with default if (is_array($attr)) { if (isset($this->_shortcodes[$tag]['attributes'])) { $attr = array_merge($this->_shortcodes[$tag]['attributes'], $attr); } } else { if (isset($this->_shortcodes[$tag]['attributes'])) { $attr = $this->_shortcodes[$tag]['attributes']; } } } if (isset($m[5])) { // Recursive shortcodes in content if ($this->hasShortcodes($m[5])) { $m[5] = $this->do_shortcode($m[5]); } // enclosing tag - extra parameter $html = $m[1] . call_user_func($this->shortcode_tags[$tag], $attr, $m[5], $tag) . $m[6]; } else { // self-closing tag $html = $m[1] . call_user_func($this->shortcode_tags[$tag], $attr, null, $tag) . $m[6]; } // Store cache $cache->store($html, $cacheId); } return $html; }