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 |
---|---|
2726 | * 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits', |
2727 | * 'domain_no_periods', 'domain_no_valid_subs', or no context. |
2728 | * |
2729 | * @since 2.8.0 |
2730 | * |
2731 | * @param string $email The sanitized email address. |
2732 | * @param string $email The email address, as provided to sanitize_email(). |
2733 | * @param string $message A message to pass to the user. |
2734 | */ |
2735 | return apply_filters( 'sanitize_email', '', $email, 'email_too_short' ); |
2736 | } |
2737 |
|
2738 | // Test for an @ character after the first position |
2739 | if ( strpos( $email, '@', 1 ) === false ) { |
2740 | /** This filter is documented in wp-includes/formatting.php */ |
2741 | return apply_filters( 'sanitize_email', '', $email, 'email_no_at' ); |
2742 | } |
2743 |
|
2744 | // Split out the local and domain parts |
2745 | list( $local, $domain ) = explode( '@', $email, 2 ); |
2746 |
|
2747 | // LOCAL PART |
2748 | // Test for invalid characters |
2749 | $local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local ); |
2750 | if ( '' === $local ) { |
2751 | /** This filter is documented in wp-includes/formatting.php */ |
2752 | return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' ); |
2753 | } |
2754 |
|
2755 | // DOMAIN PART |
2756 | // Test for sequences of periods |
2757 | $domain = preg_replace( '/\.{2,}/', '', $domain ); |
2758 | if ( '' === $domain ) { |
2759 | /** This filter is documented in wp-includes/formatting.php */ |
2760 | return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' ); |
2761 | } |
2762 |
|
2763 | // Test for leading and trailing periods and whitespace |
2764 | $domain = trim( $domain, " \t\n\r\0\x0B." ); |
2765 | if ( '' === $domain ) { |
2766 | /** This filter is documented in wp-includes/formatting.php */ |
2767 | return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' ); |
2768 | } |
2769 |
|
2770 | // Split the domain into subs |
2771 | $subs = explode( '.', $domain ); |
2772 |
|
2773 | // Assume the domain will have at least two subs |
2774 | if ( 2 > count( $subs ) ) { |
2775 | /** This filter is documented in wp-includes/formatting.php */ |
2776 | return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); |
2777 | } |
2778 |
|
2779 | // Create an array that will contain valid subs |
2780 | $new_subs = array(); |
2781 |
|
2782 | // Loop through each sub |
2783 | foreach ( $subs as $sub ) { |
2784 | // Test for leading and trailing hyphens |
2785 | $sub = trim( $sub, " \t\n\r\0\x0B-" ); |
Line | Code |
2790 | // If there's anything left, add it to the valid subs |
2791 | if ( '' !== $sub ) { |
2792 | $new_subs[] = $sub; |
2793 | } |
2794 | } |
2795 |
|
2796 | // If there aren't 2 or more valid subs |
2797 | if ( 2 > count( $new_subs ) ) { |
2798 | /** This filter is documented in wp-includes/formatting.php */ |
2799 | return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); |
2800 | } |
2801 |
|
2802 | // Join valid subs into the new domain |
2803 | $domain = join( '.', $new_subs ); |
2804 |
|
2805 | // Put the email back together |
2806 | $email = $local . '@' . $domain; |
2807 |
|
2808 | // Congratulations your email made it! |
2809 | /** This filter is documented in wp-includes/formatting.php */ |
2810 | return apply_filters( 'sanitize_email', $email, $email, null ); |
2811 | } |
2812 |
|
2813 | /** |
2814 | * Determines the difference between two timestamps. |
2815 | * |
2816 | * The difference is returned in a human readable format such as "1 hour", |
2817 | * "5 mins", "2 days". |
2818 | * |
2819 | * @since 1.5.0 |