本文整理汇总了PHP中wpcf7_get_message函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf7_get_message函数的具体用法?PHP wpcf7_get_message怎么用?PHP wpcf7_get_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf7_get_message函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例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_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;
}
示例4: 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;
}
示例5: wpcf7_text_custom_validation_message
function wpcf7_text_custom_validation_message($result, $tag)
{
$cmtagobj = new WPCF7_Shortcode($tag);
$post_id = sanitize_text_field($_POST['_wpcf7']);
$name = $cmtagobj->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) {
$value = isset($_POST[$name]) ? trim(wp_unslash(strtr((string) $_POST[$name], "\n", " "))) : '';
if ('text' == $cmtagobj->basetype) {
if ($cmtagobj->is_required() && '' == $value) {
$result->invalidate($cmtagobj, $val);
}
}
if ('email' == $cmtagobj->basetype) {
if ($cmtagobj->is_required() && '' == $value) {
$result->invalidate($cmtagobj, $val);
} elseif ('' != $value && !wpcf7_is_email($value)) {
$key = "_cf7cm_" . $name . "-valid";
$val = get_post_meta($post_id, $key, true);
if ($val) {
$result->invalidate($cmtagobj, $val);
} else {
$result->invalidate($cmtagobj, wpcf7_get_message('invalid_email'));
}
}
}
if ('url' == $cmtagobj->basetype) {
if ($cmtagobj->is_required() && '' == $value) {
$result->invalidate($cmtagobj, $val);
} elseif ('' != $value && !wpcf7_is_url($value)) {
$result->invalidate($cmtagobj, wpcf7_get_message('invalid_url'));
}
}
if ('tel' == $cmtagobj->basetype) {
if ($cmtagobj->is_required() && '' == $value) {
$result->invalidate($cmtagobj, $val);
} elseif ('' != $value && !wpcf7_is_tel($value)) {
$result->invalidate($cmtagobj, wpcf7_get_message('invalid_tel'));
}
}
if (!empty($value)) {
$maxlength = $cmtagobj->get_maxlength_option();
$minlength = $cmtagobj->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($cmtagobj, wpcf7_get_message('invalid_too_long'));
} elseif ($minlength && $code_units < $minlength) {
$result->invalidate($cmtagobj, wpcf7_get_message('invalid_too_short'));
}
}
}
}
return $result;
}
示例6: 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_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');
}
return $result;
}
示例7: wpcf7_quiz_validation_filter
function wpcf7_quiz_validation_filter($result, $tag)
{
$type = $tag['type'];
$name = $tag['name'];
$answer = wpcf7_canonicalize($_POST[$name]);
$answer_hash = wp_hash($answer, 'wpcf7_quiz');
$expected_hash = $_POST['_wpcf7_quiz_answer_' . $name];
if ($answer_hash != $expected_hash) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('quiz_answer_not_correct');
}
return $result;
}
示例8: wpcf7_quiz_validation_filter
function wpcf7_quiz_validation_filter($result, $tag)
{
$tag = new WPCF7_FormTag($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->invalidate($tag, wpcf7_get_message('quiz_answer_not_correct'));
}
return $result;
}
示例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: 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 ('textarea*' == $type) {
if ('' == $value) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('invalid_required');
}
}
return $result;
}
示例11: recaptcha_validation_filter
public function recaptcha_validation_filter($result, $tag)
{
global $wdm_recaptcha_settings_values;
$site_key = $wdm_recaptcha_settings_values->get_option('general_site_key');
$secret_key = $wdm_recaptcha_settings_values->get_option('general_secret_key');
//if site key and secret key are available, then validate captcha
if (!empty($site_key) && !empty($secret_key)) {
$tag = new WPCF7_Shortcode($tag);
$type = $tag->type;
$name = !empty($tag->name) ? $tag->name : 'recaptcha';
$recaptcha_value = isset($_POST['g-recaptcha-response']) ? (string) $_POST['g-recaptcha-response'] : '';
//cf7 4.1 replaced results array structure to object
$result_type = gettype($result);
if ($result_type === 'object') {
if (0 == strlen(trim($recaptcha_value))) {
//recaptcha is uncheked
$result->invalidate($tag, wpcf7_get_message('no_re_uncheked'));
} else {
$captcha_value = $this->check_recaptcha($recaptcha_value);
if (!$captcha_value) {
//google returned false
$result->invalidate($tag, wpcf7_get_message('no_re_bot_detected'));
}
}
} else {
if (0 == strlen(trim($recaptcha_value))) {
//recaptcha is uncheked
$result['valid'] = false;
$reason = array($name => wpcf7_get_message('no_re_uncheked'));
$result['reason'] = array_merge($result['reason'], $reason);
} else {
$captcha_value = $this->check_recaptcha($recaptcha_value);
if (!$captcha_value) {
//google returned false
$result['valid'] = false;
$reason = array($name => wpcf7_get_message('no_re_bot_detected'));
$result['reason'] = array_merge($result['reason'], $reason);
}
if ($captcha_value && true == $result['valid']) {
//reset captcha if form was submitted successfully
}
}
}
}
return $result;
}
示例12: 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['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('accept_terms');
}
if (isset($result['reason'][$name]) && ($id = $tag->get_id_option())) {
$result['idref'][$name] = $id;
}
return $result;
}
示例13: wpcf7_date_validation_filter
function wpcf7_date_validation_filter($result, $tag)
{
$tag = new WPCF7_FormTag($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->invalidate($tag, wpcf7_get_message('invalid_required'));
} elseif ('' != $value && !wpcf7_is_date($value)) {
$result->invalidate($tag, wpcf7_get_message('invalid_date'));
} elseif ('' != $value && !empty($min) && $value < $min) {
$result->invalidate($tag, wpcf7_get_message('date_too_early'));
} elseif ('' != $value && !empty($max) && $max < $value) {
$result->invalidate($tag, wpcf7_get_message('date_too_late'));
}
return $result;
}
示例14: wpcf7_number_validation_filter
function wpcf7_number_validation_filter($result, $tag)
{
$tag = new WPCF7_FormTag($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->invalidate($tag, wpcf7_get_message('invalid_required'));
} elseif ('' != $value && !wpcf7_is_number($value)) {
$result->invalidate($tag, wpcf7_get_message('invalid_number'));
} elseif ('' != $value && '' != $min && (double) $value < (double) $min) {
$result->invalidate($tag, wpcf7_get_message('number_too_small'));
} elseif ('' != $value && '' != $max && (double) $max < (double) $value) {
$result->invalidate($tag, wpcf7_get_message('number_too_large'));
}
return $result;
}
示例15: wpcf7_acceptance_validation_filter
function wpcf7_acceptance_validation_filter($result, $tag)
{
if (!wpcf7_acceptance_as_validation()) {
return $result;
}
$name = $tag['name'];
if (empty($name)) {
return $result;
}
$options = (array) $tag['options'];
$value = !empty($_POST[$name]) ? 1 : 0;
$invert = (bool) preg_grep('%^invert$%', $options);
if ($invert && $value || !$invert && !$value) {
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message('accept_terms');
}
return $result;
}