Make WordPress Core

Opened 9 years ago

Closed 8 years ago

#18436 closed feature request (fixed)

Retrieve post type information in XML-RPC

Reported by: nprasath002 Owned by:
Milestone: 3.4 Priority: normal
Severity: normal Version:
Component: XML-RPC Keywords: has-patch
Focuses: Cc:


Attachments (6)

wp.getPostType.patch (3.2 KB) - added by nprasath002 9 years ago.
wp.getPostType.2.patch (2.3 KB) - added by maxcutler 9 years ago.
wp.getPostType.3.patch (5.2 KB) - added by markoheijnen 8 years ago.
wp.getPostType.4.patch (6.0 KB) - added by markoheijnen 8 years ago.
New get all theme support function, updated PHPDoc and little changes to _prepare_post_type
wp.getPostType.5.patch (6.4 KB) - added by markoheijnen 8 years ago.
wp_getOptions can also returns post thumbnail theme support
wp.getPostType.6.patch (6.5 KB) - added by maxcutler 8 years ago.

Download all attachments as: .zip

Change History (20)

#1 @maxcutler
9 years ago

  • Cc max@… added

This and the plural version (#18437) should probably include the 'name' field in the returned array. The name may be supplied as a method parameter (or an array key in the plural version), but that forces the API consumer to keep track of it separately. It would be much easier if all the fields were returned in the same struct.

I'm also curious as to how you selected the subset of fields to return. Some that could be useful like 'public', 'export', 'menu_icon' are missing. If you don't want to add them by default, it might be nice to have the list of fields be put through a filter so that plugins can modify what gets returned.

#2 @nacin
9 years ago

Seems like it should just return get_post_type_object(). That said, some values like 'taxonomies' are only for registration, and I don't think they'd be accurate. (Not positive.) For that you'd need to consult get_object_taxonomies() and also return that value.

#3 @nprasath002
9 years ago

Returning all the information (using get_post_type_object) is costlier.
The response time of the clients will be huge for slow net connections.
We need to to have a lighter version which returns a subset of fields
and put through a filter so that plugins can extend it.

I will work on a patch and add.

#4 @maxcutler
9 years ago

Cleaned up the patch formatting and implemented tweaks recommended by nacin, using the prepare_post_type method from #18437.

nprasath002, if you are still concerned about the size of the response, perhaps we can implement a fields parameter like in #18433 and have the default value be a smaller subset. But in any case, plugins can use the xmlrpc_prepare_post_type filter to refine the response.

#5 @markoheijnen
8 years ago

  • Cc marko@… added

Created a new patch that combines this ticket with #18437. I also added filter parameter for getPostTypes and fields parameter for both.
I'm not sure how the naming should be. It's most likely it can be better grouped.

#6 @maxcutler
8 years ago

  • Cc max@… removed

#7 @maxcutler
8 years ago

  • Cc max@… added

8 years ago

New get all theme support function, updated PHPDoc and little changes to _prepare_post_type

8 years ago

wp_getOptions can also returns post thumbnail theme support

#8 @markoheijnen
8 years ago

After some discussion in the IRC chat on 2 March I decided only to return the theme support for now. That shows if the WordPress installation supports.

For all post type support you can include a new option that includes all post types with thumbnail support like the following code:

$posttype_supports = array();
foreach ( get_post_types() as $post_type ) {
	if ( post_type_supports( $post_type, 'thumbnail' ) ) {
		$posttype_supports[] = $post_type;

#9 @westi
8 years ago

The patch in wp.getPostType.5.patch looks good.

It would be nice to have some unit tests before we commit the new functions wp.getPostType and wp.getPostTypes adding the extra "option" seems like a no-brainer.

Would you be able to write some test cases for the new functions?

#10 @westi
8 years ago

  • Milestone changed from Awaiting Review to 3.4

Test case for the featured image option added in [UT568].

#11 @westi
8 years ago

Option added in [20155] props markoheijnen (which I forgot)

#12 @maxcutler
8 years ago

Refreshed patch with some minor fixes found while writing unit tests in [UT587].

#13 @westi
8 years ago

In [20271]:

XMLRPC: Add new wp.getPostType and wp.getPostTypes apis. See #18436 props maxcutler, markoheijnen and nprasath002.

#14 @maxcutler
8 years ago

  • Resolution set to fixed
  • Status changed from new to closed

New bugs or enhancements on new tickets.

Note: See TracTickets for help on using tickets.