| 3183 | /** |
| 3184 | * Retrieve revisions for a specific post. |
| 3185 | * |
| 3186 | * @since 3.5.0 |
| 3187 | * |
| 3188 | * The optional $fields parameter specifies what fields will be included |
| 3189 | * in the response array. |
| 3190 | * |
| 3191 | * @uses wp_get_post_revisions() |
| 3192 | * @see wp_getPost() for more on $fields |
| 3193 | * |
| 3194 | * @param array $args Method parameters. Contains: |
| 3195 | * - int $blog_id |
| 3196 | * - string $username |
| 3197 | * - string $password |
| 3198 | * - int $post_id |
| 3199 | * - array $fields |
| 3200 | * @return array contains a collection of posts. |
| 3201 | */ |
| 3202 | function wp_getRevisions( $args ) { |
| 3203 | if ( ! $this->minimum_args( $args, 4 ) ) |
| 3204 | return $this->error; |
| 3205 | $this->escape( $args ); |
| 3206 | |
| 3207 | $blog_id = (int) $args[0]; |
| 3208 | $username = $args[1]; |
| 3209 | $password = $args[2]; |
| 3210 | $post_id = (int) $args[3]; |
| 3211 | |
| 3212 | if ( isset( $args[4] ) ) |
| 3213 | $fields = $args[4]; |
| 3214 | else |
| 3215 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post' ), 'wp.getRevisions' ); |
| 3216 | |
| 3217 | if ( ! $user = $this->login( $username, $password ) ) |
| 3218 | return $this->error; |
| 3219 | |
| 3220 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 3221 | |
| 3222 | $posts_list = wp_get_post_revisions( $post_id ); |
| 3223 | |
| 3224 | if ( ! $posts_list ) |
| 3225 | return array(); |
| 3226 | |
| 3227 | // holds all the posts data |
| 3228 | $struct = array(); |
| 3229 | |
| 3230 | foreach ( $posts_list as $post ) { |
| 3231 | $struct[] = $this->_prepare_post( get_object_vars( $post ), $fields ); |
| 3232 | } |
| 3233 | |
| 3234 | return $struct; |
| 3235 | } |
| 3236 | |
| 3237 | /** |
| 3238 | * Restore a post revision |
| 3239 | * |
| 3240 | * @since 3.5.0 |
| 3241 | * |
| 3242 | * The optional $fields parameter specifies what fields will be included |
| 3243 | * in the response array. |
| 3244 | * |
| 3245 | * @uses wp_restore_post_revision() |
| 3246 | * @see wp_getPost() for more on $fields |
| 3247 | * |
| 3248 | * @param array $args Method parameters. Contains: |
| 3249 | * - int $blog_id |
| 3250 | * - string $username |
| 3251 | * - string $password |
| 3252 | * - int $post_id |
| 3253 | * - array $fields |
| 3254 | * @return bool false if there was an error restoring, true if success. |
| 3255 | */ |
| 3256 | function wp_restoreRevision( $args ) { |
| 3257 | if ( ! $this->minimum_args( $args, 3 ) ) |
| 3258 | return $this->error; |
| 3259 | |
| 3260 | $this->escape( $args ); |
| 3261 | |
| 3262 | $blog_id = (int) $args[0]; |
| 3263 | $username = $args[1]; |
| 3264 | $password = $args[2]; |
| 3265 | $post_id = (int) $args[3]; |
| 3266 | |
| 3267 | if ( isset( $args[4] ) ) |
| 3268 | $fields = $args[4]; |
| 3269 | else |
| 3270 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post' ), 'wp.restoreRevisions' ); |
| 3271 | |
| 3272 | if ( ! $user = $this->login( $username, $password ) ) |
| 3273 | return $this->error; |
| 3274 | |
| 3275 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 3276 | |
| 3277 | $post = wp_restore_post_revision( $post_id, $fields ); |
| 3278 | |
| 3279 | return true; |
| 3280 | } |
| 3281 | |