Skip to content
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

Improve support for distributed guest authors #2215

Merged
merged 6 commits into from
Jan 9, 2024

Conversation

leogermani
Copy link
Contributor

@leogermani leogermani commented Dec 13, 2023

Handle guest authors distributed via Newspack Network and Distributor plugins

All Submissions:

Changes proposed in this Pull Request:

Improves the support for the distributed post authors by Newspack Network.

Basically - remove the a tag for authors without a URL.

Also sends an extra information in the newspack_author_bio_name filter.

How to test the changes in this Pull Request:

See Automattic/newspack-network#25

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@miguelpeixe
Copy link
Member

Can't this be a filter inside the Newspack Network plugin so it's contained in the same codebase? Distributor has a similar strategy to filter the author to make it appear as the site name.

@leogermani
Copy link
Contributor Author

Can't this be a filter inside the Newspack Network plugin so it's contained in the same codebase? Distributor has a similar strategy to filter the author to make it appear as the site name.

Most of the things work from a filter. The only reason we need some customization here is to remove the a tags from authors without a link. If we don't do that, they will link to 404. get_author_posts_url is very loose and even if you pass an invalid ID and user_nicename it will return a link to the authors base url.

As for the avatar, we won't need anything here if we are able to add a filter to the coauthors_get_avatar in the CAP plugin itself. Otherwise there's no way to filter it.

But anyway. all this approach is still under discussion

@miguelpeixe
Copy link
Member

Thank you for explaining!

@leogermani leogermani changed the title feat: support distributed guest authors Improve support for distributed guest authors Dec 18, 2023
@leogermani leogermani self-assigned this Dec 18, 2023
@leogermani leogermani added the [Status] Needs Review The issue or pull request needs to be reviewed label Dec 18, 2023
@leogermani leogermani marked this pull request as ready for review December 18, 2023 13:47
@leogermani leogermani requested a review from a team as a code owner December 18, 2023 13:47
Copy link
Contributor

@laurelfulford laurelfulford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so cool, @leogermani! 🙌

I tested posts with single guest authors, multiple guest authors, mix of guest and regular, and a guest mapped to a regular author. The only issue I've run into is that the distributed guest author avatars don't seem to be syncing, but only for the byline at the top -- they appear as expected in the author bio at the bottom of the post. The regular author avatars work 100% as expected.

Screen Shot 2023-12-21 at 10 29 04 AM

Screen Shot 2023-12-21 at 10 29 10 AM

Job titles, bios, and email addresses were brought over as expected!

Styles
There was some discussion about whether these should be styled to match the linked authors. Personally, I'm leaning towards leaving them as the default grey -- I think that could give some visual feedback that they're not the same as the other names and (hopefully!) help set expectations that they're not going to be links. I'm open to discussing that further, though! I feel like either way we land with this, there will be publishers who want it to work "the other way" (either match the regular links, or look less like the links).

Custom CSS
I think there's a small risk existing custom CSS won't be applied as expected to these new unlinked bylines because an HTML element has been removed. I think it's super-minor though -- and it won't affect existing posts since it's a new feature, just posts going forward. I think we can tackle this as it comes up (it will likely also happen if we opt to style these to match the links).

@laurelfulford laurelfulford self-requested a review December 21, 2023 19:05
Copy link
Contributor

@laurelfulford laurelfulford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @leogermani! 8367482 fixed the issue for me:

image

I have one more change that I missed in my initial review: Newspack Sacha also has its own /author-bio.php file that would need the same changes as the main theme's file, just to make sure it's picking up the same updated author info. The separate file was to help make its centred layout easier to accomplish, but more than once I wish I'd just reworked the original file earlier on to avoid adding it!

@leogermani
Copy link
Contributor Author

Thanks for the review @laurelfulford

I've updated the checks with some recent changes on the PR in the Newspack Network plugin, but it should work just the same.

And I applied the changes to the Sacha theme.

All those ifs are not pretty, but I think it's good enough for now.

I also tested with co-authors-plus disabled in both themes just to make sure :)

Copy link
Contributor

@laurelfulford laurelfulford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @leogermani!

All those ifs are not pretty, but I think it's good enough for now.

I thought you meant the ones that were already there 😆 These files are already full of so many ifs and elses, adding more at this point can't hurt!

I retested this with Newspack and Newspack Sasha, with and without Co-Author Plus, and the single posts work as expected! 🎉

I found one more spot that may need changes, but it's not something that's actually being addressed in this PR yet, so I'm marking this as approved in case it's just easier to do it as a separate fix: clicking around, I noticed that the 'real' authors that are brought over via the Network still have the site's name as their name on the author archives. For example, this author has the display name 'laurel' but it's still showing 'Newspack Dev' (my spoke site) on the Hub archive:

image

Just let me know if you have any questions about that, or can't reproduce! I don't remember spotting that when I last tested, but I don't think I actually clicked over to the transferred author archive pages. (Also just let me know if I should spin up an Asana task for that with better steps to replicate!).

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Jan 9, 2024
@leogermani
Copy link
Contributor Author

@laurelfulford Can you check if you unmarked the "Override Author Byline" option in Distributor > Settings?

image

@laurelfulford
Copy link
Contributor

Can you check if you unmarked the "Override Author Byline" option in Distributor > Settings?

@leogermani I had it checked when this happened, but I also unchecked it both on the Hub and Spoke and could see the same issue 😕 I'll take some time this AM trying to recreate in a different set up, and can follow up with a separate task if I'm still seeing it with a link!

@leogermani leogermani merged commit e007555 into master Jan 9, 2024
1 check passed
@miguelpeixe miguelpeixe deleted the feat/support-distributed-guest-authors branch January 9, 2024 17:19
@laurelfulford
Copy link
Contributor

@leogermani Just wanted to follow up and confirm I CAN'T recreate the above on two JN sites set up with Hub & Spoke plus this PR, so that issue was totally user error 🙂

@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.84.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.84.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @alpha released [Status] Approved The pull request has been reviewed and is ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants