Automattic / Co-Authors-Plus

Multiple bylines and Guest Authors for WordPress
https://wordpress.org/plugins/co-authors-plus/
GNU General Public License v2.0
290 stars 205 forks source link

Tracking issue for further block editor and full site editing support #940

Open douglas-johnson opened 1 year ago

douglas-johnson commented 1 year ago

Continued from #932 cc @alecgeatches

Goal

Improve support for the block editor and full site editing by providing blocks to handle two use cases:

  1. Display one or more coauthors in a templated manner within post contexts and query loops.
  2. Display the queried coauthor in author archive contexts.

Features

Blocks

Block Editor

Full Site Editing

Layouts

Extensibility

Features in consideration for future versions

Approach

API

Create two API endpoints intended to GET coauthor data.

GET CoAuthors by :post-id

Use Case

Request

Response

Authorization

GET CoAuthor by :author-name

Use Case

Request

Response

Authorization

CoAuthor Objects in API Responses

These objects should have the same shape as the objects returned by get_coauthors(), with some notable exceptions.

Developer Experience

Use wp-scripts with the ability to run a single build command for all blocks and scripts in CAP.

Compatibility considerations

douglas-johnson commented 1 year ago

Notes regarding full site editing for author archives:

Here is an audit of the core blocks when used in an author archive template:

douglas-johnson commented 1 year ago

Stopping by with an updated as I continue working on this branch: https://github.com/Automattic/Co-Authors-Plus/compare/master...thoughtis:Co-Authors-Plus:block-exploration

I pushed things like:

Notes:

douglas-johnson commented 1 year ago

Since my last comment here I worked on:

I plan to work on avatars next.

douglas-johnson commented 1 year ago

Here's a video where I add coauthor bylines to a query loop on the front page through full site editing. I tried to click around to all the current features. I plan to work on layout settings next. I'm happy for feedback if anyone wants to try out the branch here.

https://github.com/Automattic/Co-Authors-Plus/assets/226381/ddeec941-355e-47b4-a701-eea03ccbb91f

GaryJones commented 1 year ago

That's looking fantastic!

alecgeatches commented 1 year ago

@douglas-johnson Excellent demo! You've put a lot of work into customization in-editor and it looks amazing.

douglas-johnson commented 1 year ago

Since my last update I worked on layout settings as planned and tried to figure out how to provide the correct context to blocks used on the author archive.

I made a new branch when I started exploring the layout changes. It is available here: https://github.com/Automattic/Co-Authors-Plus/compare/master...thoughtis:Co-Authors-Plus:issue%23940/coauthor-blocks

Using block layout

I this video I use FSE to add Co-Authors to the Post Meta template part within the Single template. It uses the block layout which supports vertical spacing between coauthors.

https://github.com/Automattic/Co-Authors-Plus/assets/226381/a336e530-67ce-461f-b337-264545e871a0

Author archive context

In this video I add CAP blocks to the author archive template without wrapping them in the Co-Authors block.

To support this I added a filter on render_block_context that provides the queried author based on the author_name query var. This works in the condition where:

  1. The request was for an author archive ( true === is_author() )
  2. The block is not wrapped in a Co-Authors block like it would be if you used it in a query loop elsewhere on the author archive.

You can see that code here: https://github.com/thoughtis/Co-Authors-Plus/blob/db8529990dd2d0dcc316ab9bd96f63e97af225fc/blocks/coauthor-display-name/class-cap-block-coauthor-display-name.php#L84

https://github.com/Automattic/Co-Authors-Plus/assets/226381/a339bf50-c6c8-4972-b1a9-5d613fc303c0

Up Next

GaryJones commented 1 year ago

Looking amazing! Intuitive, flexible, and just what's been missing all this time! Thank you for doing this.

douglas-johnson commented 1 year ago

Hi @GaryJones and @alecgeatches - I'm stopping by with one more demo. This time its for guest author feature images.

https://github.com/Automattic/Co-Authors-Plus/compare/master...thoughtis:Co-Authors-Plus:issue%23940/coauthor-blocks

With this working, I feel we have the intended features. There is still work I would like to do in documentation and developer experience as well as testing and fine tuning. I am out on vacation starting tomorrow and will be back on September 5th.

Post editor

https://github.com/Automattic/Co-Authors-Plus/assets/226381/9b567509-a3f7-4be3-812f-0581752138d7

Author archive in site editor

https://github.com/Automattic/Co-Authors-Plus/assets/226381/adfbf6d3-4016-479a-80df-7a7d405857b0

New Changes

Work before pull request

GaryJones commented 1 year ago

Amazing šŸ¤©

What's the difference between the Co-Author Avatar and Co-Author Feature Image blocks?

douglas-johnson commented 1 year ago

What's the difference between the Co-Author Avatar and Co-Author Feature Image blocks?

Avatar uses the avatar system. Its equivalent to calling get_avatar(). There are a limited number of sizes, they are always cropped square and will include Gravatars.

Feature Image is for higher resolution images and doesn't have the Gravatar fallback. Since it starts with an attachment id, we can provide the size, cropping and border settings from the core Feature Image block. Its similar to calling wp_get_attachment_image().

GaryJones commented 1 year ago

How does the Co-Author Feature Image block differ from the core Feature Image block?

douglas-johnson commented 1 year ago

How does the Co-Author Feature Image block differ from the core Feature Image block?

The core block needs to be in a post context. The co-author block uses the author context I've set up. It supports resizing, aspect ratios, and border settings, but I didn't incorporate the overlay capability of the core block.

IvanPigarev commented 1 year ago

When will these changes see the light of day? So missing working with the plugin in the block editor :( Very much waiting for the new version!

douglas-johnson commented 1 year ago

When will these changes see the light of day? So missing working with the plugin in the block editor :( Very much waiting for the new version!

Hi @IvanPigarev I'm happy to know someone else wants to use this. I can't promise when it will be released, but I will be back at work September 5th and working on the pull request as soon as possible after that. You are welcome to test with the current branch and provide any feedback.

https://github.com/thoughtis/Co-Authors-Plus/tree/issue%23940/coauthor-blocks

philcable commented 11 months ago

@douglas-johnson The blocks are looking great, and I'd very much like to use them on a project that's launching in a couple months. To that end, please let me know if there's anything specific you'd like to get feedback or thorough testing on, or if there's any other way I can help out!

douglas-johnson commented 11 months ago

Hi @philcable thanks so much for the offer. I would be happy for your feedback on whatever use case is relevant to your project. If you could use the current branch to implement some portion of your project and let me know how it goes that would be great.

I am espescially interested to have someone test the ability to make a custom block and extend the REST API data to support whatever unique data is in their custom block. But, I understand that would be an unnecessary time commitment if it's not relevant to your project.

douglas-johnson commented 11 months ago

@philcable I want to send an update in case you are actually trying to add a custom block that uses author data. I just updated the pull request to address some feedback and there are three changes that would need to be reflected in a custom block.

philcable commented 11 months ago

Thank you for keeping me posted, @douglas-johnson! I haven't had a chance to test things out just yet, but I'll let you know when I do.

audunmb commented 4 months ago

Any more work happening on this? This is the exact functionality I need, but it seems on the wp.org site that this plugin is more or less abandonded for the last 8 months? I can't contribute with code, but if I can do anything else to help, please let me know.

alecgeatches commented 4 months ago

@audunmb Great question! @douglas-johnson's work in https://github.com/Automattic/Co-Authors-Plus/pull/997 is essentially done, and it's my fault that this hasn't been merged in yet. We'll get this tested and merged this week.

alecgeatches commented 4 months ago

@douglas-johnson The next release with your changes is very nearly ready to go in https://github.com/Automattic/Co-Authors-Plus/pull/1032! I'm going to wait until next week to check with @GaryJones and ensure the release is correct, but that should be straightforward. Thank you for all of your hard work and patience, we'll get this in shortly.

douglas-johnson commented 4 months ago

@alecgeatches That's great! I'm looking forward to getting it into production.

douglas-johnson commented 3 months ago

@alecgeatches I imagine we can close this issue. Before we say goodbye to it I wanted to gauge your interest in adding support for Social Icons. We needed this at work and I think I came up with something decent. It can be a separate issue though.

Removed AIM, YahooIM and Jabber. Added TikTok, Instagram and Twitter. Kept the website input. https://github.com/thoughtis/cata-co-authors-plus/blob/0.6.3/includes/meta-fields/class-meta-fields.php

Added functions to get URLs. They are forgiving so that either usernames / handles or URLs can be stored. https://github.com/thoughtis/cata-co-authors-plus/blob/0.6.3/includes/api/block-schema/social-links/global-functions.php

Used those functions to add social_links to the coauthors/v1/ API responses. https://github.com/thoughtis/cata-co-authors-plus/blob/0.6.3/includes/api/block-schema/social-links/class-social-links.php

Added a filter on register_block_type_args so the core/social-link block is opted in to co-author context. Added a filter on render_block so we can update the url attribute of a core/social-link block when the co-author context is available. https://github.com/thoughtis/cata-co-authors-plus/blob/0.6.3/blocks/social-links/social-links.php

Now we can drop the Social Icons block into the Co-Authors block, select the services we want to display, and they will be filled in on render based on what data is available for that author. In my example video my Guest Author profile has several filled in, but the other author has none.

https://github.com/Automattic/Co-Authors-Plus/assets/226381/e80a8fed-710b-48a6-9e11-b91865ae3dc7

dhanson-wp commented 3 months ago

Social Icons block is a great idea! +1.