-
Notifications
You must be signed in to change notification settings - Fork 5
Post query, list, and Meta fixes #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…ompat, fix meta only and accept warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query is a static method , do you get any error?
I get no errors from using query through the newly added list($args) method |
I only made two changes to the old Post query version:
$args = wp_parse_args($default, $arg); The only non static reference was $this->type in the defaults |
I'm going to change the parse args back. The signature is ($args, $defaults). I thought it was opposite. |
fix parse args order
Ok, parse args is fixed |
I'm on the fence about leaving a default for post_status. I think intuitively leaving it off makes sense, but having it as a default also makes sense. My concern would be as a developer, if you specify the args, I'm not sure you would expect published to be added. It would be a breaking change though |
Anything you want me to look at changing here? |
implement query from old post class, add list function for backward compat, fix meta only and except warning.
After pulling the newest master version, I needed to implement a couple things that I used in some plugin implementations that use wp-trait.
I took the old post query implementation and adjusted it to allow for static implementation. I removed the post_type from the default params, and switched the order for wp_parse_args to apply args on top of defaults. Added list function that returns $query->posts if not empty.
The meta class I changed because when feeding in:
$meta = $this->post->find($block->ID)->meta()->only(['hook', 'priority']);
the only method was using func_get_args() which nested the array:
0 => [
0 => 'hook',
1 => 'priority'
]
This caused the array flip to complain as it was trying to flip 0 => array
Not sure about the static? Any suggestions there?