WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 10 times in this file.
Line | Code |
---|---|
1469 | * @since 0.71 |
1470 | * |
1471 | * @param string $email Email address to verify. |
1472 | * @param boolean $check_dns Whether to check the DNS for the domain using checkdnsrr(). |
1473 | * @return string|bool Either false or the valid email address. |
1474 | */ |
1475 | function is_email( $email, $check_dns = false ) { |
1476 | // Test for the minimum length the email can be |
1477 | if ( strlen( $email ) < 3 ) { |
1478 | return apply_filters( 'is_email', false, $email, 'email_too_short' ); |
1479 | } |
1480 |
|
1481 | // Test for an @ character after the first position |
1482 | if ( strpos( $email, '@', 1 ) === false ) { |
1483 | return apply_filters( 'is_email', false, $email, 'email_no_at' ); |
1484 | } |
1485 |
|
1486 | // Split out the local and domain parts |
1487 | list( $local, $domain ) = explode( '@', $email, 2 ); |
1488 |
|
1489 | // LOCAL PART |
1490 | // Test for invalid characters |
1491 | if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) { |
1492 | return apply_filters( 'is_email', false, $email, 'local_invalid_chars' ); |
1493 | } |
1494 |
|
1495 | // DOMAIN PART |
1496 | // Test for sequences of periods |
1497 | if ( preg_match( '/\.{2,}/', $domain ) ) { |
1498 | return apply_filters( 'is_email', false, $email, 'domain_period_sequence' ); |
1499 | } |
1500 |
|
1501 | // Test for leading and trailing periods and whitespace |
1502 | if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { |
1503 | return apply_filters( 'is_email', false, $email, 'domain_period_limits' ); |
1504 | } |
1505 |
|
1506 | // Split the domain into subs |
1507 | $subs = explode( '.', $domain ); |
1508 |
|
1509 | // Assume the domain will have at least two subs |
1510 | if ( 2 > count( $subs ) ) { |
1511 | return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); |
1512 | } |
1513 |
|
1514 | // Loop through each sub |
1515 | foreach ( $subs as $sub ) { |
1516 | // Test for leading and trailing hyphens and whitespace |
1517 | if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) { |
1518 | return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' ); |
1519 | } |
1520 |
|
1521 | // Test for invalid characters |
1522 | if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) { |
1523 | return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); |
1524 | } |
1525 | } |
1526 |
|
1527 | // DNS |
1528 | // Check the domain has a valid MX and A resource record |
1529 | if ( $check_dns && function_exists( 'checkdnsrr' ) && !( checkdnsrr( $domain . '.', 'MX' ) || checkdnsrr( $domain . '.', 'A' ) ) ) { |
1530 | return apply_filters( 'is_email', false, $email, 'dns_no_rr' ); |
1531 | } |
1532 |
|
1533 | // Congratulations your email made it! |
1534 | return apply_filters( 'is_email', $email, $email, null ); |
1535 | } |
1536 |
|
1537 | /** |
1538 | * Convert to ASCII from email subjects. |
1539 | * |
1540 | * @since 1.2.0 |
1541 | * @usedby wp_mail() handles charsets in email subjects |
1542 | * |
1543 | * @param string $string Subject line |