xmlrpc_getpostcategory()WP 0.71

Retrieves the post category or categories from XML-RPC XML.

If the category element is not found in the XML, the default post category from the $post_default_category global will be used instead. The return type will then be a string.

If the category element is found, the return type will be an array.

No Hooks.

Returns

String[]|String. An array of category names or default category name.

Usage

xmlrpc_getpostcategory( $content );
$content(string) (required)
XML-RPC XML Request content.

Notes

  • Global. String. $post_default_category Default XML-RPC post category.

Changelog

Since 0.71 Introduced.

xmlrpc_getpostcategory() code WP 7.0

function xmlrpc_getpostcategory( $content ) {
	global $post_default_category;
	if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) {
		$post_category = trim( $matchcat[1], ',' );
		$post_category = explode( ',', $post_category );
	} else {
		$post_category = $post_default_category;
	}
	return $post_category;
}