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 |
|---|---|
| 3099 | * 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits', |
| 3100 | * 'domain_no_periods', 'domain_no_valid_subs', or no context. |
| 3101 | * |
| 3102 | * @since 2.8.0 |
| 3103 | * |
| 3104 | * @param string $email The sanitized email address. |
| 3105 | * @param string $email The email address, as provided to sanitize_email(). |
| 3106 | * @param string $message A message to pass to the user. |
| 3107 | */ |
| 3108 | return apply_filters( 'sanitize_email', '', $email, 'email_too_short' ); |
| 3109 | } |
| 3110 | |
| 3111 | // Test for an @ character after the first position |
| 3112 | if ( strpos( $email, '@', 1 ) === false ) { |
| 3113 | /** This filter is documented in wp-includes/formatting.php */ |
| 3114 | return apply_filters( 'sanitize_email', '', $email, 'email_no_at' ); |
| 3115 | } |
| 3116 | |
| 3117 | // Split out the local and domain parts |
| 3118 | list( $local, $domain ) = explode( '@', $email, 2 ); |
| 3119 | |
| 3120 | // LOCAL PART |
| 3121 | // Test for invalid characters |
| 3122 | $local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local ); |
| 3123 | if ( '' === $local ) { |
| 3124 | /** This filter is documented in wp-includes/formatting.php */ |
| 3125 | return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' ); |
| 3126 | } |
| 3127 | |
| 3128 | // DOMAIN PART |
| 3129 | // Test for sequences of periods |
| 3130 | $domain = preg_replace( '/\.{2,}/', '', $domain ); |
| 3131 | if ( '' === $domain ) { |
| 3132 | /** This filter is documented in wp-includes/formatting.php */ |
| 3133 | return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' ); |
| 3134 | } |
| 3135 | |
| 3136 | // Test for leading and trailing periods and whitespace |
| 3137 | $domain = trim( $domain, " \t\n\r\0\x0B." ); |
| 3138 | if ( '' === $domain ) { |
| 3139 | /** This filter is documented in wp-includes/formatting.php */ |
| 3140 | return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' ); |
| 3141 | } |
| 3142 | |
| 3143 | // Split the domain into subs |
| 3144 | $subs = explode( '.', $domain ); |
| 3145 | |
| 3146 | // Assume the domain will have at least two subs |
| 3147 | if ( 2 > count( $subs ) ) { |
| 3148 | /** This filter is documented in wp-includes/formatting.php */ |
| 3149 | return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); |
| 3150 | } |
| 3151 | |
| 3152 | // Create an array that will contain valid subs |
| 3153 | $new_subs = array(); |
| 3154 | |
| 3155 | // Loop through each sub |
| 3156 | foreach ( $subs as $sub ) { |
| 3157 | // Test for leading and trailing hyphens |
| 3158 | $sub = trim( $sub, " \t\n\r\0\x0B-" ); |
| Line | Code |
| 3163 | // If there's anything left, add it to the valid subs |
| 3164 | if ( '' !== $sub ) { |
| 3165 | $new_subs[] = $sub; |
| 3166 | } |
| 3167 | } |
| 3168 | |
| 3169 | // If there aren't 2 or more valid subs |
| 3170 | if ( 2 > count( $new_subs ) ) { |
| 3171 | /** This filter is documented in wp-includes/formatting.php */ |
| 3172 | return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); |
| 3173 | } |
| 3174 | |
| 3175 | // Join valid subs into the new domain |
| 3176 | $domain = join( '.', $new_subs ); |
| 3177 | |
| 3178 | // Put the email back together |
| 3179 | $email = $local . '@' . $domain; |
| 3180 | |
| 3181 | // Congratulations your email made it! |
| 3182 | /** This filter is documented in wp-includes/formatting.php */ |
| 3183 | return apply_filters( 'sanitize_email', $email, $email, null ); |
| 3184 | } |
| 3185 | |
| 3186 | /** |
| 3187 | * Determines the difference between two timestamps. |
| 3188 | * |
| 3189 | * The difference is returned in a human readable format such as "1 hour", |
| 3190 | * "5 mins", "2 days". |
| 3191 | * |
| 3192 | * @since 1.5.0 |