xmlrpc_getpostcategory

Retrieve the post category or categories from XMLRPC XML.

Description

(string|array) xmlrpc_getpostcategory( (string) $content ); 

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.

Returns (string|array)

List of categories or category name.

Parameters (1)

0. $content (string)
XMLRPC XML Request content

Usage

  1. if ( !function_exists( 'xmlrpc_getpostcategory' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // XMLRPC XML Request content 
  5. $content = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = xmlrpc_getpostcategory($content); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function xmlrpc_getpostcategory( $content ) { 
  2. global $post_default_category; 
  3. if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) { 
  4. $post_category = trim( $matchcat[1], ', ' ); 
  5. $post_category = explode( ', ', $post_category ); 
  6. } else { 
  7. $post_category = $post_default_category; 
  8. return $post_category;