本文整理汇总了PHP中FrmField::is_option_true方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmField::is_option_true方法的具体用法?PHP FrmField::is_option_true怎么用?PHP FrmField::is_option_true使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmField
的用法示例。
在下文中一共展示了FrmField::is_option_true方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_shortcodes
public static function get_shortcodes($content, $form_id)
{
if (empty($form_id) || strpos($content, '[') === false) {
// don't continue if there are no shortcodes to check
return array(array());
}
$tagregexp = array('deletelink', 'detaillink', 'evenodd', 'get', 'entry_count', 'event_date');
$form_id = (int) $form_id;
$form_ids = array($form_id);
//get linked form ids
$fields = FrmProFormsHelper::has_repeat_field($form_id, false);
foreach ($fields as $field) {
if (FrmField::is_option_true($field, 'form_select')) {
$form_ids[] = $field->field_options['form_select'];
$tagregexp[] = $field->id;
$tagregexp[] = $field->field_key;
}
unset($field);
}
foreach ($form_ids as $form_id) {
$fields = FrmField::get_all_for_form($form_id, '', 'include');
foreach ($fields as $field) {
$tagregexp[] = $field->id;
$tagregexp[] = $field->field_key;
}
}
$tagregexp = implode('|', $tagregexp) . '|';
$tagregexp .= FrmFieldsHelper::allowed_shortcodes();
if (!ini_get('safe_mode')) {
// make sure the backtrack limit is as least at the default
$backtrack_limit = ini_get('pcre.backtrack_limit');
if ($backtrack_limit < 1000000) {
ini_set('pcre.backtrack_limit', 1000000);
}
}
preg_match_all("/\\[(if |foreach )?({$tagregexp})\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/\\])?/s", $content, $matches, PREG_PATTERN_ORDER);
// run conditional and foreach first
$new_order = $matches[0];
$move_up = array();
foreach ($new_order as $short_key => $tag) {
$conditional = preg_match('/^\\[if/s', $matches[0][$short_key]) ? true : false;
$foreach = preg_match('/^\\[foreach/s', $matches[0][$short_key]) ? true : false;
if ($conditional || $foreach) {
$move_up[$short_key] = $tag;
}
}
if (!empty($move_up)) {
$matches[0] = $move_up + $matches[0];
}
return $matches;
}
示例2: insert_extra_hidden_fields
/**
* Add confirmation and "other" hidden fields to help carry all data throughout the form
* Note: This doesn't control the HTML for fields in repeating sections
*
* @since 2.0
*
* @param array $field
* @param string $opt_key
* @param string $html_id
*/
public static function insert_extra_hidden_fields($field, $opt_key = false)
{
// If we're dealing with a repeating section, hidden fields are already taken care of
if (isset($field['original_type']) && $field['original_type'] == 'divider') {
return;
}
//If confirmation field on previous page, store value in hidden field
if (FrmField::is_option_true($field, 'conf_field') && isset($_POST['item_meta']['conf_' . $field['id']])) {
self::insert_hidden_confirmation_fields($field);
//If Other field on previous page, store value in hidden field
} else {
if (FrmField::is_option_true($field, 'other') && isset($_POST['item_meta']['other'][$field['id']])) {
self::insert_hidden_other_fields($field, $opt_key);
}
}
}
示例3: set_post_fields
public static function set_post_fields($field, $value, $errors)
{
// save file ids for later use
if ('file' == $field->type) {
global $frm_vars;
if (!isset($frm_vars['media_id'])) {
$frm_vars['media_id'] = array();
}
$frm_vars['media_id'][$field->id] = $value;
}
if (empty($value) || !FrmField::is_option_true($field, 'unique')) {
return $errors;
}
$post_form_action = FrmFormAction::get_action_for_form($field->form_id, 'wppost', 1);
if (!$post_form_action) {
return $errors;
}
// check if this is a regular post field
$post_field = array_search($field->id, $post_form_action->post_content);
$custom_field = '';
if (!$post_field) {
// check if this is a custom field
foreach ($post_form_action->post_content['post_custom_fields'] as $custom_field) {
if (isset($custom_field['field_id']) && !empty($custom_field['field_id']) && isset($custom_field['meta_name']) && !empty($custom_field['meta_name']) && $field->id == $custom_field['field_id']) {
$post_field = 'post_custom';
$custom_field = $custom_field['meta_name'];
}
}
if (!$post_field) {
return $errors;
}
}
// check for unique values in post fields
$entry_id = $_POST && isset($_POST['id']) ? $_POST['id'] : false;
$post_id = false;
if ($entry_id) {
global $wpdb;
$post_id = FrmDb::get_var($wpdb->prefix . 'frm_items', array('id' => $entry_id), 'post_id');
}
if (self::post_value_exists($post_field, $value, $post_id, $custom_field)) {
$errors['field' . $field->id] = FrmFieldsHelper::get_error_msg($field, 'unique_msg');
}
return $errors;
}
示例4: is_field_needed
/**
* Check if each field is needed in the formresults table
*
* @since 2.0.09
* @param object $f - field
* @param array $atts
* @param array $subforms_to_include
* @return boolean
*/
private static function is_field_needed($f, $atts, &$subforms_to_include)
{
if (!empty($atts['fields'])) {
if (FrmField::is_no_save_field($f->type)) {
if (FrmField::is_option_true($f, 'form_select') && (in_array($f->id, $atts['fields']) || in_array($f->field_key, $atts['fields']))) {
$subforms_to_include[] = $f->field_options['form_select'];
}
return false;
}
if (!in_array($f->form_id, $subforms_to_include) && !in_array($f->id, $atts['fields']) && !in_array($f->field_key, $atts['fields'])) {
return false;
}
} else {
if (FrmField::is_no_save_field($f->type)) {
return false;
}
}
return true;
}
示例5: esc_attr
?>
</ul>
<?php
}
} else {
if ($field['type'] == 'select') {
if (isset($field['post_field']) && $field['post_field'] == 'post_category') {
echo FrmFieldsHelper::dropdown_categories(array('name' => $field_name, 'field' => $field));
} else {
?>
<select name="<?php
echo esc_attr($field_name) . (FrmField::is_option_true($field, 'multiple') ? '[]' : '');
?>
" <?php
echo FrmField::is_option_true($field, 'size') ? 'class="auto_width"' : '';
echo FrmField::is_option_true($field, 'multiple') ? ' multiple="multiple"' : '';
?>
>
<?php
foreach ($field['options'] as $opt_key => $opt) {
$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
$selected = $field['default_value'] == $field_val || FrmFieldsHelper::get_other_val(array('opt_key', 'field')) ? ' selected="selected"' : '';
?>
<option value="<?php
echo esc_attr($field_val);
?>
"<?php
echo $selected;
?>
><?php
示例6: set_other_repeating_vals
/**
* Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
*
* @since 2.0
*
* @param object $field
* @param string|array $value
* @param array $args
*/
public static function set_other_repeating_vals($field, &$value, &$args)
{
if (!$args['parent_field_id']) {
return;
}
// Check if there are any other posted "other" values for this field
if (FrmField::is_option_true($field, 'other') && isset($_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id])) {
// Save original value
$args['temp_value'] = $value;
$args['other'] = true;
$other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
// Set the validation value now
self::set_other_validation_val($value, $other_vals, $field, $args);
}
}
示例7: add_field_class
public static function add_field_class($class, $field)
{
if ($field['type'] == 'scale' && FrmField::is_option_true($field, 'star')) {
$class .= ' star';
} else {
if ($field['type'] == 'date') {
$class .= ' frm_date';
} else {
if ($field['type'] == 'file' && FrmField::is_option_true($field, 'multiple')) {
$class .= ' frm_multiple_file';
}
}
}
// Hide the "No files selected" text if files are selected
if ($field['type'] == 'file' && !FrmField::is_option_empty($field, 'value')) {
$class .= ' frm_transparent';
}
if (!FrmAppHelper::is_admin() && FrmField::is_option_true($field, 'autocom') && ($field['type'] == 'select' || $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'select') && !empty($field['options']) && !FrmField::is_read_only($field)) {
global $frm_vars;
$frm_vars['chosen_loaded'] = true;
$class .= ' frm_chzn';
$style = FrmStylesController::get_form_style($field['form_id']);
if ($style && 'rtl' == $style->post_content['direction']) {
$class .= ' chosen-rtl';
}
}
return $class;
}
示例8: maybe_update_form_select
/**
* Switch the form_select on a repeating field or embedded form if it needs to be switched
*
* @since 2.0.16
* @param array $f
* @param array $imported
*/
private static function maybe_update_form_select(&$f, $imported)
{
if (!isset($imported['forms'])) {
return;
}
if ($f['type'] == 'form' || $f['type'] == 'divider' && FrmField::is_option_true($f['field_options'], 'repeat')) {
if (FrmField::is_option_true($f['field_options'], 'form_select')) {
$form_select = $f['field_options']['form_select'];
if (isset($imported['forms'][$form_select])) {
$f['field_options']['form_select'] = $imported['forms'][$form_select];
}
}
}
}
示例9: _e
_e('Dark', 'formidable');
?>
</option>
</select>
</td>
</tr>
<?php
}
?>
<?php
do_action('frm_' . $field['type'] . '_field_options_form', $field, $display, $values);
do_action('frm_field_options_form', $field, $display, $values);
if ($display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field']) {
?>
<tr class="frm_validation_msg <?php
echo $display['invalid'] || $field['required'] || FrmField::is_option_true($field, 'unique') || FrmField::is_option_true($field, 'conf_field') ? '' : 'frm_hidden';
?>
">
<td colspan="2">
<div class="menu-settings">
<h3 class="frm_no_bg"><?php
_e('Validation', 'formidable');
?>
</h3>
<div class="frm_validation_box">
<?php
if ($display['required']) {
?>
<p class="frm_required_details<?php
echo esc_attr($field['id'] . ($field['required'] ? '' : ' frm_hidden'));
示例10: get_multi_opts
public static function get_multi_opts($value, $field)
{
if (!$field || empty($value) || in_array($value, (array) $field->options)) {
return $value;
}
if ($field->type != 'checkbox' && $field->type != 'select') {
return $value;
}
if ($field->type == 'select' && !FrmField::is_option_true($field, 'multiple')) {
return $value;
}
$checked = is_array($value) ? $value : maybe_unserialize($value);
if (!is_array($checked)) {
$checked = explode(',', $checked);
}
if (!empty($checked) && count($checked) > 1) {
$value = array_map('trim', $checked);
}
unset($checked);
return $value;
}
示例11: get_count_values
/**
* Get values for graph with only one field and no x-axis
*
* @since 2.0
*
* @param array $values
* @param array $labels
* @param array $tooltips
* @param boolean $pie - for pie graph
* @param object $field
* @param array $args
*/
public static function get_count_values(&$values, &$labels, &$tooltips, &$pie, $field, $args)
{
// Get all inputs for this field
$inputs = self::get_generic_inputs($field, $args);
if (!$inputs) {
return;
}
// Get counts for each value
$temp_values = array_count_values(array_map('strtolower', $inputs));
// Get displayed values ( for DFE, separate values, or Other val )
if ($field->type == 'data' || $field->field_options['separate_value'] || FrmField::is_option_true($field, 'other')) {
self::get_displayed_values($temp_values, $field);
} else {
if ($field->type == 'user_id') {
self::get_user_id_values($values, $labels, $tooltips, $pie, $temp_values, $field);
return;
}
}
// Sort values by order of field options
if ($args['x_order'] == 'field_opts' && in_array($field->type, array('radio', 'checkbox', 'select', 'data'))) {
self::field_opt_order_vals($temp_values, $field);
// Sort by descending count if x_order is set to 'desc'
} else {
if ($args['x_order'] == 'desc') {
arsort($temp_values);
// Sort alphabetically by default
} else {
ksort($temp_values);
}
}
// Get slice of array
if ($args['limit']) {
$temp_values = array_slice($temp_values, 0, $args['limit']);
}
// Capitalize the first letter of each value
foreach ($temp_values as $val => $count) {
$new_val = ucwords($val);
$labels[] = $new_val;
$values[] = $count;
}
}
示例12: maybe_unserialize
<?php
if (is_array($field['options'])) {
if (!isset($field['value'])) {
$field['value'] = maybe_unserialize($field['default_value']);
}
$star = FrmField::is_option_true($field, 'star');
foreach ($field['options'] as $opt_key => $opt) {
$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
$last = end($field['options']) == $opt ? ' frm_last' : '';
if (!$star) {
?>
<div class="frm_scale <?php
echo esc_attr($last);
?>
"><label for="<?php
echo esc_attr($html_id);
?>
-<?php
echo esc_attr($opt_key);
?>
"><?php
}
?>
<input type="radio" name="<?php
echo esc_attr($field_name);
?>
" id="<?php
echo esc_attr($html_id . '-' . $opt_key);
?>
" value="<?php
示例13: flatten_multi_file_upload
/**
* Flatten multi-dimensional array for multi-file upload fields
* @since 2.0.9
*/
public static function flatten_multi_file_upload($field, &$val)
{
if ($field->type == 'file' && FrmField::is_option_true($field, 'multiple')) {
$val = FrmAppHelper::array_flatten($val);
}
}
示例14: get_other_val
/**
* Get value that belongs in "Other" text box
*
* @since 2.0.6
*
* @param array $args
*/
public static function get_other_val($args)
{
$defaults = array('opt_key' => 0, 'field' => array(), 'parent' => false, 'pointer' => false);
$args = wp_parse_args($args, $defaults);
$opt_key = $args['opt_key'];
$field = $args['field'];
$parent = $args['parent'];
$pointer = $args['pointer'];
$other_val = '';
// If option is an "other" option and there is a value set for this field,
// check if the value belongs in the current "Other" option text field
if (!FrmFieldsHelper::is_other_opt($opt_key) || !FrmField::is_option_true($field, 'value')) {
return $other_val;
}
// Check posted vals before checking saved values
// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
if ($parent && isset($_POST['item_meta'][$parent][$pointer]['other'][$field['id']])) {
if (FrmField::is_field_with_multiple_values($field)) {
$other_val = isset($_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key]) ? sanitize_text_field($_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key]) : '';
} else {
$other_val = sanitize_text_field($_POST['item_meta'][$parent][$pointer]['other'][$field['id']]);
}
return $other_val;
} else {
if (isset($field['id']) && isset($_POST['item_meta']['other'][$field['id']])) {
// For normal fields
if (FrmField::is_field_with_multiple_values($field)) {
$other_val = isset($_POST['item_meta']['other'][$field['id']][$opt_key]) ? sanitize_text_field($_POST['item_meta']['other'][$field['id']][$opt_key]) : '';
} else {
$other_val = sanitize_text_field($_POST['item_meta']['other'][$field['id']]);
}
return $other_val;
}
}
// For checkboxes
if ($field['type'] == 'checkbox' && is_array($field['value'])) {
// Check if there is an "other" val in saved value and make sure the
// "other" val is not equal to the Other checkbox option
if (isset($field['value'][$opt_key]) && $field['options'][$opt_key] != $field['value'][$opt_key]) {
$other_val = $field['value'][$opt_key];
}
} else {
/**
* For radio buttons and dropdowns
* Check if saved value equals any of the options. If not, set it as the other value.
*/
foreach ($field['options'] as $opt_key => $opt_val) {
$temp_val = is_array($opt_val) ? $opt_val['value'] : $opt_val;
// Multi-select dropdowns - key is not preserved
if (is_array($field['value'])) {
$o_key = array_search($temp_val, $field['value']);
if (isset($field['value'][$o_key])) {
unset($field['value'][$o_key], $o_key);
}
} else {
if ($temp_val == $field['value']) {
// For radio and regular dropdowns
return '';
} else {
$other_val = $field['value'];
}
}
unset($opt_key, $opt_val, $temp_val);
}
// For multi-select dropdowns only
if (is_array($field['value']) && !empty($field['value'])) {
$other_val = reset($field['value']);
}
}
return $other_val;
}
示例15: get_all_metas_for_field
/**
* Get metas for post or non-post fields
*
* @since 2.0
*/
public static function get_all_metas_for_field($field, $args = array())
{
global $wpdb;
$query = array();
if (!FrmField::is_option_true($field, 'post_field')) {
// If field is not a post field
$get_field = 'em.meta_value';
$get_table = $wpdb->prefix . 'frm_item_metas em INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)';
$query['em.field_id'] = $field->id;
$query['e.is_draft'] = 0;
} else {
if ($field->field_options['post_field'] == 'post_custom') {
// If field is a custom field
$get_field = 'pm.meta_value';
$get_table = $wpdb->postmeta . ' pm INNER JOIN ' . $wpdb->prefix . 'frm_items e ON pm.post_id=e.post_id';
$query['pm.meta_key'] = $field->field_options['custom_field'];
// Make sure to only get post metas that are linked to this form
$query['e.form_id'] = $field->form_id;
} else {
if ($field->field_options['post_field'] != 'post_category') {
// If field is a non-category post field
$get_field = 'p.' . sanitize_title($field->field_options['post_field']);
$get_table = $wpdb->posts . ' p INNER JOIN ' . $wpdb->prefix . 'frm_items e ON p.ID=e.post_id';
// Make sure to only get post metas that are linked to this form
$query['e.form_id'] = $field->form_id;
} else {
// If field is a category field
//TODO: Make this work
return array();
//$field_options = FrmProFieldsHelper::get_category_options( $field );
}
}
}
// Add queries for additional args
self::add_meta_query($query, $args);
// Get the metas
$metas = FrmDb::get_col($get_table, $query, $get_field);
// Maybe unserialize
foreach ($metas as $k => $v) {
$metas[$k] = maybe_unserialize($v);
unset($k, $v);
}
// Strip slashes
$metas = stripslashes_deep($metas);
return $metas;
}