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 |
|---|---|
| 3776 | * 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits', |
| 3777 | * 'domain_no_periods', 'domain_no_valid_subs', or no context. |
| 3778 | * |
| 3779 | * @since 2.8.0 |
| 3780 | * |
| 3781 | * @param string $sanitized_email The sanitized email address. |
| 3782 | * @param string $email The email address, as provided to sanitize_email(). |
| 3783 | * @param string|null $message A message to pass to the user. null if email is sanitized. |
| 3784 | */ |
| 3785 | return apply_filters( 'sanitize_email', '', $email, 'email_too_short' ); |
| 3786 | } |
| 3787 | |
| 3788 | // Test for an @ character after the first position. |
| 3789 | if ( strpos( $email, '@', 1 ) === false ) { |
| 3790 | /** This filter is documented in wp-includes/formatting.php */ |
| 3791 | return apply_filters( 'sanitize_email', '', $email, 'email_no_at' ); |
| 3792 | } |
| 3793 | |
| 3794 | // Split out the local and domain parts. |
| 3795 | list( $local, $domain ) = explode( '@', $email, 2 ); |
| 3796 | |
| 3797 | /* |
| 3798 | * LOCAL PART |
| 3799 | * Test for invalid characters. |
| 3800 | */ |
| 3801 | $local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local ); |
| 3802 | if ( '' === $local ) { |
| 3803 | /** This filter is documented in wp-includes/formatting.php */ |
| 3804 | return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' ); |
| 3805 | } |
| 3806 | |
| 3807 | /* |
| 3808 | * DOMAIN PART |
| 3809 | * Test for sequences of periods. |
| 3810 | */ |
| 3811 | $domain = preg_replace( '/\.{2,}/', '', $domain ); |
| 3812 | if ( '' === $domain ) { |
| 3813 | /** This filter is documented in wp-includes/formatting.php */ |
| 3814 | return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' ); |
| 3815 | } |
| 3816 | |
| 3817 | // Test for leading and trailing periods and whitespace. |
| 3818 | $domain = trim( $domain, " \t\n\r\0\x0B." ); |
| 3819 | if ( '' === $domain ) { |
| 3820 | /** This filter is documented in wp-includes/formatting.php */ |
| 3821 | return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' ); |
| 3822 | } |
| 3823 | |
| 3824 | // Split the domain into subs. |
| 3825 | $subs = explode( '.', $domain ); |
| 3826 | |
| 3827 | // Assume the domain will have at least two subs. |
| 3828 | if ( 2 > count( $subs ) ) { |
| 3829 | /** This filter is documented in wp-includes/formatting.php */ |
| 3830 | return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); |
| 3831 | } |
| 3832 | |
| 3833 | // Create an array that will contain valid subs. |
| 3834 | $new_subs = array(); |
| 3835 | |
| 3836 | // Loop through each sub. |
| 3837 | foreach ( $subs as $sub ) { |
| 3838 | // Test for leading and trailing hyphens. |
| 3839 | $sub = trim( $sub, " \t\n\r\0\x0B-" ); |
| Line | Code |
| 3844 | // If there's anything left, add it to the valid subs. |
| 3845 | if ( '' !== $sub ) { |
| 3846 | $new_subs[] = $sub; |
| 3847 | } |
| 3848 | } |
| 3849 | |
| 3850 | // If there aren't 2 or more valid subs. |
| 3851 | if ( 2 > count( $new_subs ) ) { |
| 3852 | /** This filter is documented in wp-includes/formatting.php */ |
| 3853 | return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); |
| 3854 | } |
| 3855 | |
| 3856 | // Join valid subs into the new domain. |
| 3857 | $domain = implode( '.', $new_subs ); |
| 3858 | |
| 3859 | // Put the email back together. |
| 3860 | $sanitized_email = $local . '@' . $domain; |
| 3861 | |
| 3862 | // Congratulations, your email made it! |
| 3863 | /** This filter is documented in wp-includes/formatting.php */ |
| 3864 | return apply_filters( 'sanitize_email', $sanitized_email, $email, null ); |
| 3865 | } |
| 3866 | |
| 3867 | /** |
| 3868 | * Determines the difference between two timestamps. |
| 3869 | * |
| 3870 | * The difference is returned in a human-readable format such as "1 hour", |
| 3871 | * "5 mins", "2 days". |
| 3872 | * |
| 3873 | * @since 1.5.0 |