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