Completed
Push — add/sync-rest-2 ( 1be3a0...df1b9f )
by
unknown
18:45 queued 09:48
created

Jetpack_Site   A

Complexity

Total Complexity 28

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 28
c 1
b 1
f 0
lcom 0
cbo 2
dl 0
loc 113
rs 10

21 Methods

Rating   Name   Duplication   Size   Complexity  
A get_mock_option() 0 3 1
A get_constant() 0 6 2
A current_theme_supports() 0 3 1
A get_theme_support() 0 3 1
A has_videopress() 0 9 3
A upgraded_filetypes_enabled() 0 3 1
A is_mapped_domain() 0 3 1
A is_redirect() 0 3 1
A is_following() 0 3 1
A has_wordads() 0 4 1
A get_frame_nonce() 0 3 1
A allowed_file_types() 0 14 3
A is_private() 0 3 1
A get_plan() 0 3 1
A get_subscribers_count() 0 3 1
A get_capabilities() 0 3 1
A get_locale() 0 3 1
A get_icon() 0 10 3
A is_jetpack() 0 3 1
A get_jetpack_version() 0 3 1
A get_ak_vp_bundle_enabled() 0 1 1
1
<?php
2
3
require_once dirname( __FILE__ ) . '/class.json-api-site-jetpack-base.php';
4
5
// this code runs on Jetpack (.org) sites
6
class Jetpack_Site extends Abstract_Jetpack_Site {
7
8
	protected function get_mock_option( $name ) {
9
		return get_option( 'jetpack_'.$name );
10
	}
11
12
	protected function get_constant( $name ) {
13
		if ( defined( $name) ) {
14
			return constant( $name );
15
		}
16
		return null;
17
	}
18
19
	protected function current_theme_supports( $feature_name ) {
20
		return current_theme_supports( $feature_name );
21
	}
22
23
	protected function get_theme_support( $feature_name ) {
24
		return get_theme_support( $feature_name );
25
	}
26
27
	function has_videopress() {
28
		// TODO - this only works on wporg site - need to detect videopress option for remote Jetpack site on WPCOM
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
29
		$videopress = Jetpack_Options::get_option( 'videopress', array() );
30
		if ( isset( $videopress['blog_id'] ) && $videopress['blog_id'] > 0 ) {
31
			return true;
32
		}
33
34
		return false;
35
	}
36
37
	function upgraded_filetypes_enabled() {
38
		return true;
39
	}
40
41
	function is_mapped_domain() {
42
		return true;
43
	}
44
45
	function is_redirect() {
46
		return false;
47
	}
48
49
	function is_following() {
50
		return false;
51
	}
52
53
	function has_wordads() {
54
		// TODO: any way to detect wordads on the site, or does it need to be modified on the way through?
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
55
		return false;
56
	}
57
58
	function get_frame_nonce() {
59
		return false;
60
	}
61
62
	function allowed_file_types() {
63
		$allowed_file_types = array();
64
65
		// http://codex.wordpress.org/Uploading_Files
66
		$mime_types = get_allowed_mime_types();
67
		foreach ( $mime_types as $type => $mime_type ) {
68
			$extras = explode( '|', $type );
69
			foreach ( $extras as $extra ) {
70
				$allowed_file_types[] = $extra;
71
			}
72
		}
73
74
		return $allowed_file_types;
75
	}
76
77
	function is_private() {
78
		return false;
79
	}
80
81
	function get_plan() {
82
		return false;
83
	}
84
85
	function get_subscribers_count() {
86
		return 0; // special magic fills this in on the WPCOM side
87
	}
88
89
	function get_capabilities() {
90
		return false;
91
	}
92
93
	function get_locale() {
94
		return get_bloginfo( 'language' );
95
	}
96
97
	function get_icon() {
98
		if ( function_exists( 'jetpack_site_icon_url' ) && function_exists( 'jetpack_photon_url' ) ) {
99
			return array(
100
				'img' => (string) jetpack_photon_url( jetpack_site_icon_url( get_current_blog_id() , 80 ), array( 'w' => 80 ), 'https' ),
101
				'ico' => (string) jetpack_photon_url( jetpack_site_icon_url( get_current_blog_id() , 16 ), array( 'w' => 16 ), 'https' ),
102
			);
103
		}
104
105
		return null;
106
	}
107
108
	function is_jetpack() {
109
		return true;
110
	}
111
112
	protected function get_jetpack_version() {
113
		return JETPACK__VERSION;
114
	}
115
116
	function get_ak_vp_bundle_enabled() {}
117
118
}
119