Completed
Push — fix/normalize-www-in-site-url-... ( e67e76 )
by
unknown
13:13 queued 02:59
created

WPCOM_JSON_API_Get_CustomCss_Endpoint::callback()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 13
nc 2
nop 2
dl 0
loc 20
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Custom Css endpoint
4
 *
5
 * https://public-api.wordpress.com/rest/v1.1/sites/$site/customcss/
6
 */
7
8
class WPCOM_JSON_API_Get_CustomCss_Endpoint extends WPCOM_JSON_API_Endpoint {
9
	/**
10
	 * API callback.
11
	 */
12
	function callback( $path = '', $blog_id = 0 ) {
13
		// Switch to the given blog.
14
		$blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $blog_id. This often makes code more readable.
Loading history...
15
		if ( is_wp_error( $blog_id ) ) {
16
			return $blog_id;
17
		}
18
19
		$args = array(
20
			'css' => Jetpack_Custom_CSS::get_css(),
21
			'preprocessor' => Jetpack_Custom_CSS::get_preprocessor_key(),
22
			'add_to_existing' => ! Jetpack_Custom_CSS::skip_stylesheet(),
23
		);
24
25
		$defaults = array(
26
			'css' => '',
27
			'preprocessor' => '',
28
			'add_to_existing' => true,
29
		);
30
		return wp_parse_args( $args, $defaults );
31
	}
32
}
33
34
35