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 |
---|---|
2472 | * 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits', |
2473 | * 'domain_no_periods', 'sub_hyphen_limits', 'sub_invalid_chars', or no specific context. |
2474 | * |
2475 | * @since 2.8.0 |
2476 | * |
2477 | * @param bool $is_email Whether the email address has passed the is_email() checks. Default false. |
2478 | * @param string $email The email address being checked. |
2479 | * @param string $context Context under which the email was tested. |
2480 | */ |
2481 | return apply_filters( 'is_email', false, $email, 'email_too_short' ); |
2482 | } |
2483 |
|
2484 | // Test for an @ character after the first position |
2485 | if ( strpos( $email, '@', 1 ) === false ) { |
2486 | /** This filter is documented in wp-includes/formatting.php */ |
2487 | return apply_filters( 'is_email', false, $email, 'email_no_at' ); |
2488 | } |
2489 |
|
2490 | // Split out the local and domain parts |
2491 | list( $local, $domain ) = explode( '@', $email, 2 ); |
2492 |
|
2493 | // LOCAL PART |
2494 | // Test for invalid characters |
2495 | if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) { |
2496 | /** This filter is documented in wp-includes/formatting.php */ |
2497 | return apply_filters( 'is_email', false, $email, 'local_invalid_chars' ); |
2498 | } |
2499 |
|
2500 | // DOMAIN PART |
2501 | // Test for sequences of periods |
2502 | if ( preg_match( '/\.{2,}/', $domain ) ) { |
2503 | /** This filter is documented in wp-includes/formatting.php */ |
2504 | return apply_filters( 'is_email', false, $email, 'domain_period_sequence' ); |
2505 | } |
2506 |
|
2507 | // Test for leading and trailing periods and whitespace |
2508 | if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { |
2509 | /** This filter is documented in wp-includes/formatting.php */ |
2510 | return apply_filters( 'is_email', false, $email, 'domain_period_limits' ); |
2511 | } |
2512 |
|
2513 | // Split the domain into subs |
2514 | $subs = explode( '.', $domain ); |
2515 |
|
2516 | // Assume the domain will have at least two subs |
2517 | if ( 2 > count( $subs ) ) { |
2518 | /** This filter is documented in wp-includes/formatting.php */ |
2519 | return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); |
2520 | } |
2521 |
|
2522 | // Loop through each sub |
2523 | foreach ( $subs as $sub ) { |
2524 | // Test for leading and trailing hyphens and whitespace |
2525 | if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) { |
2526 | /** This filter is documented in wp-includes/formatting.php */ |
2527 | return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' ); |
2528 | } |
2529 |
|
2530 | // Test for invalid characters |
2531 | if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) { |
2532 | /** This filter is documented in wp-includes/formatting.php */ |
2533 | return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); |
2534 | } |
2535 | } |
2536 |
|
2537 | // Congratulations your email made it! |
2538 | /** This filter is documented in wp-includes/formatting.php */ |
2539 | return apply_filters( 'is_email', $email, $email, null ); |
2540 | } |
2541 |
|
2542 | /** |
2543 | * Convert to ASCII from email subjects. |
2544 | * |
2545 | * @since 1.2.0 |
2546 | * |
2547 | * @param string $string Subject line |
2548 | * @return string Converted string to ASCII |