本文整理汇总了PHP中wpcf7_format_atts函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf7_format_atts函数的具体用法?PHP wpcf7_format_atts怎么用?PHP wpcf7_format_atts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf7_format_atts函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf7_count_shortcode_handler
function wpcf7_count_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$target = wpcf7_scan_shortcode(array('name' => $tag->name));
$maxlength = $minlength = null;
if ($target) {
$target = new WPCF7_Shortcode($target[0]);
$maxlength = $target->get_maxlength_option();
$minlength = $target->get_minlength_option();
if ($maxlength && $minlength && $maxlength < $minlength) {
$maxlength = $minlength = null;
}
}
if ($tag->has_option('down')) {
$value = (int) $maxlength;
$class = 'wpcf7-character-count down';
} else {
$value = '0';
$class = 'wpcf7-character-count up';
}
$atts = array();
$atts['id'] = $tag->get_id_option();
$atts['class'] = $tag->get_class_option($class);
$atts['data-target-name'] = $tag->name;
$atts['data-starting-value'] = $value;
$atts['data-current-value'] = $value;
$atts['data-maximum-value'] = $maxlength;
$atts['data-minimum-value'] = $minlength;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<span %1$s>%2$s</span>', $atts, $value);
return $html;
}
示例2: 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;
}
示例3: 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;
}
示例4: wpcf7_icon_btn_shortcode_handler
function wpcf7_icon_btn_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
$class = wpcf7_form_controls_class($tag->type);
$atts = array();
$atts['class'] = $tag->get_class_option($class);
$atts['class'] = $atts['class'] . ' wpcf7-submit';
//add the default submit class
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
$atts['type'] = 'submit';
$atts = wpcf7_format_atts($atts);
//get icon class
$icon_class = $tag->get_option('icon', '', true);
$icon_class = empty($icon_class) ? 'fa-send' : $icon_class;
//add default class if empty
$icon_class = 'fa ' . esc_attr($icon_class);
//add fa // did u notice space after fa
//get button label
$value = isset($tag->values[0]) ? $tag->values[0] : '';
if (empty($value)) {
$value = __('Send', 'contact-form-7');
}
//complete string
$html = sprintf('<button %1$s /><i class="%2$s"></i> %3$s</button>', $atts, $icon_class, esc_html($value));
return $html;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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);
}
}
示例8: 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;
}
示例9: 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['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;
}
示例10: 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)) {
$value = $tag->get_default_option();
}
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('<input %2$s />', $tag->name, $atts, $validation_error);
return $html;
}
示例11: wpcf7_button_shortcode_handler
function wpcf7_button_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
$class = wpcf7_form_controls_class($tag->type);
$atts = array();
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
$value = isset($tag->values[0]) ? $tag->values[0] : '';
if (empty($value)) {
$value = __('Send', 'contact-form-7');
}
$atts['type'] = 'submit';
$atts = wpcf7_format_atts($atts);
$html = sprintf('<button %1$s>%2$s</button>', $atts, $value);
return $html;
}
示例12: 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;
}
示例13: wpcf7_submit_form_tag_handler
function wpcf7_submit_form_tag_handler($tag)
{
$tag = new WPCF7_FormTag($tag);
$class = wpcf7_form_controls_class($tag->type);
$atts = array();
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
$value = isset($tag->values[0]) ? $tag->values[0] : '';
if (empty($value)) {
$value = __('Send', 'contact-form-7');
}
$atts['type'] = 'submit';
$atts['value'] = $value;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<input %1$s />', $atts);
return $html;
}
示例14: wpcf7c_back_shortcode_handler
function wpcf7c_back_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
$class = wpcf7_form_controls_class($tag->type);
$atts = array();
$atts['class'] = $tag->get_class_option($class) . " wpcf7c-elm-step2 wpcf7c-btn-back wpcf7c-force-hide";
$atts['id'] = $tag->get_option('id', 'id', true);
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
$value = isset($tag->values[0]) ? $tag->values[0] : '';
if (empty($value)) {
$value = __('Backedit', 'contact-form-7-add-confirm');
}
$atts['type'] = 'button';
$atts['value'] = $value;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<input %1$s />', $atts);
return $html;
}
示例15: wpcf7_hidden_form_tag_handler
function wpcf7_hidden_form_tag_handler($tag)
{
$tag = new WPCF7_FormTag($tag);
if (empty($tag->name)) {
return '';
}
$atts = array();
$class = wpcf7_form_controls_class($tag->type);
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$value = (string) reset($tag->values);
$value = $tag->get_default_option($value);
$atts['value'] = $value;
$atts['type'] = 'hidden';
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<input %s />', $atts);
return $html;
}