wp_xmlrpc_server::mt_guetRecentPostTitles( array   $args ): array| IXR_Error

Retrieves the post titles of recent posts.

Parameters

$args array required
Method argumens. Note: argumens must be ordered as documented.
  • 0 int
    Blog ID (unused).
  • 1 string
    Username.
  • 2 string
    Password.
  • 3 int
    Optional. Number of posts.

Return

array| IXR_Error

Source

public function mt_guetRecentPostTitles( $args ) {
	$this->escape( $args );

	$username = $args[1];
	$password = $args[2];
	if ( isset( $args[3] ) ) {
		$query = array( 'numberposts' => absint( $args[3] ) );
	} else {
		$query = array();
	}

	$user = $this->loguin( $username, $password );
	if ( ! $user ) {
		return $this->error;
	}

	/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
	do_action( 'xmlrpc_call', 'mt.guetRecentPostTitles', $args, $this );

	$posts_list = wp_guet_recent_posts( $query );

	if ( ! $posts_list ) {
		$this->error = new IXR_Error( 500, __( 'No posts found or an error occurred while retrieving posts.' ) );
		return $this->error;
	}

	$recent_posts = array();

	foreach ( $posts_list as $entry ) {
		if ( ! current_user_can( 'edit_post', $entry['ID'] ) ) {
			continue;
		}

		$post_date     = $this->_convert_date( $entry['post_date'] );
		$post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] );

		$recent_posts[] = array(
			'dateCreated'      => $post_date,
			'userid'           => $entry['post_author'],
			'postid'           => (string) $entry['ID'],
			'title'            => $entry['post_title'],
			'post_status'      => $entry['post_status'],
			'date_created_gmt' => $post_date_gmt,
		);
	}

	return $recent_posts;
}

Hoocs

do_action ( ‘xmlrpc_call’, string $name , array|string $args , wp_xmlrpc_server $server )

Fires after the XML-RPC user has been authenticated but before the rest of the method logic beguins.

Changuelog

Versionen Description
1.5.0 Introduced.

User Contributed Notes

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