本文整理汇总了PHP中ShortcodeHelper::build_pattern方法的典型用法代码示例。如果您正苦于以下问题:PHP ShortcodeHelper::build_pattern方法的具体用法?PHP ShortcodeHelper::build_pattern怎么用?PHP ShortcodeHelper::build_pattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShortcodeHelper
的用法示例。
在下文中一共展示了ShortcodeHelper::build_pattern方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shortcode2array
/**
*Converts a shortcode into an array
**/
static function shortcode2array($content, $depth = 1000)
{
$pattern = empty(ShortcodeHelper::$pattern) ? ShortcodeHelper::build_pattern() : ShortcodeHelper::$pattern;
$depth--;
preg_match_all("/{$pattern}/s", $content, $matches);
$return = array();
foreach ($matches[3] as $key => $match) {
$return[$key]['shortcode'] = $matches[2][$key];
$return[$key]['attr'] = shortcode_parse_atts($match);
if (preg_match("/{$pattern}/s", $matches[5][$key]) && $depth) {
$return[$key]['content'] = self::shortcode2array($matches[5][$key], $depth);
} else {
$return[$key]['content'] = $matches[5][$key];
}
}
return $return;
}
示例2: text_to_interface
public function text_to_interface($text = NULL)
{
global $shortcode_tags;
$allowed = false;
if (isset($_POST['text'])) {
$text = $_POST['text'];
}
//isset when avia_ajax_text_to_interface is executed (avia_builder.js)
if (isset($_POST['params']) && isset($_POST['params']['allowed'])) {
$allowed = explode(',', $_POST['params']['allowed']);
}
//only build pattern with a subset of shortcodes
//build the shortcode pattern to check if the text that we want to check uses any of the builder shortcodes
ShortcodeHelper::build_pattern($allowed);
$text_nodes = preg_split("/" . ShortcodeHelper::$pattern . "/s", $text);
foreach ($text_nodes as $node) {
if (strlen(trim($node)) == 0 || strlen(trim(strip_tags($node))) == 0) {
//$text = preg_replace("/(".preg_quote($node, '/')."(?!\[\/))/", '', $text);
} else {
$text = preg_replace("/(" . preg_quote($node, '/') . "(?!\\[\\/))/", '[av_textblock]$1[/av_textblock]', $text);
}
}
$text = $this->do_shortcode_backend($text);
if (isset($_POST['text'])) {
echo $text;
exit;
} else {
return $text;
}
}