本文整理汇总了PHP中FrmField::is_option_empty方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmField::is_option_empty方法的具体用法?PHP FrmField::is_option_empty怎么用?PHP FrmField::is_option_empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmField
的用法示例。
在下文中一共展示了FrmField::is_option_empty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: migrate_to_6
private function migrate_to_6()
{
global $wpdb;
$no_save = array_merge(FrmField::no_save_fields(), array('form', 'hidden', 'user_id'));
$fields = FrmDb::get_results($this->fields, array('type NOT' => $no_save), 'id, field_options');
$default_html = <<<DEFAULT_HTML
<div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
<label class="frm_pos_[label_position]">[field_name]
<span class="frm_required">[required_label]</span>
</label>
[input]
[if description]<div class="frm_description">[description]</div>[/if description]
</div>
DEFAULT_HTML;
$old_default_html = <<<DEFAULT_HTML
<div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
<label class="frm_pos_[label_position]">[field_name]
<span class="frm_required">[required_label]</span>
</label>
[input]
[if description]<p class="frm_description">[description]</p>[/if description]
</div>
DEFAULT_HTML;
$new_default_html = FrmFieldsHelper::get_default_html('text');
foreach ($fields as $field) {
$field->field_options = maybe_unserialize($field->field_options);
if (!FrmField::is_option_empty($field, 'custom_html') || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html) {
$field->field_options['custom_html'] = $new_default_html;
$wpdb->update($this->fields, array('field_options' => maybe_serialize($field->field_options)), array('id' => $field->id));
}
unset($field);
}
unset($default_html, $old_default_html, $fields);
}
示例2: add_shortcodes_to_html
private static function add_shortcodes_to_html($field, array &$add_html)
{
if (FrmField::is_option_empty($field, 'shortcodes')) {
return;
}
foreach ($field['shortcodes'] as $k => $v) {
if ('opt' === $k) {
continue;
}
if (is_numeric($k) && strpos($v, '=')) {
$add_html[] = $v;
} else {
if (!empty($k) && isset($add_html[$k])) {
$add_html[$k] = str_replace($k . '="', $k . '="' . $v, $add_html[$k]);
} else {
$add_html[$k] = $k . '="' . esc_attr($v) . '"';
}
}
unset($k, $v);
}
}
示例3: phone_format
public static function phone_format($field)
{
$default_format = '^((\\+\\d{1,3}(-|.| )?\\(?\\d\\)?(-| |.)?\\d{1,5})|(\\(?\\d{2,6}\\)?))(-|.| )?(\\d{3,4})(-|.| )?(\\d{4})(( x| ext)\\d{1,5}){0,1}$';
if (FrmField::is_option_empty($field, 'format')) {
$pattern = $default_format;
} else {
$pattern = FrmField::get_option($field, 'format');
}
$pattern = apply_filters('frm_phone_pattern', $pattern, $field);
// Create a regexp if format is not already a regexp
if (strpos($pattern, '^') !== 0) {
$pattern = self::create_regular_expression_from_format($pattern);
}
$pattern = '/' . $pattern . '/';
return $pattern;
}
示例4:
public static function &is_field_visible_to_user($field)
{
$visible = true;
if (FrmField::is_option_empty($field, 'admin_only')) {
return $visible;
}
if ($field->field_options['admin_only'] == 1) {
$field->field_options['admin_only'] = 'administrator';
}
if ($field->field_options['admin_only'] == 'loggedout' && is_user_logged_in() || $field->field_options['admin_only'] == 'loggedin' && !is_user_logged_in() || !in_array($field->field_options['admin_only'], array('loggedout', 'loggedin', '')) && !FrmAppHelper::user_has_permission($field->field_options['admin_only'])) {
$visible = false;
}
return $visible;
}
示例5: validate_phone_field
public static function validate_phone_field(&$errors, $field, $value)
{
if ($field->type != 'phone') {
return;
}
$default_format = '^((\\+\\d{1,3}(-|.| )?\\(?\\d\\)?(-| |.)?\\d{1,5})|(\\(?\\d{2,6}\\)?))(-|.| )?(\\d{3,4})(-|.| )?(\\d{4})(( x| ext)\\d{1,5}){0,1}$';
$pattern = !FrmField::is_option_empty($field, 'format') ? $field->field_options['format'] : $default_format;
$pattern = apply_filters('frm_phone_pattern', $pattern, $field);
//check if format is already a regular expression
if (strpos($pattern, '^') !== 0) {
//if not, create a regular expression
$pattern = preg_replace('/\\d/', '\\d', preg_quote($pattern));
$pattern = str_replace('a', '[a-z]', $pattern);
$pattern = str_replace('A', '[A-Z]', $pattern);
$pattern = str_replace('/', '\\/', $pattern);
$pattern = '/^' . $pattern . '$/';
} else {
$pattern = '/' . $pattern . '/';
}
if (!preg_match($pattern, $value)) {
$errors['field' . $field->temp_id] = FrmFieldsHelper::get_error_msg($field, 'invalid');
}
}
示例6: 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;
}
示例7: phone_format
public static function phone_format($field)
{
$default_format = '^((\\+\\d{1,3}(-|.| )?\\(?\\d\\)?(-| |.)?\\d{1,5})|(\\(?\\d{2,6}\\)?))(-|.| )?(\\d{3,4})(-|.| )?(\\d{4})(( x| ext)\\d{1,5}){0,1}$';
if (FrmField::is_option_empty($field, 'format')) {
$pattern = $default_format;
} else {
$pattern = FrmField::get_option($field, 'format');
}
$pattern = apply_filters('frm_phone_pattern', $pattern, $field);
//check if format is already a regular expression
if (strpos($pattern, '^') !== 0) {
//if not, create a regular expression
$pattern = preg_replace('/\\d/', '\\d', preg_quote($pattern));
$pattern = str_replace('a', '[a-z]', $pattern);
$pattern = str_replace('A', '[A-Z]', $pattern);
$pattern = str_replace('*', 'w', $pattern);
$pattern = str_replace('/', '\\/', $pattern);
if (strpos($pattern, '\\?') !== false) {
$parts = explode('\\?', $pattern);
$pattern = '';
foreach ($parts as $part) {
if (empty($pattern)) {
$pattern .= $part;
} else {
$pattern .= '(' . $part . ')?';
}
}
}
$pattern = '^' . $pattern . '$';
}
$pattern = '/' . $pattern . '/';
return $pattern;
}