本文整理汇总了PHP中wpcf7_get_validation_error函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf7_get_validation_error函数的具体用法?PHP wpcf7_get_validation_error怎么用?PHP wpcf7_get_validation_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf7_get_validation_error函数的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: 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;
}
示例3: wpcf7_honeypot_shortcode_handler
function wpcf7_honeypot_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('text');
$atts = array();
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_option('id', 'id', true);
$atts['message'] = __('Please leave this field empty.', 'wpcf7_honeypot');
$atts['name'] = $tag->name;
$atts['type'] = $tag->type;
$atts['nomessage'] = $tag->get_option('nomessage');
$atts['validation_error'] = $validation_error;
$inputid = !empty($atts['id']) ? 'id="' . $atts['id'] . '" ' : '';
$html = '<span class="wpcf7-form-control-wrap ' . $atts['name'] . '-wrap" style="display:none !important;visibility:hidden !important;">';
$html .= '<input ' . $inputid . 'class="' . $atts['class'] . '" type="text" name="' . $atts['name'] . '" value="" size="40" tabindex="-1" />';
if (!$atts['nomessage']) {
$html .= '<span class="hp-message">' . $atts['message'] . '</span>';
}
$html .= $validation_error . '</span>';
// Hook for filtering finished Honeypot form element.
return apply_filters('wpcf7_honeypot_html_output', $html, $atts);
}
示例4: wpcf7_quiz_shortcode_handler
function wpcf7_quiz_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['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['aria-required'] = 'true';
$pipes = $tag->pipes;
if (is_a($pipes, 'WPCF7_Pipes') && !$pipes->zero()) {
$pipe = $pipes->random_pipe();
$question = $pipe->before;
$answer = $pipe->after;
} else {
// default quiz
$question = '1+1=?';
$answer = '2';
}
$answer = wpcf7_canonicalize($answer);
$atts['type'] = 'text';
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<span class="wpcf7-form-control-wrap %1$s"><span class="wpcf7-quiz-label">%2$s</span> <input %3$s /><input type="hidden" name="_wpcf7_quiz_answer_%1$s" value="%4$s" />%5$s</span>', $tag->name, esc_html($question), $atts, wp_hash($answer, 'wpcf7_quiz'), $validation_error);
return $html;
}
示例5: wpcf7_file_shortcode_handler
function wpcf7_file_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['size'] = $tag->get_size_option('40');
$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->is_required()) {
$atts['aria-required'] = 'true';
}
$atts['type'] = 'file';
$atts['name'] = $tag->name;
$atts['value'] = '1';
$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: 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;
}
示例7: wpcf7_map_shorcode_handler
function wpcf7_map_shorcode_handler($tag)
{
if (!is_array($tag)) {
return '';
}
$type = $tag['type'];
$name = $tag['name'];
if (empty($name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($name);
$atts = '';
$class_att = '';
$class_att = wpcf7_form_controls_class($type);
if ($validation_error) {
$class_att .= ' wpcf7-not-valid';
}
if ($class_att) {
$atts .= ' class="' . trim($class_att) . '"';
}
$folder = dirname(__FILE__);
$codeFile = "{$folder}/map-code-leaflet.html";
$fh = fopen($codeFile, 'r');
$theCode = fread($fh, filesize($codeFile));
fclose($fh);
$html = '<span class="wpcf7-form-control-wrap ' . $name . '">' . $theCode . $validation_error . '<input id="CF7MapLocationHidden" type="hidden" ' . $atts . ' name="' . $name . '" /></span>';
return $html;
}
示例8: wpcf7_mathcaptcha_shortcode_handler
function wpcf7_mathcaptcha_shortcode_handler($tag)
{
if (!is_user_logged_in() || is_user_logged_in() && !Math_Captcha()->options['general']['hide_for_logged_users']) {
$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['size'] = 2;
$atts['maxlength'] = 2;
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_option('id', 'id', true);
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
$atts['aria-required'] = 'true';
$atts['type'] = 'text';
$atts['name'] = $tag->name;
$atts['value'] = '';
$atts = wpcf7_format_atts($atts);
$mc_form = Math_Captcha()->core->generate_captcha_phrase('cf7');
$mc_form[$mc_form['input']] = '<input %2$s />';
$math_captcha_title = apply_filters('math_captcha_title', Math_Captcha()->options['general']['title']);
return sprintf((empty($math_captcha_title) ? '' : $math_captcha_title) . '<span class="wpcf7-form-control-wrap %1$s">' . $mc_form[1] . $mc_form[2] . $mc_form[3] . '%3$s</span><input type="hidden" value="' . (Math_Captcha()->core->session_number - 1) . '" name="' . $tag->name . '-sn" />', $tag->name, $atts, $validation_error);
}
}
示例9: wpcf7_acceptance_shortcode_handler
function wpcf7_acceptance_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';
}
if ($tag->has_option('invert')) {
$class .= ' wpcf7-invert';
}
$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->has_option('default:on')) {
$atts['checked'] = 'checked';
}
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
$atts['type'] = 'checkbox';
$atts['name'] = $tag->name;
$atts['value'] = '1';
$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;
}
示例10: 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;
}
示例11: 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 '';
}
示例12: 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;
}
示例13: wpcf7_captchanum_shortcode_handler
function wpcf7_captchanum_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->name);
$html = '<span class="wpcf7-form-control-wrap ' . sanitize_html_class($tag->name) . '">';
$html .= apply_filters('tool_contactform7_captchanum_field', $tag->name);
$html .= '</span>';
return $html;
}
示例14: wpcf7_file_shortcode_handler
function wpcf7_file_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 '';
}
$atts = '';
$id_att = '';
$class_att = '';
$size_att = '';
$tabindex_att = '';
$class_att .= ' wpcf7-file';
if ('file*' == $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('%^([0-9]*)[/x]([0-9]*)$%', $option, $matches)) {
$size_att = (int) $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 ($size_att) {
$atts .= ' size="' . $size_att . '"';
} else {
$atts .= ' size="40"';
}
// default size
if ('' !== $tabindex_att) {
$atts .= sprintf(' tabindex="%d"', $tabindex_att);
}
$html = '<input type="file" name="' . $name . '"' . $atts . ' value="1" />';
$validation_error = wpcf7_get_validation_error($name);
$html = '<span class="wpcf7-form-control-wrap ' . $name . '">' . $html . $validation_error . '</span>';
return $html;
}
示例15: 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;
}