Allow terms to match the order in the include
parameter
#67
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.
Fix #66
To fix the problem it's necessary to change the behavior of the plugin in two aspects.
1) scporder_get_terms_orderby()
This method is used with the filter
get_terms_orderby
and changes the$orderby
ont.term_order
.To fix this, it's enough to add one more check:
2) scporder_get_object_terms()
This method is used with two filters
get_terms
andwp_get_object_terms
and sorts the found terms by theterm_order
.This situation is more complicated. To check the
include
option in an array of arguments, we need to pass the$args
parameter to the function.But this parameter is located at different positions in the mentioned hooks:
In this regard, I propose to add an auxiliary method. Its role is to invoke a neighboring method with another set of arguments:
And use a specific function for each hook: