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 9 times in this file.
| Line | Code |
|---|---|
| 2190 | * 'domain_no_periods', 'sub_hyphen_limits', 'sub_invalid_chars', or no specific context. |
| 2191 | * |
| 2192 | * @since 2.8.0 |
| 2193 | * |
| 2194 | * @param bool $is_email Whether the email address has passed the is_email() checks. Default false. |
| 2195 | * @param string $email The email address being checked. |
| 2196 | * @param string $message An explanatory message to the user. |
| 2197 | * @param string $context Context under which the email was tested. |
| 2198 | */ |
| 2199 | return apply_filters( 'is_email', false, $email, 'email_too_short' ); |
| 2200 | } |
| 2201 | |
| 2202 | // Test for an @ character after the first position |
| 2203 | if ( strpos( $email, '@', 1 ) === false ) { |
| 2204 | /** This filter is documented in wp-includes/formatting.php */ |
| 2205 | return apply_filters( 'is_email', false, $email, 'email_no_at' ); |
| 2206 | } |
| 2207 | |
| 2208 | // Split out the local and domain parts |
| 2209 | list( $local, $domain ) = explode( '@', $email, 2 ); |
| 2210 | |
| 2211 | // LOCAL PART |
| 2212 | // Test for invalid characters |
| 2213 | if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) { |
| 2214 | /** This filter is documented in wp-includes/formatting.php */ |
| 2215 | return apply_filters( 'is_email', false, $email, 'local_invalid_chars' ); |
| 2216 | } |
| 2217 | |
| 2218 | // DOMAIN PART |
| 2219 | // Test for sequences of periods |
| 2220 | if ( preg_match( '/\.{2,}/', $domain ) ) { |
| 2221 | /** This filter is documented in wp-includes/formatting.php */ |
| 2222 | return apply_filters( 'is_email', false, $email, 'domain_period_sequence' ); |
| 2223 | } |
| 2224 | |
| 2225 | // Test for leading and trailing periods and whitespace |
| 2226 | if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { |
| 2227 | /** This filter is documented in wp-includes/formatting.php */ |
| 2228 | return apply_filters( 'is_email', false, $email, 'domain_period_limits' ); |
| 2229 | } |
| 2230 | |
| 2231 | // Split the domain into subs |
| 2232 | $subs = explode( '.', $domain ); |
| 2233 | |
| 2234 | // Assume the domain will have at least two subs |
| 2235 | if ( 2 > count( $subs ) ) { |
| 2236 | /** This filter is documented in wp-includes/formatting.php */ |
| 2237 | return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); |
| 2238 | } |
| 2239 | |
| 2240 | // Loop through each sub |
| 2241 | foreach ( $subs as $sub ) { |
| 2242 | // Test for leading and trailing hyphens and whitespace |
| 2243 | if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) { |
| 2244 | /** This filter is documented in wp-includes/formatting.php */ |
| 2245 | return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' ); |
| 2246 | } |
| 2247 | |
| 2248 | // Test for invalid characters |
| 2249 | if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) { |
| 2250 | /** This filter is documented in wp-includes/formatting.php */ |
| 2251 | return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); |
| 2252 | } |
| 2253 | } |
| 2254 | |
| 2255 | // Congratulations your email made it! |
| 2256 | /** This filter is documented in wp-includes/formatting.php */ |
| 2257 | return apply_filters( 'is_email', $email, $email, null ); |
| 2258 | } |
| 2259 | |
| 2260 | /** |
| 2261 | * Convert to ASCII from email subjects. |
| 2262 | * |
| 2263 | * @since 1.2.0 |
| 2264 | * |
| 2265 | * @param string $string Subject line |
| 2266 | * @return string Converted string to ASCII |