Add some user filters.

git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@3802 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-05-26 22:49:31 +00:00
parent 5a0d39f624
commit 9bd85f8e4d
3 changed files with 56 additions and 4 deletions

View File

@ -93,16 +93,16 @@ function wp_insert_category($catarr) {
$update = false; $update = false;
$cat_name = apply_filters('pre_category_name', $cat_name); $cat_name = apply_filters('pre_category_name', $cat_name);
$category_nicename = apply_filters('pre_category_nicename', $category_nicename);
$category_description = apply_filters('pre_category_description', $category_description);
if (empty ($category_nicename)) if (empty ($category_nicename))
$category_nicename = sanitize_title($cat_name); $category_nicename = sanitize_title($cat_name);
else else
$category_nicename = sanitize_title($category_nicename); $category_nicename = sanitize_title($category_nicename);
$category_nicename = apply_filters('pre_category_nicename', $category_nicename);
if (empty ($category_description)) if (empty ($category_description))
$category_description = ''; $category_description = '';
$category_description = apply_filters('pre_category_description', $category_description);
$category_parent = (int) $category_parent; $category_parent = (int) $category_parent;
if (empty ($category_parent)) if (empty ($category_parent))

View File

@ -56,6 +56,33 @@ add_filter('pre_category_name', 'wp_filter_kses');
add_filter('pre_category_name', 'wp_specialchars', 30); add_filter('pre_category_name', 'wp_specialchars', 30);
add_filter('pre_category_description', 'wp_filter_kses'); add_filter('pre_category_description', 'wp_filter_kses');
// Users
add_filter('pre_user_display_name', 'strip_tags');
add_filter('pre_user_display_name', 'trim');
add_filter('pre_user_display_name', 'wp_filter_kses');
add_filter('pre_user_display_name', 'wp_specialchars', 30);
add_filter('pre_user_first_name', 'strip_tags');
add_filter('pre_user_first_name', 'trim');
add_filter('pre_user_first_name', 'wp_filter_kses');
add_filter('pre_user_first_name', 'wp_specialchars', 30);
add_filter('pre_user_last_name', 'strip_tags');
add_filter('pre_user_last_name', 'trim');
add_filter('pre_user_last_name', 'wp_filter_kses');
add_filter('pre_user_last_name', 'wp_specialchars', 30);
add_filter('pre_user_nickname', 'strip_tags');
add_filter('pre_user_nickname', 'trim');
add_filter('pre_user_nickname', 'wp_filter_kses');
add_filter('pre_user_nickname', 'wp_specialchars', 30);
add_filter('pre_user_description', 'strip_tags');
add_filter('pre_user_description', 'trim');
add_filter('pre_user_description', 'wp_filter_kses');
add_filter('pre_user_description', 'wp_specialchars', 30);
add_filter('pre_user_url', 'strip_tags');
add_filter('pre_user_url', 'trim');
add_filter('pre_user_url', 'clean_url');
add_filter('pre_user_email', 'trim');
add_filter('pre_user_email', 'sanitize_email');
// Places to balance tags on input // Places to balance tags on input
add_filter('content_save_pre', 'balanceTags', 50); add_filter('content_save_pre', 'balanceTags', 50);
add_filter('excerpt_save_pre', 'balanceTags', 50); add_filter('excerpt_save_pre', 'balanceTags', 50);

View File

@ -27,6 +27,7 @@ function wp_insert_user($userdata) {
// Are we updating or creating? // Are we updating or creating?
if ( !empty($ID) ) { if ( !empty($ID) ) {
$ID = (int) $ID;
$update = true; $update = true;
} else { } else {
$update = false; $update = false;
@ -35,15 +36,39 @@ function wp_insert_user($userdata) {
} }
$user_login = sanitize_user($user_login, true); $user_login = sanitize_user($user_login, true);
$user_login = apply_filters('pre_user_login', $user_login);
if ( empty($user_nicename) ) if ( empty($user_nicename) )
$user_nicename = sanitize_title( $user_login ); $user_nicename = sanitize_title( $user_login );
$user_nicename = apply_filters('pre_user_nicename', $user_nicename);
if ( empty($user_url) )
$user_url = '';
$user_url = apply_filters('pre_user_url', $user_url);
if ( empty($user_email) )
$user_email = '';
$user_email = apply_filters('pre_user_email', $user_email);
if ( empty($display_name) ) if ( empty($display_name) )
$display_name = $user_login; $display_name = $user_login;
$display_name = apply_filters('pre_user_display_name', $display_name);
if ( empty($nickname) ) if ( empty($nickname) )
$nickname = $user_login; $nickname = $user_login;
$nickname = apply_filters('pre_user_nickname', $nickname);
if ( empty($first_name) )
$first_name = '';
$first_name = apply_filters('pre_user_first_name', $first_name);
if ( empty($last_name) )
$last_name = '';
$last_name = apply_filters('pre_user_last_name', $last_name);
if ( empty($description) )
$description = '';
$description = apply_filters('pre_user_description', $description);
if ( empty($user_registered) ) if ( empty($user_registered) )
$user_registered = gmdate('Y-m-d H:i:s'); $user_registered = gmdate('Y-m-d H:i:s');