当前位置: 首页>>代码示例>>PHP>>正文


PHP ShortcodeHelper::build_pattern方法代码示例

本文整理汇总了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;
 }
开发者ID:bluedrone,项目名称:plugins,代码行数:20,代码来源:shortcode-helper.class.php

示例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;
     }
 }
开发者ID:DylanPeti,项目名称:socialize,代码行数:30,代码来源:template-builder.class.php


注:本文中的ShortcodeHelper::build_pattern方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。