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