xmlrpc_getpostcategory( string $content ): string[]|string

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

Description

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.

Parameters

$contentstringrequired
XML-RPC XML Request content.

Return

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

Source

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;
}

Changelog

VersionDescription
0.71Introduced.

User Contributed Notes

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