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 |
|---|---|
| 1949 | * 'domain_no_periods', 'sub_hyphen_limits', 'sub_invalid_chars', or no specific context. |
| 1950 | * |
| 1951 | * @since 2.8.0 |
| 1952 | * |
| 1953 | * @param bool $is_email Whether the email address has passed the is_email() checks. Default false. |
| 1954 | * @param string $email The email address being checked. |
| 1955 | * @param string $message An explanatory message to the user. |
| 1956 | * @param string $context Context under which the email was tested. |
| 1957 | */ |
| 1958 | return apply_filters( 'is_email', false, $email, 'email_too_short' ); |
| 1959 | } |
| 1960 | |
| 1961 | // Test for an @ character after the first position |
| 1962 | if ( strpos( $email, '@', 1 ) === false ) { |
| 1963 | /** This filter is documented in wp-includes/formatting.php */ |
| 1964 | return apply_filters( 'is_email', false, $email, 'email_no_at' ); |
| 1965 | } |
| 1966 | |
| 1967 | // Split out the local and domain parts |
| 1968 | list( $local, $domain ) = explode( '@', $email, 2 ); |
| 1969 | |
| 1970 | // LOCAL PART |
| 1971 | // Test for invalid characters |
| 1972 | if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) { |
| 1973 | /** This filter is documented in wp-includes/formatting.php */ |
| 1974 | return apply_filters( 'is_email', false, $email, 'local_invalid_chars' ); |
| 1975 | } |
| 1976 | |
| 1977 | // DOMAIN PART |
| 1978 | // Test for sequences of periods |
| 1979 | if ( preg_match( '/\.{2,}/', $domain ) ) { |
| 1980 | /** This filter is documented in wp-includes/formatting.php */ |
| 1981 | return apply_filters( 'is_email', false, $email, 'domain_period_sequence' ); |
| 1982 | } |
| 1983 | |
| 1984 | // Test for leading and trailing periods and whitespace |
| 1985 | if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { |
| 1986 | /** This filter is documented in wp-includes/formatting.php */ |
| 1987 | return apply_filters( 'is_email', false, $email, 'domain_period_limits' ); |
| 1988 | } |
| 1989 | |
| 1990 | // Split the domain into subs |
| 1991 | $subs = explode( '.', $domain ); |
| 1992 | |
| 1993 | // Assume the domain will have at least two subs |
| 1994 | if ( 2 > count( $subs ) ) { |
| 1995 | /** This filter is documented in wp-includes/formatting.php */ |
| 1996 | return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); |
| 1997 | } |
| 1998 | |
| 1999 | // Loop through each sub |
| 2000 | foreach ( $subs as $sub ) { |
| 2001 | // Test for leading and trailing hyphens and whitespace |
| 2002 | if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) { |
| 2003 | /** This filter is documented in wp-includes/formatting.php */ |
| 2004 | return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' ); |
| 2005 | } |
| 2006 | |
| 2007 | // Test for invalid characters |
| 2008 | if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) { |
| 2009 | /** This filter is documented in wp-includes/formatting.php */ |
| 2010 | return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); |
| 2011 | } |
| 2012 | } |
| 2013 | |
| 2014 | // Congratulations your email made it! |
| 2015 | /** This filter is documented in wp-includes/formatting.php */ |
| 2016 | return apply_filters( 'is_email', $email, $email, null ); |
| 2017 | } |
| 2018 | |
| 2019 | /** |
| 2020 | * Convert to ASCII from email subjects. |
| 2021 | * |
| 2022 | * @since 1.2.0 |
| 2023 | * |
| 2024 | * @param string $string Subject line |
| 2025 | * @return string Converted string to ASCII |