Skip to content

REST API: Settings: fix jetpack_relatedposts_enabled#7480

Merged
sirbrillig merged 1 commit intomasterfrom
sync/sirbrillig/r159322-wpcom-1500391197
Jul 18, 2017
Merged

REST API: Settings: fix jetpack_relatedposts_enabled#7480
sirbrillig merged 1 commit intomasterfrom
sync/sirbrillig/r159322-wpcom-1500391197

Conversation

@sirbrillig
Copy link
Copy Markdown
Member

See 69-gh-wp-calypso

The REST API settings endpoint includes a property jetpack_relatedposts_enabled, which is true if the Related Posts plugin will display related posts. The value from this endpoint is incorrect, however, when a site has not modified their settings. This is because the Jetpack_RelatedPosts plugin defaults the setting to be enabled if it is not set.

This change modifies the endpoint to use the same logic: if the setting is not set, it will default to reporting jetpack_relatedposts_enabled as true.

Some sites (VIP and Jetpack) default this setting to false instead, but the way this is accomplished is that when the plugin is loaded by wp-content/mu-plugins/related-posts.php, it actively changes the option to false. Since that loader should still be used by the REST API, that should mean that such sites will continue to have jetpack_relatedposts_enabled reported correctly.

This commit syncs r159322-wpcom.

Testing instructions:

  1. Choose a site which has not changed its Related Posts setting.
  2. Visit this wp-admin page on that site: https://[your-site-here]/wp-admin/options-reading.php
  3. Verify that the Related posts setting reads "Show related content after posts".
  4. BEFORE applying this patch...
  5. Using a REST API client (eg: the WPCOM developer console), query the following endpoint: GET /rest/v1.1/sites/[your-site-here]/settings
  6. Verify that settings > jetpack_relatedposts_enabled is false.
  7. Apply this patch and make sure to sandbox the REST API.
  8. Using a REST API client (eg: the WPCOM developer console), query the following endpoint: GET /rest/v1.1/sites/[your-site-here]/settings
  9. Verify that settings > jetpack_relatedposts_enabled is true.
  10. On the wp-admin page, change the setting to read "Hide related content after posts" and click "Save Changes" at the bottom.
  11. Using a REST API client (eg: the WPCOM developer console), query the following endpoint: GET /rest/v1.1/sites/[your-site-here]/settings
  12. Verify that settings > jetpack_relatedposts_enabled is false.

See 69-gh-wp-calypso

The REST API settings endpoint includes a property `jetpack_relatedposts_enabled`, which is true if the Related Posts plugin will display related posts. The value from this endpoint is incorrect, however, when a site has not modified their settings. This is because the `Jetpack_RelatedPosts` plugin defaults the setting to be enabled if it is not set.

This change modifies the endpoint to use the same logic: if the setting is not set, it will default to reporting `jetpack_relatedposts_enabled` as true.

Some sites (VIP and Jetpack) default this setting to `false` instead, but the way this is accomplished is that when the plugin is loaded by `wp-content/mu-plugins/related-posts.php`, it actively changes the option to `false`. Since that loader should still be used by the REST API, that should mean that such sites will continue to have `jetpack_relatedposts_enabled` reported correctly.

This commit syncs r159322-wpcom.
@sirbrillig sirbrillig added the [Status] Needs Review This PR is ready for review. label Jul 18, 2017
@sirbrillig sirbrillig requested review from lezama and yoavf July 18, 2017 15:24
@lezama
Copy link
Copy Markdown
Contributor

lezama commented Jul 18, 2017

LGTM 👍

@sirbrillig sirbrillig merged commit 412d63c into master Jul 18, 2017
@sirbrillig sirbrillig deleted the sync/sirbrillig/r159322-wpcom-1500391197 branch July 18, 2017 19:43
@kraftbj kraftbj removed the [Status] Needs Review This PR is ready for review. label Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants