本文整理汇总了PHP中FrmFieldsHelper::replace_shortcodes方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmFieldsHelper::replace_shortcodes方法的具体用法?PHP FrmFieldsHelper::replace_shortcodes怎么用?PHP FrmFieldsHelper::replace_shortcodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmFieldsHelper
的用法示例。
在下文中一共展示了FrmFieldsHelper::replace_shortcodes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_nonce_field
<?php
wp_nonce_field('frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id);
?>
<?php
if (isset($id)) {
?>
<input type="hidden" name="id" value="<?php
echo esc_attr($id);
?>
" /><?php
}
if ($values['fields']) {
foreach ($values['fields'] as $field) {
if (apply_filters('frm_show_normal_field_type', true, $field['type'])) {
echo FrmFieldsHelper::replace_shortcodes($field['custom_html'], $field, $errors, $form);
} else {
do_action('frm_show_other_field_type', $field, $form, array('action' => $form_action));
}
do_action('frm_get_field_scripts', $field, $form, $form->id);
}
}
$frm_settings = FrmAppHelper::get_settings();
if (FrmAppHelper::is_admin()) {
?>
<div class="frm_form_field form-field">
<label class="frm_primary_label"><?php
_e('Entry Key', 'formidable');
?>
</label>
<input type="text" name="item_key" value="<?php
示例2: esc_attr
?>
" value="<?php
echo esc_attr($field['value']);
?>
"/>
<?php
}
} else {
if ($field['type'] == 'user_id') {
global $user_ID;
echo '<input type="hidden" id="field_' . $field['field_key'] . '" name="' . $field_name . '" value="' . (is_numeric($field['value']) ? $field['value'] : ($user_ID ? $user_ID : '')) . '"/>' . "\n";
} else {
if ($field['type'] == 'break') {
global $frm_prev_page, $frm_field;
if (isset($frm_prev_page[$field['form_id']]) and $frm_prev_page[$field['form_id']] == $field['field_order']) {
echo FrmFieldsHelper::replace_shortcodes($field['custom_html'], $field, array(), $form);
$previous_fields = $frm_field->getAll("fi.type not in ('divider','captcha','break','html') and fi.form_id={$field['form_id']} and fi.field_order < {$field['field_order']}");
foreach ($previous_fields as $prev) {
if (isset($_POST['item_meta'][$prev->id])) {
if (is_array($_POST['item_meta'][$prev->id])) {
foreach ($_POST['item_meta'][$prev->id] as $checked) {
$checked = apply_filters('frm_hidden_value', $checked, (array) $prev);
echo '<input type="hidden" name="item_meta[' . $prev->id . '][]" value="' . $checked . '"/>' . "\n";
}
} else {
?>
<input type="<?php
echo apply_filters('frm_paged_field_type', 'hidden', array('field' => $prev));
?>
" id="field_<?php
echo $prev->field_key;
示例3: replace_html_shortcodes
public static function replace_html_shortcodes($html, $field, $atts)
{
if ('divider' == $field['type']) {
global $frm_vars;
$html = str_replace(array('frm_none_container', 'frm_hidden_container', 'frm_top_container', 'frm_left_container', 'frm_right_container'), '', $html);
if (isset($frm_vars['collapse_div']) && $frm_vars['collapse_div']) {
$html = "</div>\n" . $html;
$frm_vars['collapse_div'] = false;
}
if (isset($frm_vars['div']) && $frm_vars['div'] && $frm_vars['div'] != $field['id']) {
// close the div if it's from a different section
$html = "</div>\n" . $html;
$frm_vars['div'] = false;
}
if (FrmField::is_option_true($field, 'slide')) {
$trigger = ' frm_trigger';
$collapse_div = '<div class="frm_toggle_container" style="display:none;">';
} else {
$trigger = $collapse_div = '';
}
if (FrmField::is_option_true($field, 'repeat')) {
$errors = isset($atts['errors']) ? $atts['errors'] : array();
$field_name = 'item_meta[' . $field['id'] . ']';
$html_id = FrmFieldsHelper::get_html_id($field);
$frm_settings = FrmAppHelper::get_settings();
ob_start();
include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php';
$input = ob_get_contents();
ob_end_clean();
if (FrmField::is_option_true($field, 'slide')) {
$input = $collapse_div . $input . '</div>';
}
$html = str_replace('[collapse_this]', $input, $html);
} else {
self::remove_close_div($field, $html);
if (strpos($html, '[collapse_this]') !== false) {
$html = str_replace('[collapse_this]', $collapse_div, $html);
// indicate that a second div is open
if (!empty($collapse_div)) {
$frm_vars['collapse_div'] = $field['id'];
}
}
}
self::maybe_add_collapse_icon($trigger, $field, $html);
$html = str_replace('[collapse_class]', $trigger, $html);
} else {
if ($field['type'] == 'html') {
if (apply_filters('frm_use_wpautop', true)) {
$html = wpautop($html);
}
$html = apply_filters('frm_get_default_value', $html, (object) $field, false);
$html = do_shortcode($html);
} else {
if (FrmField::is_option_true($field, 'conf_field')) {
//Add confirmation field
//Get confirmation field ready for replace_shortcodes function
$conf_html = $field['custom_html'];
$conf_field = $field;
$conf_field['id'] = 'conf_' . $field['id'];
$conf_field['name'] = __('Confirm', 'formidable') . ' ' . $field['name'];
$conf_field['description'] = $field['conf_desc'];
$conf_field['field_key'] = 'conf_' . $field['field_key'];
if ($conf_field['classes']) {
$conf_field['classes'] = str_replace('first_', '', $conf_field['classes']);
} else {
if ($conf_field['conf_field'] == 'inline') {
$conf_field['classes'] = ' frm_half';
}
}
//Prevent loop
$conf_field['conf_field'] = 'stop';
//If inside of repeating section
$args = array();
if (isset($atts['section_id'])) {
$args['field_name'] = preg_replace('/\\[' . $field['id'] . '\\]$/', '', $atts['field_name']);
$args['field_name'] = $args['field_name'] . '[conf_' . $field['id'] . ']';
$args['field_id'] = 'conf_' . $atts['field_id'];
$args['field_plus_id'] = $atts['field_plus_id'];
$args['section_id'] = $atts['section_id'];
}
// Filter default value/placeholder text
$field['conf_input'] = apply_filters('frm_get_default_value', $field['conf_input'], (object) $field, false);
//If clear on focus, set default value. Otherwise, set value.
if ($conf_field['clear_on_focus'] == 1) {
$conf_field['default_value'] = $field['conf_input'];
$conf_field['value'] = '';
} else {
$conf_field['value'] = $field['conf_input'];
}
//If going back and forth between pages, keep value in confirmation field
if (isset($_POST['item_meta'])) {
$temp_args = array();
if (isset($atts['section_id'])) {
$temp_args = array('parent_field_id' => $atts['section_id'], 'key_pointer' => str_replace('-', '', $atts['field_plus_id']));
}
FrmEntriesHelper::get_posted_value($conf_field['id'], $conf_field['value'], $temp_args);
}
//Replace shortcodes
$conf_html = FrmFieldsHelper::replace_shortcodes($conf_html, $conf_field, '', '', $args);
//Add a couple of classes
//.........这里部分代码省略.........
示例4: repeat_field_set
public static function repeat_field_set($field_name, $args = array())
{
$defaults = array('i' => 0, 'entry_id' => false, 'form' => false, 'fields' => array(), 'errors' => array(), 'parent_field' => 0, 'repeat' => 0, 'row_count' => false, 'value' => '', 'field_name' => '');
$args = wp_parse_args($args, $defaults);
if (empty($args['parent_field'])) {
return;
}
if (is_numeric($args['parent_field'])) {
$args['parent_field'] = (array) FrmField::getOne($args['parent_field']);
$args['parent_field']['format'] = isset($args['parent_field']['field_options']['format']) ? $args['parent_field']['field_options']['format'] : '';
}
FrmForm::maybe_get_form($args['form']);
if (empty($args['fields'])) {
$args['fields'] = FrmField::get_all_for_form($args['form']->id);
}
$values = array();
if ($args['fields']) {
// Get the ID of the form that houses the embedded form or repeating section
$parent_form_id = $args['parent_field']['form_id'];
if (empty($args['entry_id'])) {
$values = FrmEntriesHelper::setup_new_vars($args['fields'], $args['form'], false, array('parent_form_id' => $parent_form_id));
} else {
$entry = FrmEntry::getOne($args['entry_id'], true);
if ($entry && $entry->form_id == $args['form']->id) {
$values = FrmAppHelper::setup_edit_vars($entry, 'entries', $args['fields'], false, array(), array('parent_form_id' => $parent_form_id));
} else {
return;
}
}
}
$format = isset($args['parent_field']['format']) ? $args['parent_field']['format'] : '';
$end = false;
$count = 0;
foreach ($values['fields'] as $subfield) {
if ('end_divider' == $subfield['type']) {
$end = $subfield;
} else {
if (!in_array($subfield['type'], array('hidden', 'user_id'))) {
if (isset($subfield['conf_field']) && $subfield['conf_field']) {
$count = $count + 2;
} else {
$count++;
}
}
}
unset($subfield);
}
if ($args['repeat']) {
$count++;
}
$classes = array(2 => 'half', 3 => 'third', 4 => 'fourth', 5 => 'fifth', 6 => 'sixth', 7 => 'seventh', 8 => 'eighth');
$field_class = !empty($format) && isset($classes[$count]) ? $classes[$count] : '';
echo '<div id="frm_section_' . $args['parent_field']['id'] . '-' . $args['i'] . '" class="frm_repeat_' . (empty($format) ? 'sec' : $format) . ' frm_repeat_' . $args['parent_field']['id'] . ($args['row_count'] === 0 ? ' frm_first_repeat' : '') . '">' . "\n";
self::add_hidden_repeat_entry_id($args);
self::add_default_item_meta_field($args);
$label_pos = 'top';
$field_num = 1;
foreach ($values['fields'] as $subfield) {
$subfield_name = $field_name . '[' . $args['i'] . '][' . $subfield['id'] . ']';
$subfield_plus_id = '-' . $args['i'];
$subfield_id = $subfield['id'] . '-' . $args['parent_field']['id'] . $subfield_plus_id;
if ($args['parent_field'] && !empty($args['parent_field']['value']) && isset($args['parent_field']['value']['form']) && isset($args['parent_field']['value'][$args['i']]) && isset($args['parent_field']['value'][$args['i']][$subfield['id']])) {
// this is a posted value from moving between pages, so set the POSTed value
$subfield['value'] = $args['parent_field']['value'][$args['i']][$subfield['id']];
}
if (!empty($field_class)) {
if (1 == $field_num) {
$subfield['classes'] .= ' frm_first frm_' . $field_class;
} else {
$subfield['classes'] .= ' frm_' . $field_class;
}
}
$field_num++;
if ('top' == $label_pos && in_array($subfield['label'], array('top', 'hidden', ''))) {
// add placeholder label if repeating
$label_pos = 'hidden';
}
$field_args = array('field_name' => $subfield_name, 'field_id' => $subfield_id, 'field_plus_id' => $subfield_plus_id, 'section_id' => $args['parent_field']['id']);
if (apply_filters('frm_show_normal_field_type', true, $subfield['type'])) {
echo FrmFieldsHelper::replace_shortcodes($subfield['custom_html'], $subfield, $args['errors'], $args['form'], $field_args);
} else {
do_action('frm_show_other_field_type', $subfield, $args['form'], $field_args);
}
unset($subfield_name, $subfield_id);
do_action('frm_get_field_scripts', $subfield, $args['form'], $args['parent_field']['form_id']);
}
if (!$args['repeat']) {
// Close frm_repeat div
echo '</div>' . "\n";
return;
}
$args['format'] = $format;
$args['label_pos'] = $label_pos;
$args['field_class'] = $field_class;
echo self::repeat_buttons($args, $end);
// Close frm_repeat div
echo '</div>' . "\n";
}