diff --git a/includes/client/comments.php b/includes/client/comments.php index ab071c4..e33f230 100644 --- a/includes/client/comments.php +++ b/includes/client/comments.php @@ -62,7 +62,7 @@ function get_comment_actor_slug( $comment ) { if ( $comment->user_id !== '0' ) { return get_comment_user_actor_slug( $comment->user_id ); } else { - return get_comment_email_actor_slug( $comment ); + return get_comment_guest_actor_slug( $comment ); } } @@ -75,7 +75,7 @@ function get_comment_user_actor_slug( $user_id ) { } } -function get_comment_email_actor_slug( $comment ) { +function get_comment_guest_actor_slug( $comment ) { $email_address = $comment->comment_author_email; $url = $comment->comment_author_url; if ( empty( $url ) ) { diff --git a/includes/server/actors.php b/includes/server/actors.php index f8b6d24..a819725 100644 --- a/includes/server/actors.php +++ b/includes/server/actors.php @@ -258,7 +258,7 @@ function get_create_actor_query( $slug, $type, $email = null, $url = null, $name function upsert_commenter_actor( $email_address, $url = null, $name = null, $icon = null ) { global $wpdb; - $slug = email_address_to_slug( $email_address ); + $slug = name_to_slug( $name ); $existing = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}pterotype_actors WHERE slug = %s", $slug @@ -284,8 +284,11 @@ function upsert_commenter_actor( $email_address, $url = null, $name = null, $ico return $slug; } -function email_address_to_slug( $email_address ) { - $slug = str_replace( array( '@', '.'), '_', $email_address ); - return preg_replace( '/[^a-zA-Z0-9-_]/', '', $slug ); +function name_to_slug( $name ) { + if ( ! $name ) { + return 'anonymous'; + } + $slug = str_replace( array( '@', '.', ' '), '_', $name ); + return strtolower( preg_replace( '/[^a-zA-Z0-9-_]/', '', $slug ) ); } ?>