-
Notifications
You must be signed in to change notification settings - Fork 156
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
Added ability to view all post types when Pulling from an External Connection #1002
Conversation
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.
Thanks for the PR @mehul0810
I've left couple non-blocking questions and a suggestion for the $args
in get_pull_content()
In #1017 (awaiting merge) I've made a bunch of modifications to the rest api endpoint that should make this more achievable. It will probably cause a lot of conflicts to this PR though. You'll be able to use |
@mehul0810 thanks for the PR! Could you please fill out the PR template with description, changelog, and credits information so that we can properly review and merge this? |
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.
I've left on question/comment inline.
I was getting a bunch of array to string notices so I pushed 7cdc43b to resolve that. WP_Query
accepts all
to query all of the post types so that can be used for the option.
The custom endpoint also accepts All as a shorthand.
includes/rest-api.php
Outdated
@@ -623,10 +623,11 @@ function check_post_types_permissions() { | |||
* @return \WP_REST_Response|\WP_Error | |||
*/ | |||
function get_pull_content_list( $request ) { | |||
$args = [ | |||
$post_type = ! empty( $request['post_type'] ) ? $request['post_type'] : array( 'post', 'page' ); |
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.
The default is set to post
in get_pull_content_list_args()
so it's unlikely this will ever be set to [post, page]
.
I included it back when I was rewriting this as a safety check just in case someone messes with the URL.
Was the intent with this change to default to the View All view? For internal connections Distributor offers a View All view but defaults to posts only, so I think it's best to match that for the time being.
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.
@peterwilsoncc Replaced it to show only the post
by default.
The intent with this change was to get the list of post type that needs to be listed or else default to post
. But, we are not defaulting the post type filter to View All
. It is still Post
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.
I am seeing some unusual behaviour with the "View All" selection. Watch the video below:
Screen-2024-07-10-60918.PM.mp4
Additionally, only posts are being pulled.
I can confirm that I can see something strange as well. It looks like when we select "view all" only posts by "admin" users are shown. That's what it looks on the surface(which may not be the case as well), needs more investigation. Screen.Recording.2024-07-13.at.10.30.18.AM.1.mp4 |
I think what I and sid observed was perhaps a security fix, so it's all good? #1003 (review) |
@peterwilsoncc if this looks good to you, please merge, thanks! |
It looks like it's a bug in distributor/includes/rest-api.php Line 693 in 253cf82
For multiple post types the |
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.
LGTM and tests well.
Thanks.
E2E tests are failing on the main branch so bypassing the merge requirements. |
Description of the Change
Add the ability to view all post types when pulling content from external connections.
Closes #861
How to test the Change
Changelog Entry
Credits
Props @mehul0810, @ravinderk, @cadic, @peterwilsoncc, @ankitrox, @Sidsector9, @jeffpaul.
Checklist: