WordPress / theme-test-data

Theme Test Data
622 stars 16 forks source link

.bypostauthor class is not added to comments #54

Closed DesignerThan95 closed 4 years ago

DesignerThan95 commented 4 years ago

I have the problem, that the ".bypostauthor" Class is not added to the comments of "themedemos" in the comments template post. I have changed the Name of the Themedemos User to test if the name of the comments changes. But it does not.

joyously commented 4 years ago

Each user has an option for "Display name as", where the user can choose to show the nickname, first name, last name, or first and last. So the theme should be showing the name as chosen by the user in their profile. But the post author user name is matched to the comment user name, and if they match, the comment should have the class bypostauthor.

DesignerThan95 commented 4 years ago

I have checked it now. The post author user name is themedemos and the comment user name matches it. I have done some debugging, and in the method get_comment_class the core checks if the user_id is higher than 0 and later it checks if the user_id of the post author and the comment author are the same.

Thats the Core Code: // Add classes for comment authors that are registered users. if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) { $classes[] = 'byuser'; $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id ); // For comment authors who are the author of the post if ( $post = get_post( $post_id ) ) { if ( $comment->user_id === $post->post_author ) { $classes[] = 'bypostauthor'; } } }

DesignerThan95 commented 4 years ago

I have opened an Issue and made a pull request for my fix in the wordpress importer. https://github.com/WordPress/wordpress-importer/issues/55

DesignerThan95 commented 4 years ago

It seams that it is not an issue of the data that is being imported. It is an issue with the importer plugin.