On this page
wp_xmlrpc_server::wp_getPostFormats( array $args ): array|IXR_Error
Retrieves a list of post formats used by the site.
Parameters
$argsarray Required-
Method arguments. Note: arguments must be ordered as documented.
- int
Blog ID (unused).
1stringUsername.2stringPassword.
- int
Return
array|IXR_Error List of post formats, otherwise IXR_Error object.
Source
File: wp-includes/class-wp-xmlrpc-server.php. View all references
public function wp_getPostFormats( $args ) {
$this->escape( $args );
$username = $args[1];
$password = $args[2];
$user = $this->login( $username, $password );
if ( ! $user ) {
return $this->error;
}
if ( ! current_user_can( 'edit_posts' ) ) {
return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
}
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getPostFormats', $args, $this );
$formats = get_post_format_strings();
// Find out if they want a list of currently supports formats.
if ( isset( $args[3] ) && is_array( $args[3] ) ) {
if ( $args[3]['show-supported'] ) {
if ( current_theme_supports( 'post-formats' ) ) {
$supported = get_theme_support( 'post-formats' );
$data = array();
$data['all'] = $formats;
$data['supported'] = $supported[0];
$formats = $data;
}
}
}
return $formats;
}
Hooks
- do_action( 'xmlrpc_call',
string $name ,array|string $args ,wp_xmlrpc_server $server ) -
Fires after the XML-RPC user has been authenticated but before the rest of the method logic begins.
Related
Uses
| Uses | Description |
|---|---|
| get_post_format_strings() wp-includes/post-formats.php | Returns an array of post format slugs to their translated and pretty display versions |
| get_theme_support() wp-includes/theme.php | Gets the theme support arguments passed when registering that support. |
| IXR_Error::__construct() wp-includes/IXR/class-IXR-error.php | PHP5 constructor. |
| current_user_can() wp-includes/capabilities.php | Returns whether the current user has the specified capability. |
| current_theme_supports() wp-includes/theme.php | Checks a theme’s support for a given feature. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| do_action() wp-includes/plugin.php | Calls the callback functions that have been added to an action hook. |
| wp_xmlrpc_server::escape() wp-includes/class-wp-xmlrpc-server.php | Escape string or array of strings for database. |
| wp_xmlrpc_server::login() wp-includes/class-wp-xmlrpc-server.php | Log user in. |
Changelog
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_getpostformats