Use Jetpack_RelatedPosts::get_options() to get options for server-rendered Related Posts #14386
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It was discovered by @jamesozzie that filtering options for rendering Related Posts does not work on AMP pages. For example, in response to a support forum topic he was looking to reduce the number of posts displayed from 3 to 2 with code like so:
This turned out not to work because AMP pages render the Related Posts using
Jetpack_RelatedPosts::get_server_rendered_html()and this method was callingJetpack_Options::get_option( 'relatedposts', array() )rather thanJetpack_RelatedPosts::get_options(), and only the later method applies thejetpack_relatedposts_filter_optionsfilter (as well as apply other normalizations).This PR updates
\Jetpack_RelatedPosts::get_server_rendered_html()to useJetpack_RelatedPosts::get_options()rather than the lower-levelJetpack_Options::get_option( 'relatedposts', array() ).Issue introduced in Jetpack 7.6 via #13028 for #9556.
Changes proposed in this Pull Request:
Is this a new feature or does it add/remove features to an existing part of Jetpack?
Testing instructions:
jetpackme_more_related_postsfilter to change thesize(see above).Proposed changelog entry for your changes:
Jetpack_RelatedPosts::get_options()to get options for server-rendered Related Posts