: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$post_type = get_post_type_object( 'post' );
if ( ! current_user_can( $post_type->cap->edit_posts ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) );
$query['post_type'] = $post_type->name;
if ( isset( $filter['post_status'] ) ) {
$query['post_status'] = $filter['post_status'];
if ( isset( $filter['number'] ) ) {
$query['numberposts'] = absint( $filter['number'] );
if ( isset( $filter['offset'] ) ) {
$query['offset'] = absint( $filter['offset'] );
if ( isset( $filter['orderby'] ) ) {
$query['orderby'] = $filter['orderby'];
if ( isset( $filter['order'] ) ) {
$query['order'] = $filter['order'];
if ( isset( $filter['s'] ) ) {
$query['s'] = $filter['s'];
$posts_list = wp_get_recent_posts( $query );
// Holds all the posts data.
foreach ( $posts_list as $post ) {
if ( ! current_user_can( 'edit_post', $post['ID'] ) ) {
$struct[] = $this->_prepare_post( $post, $fields );
* Method arguments. Note: arguments must be ordered as documented.
* @type int $0 Blog ID (unused).
* @type string $1 Username.
* @type string $2 Password.
* @type array $3 Content struct for adding a new term. The struct must contain
* the term 'name' and 'taxonomy'. Optional accepted values include
* 'parent', 'description', and 'slug'.
* @return int|IXR_Error The term ID on success, or an IXR_Error object on failure.
public function wp_newTerm( $args ) {
if ( ! $this->minimum_args( $args, 4 ) ) {
$content_struct = $args[3];
$user = $this->login( $username, $password );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.newTerm', $args, $this );
if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) {
return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
$taxonomy = get_taxonomy( $content_struct['taxonomy'] );
if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) );
$taxonomy = (array) $taxonomy;
// Hold the data of the term.
$term_data['name'] = trim( $content_struct['name'] );
if ( empty( $term_data['name'] ) ) {
return new IXR_Error( 403, __( 'The term name cannot be empty.' ) );
if ( isset( $content_struct['parent'] ) ) {
if ( ! $taxonomy['hierarchical'] ) {
return new IXR_Error( 403, __( 'This taxonomy is not hierarchical.' ) );
$parent_term_id = (int) $content_struct['parent'];
$parent_term = get_term( $parent_term_id, $taxonomy['name'] );
if ( is_wp_error( $parent_term ) ) {
return new IXR_Error( 500, $parent_term->get_error_message() );
return new IXR_Error( 403, __( 'Parent term does not exist.' ) );
$term_data['parent'] = $content_struct['parent'];
if ( isset( $content_struct['description'] ) ) {
$term_data['description'] = $content_struct['description'];
if ( isset( $content_struct['slug'] ) ) {
$term_data['slug'] = $content_struct['slug'];
$term = wp_insert_term( $term_data['name'], $taxonomy['name'], $term_data );
if ( is_wp_error( $term ) ) {
return new IXR_Error( 500, $term->get_error_message() );
return new IXR_Error( 500, __( 'Sorry, the term could not be created.' ) );
if ( isset( $content_struct['custom_fields'] ) ) {
$this->set_term_custom_fields( $term['term_id'], $content_struct['custom_fields'] );
return (string) $term['term_id'];
* Method arguments. Note: arguments must be ordered as documented.
* @type int $0 Blog ID (unused).
* @type string $1 Username.
* @type string $2 Password.
* @type array $4 Content struct for editing a term. The struct must contain the
* term 'taxonomy'. Optional accepted values include 'name', 'parent',
* 'description', and 'slug'.
* @return true|IXR_Error True on success, IXR_Error instance on failure.
public function wp_editTerm( $args ) {
if ( ! $this->minimum_args( $args, 5 ) ) {
$term_id = (int) $args[3];
$content_struct = $args[4];
$user = $this->login( $username, $password );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.editTerm', $args, $this );
if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) {
return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
$taxonomy = get_taxonomy( $content_struct['taxonomy'] );
$taxonomy = (array) $taxonomy;
// Hold the data of the term.
$term = get_term( $term_id, $content_struct['taxonomy'] );
if ( is_wp_error( $term ) ) {
return new IXR_Error( 500, $term->get_error_message() );
return new IXR_Error( 404, __( 'Invalid term ID.' ) );
if ( ! current_user_can( 'edit_term', $term_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this term.' ) );
if ( isset( $content_struct['name'] ) ) {
$term_data['name'] = trim( $content_struct['name'] );
if ( empty( $term_data['name'] ) ) {
return new IXR_Error( 403, __( 'The term name cannot be empty.' ) );
if ( ! empty( $content_struct['parent'] ) ) {
if ( ! $taxonomy['hierarchical'] ) {
return new IXR_Error( 403, __( 'Cannot set parent term, taxonomy is not hierarchical.' ) );
$parent_term_id = (int) $content_struct['parent'];
$parent_term = get_term( $parent_term_id, $taxonomy['name'] );
if ( is_wp_error( $parent_term ) ) {
return new IXR_Error( 500, $parent_term->get_error_message() );
return new IXR_Error( 403, __( 'Parent term does not exist.' ) );
$term_data['parent'] = $content_struct['parent'];
if ( isset( $content_struct['description'] ) ) {
$term_data['description'] = $content_struct['description'];
if ( isset( $content_struct['slug'] ) ) {
$term_data['slug'] = $content_struct['slug'];
$term = wp_update_term( $term_id, $taxonomy['name'], $term_data );
if ( is_wp_error( $term ) ) {
return new IXR_Error( 500, $term->get_error_message() );
return new IXR_Error( 500, __( 'Sorry, editing the term failed.' ) );
if ( isset( $content_struct['custom_fields'] ) ) {
$this->set_term_custom_fields( $term_id, $content_struct['custom_fields'] );
* Method arguments. Note: arguments must be ordered as documented.
* @type int $0 Blog ID (unused).
* @type string $1 Username.
* @type string $2 Password.
* @type string $3 Taxonomy name.
* @return true|IXR_Error True on success, IXR_Error instance on failure.
public function wp_deleteTerm( $args ) {
if ( ! $this->minimum_args( $args, 5 ) ) {
$term_id = (int) $args[4];
$user = $this->login( $username, $password );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.deleteTerm', $args, $this );
if ( ! taxonomy_exists( $taxonomy ) ) {
return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
$taxonomy = get_taxonomy( $taxonomy );
$term = get_term( $term_id, $taxonomy->name );
if ( is_wp_error( $term ) ) {
return new IXR_Error( 500, $term->get_error_message() );
return new IXR_Error( 404, __( 'Invalid term ID.' ) );
if ( ! current_user_can( 'delete_term', $term_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this term.' ) );
$result = wp_delete_term( $term_id, $taxonomy->name );
if ( is_wp_error( $result ) ) {
return new IXR_Error( 500, $term->get_error_message() );
return new IXR_Error( 500, __( 'Sorry, deleting the term failed.' ) );
* Method arguments. Note: arguments must be ordered as documented.
* @type int $0 Blog ID (unused).
* @type string $1 Username.
* @type string $2 Password.
* @type string $3 Taxonomy name.
* @return array|IXR_Error IXR_Error on failure, array on success, containing:
public function wp_getTerm( $args ) {
if ( ! $this->minimum_args( $args, 5 ) ) {
$term_id = (int) $args[4];
$user = $this->login( $username, $password );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getTerm', $args, $this );
if ( ! taxonomy_exists( $taxonomy ) ) {
return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
$taxonomy = get_taxonomy( $taxonomy );
$term = get_term( $term_id, $taxonomy->name, ARRAY_A );
if ( is_wp_error( $term ) ) {
return new IXR_Error( 500, $term->get_error_message() );
return new IXR_Error( 404, __( 'Invalid term ID.' ) );
if ( ! current_user_can( 'assign_term', $term_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign this term.' ) );
return $this->_prepare_term( $term );
* Retrieves all terms for a taxonomy.
* The optional $filter parameter modifies the query used to retrieve terms.
* Accepted keys are 'number', 'offset', 'orderby', 'order', 'hide_empty', and 'search'.
* Method arguments. Note: arguments must be ordered as documented.
* @type int $0 Blog ID (unused).
* @type string $1 Username.
* @type string $2 Password.
* @type string $3 Taxonomy name.
* @type array $4 Optional. Modifies the query used to retrieve posts. Accepts 'number',
* 'offset', 'orderby', 'order', 'hide_empty', and 'search'. Default empty array.
* @return array|IXR_Error An associative array of terms data on success, IXR_Error instance otherwise.
public function wp_getTerms( $args ) {
if ( ! $this->minimum_args( $args, 4 ) ) {
$filter = isset( $args[4] ) ? $args[4] : array();
$user = $this->login( $username, $password );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getTerms', $args, $this );
if ( ! taxonomy_exists( $taxonomy ) ) {
return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
$taxonomy = get_taxonomy( $taxonomy );
if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
$query = array( 'taxonomy' => $taxonomy->name );
if ( isset( $filter['number'] ) ) {
$query['number'] = absint( $filter['number'] );
if ( isset( $filter['offset'] ) ) {
$query['offset'] = absint( $filter['offset'] );
if ( isset( $filter['orderby'] ) ) {
$query['orderby'] = $filter['orderby'];
if ( isset( $filter['order'] ) ) {
$query['order'] = $filter['order'];
if ( isset( $filter['hide_empty'] ) ) {
$query['hide_empty'] = $filter['hide_empty'];
if ( isset( $filter['search'] ) ) {
$query['search'] = $filter['search'];
$terms = get_terms( $query );
if ( is_wp_error( $terms ) ) {
return new IXR_Error( 500, $terms->get_error_message() );