Completed
Push — merge/json-endpoints/082017 ( 1801a4...c41961 )
by
unknown
16:21 queued 06:15
created

callback()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 3
nop 2
dl 0
loc 20
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
class WPCOM_JSON_API_Bulk_Delete_Post_Endpoint extends WPCOM_JSON_API_Update_Post_v1_1_Endpoint {
4
	function callback( $path = '', $blog_id = 0 ) {
5
		$blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
6
		if ( is_wp_error( $blog_id ) ) {
7
			return $blog_id;
8
		}
9
10
		$input = $this->input();
11
12
		$post_ids = (array) $input['post_ids'];
13
14
		$result = array(
15
			'results' => array(),
16
		);
17
18
		foreach( $post_ids as $post_id ) {
19
			$result['results'][ $post_id ] = $this->delete_post( $path, $blog_id, $post_id );
20
		}
21
22
		return $result;
23
	}
24
}
25