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 8 times in this file.
Line | Code |
---|---|
3622 | * 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits', |
3623 | * 'domain_no_periods', 'domain_no_valid_subs', or no context. |
3624 | * |
3625 | * @since 2.8.0 |
3626 | * |
3627 | * @param string $sanitized_email The sanitized email address. |
3628 | * @param string $email The email address, as provided to sanitize_email(). |
3629 | * @param string|null $message A message to pass to the user. null if email is sanitized. |
3630 | */ |
3631 | return apply_filters( 'sanitize_email', '', $email, 'email_too_short' ); |
3632 | } |
3633 |
|
3634 | // Test for an @ character after the first position. |
3635 | if ( strpos( $email, '@', 1 ) === false ) { |
3636 | /** This filter is documented in wp-includes/formatting.php */ |
3637 | return apply_filters( 'sanitize_email', '', $email, 'email_no_at' ); |
3638 | } |
3639 |
|
3640 | // Split out the local and domain parts. |
3641 | list( $local, $domain ) = explode( '@', $email, 2 ); |
3642 |
|
3643 | // LOCAL PART |
3644 | // Test for invalid characters. |
3645 | $local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local ); |
3646 | if ( '' === $local ) { |
3647 | /** This filter is documented in wp-includes/formatting.php */ |
3648 | return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' ); |
3649 | } |
3650 |
|
3651 | // DOMAIN PART |
3652 | // Test for sequences of periods. |
3653 | $domain = preg_replace( '/\.{2,}/', '', $domain ); |
3654 | if ( '' === $domain ) { |
3655 | /** This filter is documented in wp-includes/formatting.php */ |
3656 | return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' ); |
3657 | } |
3658 |
|
3659 | // Test for leading and trailing periods and whitespace. |
3660 | $domain = trim( $domain, " \t\n\r\0\x0B." ); |
3661 | if ( '' === $domain ) { |
3662 | /** This filter is documented in wp-includes/formatting.php */ |
3663 | return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' ); |
3664 | } |
3665 |
|
3666 | // Split the domain into subs. |
3667 | $subs = explode( '.', $domain ); |
3668 |
|
3669 | // Assume the domain will have at least two subs. |
3670 | if ( 2 > count( $subs ) ) { |
3671 | /** This filter is documented in wp-includes/formatting.php */ |
3672 | return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); |
3673 | } |
3674 |
|
3675 | // Create an array that will contain valid subs. |
3676 | $new_subs = array(); |
3677 |
|
3678 | // Loop through each sub. |
3679 | foreach ( $subs as $sub ) { |
3680 | // Test for leading and trailing hyphens. |
3681 | $sub = trim( $sub, " \t\n\r\0\x0B-" ); |
Line | Code |
3686 | // If there's anything left, add it to the valid subs. |
3687 | if ( '' !== $sub ) { |
3688 | $new_subs[] = $sub; |
3689 | } |
3690 | } |
3691 |
|
3692 | // If there aren't 2 or more valid subs. |
3693 | if ( 2 > count( $new_subs ) ) { |
3694 | /** This filter is documented in wp-includes/formatting.php */ |
3695 | return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); |
3696 | } |
3697 |
|
3698 | // Join valid subs into the new domain. |
3699 | $domain = join( '.', $new_subs ); |
3700 |
|
3701 | // Put the email back together. |
3702 | $sanitized_email = $local . '@' . $domain; |
3703 |
|
3704 | // Congratulations, your email made it! |
3705 | /** This filter is documented in wp-includes/formatting.php */ |
3706 | return apply_filters( 'sanitize_email', $sanitized_email, $email, null ); |
3707 | } |
3708 |
|
3709 | /** |
3710 | * Determines the difference between two timestamps. |
3711 | * |
3712 | * The difference is returned in a human readable format such as "1 hour", |
3713 | * "5 mins", "2 days". |
3714 | * |
3715 | * @since 1.5.0 |