本文整理汇总了PHP中WPCF7_Shortcode类的典型用法代码示例。如果您正苦于以下问题:PHP WPCF7_Shortcode类的具体用法?PHP WPCF7_Shortcode怎么用?PHP WPCF7_Shortcode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WPCF7_Shortcode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: wpcf7_date_validation_filter
function wpcf7_date_validation_filter($result, $tag)
{
$tag = new WPCF7_Shortcode($tag);
$name = $tag->name;
$min = $tag->get_date_option('min');
$max = $tag->get_date_option('max');
$value = isset($_POST[$name]) ? trim(strtr((string) $_POST[$name], "\n", " ")) : '';
if ($tag->is_required() && '' == $value) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('invalid_required');
} elseif ('' != $value && !wpcf7_is_date($value)) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('invalid_date');
} elseif ('' != $value && !empty($min) && $value < $min) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('date_too_early');
} elseif ('' != $value && !empty($max) && $max < $value) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('date_too_late');
}
if (isset($result['reason'][$name]) && ($id = $tag->get_id_option())) {
$result['idref'][$name] = $id;
}
return $result;
}
示例3: wpcf7_number_validation_filter
function wpcf7_number_validation_filter($result, $tag)
{
$tag = new WPCF7_Shortcode($tag);
$name = $tag->name;
$value = isset($_POST[$name]) ? trim(strtr((string) $_POST[$name], "\n", " ")) : '';
$min = $tag->get_option('min', 'signed_int', true);
$max = $tag->get_option('max', 'signed_int', true);
if ($tag->is_required() && '' == $value) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('invalid_required');
} elseif ('' != $value && !wpcf7_is_number($value)) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('invalid_number');
} elseif ('' != $value && '' != $min && (double) $value < (double) $min) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('number_too_small');
} elseif ('' != $value && '' != $max && (double) $max < (double) $value) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('number_too_large');
}
if (isset($result['reason'][$name]) && ($id = $tag->get_id_option())) {
$result['idref'][$name] = $id;
}
return $result;
}
示例4: wpcf7_textarea_validation_filter
function wpcf7_textarea_validation_filter($result, $tag)
{
$tag = new WPCF7_Shortcode($tag);
$type = $tag->type;
$name = $tag->name;
$value = isset($_POST[$name]) ? (string) $_POST[$name] : '';
if ($tag->is_required() && '' == $value) {
$result->invalidate($tag, wpcf7_get_message('invalid_required'));
}
if (!empty($value)) {
$maxlength = $tag->get_maxlength_option();
$minlength = $tag->get_minlength_option();
if ($maxlength && $minlength && $maxlength < $minlength) {
$maxlength = $minlength = null;
}
$code_units = wpcf7_count_code_units($value);
if (false !== $code_units) {
if ($maxlength && $maxlength < $code_units) {
$result->invalidate($tag, wpcf7_get_message('invalid_too_long'));
} elseif ($minlength && $code_units < $minlength) {
$result->invalidate($tag, wpcf7_get_message('invalid_too_short'));
}
}
}
return $result;
}
示例5: 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);
}
示例6: wpcf7_birthday_validation_filter
function wpcf7_birthday_validation_filter($result, $tag)
{
$tag = new WPCF7_Shortcode($tag);
$name = $tag->name;
$value = isset($_POST[$name]) ? trim(wp_unslash(strtr((string) $_POST[$name], "\n", " "))) : '';
if ('birthday' == $tag->type && $value != '') {
if (preg_match('@^(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[0-2])$@', $value) != 1) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('invalid_birthday');
}
}
if ('birthday*' == $tag->type) {
if ($value == '') {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('invalid_required');
} else {
if (preg_match('@^(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[0-2])$@', $value) != 1) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('invalid_birthday');
}
}
}
if (isset($result['reason'][$name]) && ($id = $tag->get_id_option())) {
$result['idref'][$name] = $id;
}
return $result;
}
示例7: 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;
}
示例8: 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;
}
示例9: wpcf7_acceptance_validation_filter
function wpcf7_acceptance_validation_filter($result, $tag)
{
if (!wpcf7_acceptance_as_validation()) {
return $result;
}
$tag = new WPCF7_Shortcode($tag);
$name = $tag->name;
$value = !empty($_POST[$name]) ? 1 : 0;
$invert = $tag->has_option('invert');
if ($invert && $value || !$invert && !$value) {
$result->invalidate($tag, wpcf7_get_message('accept_terms'));
}
return $result;
}
示例10: 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 '';
}
示例11: 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;
}
示例12: wpcf7_text_validation_filter
function wpcf7_text_validation_filter($result, $tag)
{
$tag = new WPCF7_Shortcode($tag);
$name = $tag->name;
$value = isset($_POST[$name]) ? trim(wp_unslash(strtr((string) $_POST[$name], "\n", " "))) : '';
if ('text' == $tag->basetype) {
if ($tag->is_required() && '' == $value) {
$result->invalidate($tag, wpcf7_get_message('invalid_required'));
}
}
if ('email' == $tag->basetype) {
if ($tag->is_required() && '' == $value) {
$result->invalidate($tag, wpcf7_get_message('invalid_required'));
} elseif ('' != $value && !wpcf7_is_email($value)) {
$result->invalidate($tag, wpcf7_get_message('invalid_email'));
}
}
if ('url' == $tag->basetype) {
if ($tag->is_required() && '' == $value) {
$result->invalidate($tag, wpcf7_get_message('invalid_required'));
} elseif ('' != $value && !wpcf7_is_url($value)) {
$result->invalidate($tag, wpcf7_get_message('invalid_url'));
}
}
if ('tel' == $tag->basetype) {
if ($tag->is_required() && '' == $value) {
$result->invalidate($tag, wpcf7_get_message('invalid_required'));
} elseif ('' != $value && !wpcf7_is_tel($value)) {
$result->invalidate($tag, wpcf7_get_message('invalid_tel'));
}
}
if (!empty($value)) {
$maxlength = $tag->get_maxlength_option();
$minlength = $tag->get_minlength_option();
if ($maxlength && $minlength && $maxlength < $minlength) {
$maxlength = $minlength = null;
}
$code_units = wpcf7_count_code_units($value);
if (false !== $code_units) {
if ($maxlength && $maxlength < $code_units) {
$result->invalidate($tag, wpcf7_get_message('invalid_too_long'));
} elseif ($minlength && $code_units < $minlength) {
$result->invalidate($tag, wpcf7_get_message('invalid_too_short'));
}
}
}
return $result;
}
示例13: wpcf7_custom_textarea_validation_message
function wpcf7_custom_textarea_validation_message($result, $tag)
{
$cmtatag = new WPCF7_Shortcode($tag);
$type = $cmtatag->type;
$name = $cmtatag->name;
$post_id = sanitize_text_field($_POST['_wpcf7']);
$value = isset($_POST[$name]) ? (string) $_POST[$name] : '';
$key = "_cf7cm_" . $name;
$val = get_post_meta($post_id, $key, true);
$enable = get_post_meta($post_id, '_cf7cm_enable_errors');
if ($enable[0] != 0) {
if ($cmtatag->is_required() && '' == $value) {
$result->invalidate($cmtatag, $val);
}
if (!empty($value)) {
$maxlength = $cmtatag->get_maxlength_option();
$minlength = $cmtatag->get_minlength_option();
if ($maxlength && $minlength && $maxlength < $minlength) {
$maxlength = $minlength = null;
}
$code_units = wpcf7_count_code_units($value);
if (false !== $code_units) {
if ($maxlength && $maxlength < $code_units) {
$result->invalidate($cmtatag, $val);
} elseif ($minlength && $code_units < $minlength) {
$result->invalidate($cmtatag, $val);
}
}
}
}
return $result;
}
示例14: cf7bs_submit_shortcode_handler
function cf7bs_submit_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
$class = wpcf7_form_controls_class($tag->type);
$value = isset($tag->values[0]) ? $tag->values[0] : '';
if (empty($value)) {
$value = __('Send', 'contact-form-7');
}
$size = cf7bs_get_form_property('submit_size');
if (!$size) {
$size = cf7bs_get_form_property('size');
}
$button = new CF7BS_Button(array('mode' => 'submit', 'id' => $tag->get_option('id', 'id', true), 'class' => $tag->get_class_option($class), 'title' => $value, 'type' => cf7bs_get_form_property('submit_type'), 'size' => $size, 'tabindex' => $tag->get_option('tabindex', 'int', true), 'align' => $tag->get_option('align', '[A-Za-z]+', true), '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')));
$html = $button->display(false);
return $html;
}
示例15: wpcf7_quiz_validation_filter
function wpcf7_quiz_validation_filter($result, $tag)
{
$tag = new WPCF7_Shortcode($tag);
$name = $tag->name;
$answer = isset($_POST[$name]) ? wpcf7_canonicalize($_POST[$name]) : '';
$answer = wp_unslash($answer);
$answer_hash = wp_hash($answer, 'wpcf7_quiz');
$expected_hash = isset($_POST['_wpcf7_quiz_answer_' . $name]) ? (string) $_POST['_wpcf7_quiz_answer_' . $name] : '';
if ($answer_hash != $expected_hash) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('quiz_answer_not_correct');
}
if (isset($result['reason'][$name]) && ($id = $tag->get_id_option())) {
$result['idref'][$name] = $id;
}
return $result;
}