1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Automattic\Jetpack\Sync\Functions; |
4
|
|
|
|
5
|
|
|
require_once dirname( __FILE__ ) . '/class.json-api-site-jetpack-base.php'; |
6
|
|
|
require_once dirname( __FILE__ ) . '/class.json-api-post-jetpack.php'; |
7
|
|
|
|
8
|
|
|
// this code runs on Jetpack (.org) sites |
9
|
|
|
class Jetpack_Site extends Abstract_Jetpack_Site { |
10
|
|
|
|
11
|
|
|
protected function get_mock_option( $name ) { |
12
|
|
|
return get_option( 'jetpack_'.$name ); |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
protected function get_constant( $name ) { |
16
|
|
|
if ( defined( $name) ) { |
17
|
|
|
return constant( $name ); |
18
|
|
|
} |
19
|
|
|
return null; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
protected function main_network_site() { |
23
|
|
|
return network_site_url(); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
protected function wp_version() { |
27
|
|
|
global $wp_version; |
28
|
|
|
return $wp_version; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
protected function max_upload_size() { |
32
|
|
|
return wp_max_upload_size(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
protected function wp_memory_limit() { |
36
|
|
|
return wp_convert_hr_to_bytes( WP_MEMORY_LIMIT ); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
protected function wp_max_memory_limit() { |
40
|
|
|
return wp_convert_hr_to_bytes( WP_MAX_MEMORY_LIMIT ); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
protected function is_main_network() { |
44
|
|
|
return Jetpack::is_multi_network(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function is_multisite() { |
48
|
|
|
return (bool) is_multisite(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function is_single_user_site() { |
52
|
|
|
return (bool) Jetpack::is_single_user_site(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
protected function is_version_controlled() { |
56
|
|
|
return Functions::is_version_controlled(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
protected function file_system_write_access() { |
60
|
|
|
return Functions::file_system_write_access(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
protected function current_theme_supports( $feature_name ) { |
64
|
|
|
return current_theme_supports( $feature_name ); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
protected function get_theme_support( $feature_name ) { |
68
|
|
|
return get_theme_support( $feature_name ); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function get_updates() { |
72
|
|
|
return (array) Jetpack::get_updates(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
function get_id() { |
76
|
|
|
return $this->platform->token->blog_id; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
function has_videopress() { |
80
|
|
|
// TODO - this only works on wporg site - need to detect videopress option for remote Jetpack site on WPCOM |
81
|
|
|
$videopress = Jetpack_Options::get_option( 'videopress', array() ); |
82
|
|
|
if ( isset( $videopress['blog_id'] ) && $videopress['blog_id'] > 0 ) { |
83
|
|
|
return true; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
return false; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
function upgraded_filetypes_enabled() { |
90
|
|
|
return true; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
function is_mapped_domain() { |
94
|
|
|
return true; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
function is_redirect() { |
98
|
|
|
return false; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
function is_following() { |
102
|
|
|
return false; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
function has_wordads() { |
106
|
|
|
return Jetpack::is_module_active( 'wordads' ); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
function get_frame_nonce() { |
110
|
|
|
return false; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
function get_jetpack_frame_nonce() { |
114
|
|
|
return false; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
function is_headstart_fresh() { |
118
|
|
|
return false; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
function allowed_file_types() { |
122
|
|
|
$allowed_file_types = array(); |
123
|
|
|
|
124
|
|
|
// https://codex.wordpress.org/Uploading_Files |
125
|
|
|
$mime_types = get_allowed_mime_types(); |
126
|
|
|
foreach ( $mime_types as $type => $mime_type ) { |
127
|
|
|
$extras = explode( '|', $type ); |
128
|
|
|
foreach ( $extras as $extra ) { |
129
|
|
|
$allowed_file_types[] = $extra; |
130
|
|
|
} |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
return $allowed_file_types; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
function is_private() { |
137
|
|
|
return false; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
function get_plan() { |
141
|
|
|
return false; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
function get_subscribers_count() { |
145
|
|
|
return 0; // special magic fills this in on the WPCOM side |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
function get_capabilities() { |
149
|
|
|
return false; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
function get_locale() { |
153
|
|
|
return get_bloginfo( 'language' ); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
function is_jetpack() { |
157
|
|
|
return true; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
public function get_jetpack_version() { |
161
|
|
|
return JETPACK__VERSION; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
function get_ak_vp_bundle_enabled() {} |
165
|
|
|
|
166
|
|
|
function get_jetpack_seo_front_page_description() { |
167
|
|
|
return Jetpack_SEO_Utils::get_front_page_meta_description(); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
function get_jetpack_seo_title_formats() { |
171
|
|
|
return Jetpack_SEO_Titles::get_custom_title_formats(); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
function get_verification_services_codes() { |
175
|
|
|
return get_option( 'verification_services_codes', null ); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
function get_podcasting_archive() { |
179
|
|
|
return null; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
function is_connected_site() { |
183
|
|
|
return true; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
function current_user_can( $role ) { |
187
|
|
|
return current_user_can( $role ); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Check if full site editing should be considered as currently active. Full site editing |
192
|
|
|
* requires the FSE plugin to be installed and activated, as well the current |
193
|
|
|
* theme to be FSE compatible. The plugin can also be explicitly disabled via the |
194
|
|
|
* a8c_disable_full_site_editing filter. |
195
|
|
|
* |
196
|
|
|
* @since 7.7.0 |
197
|
|
|
* |
198
|
|
|
* @return bool true if full site editing is currently active. |
199
|
|
|
*/ |
200
|
|
|
function is_fse_active() { |
201
|
|
|
if ( ! Jetpack::is_plugin_active( 'full-site-editing/full-site-editing-plugin.php' ) ) { |
202
|
|
|
return false; |
203
|
|
|
} |
204
|
|
|
return function_exists( '\A8C\FSE\is_full_site_editing_active' ) && \A8C\FSE\is_full_site_editing_active(); |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Return the last engine used for an import on the site. |
209
|
|
|
* |
210
|
|
|
* This option is not used in Jetpack. |
211
|
|
|
*/ |
212
|
|
|
function get_import_engine() { |
213
|
|
|
return null; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* Post functions |
218
|
|
|
*/ |
219
|
|
|
|
220
|
|
|
function wrap_post( $post, $context ) { |
221
|
|
|
return new Jetpack_Post( $this, $post, $context ); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
} |
225
|
|
|
|