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 get_id() { |
32
|
|
|
return $this->platform->token->blog_id; |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
function has_videopress() { |
36
|
|
|
// TODO - this only works on wporg site - need to detect videopress option for remote Jetpack site on WPCOM |
|
|
|
|
37
|
|
|
$videopress = Jetpack_Options::get_option( 'videopress', array() ); |
38
|
|
|
if ( isset( $videopress['blog_id'] ) && $videopress['blog_id'] > 0 ) { |
39
|
|
|
return true; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
return false; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
function upgraded_filetypes_enabled() { |
46
|
|
|
return true; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
function is_mapped_domain() { |
50
|
|
|
return true; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
function is_redirect() { |
54
|
|
|
return false; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
function is_following() { |
58
|
|
|
return false; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
function has_wordads() { |
62
|
|
|
// TODO: any way to detect wordads on the site, or does it need to be modified on the way through? |
|
|
|
|
63
|
|
|
return false; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
function get_frame_nonce() { |
67
|
|
|
return false; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
function allowed_file_types() { |
71
|
|
|
$allowed_file_types = array(); |
72
|
|
|
|
73
|
|
|
// http://codex.wordpress.org/Uploading_Files |
74
|
|
|
$mime_types = get_allowed_mime_types(); |
75
|
|
|
foreach ( $mime_types as $type => $mime_type ) { |
76
|
|
|
$extras = explode( '|', $type ); |
77
|
|
|
foreach ( $extras as $extra ) { |
78
|
|
|
$allowed_file_types[] = $extra; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $allowed_file_types; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
function is_private() { |
86
|
|
|
return false; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
function get_plan() { |
90
|
|
|
return false; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
function get_subscribers_count() { |
94
|
|
|
return 0; // special magic fills this in on the WPCOM side |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
function get_capabilities() { |
98
|
|
|
return false; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
function get_locale() { |
102
|
|
|
return get_bloginfo( 'language' ); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
function get_icon() { |
106
|
|
|
if ( function_exists( 'jetpack_site_icon_url' ) && function_exists( 'jetpack_photon_url' ) ) { |
107
|
|
|
return array( |
108
|
|
|
'img' => (string) jetpack_photon_url( jetpack_site_icon_url( get_current_blog_id() , 80 ), array( 'w' => 80 ), 'https' ), |
109
|
|
|
'ico' => (string) jetpack_photon_url( jetpack_site_icon_url( get_current_blog_id() , 16 ), array( 'w' => 16 ), 'https' ), |
110
|
|
|
); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
return null; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
function is_jetpack() { |
117
|
|
|
return true; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
protected function get_jetpack_version() { |
121
|
|
|
return JETPACK__VERSION; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
function get_ak_vp_bundle_enabled() {} |
125
|
|
|
|
126
|
|
|
} |
127
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: