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 9 times in this file.
| Line | Code |
|---|---|
| 1542 | * @param boolean $deprecated Deprecated. |
| 1543 | * @return string|bool Either false or the valid email address. |
| 1544 | */ |
| 1545 | function is_email( $email, $deprecated = false ) { |
| 1546 | if ( ! empty( $deprecated ) ) |
| 1547 | _deprecated_argument( __FUNCTION__, '3.0' ); |
| 1548 | |
| 1549 | // Test for the minimum length the email can be |
| 1550 | if ( strlen( $email ) < 3 ) { |
| 1551 | return apply_filters( 'is_email', false, $email, 'email_too_short' ); |
| 1552 | } |
| 1553 | |
| 1554 | // Test for an @ character after the first position |
| 1555 | if ( strpos( $email, '@', 1 ) === false ) { |
| 1556 | return apply_filters( 'is_email', false, $email, 'email_no_at' ); |
| 1557 | } |
| 1558 | |
| 1559 | // Split out the local and domain parts |
| 1560 | list( $local, $domain ) = explode( '@', $email, 2 ); |
| 1561 | |
| 1562 | // LOCAL PART |
| 1563 | // Test for invalid characters |
| 1564 | if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) { |
| 1565 | return apply_filters( 'is_email', false, $email, 'local_invalid_chars' ); |
| 1566 | } |
| 1567 | |
| 1568 | // DOMAIN PART |
| 1569 | // Test for sequences of periods |
| 1570 | if ( preg_match( '/\.{2,}/', $domain ) ) { |
| 1571 | return apply_filters( 'is_email', false, $email, 'domain_period_sequence' ); |
| 1572 | } |
| 1573 | |
| 1574 | // Test for leading and trailing periods and whitespace |
| 1575 | if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { |
| 1576 | return apply_filters( 'is_email', false, $email, 'domain_period_limits' ); |
| 1577 | } |
| 1578 | |
| 1579 | // Split the domain into subs |
| 1580 | $subs = explode( '.', $domain ); |
| 1581 | |
| 1582 | // Assume the domain will have at least two subs |
| 1583 | if ( 2 > count( $subs ) ) { |
| 1584 | return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); |
| 1585 | } |
| 1586 | |
| 1587 | // Loop through each sub |
| 1588 | foreach ( $subs as $sub ) { |
| 1589 | // Test for leading and trailing hyphens and whitespace |
| 1590 | if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) { |
| 1591 | return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' ); |
| 1592 | } |
| 1593 | |
| 1594 | // Test for invalid characters |
| 1595 | if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) { |
| 1596 | return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); |
| 1597 | } |
| 1598 | } |
| 1599 | |
| 1600 | // Congratulations your email made it! |
| 1601 | return apply_filters( 'is_email', $email, $email, null ); |
| 1602 | } |
| 1603 | |
| 1604 | /** |
| 1605 | * Convert to ASCII from email subjects. |
| 1606 | * |
| 1607 | * @since 1.2.0 |
| 1608 | * @usedby wp_mail() handles charsets in email subjects |
| 1609 | * |
| 1610 | * @param string $string Subject line |