-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Post Author block now includes option to link author archive #42670
Post Author block now includes option to link author archive #42670
Conversation
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @philwp! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
Thank you for creating this PR @philwp @michalczaplinski and @c4rl0sbr4v0 Perhaps you can take a look at this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your contribution!! I added some small details.
@@ -23,6 +23,9 @@ | |||
}, | |||
"byline": { | |||
"type": "string" | |||
}, | |||
"linked": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may better use isLink, so that way is similar to other blocks like:
"isLink": { |
"isLink": { |
Also would be cool to have a default value here.
$link = ! empty( $attributes['linked'] ) ? get_author_posts_url( $author_id ) : ''; | ||
$author_name = $link ? '<a href="' . $link . '">' . get_the_author_meta( 'display_name', $author_id ) . '</a>' : get_the_author_meta( 'display_name', $author_id ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is working fine, but, maybe, in order to keep consistency with other blocks, we could do:
- Define the default author name:
$author_name = get_the_author_meta( 'display_name', $author_id );
- Update the value if the link attribute is enabled:
if ( ! empty( $attributes['isLink'] ) && ! empty( $attributes['linkTarget'] ) ) {
$comment_author = sprintf( '<a rel="external nofollow ugc" href="%1s" target="%2s" >%3s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $comment_author );
}
- Check if rel attribute is needed, add a target option.
Comment Author Name block is an example you can use 😄
gutenberg/packages/block-library/src/comment-author-name/index.php
Lines 37 to 39 in ac4d4b0
if ( ! empty( $attributes['isLink'] ) && ! empty( $attributes['linkTarget'] ) ) { | |
$comment_author = sprintf( '<a rel="external nofollow ugc" href="%1s" target="%2s" >%3s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $comment_author ); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll update to match the implementation used in comment-author-name
.
@philwp , we need to run in order to pass all the tests, thanks for your contribution to the project! 🎉
|
@philwp , sorry, in order to pass the JS unit tests, as you added new attributes to a block, you have to regenerate the fixtures. Thanks!! |
Congratulations on your first merged pull request, @philwp! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts: https://profiles.wordpress.org/me/profile/edit/ And if you don't have a WordPress.org account, you can create one on this page: https://login.wordpress.org/register Kudos! |
What?
Adds a toggle option to add a link to the Author's archive page.
Why?
Resolves #41554
How?
If the
linked
attribute istrue
Testing Instructions
Post Author
block.Link author name to author page
Screenshots or screencast