本文整理汇总了PHP中wpcf7_is_posted函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf7_is_posted函数的具体用法?PHP wpcf7_is_posted怎么用?PHP wpcf7_is_posted使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf7_is_posted函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cf7bs_number_shortcode_handler
function cf7bs_number_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$mode = $status = 'default';
$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';
$status = 'error';
}
if ($tag->is_required()) {
$mode = 'required';
}
$value = (string) reset($tag->values);
$placeholder = '';
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$placeholder = $value;
$value = '';
}
if (wpcf7_is_posted() && isset($_POST[$tag->name])) {
$value = stripslashes_deep($_POST[$tag->name]);
} elseif (isset($_GET) && array_key_exists($tag->name, $_GET)) {
$value = stripslashes_deep(rawurldecode($_GET[$tag->name]));
}
$field = new CF7BS_Form_Field(array('name' => $tag->name, 'id' => $tag->get_option('id', 'id', true), 'class' => $tag->get_class_option($class), 'type' => wpcf7_support_html5() ? $tag->basetype : 'text', 'value' => $value, 'placeholder' => $placeholder, 'label' => $tag->content, 'options' => array('min' => $tag->get_option('min', 'signed_int', true), 'max' => $tag->get_option('max', 'signed_int', true), 'step' => $tag->get_option('step', 'int', true)), 'help_text' => $validation_error, 'size' => cf7bs_get_form_property('size'), 'grid_columns' => cf7bs_get_form_property('grid_columns'), 'form_layout' => cf7bs_get_form_property('layout'), 'form_label_width' => cf7bs_get_form_property('label_width'), 'form_breakpoint' => cf7bs_get_form_property('breakpoint'), 'mode' => $mode, 'status' => $status, 'readonly' => $tag->has_option('readonly') ? true : false, 'tabindex' => $tag->get_option('tabindex', 'int', true), 'wrapper_class' => $tag->name));
$html = $field->display(false);
return $html;
}
示例2: shortcode_handler
public static function 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-date');
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_option('id', 'id', true);
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
$atts['type'] = 'text';
if ($tag->has_option('readonly')) {
$atts['readonly'] = 'readonly';
}
if ($tag->is_required()) {
$atts['aria-required'] = 'true';
}
$value = (string) reset($tag->values);
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$atts['placeholder'] = $value;
$value = '';
}
if (wpcf7_is_posted() && isset($_POST[$tag->name])) {
$value = stripslashes_deep($_POST[$tag->name]);
}
$atts['value'] = $value;
$dpOptions = array();
$dpOptions['dateFormat'] = str_replace('_', ' ', $tag->get_option('date-format', '', true));
$dpOptions['minDate'] = $tag->get_option('min-date', '', true);
$dpOptions['maxDate'] = $tag->get_option('max-date', '', true);
$dpOptions['firstDay'] = (int) $tag->get_option('first-day', 'int', true);
$dpOptions['showAnim'] = $tag->get_option('animate', '', true);
$dpOptions['yearRange'] = str_replace('-', ':', $tag->get_option('year-range', '', true));
$dpOptions['numberOfMonths'] = (int) $tag->get_option('months', 'int', true);
$dpOptions['showButtonPanel'] = $tag->has_option('buttons');
$dpOptions['changeMonth'] = $tag->has_option('change-month');
$dpOptions['changeYear'] = $tag->has_option('change-year');
$dpOptions['noWeekends'] = $tag->has_option('no-weekends');
$inline = $tag->has_option('inline');
if ($inline) {
$dpOptions['altField'] = "#{$tag->name}_alt";
$atts['id'] = "{$tag->name}_alt";
}
$atts['type'] = $inline ? 'hidden' : '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 %4$s</span>', $tag->name, $atts, $validation_error, $inline ? "<div id=\"{$tag->name}_datepicker\"></div>" : '');
$html = apply_filters('cf7dp_date_input', $html);
$dp_selector = $inline ? '#' . $tag->name . '_datepicker' : $tag->name;
$dp = new CF7_DateTimePicker('date', $dp_selector, $dpOptions);
self::$inline_js[] = $dp->generate_code($inline);
return $html;
}
示例3: cf7bs_file_shortcode_handler
function cf7bs_file_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$mode = $status = 'default';
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type);
if ($validation_error) {
$class .= ' wpcf7-not-valid';
$status = 'error';
}
// size is not used since Bootstrap input fields always scale 100%
//$atts['size'] = $tag->get_size_option( '40' );
if ($tag->is_required()) {
$mode = 'required';
}
$value = (string) reset($tag->values);
$placeholder = '';
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$placeholder = $value;
$value = '';
} elseif (empty($value)) {
$value = $tag->get_default_option();
}
if (wpcf7_is_posted() && isset($_POST[$tag->name])) {
$value = stripslashes_deep($_POST[$tag->name]);
}
$field = new CF7BS_Form_Field(cf7bs_apply_field_args_filter(array('name' => $tag->name, 'id' => $tag->get_option('id', 'id', true), 'class' => $tag->get_class_option($class), 'type' => 'file', 'value' => '1', 'label' => $tag->content, 'help_text' => $validation_error, 'size' => cf7bs_get_form_property('size'), 'grid_columns' => cf7bs_get_form_property('grid_columns'), 'form_layout' => cf7bs_get_form_property('layout'), 'form_label_width' => cf7bs_get_form_property('label_width'), 'form_breakpoint' => cf7bs_get_form_property('breakpoint'), 'mode' => $mode, 'status' => $status, 'tabindex' => $tag->get_option('tabindex', 'int', true), 'wrapper_class' => $tag->name), $tag->basetype, $tag->name));
$html = $field->display(false);
return $html;
}
示例4: cf7bs_captcha_shortcode_handler
function cf7bs_captcha_shortcode_handler($tag)
{
$tag_obj = new WPCF7_Shortcode($tag);
if ('captchac' == $tag_obj->type && !class_exists('ReallySimpleCaptcha')) {
return '<em>' . __('To use CAPTCHA, you need <a href="http://wordpress.org/extend/plugins/really-simple-captcha/">Really Simple CAPTCHA</a> plugin installed.', 'bootstrap-for-contact-form-7') . '</em>';
}
if (empty($tag_obj->name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag_obj->name);
if ('captchac' == $tag_obj->type) {
if ($image_sizes_array = preg_grep('%^size:[smlSML]$%', $tag['options'])) {
$tag['options'] = array_values(array_diff_key($tag['options'], $image_sizes_array));
}
$size = cf7bs_get_form_property('size');
$image_size = 'large' == $size ? 'l' : ('small' == $size ? 's' : 'm');
$tag['options'][] = 'size:' . $image_size;
$field = new CF7BS_Form_Field(cf7bs_apply_field_args_filter(array('name' => wpcf7_captcha_shortcode_handler($tag), 'type' => 'custom', 'label' => $tag_obj->content, 'help_text' => $validation_error, 'grid_columns' => cf7bs_get_form_property('grid_columns'), 'form_layout' => cf7bs_get_form_property('layout'), 'form_label_width' => cf7bs_get_form_property('label_width'), 'form_breakpoint' => cf7bs_get_form_property('breakpoint'), 'tabindex' => false, 'wrapper_class' => ''), $tag_obj->basetype, $tag_obj->name));
$html = $field->display(false);
return $html;
} elseif ('captchar' == $tag_obj->type) {
$mode = $status = 'default';
$class = wpcf7_form_controls_class($tag_obj->type, 'wpcf7-text');
if ($validation_error) {
$class .= ' wpcf7-not-valid';
$status = 'error';
}
// size is not used since Bootstrap input fields always scale 100%
//$atts['size'] = $tag->get_size_option( '40' );
$value = (string) reset($tag_obj->values);
$placeholder = '';
if (wpcf7_is_posted()) {
$value = '';
}
if ($tag_obj->has_option('placeholder') || $tag_obj->has_option('watermark')) {
$placeholder = $value;
$value = '';
}
$input_before = $input_after = '';
if ($tag_obj->has_option('include_captchac') && class_exists('ReallySimpleCaptcha')) {
$captchac_mode = $tag_obj->get_option('include_captchac', '[A-Za-z]+', true);
if ($captchac_mode && 'after' == strtolower($captchac_mode)) {
$captchac_mode = 'input_after';
} else {
$captchac_mode = 'input_before';
}
$tag = cf7bs_captchar_to_captchac($tag);
${$captchac_mode} = wpcf7_captcha_shortcode_handler($tag);
}
$field = new CF7BS_Form_Field(cf7bs_apply_field_args_filter(array('name' => $tag_obj->name, 'id' => $tag_obj->get_option('id', 'id', true), 'class' => $tag_obj->get_class_option($class), 'type' => 'text', 'value' => $value, 'placeholder' => $placeholder, 'label' => $tag_obj->content, 'help_text' => $validation_error, 'size' => cf7bs_get_form_property('size'), 'form_layout' => cf7bs_get_form_property('layout'), 'form_label_width' => cf7bs_get_form_property('label_width'), 'form_breakpoint' => cf7bs_get_form_property('breakpoint'), 'mode' => $mode, 'status' => $status, 'maxlength' => $tag_obj->get_maxlength_option(), 'tabindex' => $tag_obj->get_option('tabindex', 'int', true), 'wrapper_class' => $tag_obj->name, 'input_before' => $input_before, 'input_after' => $input_after, 'input_before_class' => 'input-group-addon input-group-has-image', 'input_after_class' => 'input-group-addon input-group-has-image'), $tag_obj->basetype, $tag_obj->name));
$html = $field->display(false);
return $html;
}
return '';
}
示例5: wpcf7_text_shortcode_handler
function wpcf7_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['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_option('id', 'id', true);
$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 = '';
} elseif (empty($value) && is_user_logged_in()) {
$user = wp_get_current_user();
$user_options = array('default:user_login' => 'user_login', 'default:user_email' => 'user_email', 'default:user_url' => 'user_url', 'default:user_first_name' => 'first_name', 'default:user_last_name' => 'last_name', 'default:user_nickname' => 'nickname', 'default:user_display_name' => 'display_name');
foreach ($user_options as $option => $prop) {
if ($tag->has_option($option)) {
$value = $user->{$prop};
break;
}
}
}
if (wpcf7_is_posted() && isset($_POST[$tag->name])) {
$value = stripslashes_deep($_POST[$tag->name]);
}
$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>', $tag->name, $atts, $validation_error);
return $html;
}
示例6: wpcf7_text_shortcode_handler
function wpcf7_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['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 = '';
} elseif ('' === $value) {
$value = $tag->get_default_option();
}
if (wpcf7_is_posted() && isset($_POST[$tag->name])) {
$value = wp_unslash($_POST[$tag->name]);
}
$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;
}
示例7: wpcf7_date_shortcode_handler
function wpcf7_date_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-date';
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_option('id', 'id', true);
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
$atts['min'] = $tag->get_option('min', 'date', true);
$atts['max'] = $tag->get_option('max', 'date', 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 = '';
}
if (wpcf7_is_posted() && isset($_POST[$tag->name])) {
$value = stripslashes_deep($_POST[$tag->name]);
}
$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>', $tag->name, $atts, $validation_error);
return $html;
}
示例8: 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('');
$atts['rows'] = $tag->get_rows_option('');
$atts['maxlength'] = $tag->get_maxlength_option();
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_option('id', 'id', true);
$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->content) {
$value = $tag->content;
}
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$atts['placeholder'] = $value;
$value = '';
}
if (wpcf7_is_posted() && isset($_POST[$tag->name])) {
$value = stripslashes_deep($_POST[$tag->name]);
}
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<textarea %2$s></textarea>', $tag->name, $atts, esc_textarea($value), $validation_error);
return $html;
}
示例9: cf7bs_checkbox_shortcode_handler
function cf7bs_checkbox_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$mode = $status = 'default';
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type);
if ($validation_error) {
$class .= ' wpcf7-not-valid';
$status = 'error';
}
$exclusive = $tag->has_option('exclusive');
$free_text = $tag->has_option('free_text');
$multiple = false;
if ('checkbox' == $tag->basetype) {
$multiple = !$exclusive;
} else {
$exclusive = false;
}
if ($exclusive) {
$class .= ' wpcf7-exclusive-checkbox';
}
if ($tag->is_required()) {
$mode = 'required';
}
$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);
$options = array();
$checked = '';
if ($multiple) {
$checked = array();
}
if (isset($_POST[$tag->name])) {
$post = $_POST[$tag->name];
} else {
if (isset($_GET[$tag->name])) {
if ($multiple) {
$get = cf7bs_array_decode(rawurldecode($_GET[$tag->name]));
} else {
$get = rawurldecode($_GET[$tag->name]);
}
}
$post = $multiple ? array() : '';
}
$posted = wpcf7_is_posted();
$count = 0;
foreach ((array) $tag->values as $key => $value) {
if ($free_text && $count == count($tag->values) - 1) {
$options[$value] = '<input type="text" name="' . sprintf('_wpcf7_%1$s_free_text_%2$s', $tag->basetype, $tag->name) . '" class="wpcf7-free-text">';
} else {
$options[$value] = isset($labels[$key]) ? $labels[$key] : $value;
}
if ($posted && !empty($post)) {
if ($multiple && in_array(esc_sql($value), (array) $post)) {
$checked[] = $value;
}
if (!$multiple && $post == esc_sql($value)) {
$checked = $value;
}
} elseif (isset($get) && !empty($get)) {
if ($multiple && in_array(esc_sql($value), (array) $get)) {
$checked[] = $value;
}
if (!$multiple && $get == esc_sql($value)) {
$checked = $value;
}
} elseif (in_array($key + 1, (array) $defaults)) {
if ($multiple) {
$checked[] = $value;
} else {
$checked = $value;
}
}
$count++;
}
$label = $tag->content;
if (count($options) < 1) {
//.........这里部分代码省略.........
示例10: wpcf7_captcha_shortcode_handler
function wpcf7_captcha_shortcode_handler($tag)
{
if (!is_array($tag)) {
return '';
}
$type = $tag['type'];
$name = $tag['name'];
$options = (array) $tag['options'];
$values = (array) $tag['values'];
if (empty($name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($name);
$atts = $id_att = $size_att = $maxlength_att = $tabindex_att = $title_att = '';
$class_att = wpcf7_form_controls_class($type);
if ('captchac' == $type) {
$class_att .= ' wpcf7-captcha-' . $name;
}
if ($validation_error && 'captchar' == $type) {
$class_att .= ' wpcf7-not-valid';
}
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
} elseif (preg_match('%^class:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$class_att .= ' ' . $matches[1];
} elseif (preg_match('%^([0-9]*)[/x]([0-9]*)$%', $option, $matches)) {
$size_att = (int) $matches[1];
$maxlength_att = (int) $matches[2];
} elseif (preg_match('%^tabindex:(\\d+)$%', $option, $matches)) {
$tabindex_att = (int) $matches[1];
}
}
// Value.
$value = '';
if ('captchar' == $type && !wpcf7_is_posted() && isset($values[0])) {
$value = $values[0];
if (wpcf7_script_is() && preg_grep('%^watermark$%', $options)) {
$class_att .= ' wpcf7-use-title-as-watermark';
$title_att .= sprintf(' %s', $value);
$value = '';
}
}
if ($id_att) {
$atts .= ' id="' . trim($id_att) . '"';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
if ('captchac' == $type) {
if (!class_exists('ReallySimpleCaptcha')) {
return '<em>' . __('To use CAPTCHA, you need <a href="http://wordpress.org/extend/plugins/really-simple-captcha/">Really Simple CAPTCHA</a> plugin installed.', 'wpcf7') . '</em>';
}
$op = array();
// Default
$op['img_size'] = array(72, 24);
$op['base'] = array(6, 18);
$op['font_size'] = 14;
$op['font_char_width'] = 15;
$op = array_merge($op, wpcf7_captchac_options($options));
if (!($filename = wpcf7_generate_captcha($op))) {
return '';
}
if (is_array($op['img_size'])) {
$atts .= ' width="' . $op['img_size'][0] . '" height="' . $op['img_size'][1] . '"';
}
$captcha_url = trailingslashit(wpcf7_captcha_tmp_url()) . $filename;
$html = '<img alt="captcha" src="' . $captcha_url . '"' . $atts . ' />';
$ref = substr($filename, 0, strrpos($filename, '.'));
$html = '<input type="hidden" name="_wpcf7_captcha_challenge_' . $name . '" value="' . $ref . '" />' . $html;
return $html;
} elseif ('captchar' == $type) {
if ($size_att) {
$atts .= ' size="' . $size_att . '"';
} else {
$atts .= ' size="40"';
}
// default size
if ($maxlength_att) {
$atts .= ' maxlength="' . $maxlength_att . '"';
}
if ('' !== $tabindex_att) {
$atts .= sprintf(' tabindex="%d"', $tabindex_att);
}
if ('' !== $title_att) {
$atts .= sprintf(' title="%s"', trim(esc_attr($title_att)));
}
$html = '<input type="text" name="' . $name . '" value="' . esc_attr($value) . '"' . $atts . ' />';
$html = '<span class="wpcf7-form-control-wrap ' . $name . '">' . $html . $validation_error . '</span>';
return $html;
}
}
示例11: 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');
$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_option('id', 'id', true);
$tabindex = $tag->get_option('tabindex', 'int', true);
if (false !== $tabindex) {
$tabindex = absint($tabindex);
}
$defaults = array();
if ($matches = $tag->get_first_match_option('/^default:([0-9_]+)$/')) {
$defaults = explode('_', $matches[1]);
}
if (isset($_POST[$tag->name])) {
$post = $_POST[$tag->name];
} else {
$post = $multiple ? array() : '';
}
$is_posted = wpcf7_is_posted();
$html = '';
foreach ((array) $tag->values as $key => $value) {
$checked = false;
if ($is_posted && !empty($post)) {
if ($multiple && in_array(esc_sql($value), (array) $post)) {
$checked = true;
}
if (!$multiple && $post == esc_sql($value)) {
$checked = true;
}
} else {
if (in_array($key + 1, (array) $defaults)) {
$checked = true;
}
}
if (isset($tag->labels[$key])) {
$label = $tag->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>';
}
$item = '<span class="wpcf7-list-item">' . $item . '</span>';
$html .= $item;
if (false !== $tabindex) {
$tabindex += 1;
}
}
$atts = wpcf7_format_atts($atts);
$html = sprintf('<span class="wpcf7-form-control-wrap %1$s"><span %2$s>%3$s</span>%4$s</span>', $tag->name, $atts, $html, $validation_error);
return $html;
}
示例12: cf7bs_select_shortcode_handler
function cf7bs_select_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$mode = $status = 'default';
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type);
if ($validation_error) {
$class .= ' wpcf7-not-valid';
$status = 'error';
}
if ($tag->is_required()) {
$mode = 'required';
}
$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 = explode('_', $matches[1]);
}
$defaults = array_unique($defaults);
$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);
$shifted = false;
if ($empty_select || $include_blank) {
array_unshift($labels, '---');
array_unshift($values, '');
$shifted = true;
} elseif ($first_as_label) {
$values[0] = '';
}
$options = array();
$selected = '';
if ($multiple) {
$selected = array();
}
if (isset($_POST[$tag->name])) {
$post = $_POST[$tag->name];
} else {
if (isset($_GET[$tag->name])) {
if ($multiple) {
$get = cf7bs_array_decode(rawurldecode($_GET[$tag->name]));
} else {
$get = rawurldecode($_GET[$tag->name]);
}
}
$post = $multiple ? array() : '';
}
$posted = wpcf7_is_posted();
foreach ($values as $key => $value) {
$options[$value] = isset($labels[$key]) ? $labels[$key] : $value;
if ($posted && !empty($post)) {
if ($multiple && in_array(esc_sql($value), (array) $post)) {
$selected[] = $value;
}
if (!$multiple && $post == esc_sql($value)) {
$selected = $value;
}
} elseif (isset($get) && !empty($get)) {
if ($multiple && in_array(esc_sql($value), (array) $get)) {
$selected[] = $value;
}
if (!$multiple && $get == esc_sql($value)) {
$selected = $value;
}
} elseif (!$shifted && in_array((int) $key + 1, (array) $defaults) || $shifted && in_array((int) $key, (array) $defaults)) {
if ($multiple) {
$selected[] = $value;
} else {
$selected = $value;
}
}
}
$field = new CF7BS_Form_Field(cf7bs_apply_field_args_filter(array('name' => $tag->name, 'id' => $tag->get_option('id', 'id', true), 'class' => $tag->get_class_option($class), 'type' => $multiple ? 'multiselect' : 'select', 'value' => $selected, 'label' => $tag->content, 'options' => $options, 'help_text' => $validation_error, 'size' => cf7bs_get_form_property('size'), 'grid_columns' => cf7bs_get_form_property('grid_columns'), 'form_layout' => cf7bs_get_form_property('layout'), 'form_label_width' => cf7bs_get_form_property('label_width'), 'form_breakpoint' => cf7bs_get_form_property('breakpoint'), 'mode' => $mode, 'status' => $status, 'tabindex' => $tag->get_option('tabindex', 'int', true), 'wrapper_class' => $tag->name), $tag->basetype, $tag->name));
$html = $field->display(false);
return $html;
}
示例13: wpcf7_checkbox_shortcode_handler
function wpcf7_checkbox_shortcode_handler($tag)
{
if (!is_array($tag)) {
return '';
}
$type = $tag['type'];
$name = $tag['name'];
$options = (array) $tag['options'];
$values = (array) $tag['values'];
$labels = (array) $tag['labels'];
if (empty($name)) {
return '';
}
$atts = '';
$id_att = '';
$class_att = '';
$tabindex_att = '';
$defaults = array();
$label_first = false;
$use_label_element = false;
if ('checkbox*' == $type) {
$class_att .= ' wpcf7-validates-as-required';
}
if ('checkbox' == $type || 'checkbox*' == $type) {
$class_att .= ' wpcf7-checkbox';
}
if ('radio' == $type) {
$class_att .= ' wpcf7-radio';
}
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
} elseif (preg_match('%^class:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$class_att .= ' ' . $matches[1];
} elseif (preg_match('/^default:([0-9_]+)$/', $option, $matches)) {
$defaults = explode('_', $matches[1]);
} elseif (preg_match('%^label[_-]?first$%', $option)) {
$label_first = true;
} elseif (preg_match('%^use[_-]?label[_-]?element$%', $option)) {
$use_label_element = true;
} elseif (preg_match('%^tabindex:(\\d+)$%', $option, $matches)) {
$tabindex_att = (int) $matches[1];
}
}
$multiple = false;
$exclusive = (bool) preg_grep('%^exclusive$%', $options);
if ('checkbox' == $type || 'checkbox*' == $type) {
$multiple = !$exclusive;
} else {
// radio
$exclusive = false;
}
if ($exclusive) {
$class_att .= ' wpcf7-exclusive-checkbox';
}
if ($id_att) {
$atts .= ' id="' . trim($id_att) . '"';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
$html = '';
$input_type = rtrim($type, '*');
$posted = wpcf7_is_posted();
foreach ($values as $key => $value) {
$checked = false;
if ($posted && !empty($_POST[$name])) {
if ($multiple && in_array(esc_sql($value), (array) $_POST[$name])) {
$checked = true;
}
if (!$multiple && $_POST[$name] == esc_sql($value)) {
$checked = true;
}
} else {
if (in_array($key + 1, (array) $defaults)) {
$checked = true;
}
}
$checked = $checked ? ' checked="checked"' : '';
if ('' !== $tabindex_att) {
$tabindex = sprintf(' tabindex="%d"', $tabindex_att);
$tabindex_att += 1;
} else {
$tabindex = '';
}
if (isset($labels[$key])) {
$label = $labels[$key];
} else {
$label = $value;
}
if ($label_first) {
// put label first, input last
$item = '<span class="wpcf7-list-item-label">' . esc_html($label) . '</span> ';
$item .= '<input type="' . $input_type . '" name="' . $name . ($multiple ? '[]' : '') . '" value="' . esc_attr($value) . '"' . $checked . $tabindex . ' />';
} else {
$item = '<input type="' . $input_type . '" name="' . $name . ($multiple ? '[]' : '') . '" value="' . esc_attr($value) . '"' . $checked . $tabindex . ' />';
$item .= ' <span class="wpcf7-list-item-label">' . esc_html($label) . '</span>';
}
if ($use_label_element) {
$item = '<label>' . $item . '</label>';
//.........这里部分代码省略.........
示例14: wpcf7_select_shortcode_handler
function wpcf7_select_shortcode_handler($tag)
{
if (!is_array($tag)) {
return '';
}
$type = $tag['type'];
$name = $tag['name'];
$options = (array) $tag['options'];
$values = (array) $tag['values'];
$labels = (array) $tag['labels'];
if (empty($name)) {
return '';
}
$atts = '';
$id_att = '';
$class_att = '';
$tabindex_att = '';
$defaults = array();
$class_att .= ' wpcf7-select';
if ('select*' == $type) {
$class_att .= ' wpcf7-validates-as-required';
}
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
} elseif (preg_match('%^class:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$class_att .= ' ' . $matches[1];
} elseif (preg_match('/^default:([0-9_]+)$/', $option, $matches)) {
$defaults = explode('_', $matches[1]);
} elseif (preg_match('%^tabindex:(\\d+)$%', $option, $matches)) {
$tabindex_att = (int) $matches[1];
}
}
if ($id_att) {
$atts .= ' id="' . trim($id_att) . '"';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
if ('' !== $tabindex_att) {
$atts .= sprintf(' tabindex="%d"', $tabindex_att);
}
$multiple = (bool) preg_grep('%^multiple$%', $options);
$include_blank = (bool) preg_grep('%^include_blank$%', $options);
$empty_select = empty($values);
if ($empty_select || $include_blank) {
array_unshift($labels, '---');
array_unshift($values, '---');
}
$html = '';
$posted = wpcf7_is_posted();
foreach ($values as $key => $value) {
$selected = false;
if ($posted) {
if ($multiple && in_array(esc_sql($value), (array) $_POST[$name])) {
$selected = true;
}
if (!$multiple && $_POST[$name] == esc_sql($value)) {
$selected = true;
}
} else {
if (!$empty_select && in_array($key + 1, (array) $defaults)) {
$selected = true;
}
}
$selected = $selected ? ' selected="selected"' : '';
if (isset($labels[$key])) {
$label = $labels[$key];
} else {
$label = $value;
}
$html .= '<option value="' . esc_attr($value) . '"' . $selected . '>' . esc_html($label) . '</option>';
}
if ($multiple) {
$atts .= ' multiple="multiple"';
}
$html = '<select name="' . $name . ($multiple ? '[]' : '') . '"' . $atts . '>' . $html . '</select>';
$validation_error = wpcf7_get_validation_error($name);
$html = '<span class="wpcf7-form-control-wrap ' . $name . '">' . $html . $validation_error . '</span>';
return $html;
}
示例15: 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])) {
//.........这里部分代码省略.........