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

Detect ACF blocks in preview, regardless of display mode #262

Merged
merged 3 commits into from
Jul 21, 2020

Conversation

TimVevida
Copy link

@TimVevida TimVevida commented Jun 16, 2020

Summary

Previously, only ACF block which were set to preview mode (the default mode) were communicated to Yoast SEO. However, any block mode can switch to the preview state, either automatically or manually, in the block editor. This patch just checks if such a preview exists, instead of relying on the block being in one of the modes.

This PR can be summarized in the following changelog entry:

  • Fixes a bug where the content of ACF blocks in 'auto' mode was not taken into account when the block (automatically) switched to preview mode. Props to TimVevida

Relevant technical choices:

During testing, I found that the order of the content passed to Yoast SEO can vary, blocks in the edit state are added as individual fields earlier in the process. Because the best results are achieved when all blocks are in the preview state, this does not seem a big deal. I do not have enough knowledge of Yoast SEO to know whether this affects SEO scoring. When needed, the fields could be sorted using compareDocumentPosition.

Test instructions

This PR can be tested by following these steps:

  • Create ACF blocks with different modes (none/preview, auto or edit, see the docs).
  • Add these blocks to a post/page.
  • Check if all content is passed to Yoast SEO, regardless of view mode.

Fixes #261

Tim Havinga added 3 commits June 16, 2020 11:24
Fields in any mode can be set to preview, so make the check independent
of that. Just check if a preview div exists.
@DB-Alex
Copy link

DB-Alex commented Jul 3, 2020

@IreneStr any idea when this will be merged?

@IreneStr
Copy link
Contributor

@alexvandervegt My apologies for this late reply. I've been out of office. I'll make sure a dev will look at this PR this week!

@maartenleenders
Copy link
Contributor

Hi! Sorry for the delay, took me while to understand what exactly is being fixed here. But the auto mode was indeed broken, and your code fixes it. Thanks!

Acceptance 👍

@maartenleenders maartenleenders added the changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog label Jul 21, 2020
@maartenleenders maartenleenders merged commit 401624f into Yoast:develop Jul 21, 2020
@maartenleenders maartenleenders added this to the 2.6.0 / Next release milestone Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog community-patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Content of ACF blocks with mode "auto" is not analyzed
5 participants