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.
Description of the Change
This is a follow up to #350.
If Yoast is not being used, everything works as expected. But if Yoast is installed, if no category is selected, we return the value
null
, which breaks our sync. This PR adjust ourget_primary_category
function to add some better checks, ensuring if we don't have a primary category set we fallback to grabbing the first category set. Or if we have a primary category set but that category no longer exists, we now check for that and returnfalse
instead.If we return
false
in this function, we've also adjusted the output to the tracker to ensure we are sending an empty array instead of an array with an empty string in it.Alternate Designs
None
Possible Drawbacks
None
Verification Process
Verify that setting categories sends the correct data to Sophi both with Yoast installed and with it not. Try setting one category, multiple categories and no categories.
Checklist: