Skip to content

Related posts: use latest core function to check block-based theme - #24622

Merged
jeherve merged 3 commits into
masterfrom
fix/related-posts-fse
Jun 7, 2022
Merged

jeherve merged 3 commits into
masterfrom
fix/related-posts-fse

Conversation

@jeherve

@jeherve jeherve commented Jun 2, 2022 •

Copy link
Copy Markdown
Member

Fixes #24619

Changes proposed in this Pull Request:

  • We previously only relied on a function provided in Gutenberg, gutenberg_is_fse_theme(), to check whether a theme was a block-based theme. Now that the feature made its way to core, there is a Core function we can (and should) use instead: wp_is_block_theme().

Note

I had originally added a new test, but I could not get it to work. I kept receiving this error:

1) Automattic\Jetpack\Test_Blocks::test_is_fse_theme_via_core_function
Patchwork\Exceptions\DefinedTooEarly: The file that defines wp_is_block_theme() was included earlier than Patchwork. This is likely a result of an improper setup; see readme for details.

Jetpack product discussion

  • N/A

Does this pull request change what data or activity we track or use?

  • No

Testing instructions:

  • Start with a site with some existing content.
  • Go to Jetpack > Settings > Traffic and enable Related Posts.
  • Go to Appearance > Themes and enable the Twenty Twenty Two theme.
  • Go to Appearance > Editor, and pick the single post editor.
  • Add the Related Posts Block somewhere in the template, and save your changes.
  • Visit a single post.
  • You should only see one set of related posts on the page.

@jeherve jeherve added this to the jetpack/11.1 milestone Jun 2, 2022
@jeherve jeherve added [Focus] FSE Issues related to the site editor / Full Site Editing / FSE feature in Gutenberg [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Feature] Related Posts [Block] Related Posts [Pri] Normal [Status] Needs Review This PR is ready for review. Bug When a feature is broken and / or not performing as intended labels Jun 2, 2022
@jeherve jeherve self-assigned this Jun 2, 2022
@github-actions

github-actions Bot commented Jun 2, 2022 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.

@jeherve jeherve added [Status] In Progress and removed [Status] Needs Review This PR is ready for review. labels Jun 2, 2022
I cannot figure out how to mock wp_is_block_theme() as it is already defined.
@jeherve jeherve added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Jun 2, 2022

@coder-karen coder-karen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests well.

Pretty sure it's not within the scope of this PR (and not sure if it's expected behaviour), but if I then go and add an additional Related Posts block to a post after adding it to the single post template, the second one shows up. If I try and add another RP block to the page, the RP block option is 'greyed out' - yet it let me add it the first time. Something for another PR?

Anyway will approve this one as it does what it advertises to do!

@coder-karen coder-karen added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Jun 7, 2022
@jeherve

jeherve commented Jun 7, 2022

Copy link
Copy Markdown
Member Author

if I then go and add an additional Related Posts block to a post after adding it to the single post template, the second one shows up. If I try and add another RP block to the page, the RP block option is 'greyed out' - yet it let me add it the first time. Something for another PR?

I believe that's expected. We've set it so the Related Posts block can only be used once per post:

You consequently get one per post, and then additional blocks outside of the post context, when you use the site editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Related Posts Bug When a feature is broken and / or not performing as intended [Feature] Related Posts [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Focus] FSE Issues related to the site editor / Full Site Editing / FSE feature in Gutenberg [Package] Blocks [Pri] Normal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Related Posts Block Doesn't Work as Expected; Duplicates Related Posts

2 participants