Completed
Push — fix/site-api-updates ( 8614e2...200596 )
by
unknown
16:10 queued 07:22
created

Jetpack_Site   A

Complexity

Total Complexity 29

Size/Duplication

Total Lines 117
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 29
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 117
rs 10

22 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 get_updates() 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
	protected function get_updates() {
28
		return (array) Jetpack::get_updates();
29
	}
30
31
	function has_videopress() {
32
		// 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...
33
		$videopress = Jetpack_Options::get_option( 'videopress', array() );
34
		if ( isset( $videopress['blog_id'] ) && $videopress['blog_id'] > 0 ) {
35
			return true;
36
		}
37
38
		return false;
39
	}
40
41
	function upgraded_filetypes_enabled() {
42
		return true;
43
	}
44
45
	function is_mapped_domain() {
46
		return true;
47
	}
48
49
	function is_redirect() {
50
		return false;
51
	}
52
53
	function is_following() {
54
		return false;
55
	}
56
57
	function has_wordads() {
58
		// 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...
59
		return false;
60
	}
61
62
	function get_frame_nonce() {
63
		return false;
64
	}
65
66
	function allowed_file_types() {
67
		$allowed_file_types = array();
68
69
		// http://codex.wordpress.org/Uploading_Files
70
		$mime_types = get_allowed_mime_types();
71
		foreach ( $mime_types as $type => $mime_type ) {
72
			$extras = explode( '|', $type );
73
			foreach ( $extras as $extra ) {
74
				$allowed_file_types[] = $extra;
75
			}
76
		}
77
78
		return $allowed_file_types;
79
	}
80
81
	function is_private() {
82
		return false;
83
	}
84
85
	function get_plan() {
86
		return false;
87
	}
88
89
	function get_subscribers_count() {
90
		return 0; // special magic fills this in on the WPCOM side
91
	}
92
93
	function get_capabilities() {
94
		return false;
95
	}
96
97
	function get_locale() {
98
		return get_bloginfo( 'language' );
99
	}
100
101
	function get_icon() {
102
		if ( function_exists( 'jetpack_site_icon_url' ) && function_exists( 'jetpack_photon_url' ) ) {
103
			return array(
104
				'img' => (string) jetpack_photon_url( jetpack_site_icon_url( get_current_blog_id() , 80 ), array( 'w' => 80 ), 'https' ),
105
				'ico' => (string) jetpack_photon_url( jetpack_site_icon_url( get_current_blog_id() , 16 ), array( 'w' => 16 ), 'https' ),
106
			);
107
		}
108
109
		return null;
110
	}
111
112
	function is_jetpack() {
113
		return true;
114
	}
115
116
	protected function get_jetpack_version() {
117
		return JETPACK__VERSION;
118
	}
119
120
	function get_ak_vp_bundle_enabled() {}
121
122
}
123