is_email() │ WP 0.71
Перевіряє, чи є переданий рядок адресою e-mail.
1 раз – 0.000105 сек
(швидко) | 50000 разів – 0.14 сек
(дуже швидко)
(швидко) | 50000 разів – 0.14 сек
(дуже швидко)
Хуки з функції
Повертає
Строку|false.
Використання
if( is_email( $email ) ){
// це пошта...
}- $email
(рядок) (обов’язковий) - email який потрібно перевірити.
Приклади
0
#1 Перевіримо правильність написання email адреси:
<?php if ( is_email( '[email protected]' ) ) { echo 'email адреса коректна.'; } ?>
список змін
| З версії 0.71 | Введено. |
Код is_email() is email WP 6.0.2
function is_email( $email, $deprecated = false ) {
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '3.0.0');
}
// Test for the minimum length the email can be.
if ( strlen ( $ email ) < 6 ) {
/**
* Filters whether an email address is valid.
*
* Цей filter is evaluated under several different contexts, such as 'email_too_short',
* 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits',
* 'domain_no_periods', 'sub_hyphen_limits', 'sub_invalid_chars', або не specific context.
*
* @ Since 2.8.0
*
* @param string|false $is_email Електронна адреса, якщо успішно пройде is_email() checks, false otherwise.
* @param string $email The email address being checked.
* @param string $context Context під яким email був tested.
*/
return apply_filters( 'is_email', false, $email, 'email_too_short' );
}
// Test for an @ character after the first position.
if ( strpos( $email, '@', 1 ) === false ) {
/** Цей filter is documented в wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'email_no_at' );
}
// Split out the local and domain parts.
list ($ local, $ domain) = explode ( '@', $ email, 2);
// LOCAL PART
// Test for invalid characters.
if ( ! preg_match( '/^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+$/', $local ) ) {
/** Цей filter is documented в wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'local_invalid_chars' );
}
// DOMAIN PART
// Test for sequences of periods.
if ( preg_match( '/.{2,}/', $domain ) ) {
/** Цей filter is documented в wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'domain_period_sequence' );
}
// Test for leading and trailing periods and whitespace.
if ( trim( $domain , " tnr x0B. " ) !== $domain ) {
/** Цей filter is documented в wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'domain_period_limits' );
}
// Split the domain into subs.
$subs = explode('.', $domain);
// Assume the domain will have at least two subs.
if ( 2 > count( $subs ) ) {
/** Цей filter is documented в wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'domain_no_periods' );
}
// Loop through each sub.
foreach ( $subs as $sub ) {
// Test for leading and trailing hyphens and whitespace.
if ( trim( $sub, " tnr x0B-" ) !== $sub ) {
/** Цей filter is documented в wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' );
}
// Test for invalid characters.
if ( ! preg_match( '/^[a-z0-9-]+$/i', $sub ) ) {
/** Цей filter is documented в wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' );
}
}
// Congratulations, your email made it!
/** Цей filter is documented в wp-includes/formatting.php */
return apply_filters('is_email', $email, $email, null);
}Зв’язані функції
validate (перевірка)
Умовні теги (все)
- cat_is_ancestor_of()
- category_exists()
- comments_open()
- email_exists()
- has_block()
- has_category()
- has_custom_header()
- has_excerpt()
- has_nav_menu()
- has_post_thumbnail()
- has_shortcode()
- has_tag()
- has_term()
- have_comments()
- have_posts()
- in_category()
- in_the_loop()
- is_404()
- is_active_sidebar()
- is_admin()
- is_admin_bar_showing()
- is_archive()
- is_attachment()
- is_author()
- is_blog_admin()
- is_category()
- is_child_theme()
- is_comment_feed()
- is_customize_preview()
- is_date()
- is_day()
- is_dynamic_sidebar()
- is_embed()
- is_feed()
- is_front_page()
- is_header_video_active()
- is_home()
- is_local_attachment()
- is_main_query()
- is_month()
- is_multi_author()
- is_multisite()
- is_nav_menu()
- is_network_admin()
- is_new_day()
- is_page()
- is_page_template()
- is_paged()
- is_plugin_active()
- is_post_type_archive()
- is_post_type_hierarchical()
- is_preview()
- is_robots()
- is_search()
- is_single()
- is_singular()
- is_ssl()
- is_sticky()
- is_tag()
- is_tax()
- is_taxonomy_hierarchical()
- is_textdomain_loaded()
- is_time()
- is_trackback()
- is_user_admin()
- is_user_logged_in()
- is_year()
- pings_open()
- post_exists()
- post_password_required()
- shortcode_exists()
- tag_exists()
- taxonomy_exists()
- term_exists()
- term_is_ancestor_of()
- wp_attachment_is()
- wp_doing_ajax()
- wp_doing_cron()
- wp_is_mobile()
- wp_is_post_autosave()
- wp_is_post_revision()
- wp_is_using_https()
- wp_script_is()