Allow to filter query_args in post_select ajax call#744
Allow to filter query_args in post_select ajax call#744ivankristianto wants to merge 4 commits intowp-shortcake:masterfrom
Conversation
|
I can see how this would be useful, but - since editors containing shortcodes can appear in more places than just on a post edit screen - I think we might need to figure out a more abstract way of representing the context of the current editor, which then can be passed into queries like ajax call for 'post_select' fields. I have a branch started locally trying to address this for #661 which I need to polish up. I'll see if it can work well with what you have here. Finally, it might be good to see the javascript logic live inside the parent class |
|
Thanks @goldenapples interested to see how you did the abstraction. |
js/src/views/select2-field.js
Outdated
| shortcode : this.shortcode.get( 'shortcode_tag'), | ||
| attr : this.model.get( 'attr' ) | ||
| attr : this.model.get( 'attr' ), | ||
| postid : $( '#post_ID' ).val() |
There was a problem hiding this comment.
There's actually one other place in select2-fields.js where we should be passing the post ID. Can we also add the postid argument to the search ajax request here?
(Sorry, I think I highlighted the wrong array in my earlier comment - this is the request for initially loading the preselected posts when opening a shortcode ui.)
|
@goldenapples lol i didn't realize that either. I updated the PR |
I add post id to the post_select ajax call, then a allow to alter the query args for more extendability.
This will solve my issue that return the post list based on which post type it's currently editing.
and it also can fix this issue #625