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


PHP FrmFieldsHelper::get_shortcode_tag方法代码示例

本文整理汇总了PHP中FrmFieldsHelper::get_shortcode_tag方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmFieldsHelper::get_shortcode_tag方法的具体用法?PHP FrmFieldsHelper::get_shortcode_tag怎么用?PHP FrmFieldsHelper::get_shortcode_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FrmFieldsHelper的用法示例。


在下文中一共展示了FrmFieldsHelper::get_shortcode_tag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: replace_single_shortcode

 public static function replace_single_shortcode($shortcodes, $short_key, $tag, $entry, $display, $args, &$content)
 {
     global $post;
     $conditional = preg_match('/^\\[if/s', $shortcodes[0][$short_key]) ? true : false;
     $foreach = preg_match('/^\\[foreach/s', $shortcodes[0][$short_key]) ? true : false;
     $atts = shortcode_parse_atts($shortcodes[3][$short_key]);
     $tag = FrmFieldsHelper::get_shortcode_tag($shortcodes, $short_key, compact('conditional', 'foreach'));
     if (strpos($tag, '-')) {
         $switch_tags = array('post-id', 'created-at', 'updated-at', 'created-by', 'updated-by', 'parent-id');
         if (in_array($tag, $switch_tags)) {
             $tag = str_replace('-', '_', $tag);
         }
         unset($switch_tags);
     }
     $tags = array('event_date', 'entry_count', 'detaillink', 'editlink', 'deletelink', 'created_at', 'updated_at', 'created_by', 'updated_by', 'evenodd', 'post_id', 'parent_id', 'id');
     if (in_array($tag, $tags)) {
         $args['entry'] = $entry;
         $args['tag'] = $tag;
         $args['conditional'] = $conditional;
         $function = 'do_shortcode_' . $tag;
         self::$function($content, $atts, $shortcodes, $short_key, $args, $display);
         return;
     }
     $field = FrmField::getOne($tag);
     if (!$field) {
         return;
     }
     if (!$foreach && !$conditional && isset($atts['show']) && ($atts['show'] == 'field_label' || $atts['show'] == 'description')) {
         // get the field label or description and return before any other checking
         $replace_with = $atts['show'] == 'field_label' ? $field->name : $field->description;
         $content = str_replace($shortcodes[0][$short_key], $replace_with, $content);
         return;
     }
     $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
     if ($field->form_id == $entry->form_id) {
         $replace_with = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $field, $atts);
     } else {
         // get entry ids linked through repeat field or embeded form
         $child_entries = FrmProEntry::get_sub_entries($entry->id, true);
         $replace_with = FrmProEntryMetaHelper::get_sub_meta_values($child_entries, $field, $atts);
         $replace_with = FrmAppHelper::array_flatten($replace_with);
     }
     $atts['entry_id'] = $entry->id;
     $atts['entry_key'] = $entry->item_key;
     $atts['post_id'] = $entry->post_id;
     $replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field);
     self::get_file_from_atts($atts, $field, $replace_with);
     if (isset($atts['show']) && $atts['show'] == 'count') {
         $replace_with = is_array($replace_with) ? count($replace_with) : !empty($replace_with);
     } else {
         if (is_array($replace_with) && !$foreach) {
             $replace_with = FrmAppHelper::array_flatten($replace_with);
             $replace_with = implode($sep, $replace_with);
         }
     }
     if ($foreach) {
         $atts['short_key'] = $shortcodes[0][$short_key];
         $args['display'] = $display;
         self::check_conditional_shortcode($content, $replace_with, $atts, $tag, 'foreach', $args);
     } else {
         if ($conditional) {
             $atts['short_key'] = $shortcodes[0][$short_key];
             self::check_conditional_shortcode($content, $replace_with, $atts, $tag, 'if', array('field' => $field));
         } else {
             if (empty($replace_with) && $replace_with != '0') {
                 $replace_with = '';
                 if ($field->type == 'number') {
                     $replace_with = '0';
                 }
             } else {
                 $replace_with = FrmFieldsHelper::get_display_value($replace_with, $field, $atts);
             }
             self::trigger_shortcode_atts($atts, $display, $args, $replace_with);
             $content = str_replace($shortcodes[0][$short_key], $replace_with, $content);
         }
     }
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:77,代码来源:FrmProFieldsHelper.php


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