wp_xmlrpc_server::wp_getPostTypes( array $args ): array|IXR_Error

Retrieves post types.

Description

See also

Parameters

$argsarrayrequired
Method arguments. Note: arguments must be ordered as documented.
  • 0 int
    Blog ID (unused).
  • 1 string
    Username.
  • 2 string
    Password.
  • 3 array
    Optional. Query arguments.
  • 4 array
    Optional. Fields to fetch.

Return

array|IXR_Error

Source

 *
 * @param array $args {
 *     Method arguments. Note: arguments must be ordered as documented.
 *
 *     @type int    $0 Blog ID (unused).
 *     @type string $1 Username.
 *     @type string $2 Password.
 *     @type array  $3 Optional. Query arguments.
 *     @type array  $4 Optional. Fields to fetch.
 * }
 * @return array|IXR_Error
 */
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' );
	}

	$user = $this->login( $username, $password );
	if ( ! $user ) {
		return $this->error;
	}

	/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
	do_action( 'xmlrpc_call', 'wp.getPostTypes', $args, $this );

	$post_types = get_post_types( $filter, 'objects' );

Changelog

VersionDescription
3.4.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.