本文整理汇总了PHP中wpcf7_support_html5函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf7_support_html5函数的具体用法?PHP wpcf7_support_html5怎么用?PHP wpcf7_support_html5使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf7_support_html5函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: mango_wpcf7_text_shortcode_handler
function mango_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_id = '';
$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_id = $atts['id'];
$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);
$atts['value'] = $value;
if (wpcf7_support_html5()) {
$atts['type'] = $tag->basetype;
} else {
$atts['type'] = 'text';
}
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts($atts);
if ($atts_id == 'disabledInput') {
$html = sprintf('<input %1$s disabled />%2$s', $atts, $validation_error);
} else {
$html = sprintf('<input %1$s />%2$s', $atts, $validation_error);
}
return $html;
}
示例4: wpcf7_text_form_tag_handler
function wpcf7_text_form_tag_handler($tag)
{
$tag = new WPCF7_FormTag($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);
$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 = (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;
}
示例5: 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 = '';
}
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;
}
示例6: form_html
public function form_html($args = '')
{
$args = wp_parse_args($args, array('html_id' => '', 'html_name' => '', 'html_class' => '', 'output' => 'form'));
if ('raw_form' == $args['output']) {
return '<pre class="wpcf7-raw-form"><code>' . esc_html($this->prop('form')) . '</code></pre>';
}
$this->unit_tag = self::get_unit_tag($this->id);
$html = sprintf('<div %s>', wpcf7_format_atts(array('role' => 'form', 'class' => 'wpcf7', 'id' => $this->unit_tag, get_option('html_type') == 'text/html' ? 'lang' : 'xml:lang' => str_replace('_', '-', $this->locale), 'dir' => wpcf7_is_rtl($this->locale) ? 'rtl' : 'ltr'))) . "\n";
$html .= $this->screen_reader_response() . "\n";
$url = wpcf7_get_request_uri();
if ($frag = strstr($url, '#')) {
$url = substr($url, 0, -strlen($frag));
}
$url .= '#' . $this->unit_tag;
$url = apply_filters('wpcf7_form_action_url', $url);
$id_attr = apply_filters('wpcf7_form_id_attr', preg_replace('/[^A-Za-z0-9:._-]/', '', $args['html_id']));
$name_attr = apply_filters('wpcf7_form_name_attr', preg_replace('/[^A-Za-z0-9:._-]/', '', $args['html_name']));
$class = 'wpcf7-form';
if ($this->is_posted()) {
$submission = WPCF7_Submission::get_instance();
if ($submission->is('validation_failed')) {
$class .= ' invalid';
} elseif ($submission->is('spam')) {
$class .= ' spam';
} elseif ($submission->is('mail_sent')) {
$class .= ' sent';
} elseif ($submission->is('mail_failed')) {
$class .= ' failed';
}
}
if ($args['html_class']) {
$class .= ' ' . $args['html_class'];
}
if ($this->in_demo_mode()) {
$class .= ' demo';
}
$class = explode(' ', $class);
$class = array_map('sanitize_html_class', $class);
$class = array_filter($class);
$class = array_unique($class);
$class = implode(' ', $class);
$class = apply_filters('wpcf7_form_class_attr', $class);
$enctype = apply_filters('wpcf7_form_enctype', '');
$novalidate = apply_filters('wpcf7_form_novalidate', wpcf7_support_html5());
$atts = array('action' => esc_url($url), 'method' => 'post', 'class' => $class, 'enctype' => wpcf7_enctype_value($enctype), 'novalidate' => $novalidate ? 'novalidate' : '');
if ('' !== $id_attr) {
$atts['id'] = $id_attr;
}
if ('' !== $name_attr) {
$atts['name'] = $name_attr;
}
$atts = wpcf7_format_atts($atts);
$html .= sprintf('<form %s>', $atts) . "\n";
$html .= $this->form_hidden_fields();
$html .= $this->form_elements();
if (!$this->responses_count) {
$html .= $this->form_response_output();
}
$html .= '</form>';
$html .= '</div>';
return $html;
}
示例7: form_html
function form_html()
{
global $wpcf7;
$form = '<div class="wpcf7" id="' . $this->unit_tag . '">';
$url = wpcf7_get_request_uri();
if ($frag = strstr($url, '#')) {
$url = substr($url, 0, -strlen($frag));
}
$url .= '#' . $this->unit_tag;
$url = apply_filters('wpcf7_form_action_url', $url);
$class = 'wpcf7-form';
if ($this->is_posted()) {
if (empty($wpcf7->result['valid'])) {
$class .= ' invalid';
} elseif (!empty($wpcf7->result['spam'])) {
$class .= ' spam';
} elseif (!empty($wpcf7->result['mail_sent'])) {
$class .= ' sent';
} else {
$class .= ' failed';
}
}
$class = apply_filters('wpcf7_form_class_attr', $class);
$enctype = apply_filters('wpcf7_form_enctype', '');
$novalidate = apply_filters('wpcf7_form_novalidate', wpcf7_support_html5() ? ' novalidate="novalidate"' : '');
$form .= '<form action="' . esc_url_raw($url) . '" method="post"' . ' class="' . esc_attr($class) . '"' . $enctype . $novalidate . '>' . "\n";
$form .= $this->form_hidden_fields();
$form .= $this->form_elements();
if (!$this->responses_count) {
$form .= $this->form_response_output();
}
$form .= '</form>';
$form .= '</div>';
return $form;
}
示例8: cf7bs_text_shortcode_handler
function cf7bs_text_shortcode_handler($tag)
{
$tag_obj = new WPCF7_Shortcode($tag);
if (empty($tag_obj->name)) {
return '';
}
$mode = $status = 'default';
$validation_error = wpcf7_get_validation_error($tag_obj->name);
$class = wpcf7_form_controls_class($tag_obj->type, 'wpcf7-text');
if (in_array($tag_obj->basetype, array('email', 'url', 'tel'))) {
$class .= ' wpcf7-validates-as-' . $tag_obj->basetype;
}
if ($validation_error) {
$class .= ' wpcf7-not-valid';
$status = 'error';
}
// size is not used since Bootstrap input fields always scale 100%
//$atts['size'] = $tag_obj->get_size_option( '40' );
if ($tag_obj->is_required()) {
$mode = 'required';
}
$value = (string) reset($tag_obj->values);
$placeholder = '';
if ($tag_obj->has_option('placeholder') || $tag_obj->has_option('watermark')) {
$placeholder = $value;
$value = '';
}
$value = $tag_obj->get_default_option($value);
if (wpcf7_is_posted() && isset($_POST[$tag_obj->name])) {
$value = stripslashes_deep($_POST[$tag_obj->name]);
} elseif (isset($_GET) && array_key_exists($tag_obj->name, $_GET)) {
$value = stripslashes_deep(rawurldecode($_GET[$tag_obj->name]));
}
$input_before = $tag_obj->get_first_match_option('/input_before:([^\\s]+)/');
$input_after = $tag_obj->get_first_match_option('/input_after:([^\\s]+)/');
if (is_array($input_before) && isset($input_before[1])) {
$input_before = str_replace('---', ' ', $input_before[1]);
} else {
$input_before = '';
}
if (is_array($input_after) && isset($input_after[1])) {
$input_after = str_replace('---', ' ', $input_after[1]);
} else {
$input_after = '';
}
if ($tag_obj->has_option('include_count')) {
$count_mode = 'input_after';
$count_down = false;
$count_options = $tag_obj->get_option('include_count', '[A-Za-z]+(:[A-Za-z]+)?', true);
if ($count_options) {
$count_options = explode(':', $count_options);
foreach ($count_options as $count_option) {
switch ($count_option) {
case 'down':
case 'DOWN':
$count_down = true;
break;
case 'before':
case 'BEFORE':
$count_mode = 'input_before';
break;
default:
}
}
}
$tag = cf7bs_text_to_count($tag, $count_down);
if (!empty(${$count_mode})) {
${$count_mode} = wpcf7_count_shortcode_handler($tag) . ' ' . ${$count_mode};
} else {
${$count_mode} = wpcf7_count_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' => wpcf7_support_html5() ? $tag_obj->basetype : 'text', 'value' => $value, 'placeholder' => $placeholder, 'label' => $tag_obj->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, 'readonly' => $tag_obj->has_option('readonly') ? true : false, 'minlength' => $tag_obj->get_minlength_option(), '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), $tag_obj->basetype, $tag_obj->name));
$html = $field->display(false);
return $html;
}
示例9: form_html
public function form_html($atts = array())
{
$atts = wp_parse_args($atts, array('html_id' => '', 'html_class' => ''));
$this->unit_tag = self::get_unit_tag($this->id);
$form = '<div class="wpcf7" id="' . $this->unit_tag . '">';
$url = wpcf7_get_request_uri();
if ($frag = strstr($url, '#')) {
$url = substr($url, 0, -strlen($frag));
}
$url .= '#' . $this->unit_tag;
$url = apply_filters('wpcf7_form_action_url', $url);
$id_attr = apply_filters('wpcf7_form_id_attr', preg_replace('/[^A-Za-z0-9:._-]/', '', $atts['html_id']));
$class = 'wpcf7-form';
$result = self::get_submission_status($this->id);
if ($this->is_posted()) {
if (empty($result['valid'])) {
$class .= ' invalid';
} elseif (!empty($result['spam'])) {
$class .= ' spam';
} elseif (!empty($result['mail_sent'])) {
$class .= ' sent';
} else {
$class .= ' failed';
}
}
$atts['html_class'] = array_unique(array_map('sanitize_html_class', explode(' ', $atts['html_class'])));
if ($atts['html_class']) {
$class .= ' ' . implode(' ', $atts['html_class']);
}
$class = apply_filters('wpcf7_form_class_attr', trim($class));
$enctype = apply_filters('wpcf7_form_enctype', '');
$novalidate = apply_filters('wpcf7_form_novalidate', wpcf7_support_html5() ? ' novalidate="novalidate"' : '');
$form .= '<form action="' . esc_url_raw($url) . '" method="post"' . ($id_attr ? ' id="' . esc_attr($id_attr) . '"' : '') . ' class="' . esc_attr($class) . '"' . $enctype . $novalidate . '>' . "\n";
$form .= $this->form_hidden_fields();
$form .= $this->form_elements();
if (!$this->responses_count) {
$form .= $this->form_response_output();
}
$form .= '</form>';
$form .= '</div>';
return $form;
}
示例10: reset
$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);
$class = wpcf7_form_controls_class($tag->type);
$atts = [];
示例11: cf7bs_form_novalidate
function cf7bs_form_novalidate($novalidate)
{
if (wpcf7_support_html5()) {
return ' novalidate';
}
return '';
}