xmlrpc_getpostcategory()WP 0.71

Retrieves the post category or categories from XMLRPC XML.

If the category element is not found, then the default post category will be used. The return type then would be what $post_default_category. If the category is found, then it will always be an array.

Хуков нет.

Возвращает

Строку|Массив. List of categories or category name.

Использование

xmlrpc_getpostcategory( $content );
$content(строка) (обязательный)
XMLRPC XML Request content

Заметки

  • Global. Строка. $post_default_category Default XML-RPC post category.

Список изменений

С версии 0.71 Введена.

Код xmlrpc_getpostcategory() WP 6.5.2

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