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

bugfix: content in acf-fields was not included in analyses. #329

Conversation

hdvos
Copy link
Contributor

@hdvos hdvos commented Jan 26, 2023

Summary

This bug was caused by wordproof being activated for a yet unknown reason.

This PR can be summarized in the following changelog entry:

  • Fixes a bug where the content in ACF fields was not included in analyses in Classic editor when WordProof plugin was activated.

Relevant technical choices:

  • This code from wpseo was duplicated in this repository. There was no straight forward way to export and import it between repositories.
  • This repository does not use ES6 (yet), so the importing and exporting of modules is a bit awkward.

Test instructions

This PR can be tested by following these steps:

NOTE: highlighting is not possible in custom fields. This is known. This issue was created for that.

Prep

  • Install and activate yoastseo and yoastseo premium.
  • Install and activate Advanced Custom Fields.
  • Install and activate classic editor.
  • Install and activate wordproof
  • Install and activate ACF Content Analysis for Yoast SEO
    • Instructions for Lingo
    • Clone https://github.com/Yoast/yoast-acf-analysis
    • Checkout 19508-the-content-in-acf-fields-is-not-detected-for-analysis-when-classic-editor-is-used
    • Build:
      • composer install
      • yarn
      • yarn build (NOTE: not grunt build)
  • Create a custom field (if you don't have one).
    • Go to custom fields
    • Add a field group
    • Go to settings for this field group and make sure it is available for post, page and product, in order to be able to fully test it. See screenshot below.
    • Within the field group add a new field. It is easiest if the field type is text area
    • If you open a post/page/product with classic editor, the the field should appear at the bottom.

image

Test analyses

  • Create a post/page/product.
  • Add some text for example this sample
    (Minimum of 300 words such as to be sure that all analyses are available).

Passive voice

  • Add a passive sentence to the custom field. For example: The cat was greeted by the dog.
  • Make sure that the percentage of passive sentences increases. (When using the example text, it increases from 60% to 61.3%

Inclusive language

  • Add a non inclusive word to the custom field. For example midget.
  • Make sure that midget is recognized by inclusive language analysis.

Keyphrase analyses

  • Add apple as the keyphrase.
  • Add the word apple to the custom field.
  • Look at keyphrase density and keyphrase distribution. Make sure that the count of keyphrases is 1 higher. When using the example text, the count goes from 24 times to 25 times.

Paragraph length

  • Add a paragraph of at least 150 words to the custom field. (You can copy/past the last paragraph from the example text.
  • Make sure the number of too long paragraphs is upped by one. If you use the example text, the number of too long paragraphs goes from 1 to 2.

Test compatibility with previous wordpress versions

This bug was probably caused by a change in wordpress core. So it is good to confirm it still works with older versions.

  • Downgrade wordpress to 5.9. You can use WP Downgrade plugin for that.
  • Repeat the tests above.
  • Upgrade wordpress back to the most recent version (6.1.1. at the time of writing).

Test with wordproof disabled

  • Disable the wordproof plugin. Repeat the tests above.

Test block editor.

Make sure that the behaviour in the block editor is not affected.

  • De-activate classic editor
  • Open the previous post in the default editor.
  • Repeat the tests above.

Repeat with Page and woo-product.

Fixes #19508

@hdvos hdvos added the changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog label Jan 26, 2023
@hdvos hdvos changed the title use different method to check for active editor bugfix: content in acf-fields was not included in analyses. Jan 26, 2023
@hdvos hdvos marked this pull request as ready for review January 26, 2023 14:55
@hdvos hdvos added this to the 3.x / Next Release milestone Jan 26, 2023
Comment on lines 16 to 20
// Check whether classic editor is used.
if ( isTinyMCEAvailable( "content" ) ) {
acfFields = acf.get_fields();
} else {
// Assume Gutenberg is used.
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed in this thread, we already have a reliable method to know whether the editor is Gutenberg or not, by accessing window.wpseoScriptData.isBlockEditor. If we can use this in this check, it means that we wouldn't need to duplicate the helper logic for tinyMCE.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, in this file js/src/collect/collect-v5.js, we have another check that uses wp.data.select( "core/block-editor" ) (line 44). I think it's safer that we also change that check :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed in this thread, we already have a reliable method to know whether the editor is Gutenberg or not, by accessing window.wpseoScriptData.isBlockEditor. If we can use this in this check, it means that we wouldn't need to duplicate the helper logic for tinyMCE.

Agreed! I adapted it. We do not have to reset the variable in yoast-acf-analysis

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, in this file js/src/collect/collect-v5.js, we have another check that uses wp.data.select( "core/block-editor" ) (line 44). I think it's safer that we also change that check :)

Disagreed: unlike the check that we changed, this check is not primarily aimed ad checking which editor is active. It primarily checks if the core/block-editor is available (not undefined) so that it can safely call var blocks = wp.data.select( "core/block-editor" ).getBlocks(); a few lines later.

Copy link
Contributor

@FAMarfuaty FAMarfuaty left a comment

Choose a reason for hiding this comment

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

Code looks good 🤝
I suggested some comment improvements :)

hdvos and others added 2 commits January 31, 2023 11:13
Co-authored-by: Aida Marfuaty <48715883+FAMarfuaty@users.noreply.github.com>
Co-authored-by: Aida Marfuaty <48715883+FAMarfuaty@users.noreply.github.com>
@hdvos
Copy link
Contributor Author

hdvos commented Jan 31, 2023

Thank you for the suggestions, agreed. I committed them.

@FAMarfuaty
Copy link
Contributor

Acceptance test 💯

  • I also tested other assessments not mentioned in the PR such as Word Complexity, Consecutive sentences, and Transition words assessments.
  • I also tested in Custom post type

@FAMarfuaty FAMarfuaty merged commit af22f34 into develop Jan 31, 2023
@FAMarfuaty FAMarfuaty deleted the 19508-the-content-in-acf-fields-is-not-detected-for-analysis-when-classic-editor-is-used branch January 31, 2023 12:59
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The content in ACF fields is not detected for analysis when Classic Editor is used
2 participants