WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

wp_xmlrpc_server::wp_getRevisions() WP 3.5.0

Retrieve revisions for a specific post.

Это метод класса: wp_xmlrpc_server

Хуки из метода
Возвращает

Массив/IXR_Error. contains a collection of posts.

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

$wp_xmlrpc_server = new wp_xmlrpc_server();
$var = $wp_xmlrpc_server->wp_getRevisions( $args );
$args(массив) (обязательный)

Method arguments. Note: arguments must be ordered as documented.

  • $blog_id (число)
    (unused)

  • $username (строка)

  • $password (строка)

  • $post_id (число)

  • $fields (массив)
    (optional)

Заметки

  • Смотрите: wp_getPost() for more on $fields

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

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

Код wp xmlrpc server::wp getRevisions: wp-includes/class-wp-xmlrpc-server.php WP 5.2.3

<?php
public function wp_getRevisions( $args ) {
	if ( ! $this->minimum_args( $args, 4 ) ) {
		return $this->error;
	}

	$this->escape( $args );

	$username = $args[1];
	$password = $args[2];
	$post_id  = (int) $args[3];

	if ( isset( $args[4] ) ) {
		$fields = $args[4];
	} else {
		/**
		 * Filters the default revision query fields used by the given XML-RPC method.
		 *
		 * @since 3.5.0
		 *
		 * @param array  $field  An array of revision query fields.
		 * @param string $method The method name.
		 */
		$fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' );
	}

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

	/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
	do_action( 'xmlrpc_call', 'wp.getRevisions' );

	if ( ! $post = get_post( $post_id ) ) {
		return new IXR_Error( 404, __( 'Invalid post ID.' ) );
	}

	if ( ! current_user_can( 'edit_post', $post_id ) ) {
		return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
	}

	// Check if revisions are enabled.
	if ( ! wp_revisions_enabled( $post ) ) {
		return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) );
	}

	$revisions = wp_get_post_revisions( $post_id );

	if ( ! $revisions ) {
		return array();
	}

	$struct = array();

	foreach ( $revisions as $revision ) {
		if ( ! current_user_can( 'read_post', $revision->ID ) ) {
			continue;
		}

		// Skip autosaves
		if ( wp_is_post_autosave( $revision ) ) {
			continue;
		}

		$struct[] = $this->_prepare_post( get_object_vars( $revision ), $fields );
	}

	return $struct;
}