2.x Update function signature for Term::posts()#2258
Merged
acobster merged 13 commits into2.x-posts-apifrom Oct 7, 2020
Merged
2.x Update function signature for Term::posts()#2258acobster merged 13 commits into2.x-posts-apifrom
acobster merged 13 commits into2.x-posts-apifrom
Conversation
jarednova
approved these changes
Jun 10, 2020
Member
|
The code looks good. As for the three failing tests, here they are for easy reference: ... looks pretty straightforward to solve in conjunction with Factories |
Member
Author
Yes, but first the Post Factories need to be used in |
23c3421 to
b0d086a
Compare
2316/deprecate term getter
Collaborator
|
@jarednova this is looking good to me, but I'm wondering if you think adding an |
Member
|
@acobster agreed, while things are fresh and open let's add that in. |
Member
Author
Cool, I added the parameter in 263bed9. |
…manually Favoring changes from 2.x-posts-api
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.
Tickets:
Issue
I almost forgot again about what we discussed in the linked Tickets above.
Solution
This pull request updates the function signature for
Term::posts()to use the same pattern that we use for a lot of other functions.Impact
There’s no backwards compatibility, but I added checks when the wrong parameters are passed.
Because I changed the
Term::posts()function, I had to update theTerm::get_post()function as well. This will trigger a doing-it-wrong notice now. Because we can no longer support the former arguments, this is not a formal deprecation anymore.Usage Changes
Old usage
In PHP:
And in Twig:
{% for book in genre.posts(-1, 'book) %}New usage
In PHP:
And in Twig:
{% for book in genre.posts({ post_type: 'book', posts_per_page: -1, orderby: 'menu_order' }) %}Considerations
None.
Testing
There are tests that are still failing because of the class parameter that is not supported anymore. We should probably wait until the post factory is finished and update the tests then.