public
Last active

T5 Extend Email Checks

  • Download Gist
t5-extend-email-checks.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<?php # -*- coding: utf-8 -*-
/*
Plugin Name: T5 Extend Email Checks
Description: Overrides the results of the functions <code>is_email()</code> and <code>sanitize_email()</code>. Allows for example <code>me@localhost</code> or punycode encoded email adresses by using PHP’s internal filter function.
Version: 2012.08.29
Plugin URI: http://toscho.de/?p=2195
Author: Thomas Scholz
Author URI: http://toscho.de
License: MIT
*/
! defined( 'ABSPATH' ) and exit;
 
if ( ! function_exists( 't5_extend_email_checks' ) )
{
add_filter( 'is_email', 'extend_email_checks', 10, 2 );
add_filter( 'sanitize_email', 'extend_email_checks', 10, 2 );
 
function t5_extend_email_checks( $result, $email )
{
return filter_var( $email, FILTER_VALIDATE_EMAIL );
}
}

Is there a reason you don't return the filtered $email if the filter_var did not false?

Uhm … but I do exactly this!?

filtered in the meaning of filter_var(), e.g.: return filter_var( $email, FILTER_VALIDATE_EMAIL ); -- filter_var will either return FALSE or the filtered value of $email. In your gist you return $email unfiltered.

Oh, I see. :) Changed.

Ive tested this and it still errors on an apostrophe.. is it working for you ?

Do you mean an apostrophe in a mail address or a parse error?

no, no parse error, but the address is still rejected.

does the PHP filter not allow apostrophes ?

The filter allows apostrophes, at least the fake apostrophe '. Hm, the WordPress functions should allow it too. I’m not sure what happens here.

They, dont, its a logged issue in WP Trac. Im trying to find the easiest workaround...

Are we going to get this change pushed into a future release ?

https://wordpress.org/support/topic/writing-a-plugin-to-amend-the-core-possible?replies=9#post-2769861

It would be handy to support email address's properly...

There is an open ticket: http://core.trac.wordpress.org/ticket/17433

Go, vote for it, add Unit tests. Then it may become part of the core.

That's not quite the same issue, but i appreciate it needs to be voted up..
Can we add the apostrophe issue to the same core change maybe ?

Thanks

Ben

On Mon, Apr 23, 2012 at 11:32 AM, Thomas Scholz <
reply@reply.github.com

wrote:

There is an open ticket: http://core.trac.wordpress.org/ticket/17433

Go, vote for it, add Unit tests. Then it may become part of the core.


Reply to this email directly or view it on GitHub:
https://gist.github.com/972837

Ask on Trac. I have no influence to core development.

The callback functions need the t5_ prefix - have forked a working example.

Note that apostrophes are escaped by WordPress, so they are still invalid.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.