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 |
|---|---|
| 3688 | * 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits', |
| 3689 | * 'domain_no_periods', 'domain_no_valid_subs', or no context. |
| 3690 | * |
| 3691 | * @since 2.8.0 |
| 3692 | * |
| 3693 | * @param string $sanitized_email The sanitized email address. |
| 3694 | * @param string $email The email address, as provided to sanitize_email(). |
| 3695 | * @param string|null $message A message to pass to the user. null if email is sanitized. |
| 3696 | */ |
| 3697 | return apply_filters( 'sanitize_email', '', $email, 'email_too_short' ); |
| 3698 | } |
| 3699 | |
| 3700 | // Test for an @ character after the first position. |
| 3701 | if ( strpos( $email, '@', 1 ) === false ) { |
| 3702 | /** This filter is documented in wp-includes/formatting.php */ |
| 3703 | return apply_filters( 'sanitize_email', '', $email, 'email_no_at' ); |
| 3704 | } |
| 3705 | |
| 3706 | // Split out the local and domain parts. |
| 3707 | list( $local, $domain ) = explode( '@', $email, 2 ); |
| 3708 | |
| 3709 | // LOCAL PART |
| 3710 | // Test for invalid characters. |
| 3711 | $local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local ); |
| 3712 | if ( '' === $local ) { |
| 3713 | /** This filter is documented in wp-includes/formatting.php */ |
| 3714 | return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' ); |
| 3715 | } |
| 3716 | |
| 3717 | // DOMAIN PART |
| 3718 | // Test for sequences of periods. |
| 3719 | $domain = preg_replace( '/\.{2,}/', '', $domain ); |
| 3720 | if ( '' === $domain ) { |
| 3721 | /** This filter is documented in wp-includes/formatting.php */ |
| 3722 | return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' ); |
| 3723 | } |
| 3724 | |
| 3725 | // Test for leading and trailing periods and whitespace. |
| 3726 | $domain = trim( $domain, " \t\n\r\0\x0B." ); |
| 3727 | if ( '' === $domain ) { |
| 3728 | /** This filter is documented in wp-includes/formatting.php */ |
| 3729 | return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' ); |
| 3730 | } |
| 3731 | |
| 3732 | // Split the domain into subs. |
| 3733 | $subs = explode( '.', $domain ); |
| 3734 | |
| 3735 | // Assume the domain will have at least two subs. |
| 3736 | if ( 2 > count( $subs ) ) { |
| 3737 | /** This filter is documented in wp-includes/formatting.php */ |
| 3738 | return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); |
| 3739 | } |
| 3740 | |
| 3741 | // Create an array that will contain valid subs. |
| 3742 | $new_subs = array(); |
| 3743 | |
| 3744 | // Loop through each sub. |
| 3745 | foreach ( $subs as $sub ) { |
| 3746 | // Test for leading and trailing hyphens. |
| 3747 | $sub = trim( $sub, " \t\n\r\0\x0B-" ); |
| Line | Code |
| 3752 | // If there's anything left, add it to the valid subs. |
| 3753 | if ( '' !== $sub ) { |
| 3754 | $new_subs[] = $sub; |
| 3755 | } |
| 3756 | } |
| 3757 | |
| 3758 | // If there aren't 2 or more valid subs. |
| 3759 | if ( 2 > count( $new_subs ) ) { |
| 3760 | /** This filter is documented in wp-includes/formatting.php */ |
| 3761 | return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); |
| 3762 | } |
| 3763 | |
| 3764 | // Join valid subs into the new domain. |
| 3765 | $domain = implode( '.', $new_subs ); |
| 3766 | |
| 3767 | // Put the email back together. |
| 3768 | $sanitized_email = $local . '@' . $domain; |
| 3769 | |
| 3770 | // Congratulations, your email made it! |
| 3771 | /** This filter is documented in wp-includes/formatting.php */ |
| 3772 | return apply_filters( 'sanitize_email', $sanitized_email, $email, null ); |
| 3773 | } |
| 3774 | |
| 3775 | /** |
| 3776 | * Determines the difference between two timestamps. |
| 3777 | * |
| 3778 | * The difference is returned in a human readable format such as "1 hour", |
| 3779 | * "5 mins", "2 days". |
| 3780 | * |
| 3781 | * @since 1.5.0 |