本文整理汇总了PHP中wpcf7_get_hangover函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf7_get_hangover函数的具体用法?PHP wpcf7_get_hangover怎么用?PHP wpcf7_get_hangover使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf7_get_hangover函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf7dtx_dynamictext_shortcode_handler
function wpcf7dtx_dynamictext_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type, 'wpcf7dtx-dynamictext');
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$atts['size'] = $tag->get_size_option('40');
$atts['maxlength'] = $tag->get_maxlength_option();
$atts['minlength'] = $tag->get_minlength_option();
if ($atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength']) {
unset($atts['maxlength'], $atts['minlength']);
}
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
if ($tag->has_option('readonly')) {
$atts['readonly'] = 'readonly';
}
if ($tag->is_required()) {
$atts['aria-required'] = 'true';
}
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
$value = (string) reset($tag->values);
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$atts['placeholder'] = $value;
$value = '';
}
$value = $tag->get_default_option($value);
$value = wpcf7_get_hangover($tag->name, $value);
$scval = do_shortcode('[' . $value . ']');
if ($scval != '[' . $value . ']') {
$value = esc_attr($scval);
}
$atts['value'] = $value;
//echo '<pre>'; print_r( $tag ); echo '</pre>';
switch ($tag->basetype) {
case 'dynamictext':
$atts['type'] = 'text';
break;
case 'dynamichidden':
$atts['type'] = 'hidden';
break;
default:
$atts['type'] = 'text';
break;
}
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>', sanitize_html_class($tag->name), $atts, $validation_error);
return $html;
}
示例2: quai10_text_shortcode_handler
function quai10_text_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type, 'wpcf7-text');
if (in_array($tag->basetype, array('email', 'url', 'tel'))) {
$class .= ' wpcf7-validates-as-' . $tag->basetype;
}
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$atts['size'] = $tag->get_size_option('40');
$atts['maxlength'] = $tag->get_maxlength_option();
$atts['minlength'] = $tag->get_minlength_option();
if ($atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength']) {
unset($atts['maxlength'], $atts['minlength']);
}
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
if ($tag->has_option('readonly')) {
$atts['readonly'] = 'readonly';
}
if ($tag->is_required()) {
$atts['aria-required'] = 'true';
$atts['required'] = 'true';
}
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
$value = (string) reset($tag->values);
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$atts['placeholder'] = $value;
$value = '';
}
$value = $tag->get_default_option($value);
$value = wpcf7_get_hangover($tag->name, $value);
$atts['value'] = $value;
if (wpcf7_support_html5()) {
$atts['type'] = $tag->basetype;
} else {
$atts['type'] = 'text';
}
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<input class="%1$s" %2$s />%3$s', sanitize_html_class($tag->name), $atts, $validation_error);
return $html;
}
示例3: wpcf7_number_shortcode_handler
function wpcf7_number_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type);
$class .= ' wpcf7-validates-as-number';
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
$atts['min'] = $tag->get_option('min', 'signed_int', true);
$atts['max'] = $tag->get_option('max', 'signed_int', true);
$atts['step'] = $tag->get_option('step', 'int', true);
if ($tag->has_option('readonly')) {
$atts['readonly'] = 'readonly';
}
if ($tag->is_required()) {
$atts['aria-required'] = 'true';
}
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
$value = (string) reset($tag->values);
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$atts['placeholder'] = $value;
$value = '';
}
$value = $tag->get_default_option($value);
$value = wpcf7_get_hangover($tag->name, $value);
$atts['value'] = $value;
if (wpcf7_support_html5()) {
$atts['type'] = $tag->basetype;
} else {
$atts['type'] = 'text';
}
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>', sanitize_html_class($tag->name), $atts, $validation_error);
return $html;
}
示例4: wpcf7_textarea_shortcode_handler
function wpcf7_textarea_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type);
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$atts['cols'] = $tag->get_cols_option('40');
$atts['rows'] = $tag->get_rows_option('10');
$atts['maxlength'] = $tag->get_maxlength_option();
$atts['minlength'] = $tag->get_minlength_option();
if ($atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength']) {
unset($atts['maxlength'], $atts['minlength']);
}
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
$atts['autocomplete'] = $tag->get_option('autocomplete', '[-0-9a-zA-Z]+', true);
if ($tag->has_option('readonly')) {
$atts['readonly'] = 'readonly';
}
if ($tag->is_required()) {
$atts['aria-required'] = 'true';
}
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
$value = empty($tag->content) ? (string) reset($tag->values) : $tag->content;
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$atts['placeholder'] = $value;
$value = '';
}
$value = $tag->get_default_option($value);
$value = wpcf7_get_hangover($tag->name, $value);
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<span class="wpcf7-form-control-wrap %1$s"><textarea %2$s>%3$s</textarea>%4$s</span>', sanitize_html_class($tag->name), $atts, esc_textarea($value), $validation_error);
return $html;
}
示例5: wpcf7_robottrap_shortcode_handler
function wpcf7_robottrap_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
// default field name
if (empty($tag->name)) {
$tag->name = 'email-verify';
}
// per field errors
$validation_error = wpcf7_get_validation_error($tag->name);
// add wpcf7 specific classes
$class = wpcf7_form_controls_class('text');
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$atts['size'] = $tag->get_size_option('40');
$atts['maxlength'] = $tag->get_maxlength_option();
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
/**
* Robots may look for the word "hidden".
*
* @ignore Commented out.
*/
//$atts['aria-hidden'] = 'true';
$value = (string) reset($tag->values);
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$atts['placeholder'] = $value;
$value = '';
} elseif ('' === $value) {
$value = $tag->get_default_option();
}
$value = wpcf7_get_hangover($tag->name, $value);
$atts['value'] = $value;
$atts['type'] = 'text';
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<span class="wpcf7-form-control-wrap %s"><input %s />%s</span>', sanitize_html_class($tag->name), $atts, $validation_error);
return $html;
}
示例6: wpcf7_select_shortcode_handler
function wpcf7_select_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type);
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
if ($tag->is_required()) {
$atts['aria-required'] = 'true';
}
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
$defaults = array();
if ($matches = $tag->get_first_match_option('/^default:([0-9_]+)$/')) {
$defaults = explode('_', $matches[1]);
}
$multiple = $tag->has_option('multiple');
$include_blank = $tag->has_option('include_blank');
$first_as_label = $tag->has_option('first_as_label');
$values = $tag->values;
$labels = $tag->labels;
if ($data = (array) $tag->get_data_option()) {
$values = array_merge($values, array_values($data));
$labels = array_merge($labels, array_values($data));
}
$empty_select = empty($values);
if ($empty_select || $include_blank) {
array_unshift($labels, '---');
array_unshift($values, '');
} elseif ($first_as_label) {
$values[0] = '';
}
$html = '';
$hangover = wpcf7_get_hangover($tag->name);
foreach ($values as $key => $value) {
$selected = false;
if ($hangover) {
if ($multiple) {
$selected = in_array(esc_sql($value), (array) $hangover);
} else {
$selected = $hangover == esc_sql($value);
}
} else {
if (!$empty_select && in_array($key + 1, (array) $defaults)) {
$selected = true;
}
}
$item_atts = array('value' => $value, 'selected' => $selected ? 'selected' : '');
$item_atts = wpcf7_format_atts($item_atts);
$label = isset($labels[$key]) ? $labels[$key] : $value;
$html .= sprintf('<option %1$s>%2$s</option>', $item_atts, esc_html($label));
}
if ($multiple) {
$atts['multiple'] = 'multiple';
}
$atts['name'] = $tag->name . ($multiple ? '[]' : '');
$atts = wpcf7_format_atts($atts);
$html = sprintf('<span class="wpcf7-form-control-wrap %1$s"><select %2$s>%3$s</select>%4$s</span>', sanitize_html_class($tag->name), $atts, $html, $validation_error);
return $html;
}
示例7: wpcf7_checkbox_shortcode_handler
function wpcf7_checkbox_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type);
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
$label_first = $tag->has_option('label_first');
$use_label_element = $tag->has_option('use_label_element');
$exclusive = $tag->has_option('exclusive');
$free_text = $tag->has_option('free_text');
$multiple = false;
if ('checkbox' == $tag->basetype) {
$multiple = !$exclusive;
} else {
// radio
$exclusive = false;
}
if ($exclusive) {
$class .= ' wpcf7-exclusive-checkbox';
}
$atts = array();
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$tabindex = $tag->get_option('tabindex', 'int', true);
if (false !== $tabindex) {
$tabindex = absint($tabindex);
}
$html = '';
$count = 0;
$values = (array) $tag->values;
$labels = (array) $tag->labels;
if ($data = (array) $tag->get_data_option()) {
if ($free_text) {
$values = array_merge(array_slice($values, 0, -1), array_values($data), array_slice($values, -1));
$labels = array_merge(array_slice($labels, 0, -1), array_values($data), array_slice($labels, -1));
} else {
$values = array_merge($values, array_values($data));
$labels = array_merge($labels, array_values($data));
}
}
$defaults = array();
$default_choice = $tag->get_default_option(null, 'multiple=1');
foreach ($default_choice as $value) {
$key = array_search($value, $values, true);
if (false !== $key) {
$defaults[] = (int) $key + 1;
}
}
if ($matches = $tag->get_first_match_option('/^default:([0-9_]+)$/')) {
$defaults = array_merge($defaults, explode('_', $matches[1]));
}
$defaults = array_unique($defaults);
$hangover = wpcf7_get_hangover($tag->name, $multiple ? array() : '');
foreach ($values as $key => $value) {
$class = 'wpcf7-list-item';
$checked = false;
if ($hangover) {
if ($multiple) {
$checked = in_array(esc_sql($value), (array) $hangover);
} else {
$checked = $hangover == esc_sql($value);
}
} else {
$checked = in_array($key + 1, (array) $defaults);
}
if (isset($labels[$key])) {
$label = $labels[$key];
} else {
$label = $value;
}
$item_atts = array('type' => $tag->basetype, 'name' => $tag->name . ($multiple ? '[]' : ''), 'value' => $value, 'checked' => $checked ? 'checked' : '', 'tabindex' => $tabindex ? $tabindex : '');
$item_atts = wpcf7_format_atts($item_atts);
if ($label_first) {
// put label first, input last
$item = sprintf('<span class="wpcf7-list-item-label">%1$s</span> <input %2$s />', esc_html($label), $item_atts);
} else {
$item = sprintf('<input %2$s /> <span class="wpcf7-list-item-label">%1$s</span>', esc_html($label), $item_atts);
}
if ($use_label_element) {
$item = '<label>' . $item . '</label>';
}
if (false !== $tabindex) {
$tabindex += 1;
}
$count += 1;
if (1 == $count) {
$class .= ' first';
}
if (count($values) == $count) {
// last round
$class .= ' last';
if ($free_text) {
$free_text_name = sprintf('_wpcf7_%1$s_free_text_%2$s', $tag->basetype, $tag->name);
$free_text_atts = array('name' => $free_text_name, 'class' => 'wpcf7-free-text', 'tabindex' => $tabindex ? $tabindex : '');
if (wpcf7_is_posted() && isset($_POST[$free_text_name])) {
//.........这里部分代码省略.........
示例8: wpcf7_hidden_shortcode_handler
function wpcf7_hidden_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type, 'wpcf7-hidden');
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
$class .= ' wpcf7-hidden';
if ('hidden*' === $tag->type) {
$class .= ' wpcf7-validates-as-required';
}
$value = (string) reset($tag->values);
$placeholder = '';
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$placeholder = $value;
$value = '';
}
$default_value = $tag->get_default_option($value);
$value = contact_form_7_hidden_fields_fill_post_data($value, $tag);
// Post data hasn't filled yet. No arrays.
if ($default_value === $value) {
$value = contact_form_7_hidden_fields_fill_user_data($value);
}
// Arrays get imploded.
$value = is_array($value) ? implode(apply_filters('wpcf7_hidden_field_implode_glue', ', '), $value) : $value;
// Make sure we're using a string. Objects get JSON-encoded.
if (!is_string($value)) {
$value = json_encode($value);
}
$value = apply_filters('wpcf7_hidden_field_value', apply_filters('wpcf7_hidden_field_value_' . $tag->get_id_option(), $value));
$value = wpcf7_get_hangover($tag->name, $value);
$atts = array('type' => 'hidden', 'class' => $tag->get_class_option($class), 'id' => $tag->get_id_option(), 'name' => $tag->name, 'tabindex' => $tag->get_option('tabindex', 'int', true), 'placeholder' => $placeholder, 'value' => $value);
$atts = wpcf7_format_atts($atts);
$html = sprintf('<input %1$s />%2$s', $atts, $validation_error);
return $html;
}
示例9: wpcf7_orders_shortcode_handler
function wpcf7_orders_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (!is_user_logged_in()) {
return 'Please login first to show orders';
}
if (empty($tag->name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type);
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
if ($tag->is_required()) {
$atts['aria-required'] = 'true';
}
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
$multiple = $tag->has_option('multiple');
$include_blank = $tag->has_option('include_blank');
$first_as_label = $tag->has_option('first_as_label');
// Change order query settings here
$order_posts = get_posts(array('post_type' => 'shop_order', 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_status' => 'publish', 'numberposts' => -1));
// Display order options
$values = array();
foreach ($order_posts as $order) {
// Set `values` with order ID & order title
$values[] = '#' . $order->ID . ' | ' . $order->post_title;
}
$values = $values;
$labels = array_values($values);
$shifted = false;
if ($include_blank || empty($values)) {
array_unshift($labels, '---');
array_unshift($values, '');
$shifted = true;
} elseif ($first_as_label) {
$values[0] = '';
}
$html = '';
$hangover = wpcf7_get_hangover($tag->name);
foreach ($values as $key => $value) {
$selected = false;
if ($hangover) {
if ($multiple) {
$selected = in_array(esc_sql($value), (array) $hangover);
} else {
$selected = $hangover == esc_sql($value);
}
} else {
if (!$shifted && in_array((int) $key + 1, (array) $defaults)) {
$selected = true;
} elseif ($shifted && in_array((int) $key, (array) $defaults)) {
$selected = true;
}
}
$item_atts = array('value' => $value, 'selected' => $selected ? 'selected' : '');
$item_atts = wpcf7_format_atts($item_atts);
$label = isset($labels[$key]) ? $labels[$key] : $value;
$html .= sprintf('<option %1$s>%2$s</option>', $item_atts, esc_html($label));
}
if ($multiple) {
$atts['multiple'] = 'multiple';
}
$atts['name'] = $tag->name . ($multiple ? '[]' : '');
$atts = wpcf7_format_atts($atts);
$html = sprintf('<span class="wpcf7-form-control-wrap %1$s"><select %2$s>%3$s</select>%4$s</span>', sanitize_html_class($tag->name), $atts, $html, $validation_error);
return $html;
}
示例10: reset
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
if ($tag->has_option('readonly')) {
$atts['readonly'] = 'readonly';
}
if ($tag->is_required()) {
$atts['aria-required'] = 'true';
$atts['required'] = 'true';
}
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
$value = (string) reset($tag->values);
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$atts['placeholder'] = $value;
$value = '';
}
$value = $tag->get_default_option($value);
$value = wpcf7_get_hangover($tag->name, $value);
$atts['value'] = $value;
if (wpcf7_support_html5()) {
$atts['type'] = $tag->basetype;
} else {
$atts['type'] = 'text';
}
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<input class="%1$s" %2$s />%3$s', sanitize_html_class($tag->name), $atts, $validation_error);
return $html;
}, true);
});
add_action('wpcf7_init', function () {
wpcf7_add_shortcode('submit', function ($tag) {
$tag = new WPCF7_Shortcode($tag);
示例11: textarea_shortcode_handler
/**
* Outputs the HTML for the textarea shortcode. We're replacing the default
* CF7 textarea shortcode. If the user wants a word limit instead of a character
* limit, we need to remove the maxlength attribute from the element.
*
* @param $tag
* @return string
*/
function textarea_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type);
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$atts['cols'] = $tag->get_cols_option('40');
$atts['rows'] = $tag->get_rows_option('10');
$atts['maxlength'] = $tag->get_maxlength_option();
$atts['minlength'] = $tag->get_minlength_option();
if ($atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength']) {
unset($atts['maxlength'], $atts['minlength']);
}
$maxlengthwords = false;
$minlengthwords = false;
// Check whether the field has a min or max word length
foreach ($tag->options as $key => $option) {
if (stristr($option, 'maxlengthwords:true')) {
$maxlengthwords = true;
}
if (stristr($option, 'minlengthwords:true')) {
$minlengthwords = true;
}
}
// If this field has either the min or max word length validation,
// remove the maxlength and minlength variables because we aren't
// validating for character length
if ($maxlengthwords === true || $minlengthwords === true) {
unset($atts['maxlength'], $atts['minlength']);
}
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
if ($tag->has_option('readonly')) {
$atts['readonly'] = 'readonly';
}
if ($tag->is_required()) {
$atts['aria-required'] = 'true';
}
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
$value = empty($tag->content) ? (string) reset($tag->values) : $tag->content;
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$atts['placeholder'] = $value;
$value = '';
}
$value = $tag->get_default_option($value);
$value = wpcf7_get_hangover($tag->name, $value);
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<span class="wpcf7-form-control-wrap %1$s"><textarea %2$s>%3$s</textarea>%4$s</span>', sanitize_html_class($tag->name), $atts, esc_textarea($value), $validation_error);
return $html;
}
示例12: mango_checkbox_shortcode_handler
function mango_checkbox_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type);
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
$label_first = $tag->has_option('label_first');
$use_label_element = $tag->has_option('use_label_element');
$exclusive = $tag->has_option('exclusive');
$free_text = $tag->has_option('free_text');
$multiple = false;
if ('checkbox' == $tag->basetype) {
$multiple = !$exclusive;
} else {
// radio
$exclusive = false;
}
if ($exclusive) {
$class .= ' wpcf7-exclusive-checkbox';
}
$atts = array();
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$tabindex = $tag->get_option('tabindex', 'int', true);
if (false !== $tabindex) {
$tabindex = absint($tabindex);
}
$html = '';
$count = 0;
$values = (array) $tag->values;
$labels = (array) $tag->labels;
if ($data = (array) $tag->get_data_option()) {
if ($free_text) {
$values = array_merge(array_slice($values, 0, -1), array_values($data), array_slice($values, -1));
$labels = array_merge(array_slice($labels, 0, -1), array_values($data), array_slice($labels, -1));
} else {
$values = array_merge($values, array_values($data));
$labels = array_merge($labels, array_values($data));
}
}
$defaults = array();
$default_choice = $tag->get_default_option(null, 'multiple=1');
foreach ($default_choice as $value) {
$key = array_search($value, $values, true);
if (false !== $key) {
$defaults[] = (int) $key + 1;
}
}
$defaults = array_unique($defaults);
$hangover = wpcf7_get_hangover($tag->name, $multiple ? array() : '');
$i = 0;
foreach ($values as $key => $value) {
if ($value == 'mango_same_line' || $value == 'mango_custom') {
continue;
}
$ex = explode("|", $tag->raw_values[$i]);
$i++;
if (count($ex) == 1) {
$disable = '';
} else {
$disable = $ex[1];
}
$class = 'wpcf7-list-item';
$checked = false;
if ($hangover) {
if ($multiple) {
$checked = in_array(esc_sql($value), (array) $hangover);
} else {
$checked = $hangover == esc_sql($value);
}
} else {
$checked = in_array($key + 1, (array) $defaults);
}
if (isset($labels[$key])) {
$label = $labels[$key];
} else {
$label = $value;
}
$item_atts = array('type' => $tag->basetype, 'name' => $tag->name . ($multiple ? '[]' : ''), 'value' => $value, 'checked' => $checked ? 'checked' : '', 'tabindex' => $tabindex ? $tabindex : '');
$item_atts = wpcf7_format_atts($item_atts);
if ($label_first) {
// put label first, input last
if (in_array('mango_custom', $values)) {
$item = sprintf('<span>%1$s</span><span class="custom-' . esc_attr($tag->basetype) . '-container"><input %2$s /><span class="custom-' . esc_attr($tag->basetype) . '-icon"></span></span>', esc_html($label), $item_atts);
} else {
$item = sprintf('%1$s <input %2$s %3$s />', esc_html($label), $item_atts, $disable);
}
} else {
if (in_array('mango_custom', $values)) {
$item = sprintf('<span class="custom-' . esc_attr($tag->basetype) . '-container"><input %2$s /><span class="custom-' . esc_attr($tag->basetype) . '-icon"></span></span><span>%1$s</span>', esc_html($label), $item_atts);
} else {
$item = sprintf('<input %2$s %3$s /> %1$s', esc_html($label), $item_atts, $disable);
}
}
if ($use_label_element) {
//.........这里部分代码省略.........