Related Posts: Only attempt to grab related posts for Published posts.#9495
Merged
dereksmart merged 1 commit intomasterfrom May 14, 2018
Merged
Related Posts: Only attempt to grab related posts for Published posts.#9495dereksmart merged 1 commit intomasterfrom
dereksmart merged 1 commit intomasterfrom
Conversation
jeherve
requested changes
May 8, 2018
Member
jeherve
left a comment
There was a problem hiding this comment.
Looking good, just some minor nitpicking on my part.
| } | ||
|
|
||
| if ( ! $options['enabled'] || 0 == (int)$post_id || empty( $options['size'] ) ) | ||
| if ( ! $options['enabled'] || 0 == (int)$post_id || empty( $options['size'] ) || get_post_status( $post_id) !== 'publish' ) { |
Member
There was a problem hiding this comment.
You may want to use a Yoda condition here.
Contributor
Author
There was a problem hiding this comment.
I didn't think we needed a Yoda since we're not dealing with a variable?
Member
There was a problem hiding this comment.
That works for me. I would personally use a Yoda for consistency, but it's really nitpicking. Marking as ready to merge. 👍
Contributor
|
Created a new revision for this PR: D13102-code |
Contributor
|
Created a new revision for this PR: D13259-code |
This was referenced Mar 13, 2019
kraftbj
added a commit
that referenced
this pull request
Mar 26, 2019
* Revert "Removing enabled and published checks" The regressed the fix added in #9495 and breaks the jetpack_relatedposts_filter_options filter's use of "enabled". This reverts commit 237c30f. * Add strict check * Increase readability and PHPCS for the changed function * Remove check for published posts to allow previews to render RPs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #9494
Attempting to grab Related Posts for an unpublished post doesn't really make sense for our use case as we could cache the result for a post that changes drastically before publishing.
Changelog entry
Related Posts: Made it not try to fetch related posts for an unpublished post.