wp_xmlrpc_server::wp_getPostTypes( array $args )
Retrieves post types.
Description
See also
Parameters
- $args
-
(Required) Method arguments. Note: arguments must be ordered as documented.<br>
- (int) Blog ID (unused).<br>
- '1'
(string) Username.<br> - '2'
(string) Password.<br> - '3'
(array) Optional. Query arguments.<br> - '4'
(array) Optional. Fields to fetch.<br>
Return
(array|IXR_Error)
Source
File: wp-includes/class-wp-xmlrpc-server.php
public function wp_getPostTypes( $args ) {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$username = $args[1];
$password = $args[2];
$filter = isset( $args[3] ) ? $args[3] : array( 'public' => true );
if ( isset( $args[4] ) ) {
$fields = $args[4];
} else {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
$fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' );
}
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getPostTypes' );
$post_types = get_post_types( $filter, 'objects' );
$struct = array();
foreach ( $post_types as $post_type ) {
if ( ! current_user_can( $post_type->cap->edit_posts ) )
continue;
$struct[$post_type->name] = $this->_prepare_post_type( $post_type, $fields );
}
return $struct;
}
Changelog
Version | Description |
---|---|
3.4.0 | Introduced. |