Completed
Push — add/rest-api-memory-options ( 796a03 )
by
unknown
11:58
created

Jetpack_Site::wp_memory_limit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
require_once dirname( __FILE__ ) . '/class.json-api-site-jetpack-base.php';
4
require_once dirname( __FILE__ ) . '/class.json-api-post-jetpack.php';
5
6
// this code runs on Jetpack (.org) sites
7
class Jetpack_Site extends Abstract_Jetpack_Site {
8
9
	protected function get_mock_option( $name ) {
10
		return get_option( 'jetpack_'.$name );
11
	}
12
13
	protected function get_constant( $name ) {
14
		if ( defined( $name) ) {
15
			return constant( $name );
16
		}
17
		return null;
18
	}
19
20
	protected function main_network_site() {
21
		return network_site_url();
22
	}
23
24
	protected function wp_version() {
25
		global $wp_version;
26
		return $wp_version;
27
	}
28
29
	protected function max_upload_size() {
30
		return wp_max_upload_size();
31
	}
32
33
	protected function wp_memory_limit() {
34
		return wp_convert_hr_to_bytes( WP_MEMORY_LIMIT );
35
	}
36
37
	protected function wp_max_memory_limit() {
38
		return wp_convert_hr_to_bytes( WP_MAX_MEMORY_LIMIT );
39
	}
40
41
	protected function is_main_network() {
42
		return Jetpack::is_multi_network();
43
	}
44
45
	public function is_multisite() {
46
		return (bool) is_multisite();
47
	}
48
49
	public function is_single_user_site() {
50
		return (bool) Jetpack::is_single_user_site();
51
	}
52
53
	protected function is_version_controlled() {
54
		return Jetpack_Sync_Functions::is_version_controlled();
55
	}
56
57
	protected function file_system_write_access() {
58
		return Jetpack_Sync_Functions::file_system_write_access();
59
	}
60
61
	protected function current_theme_supports( $feature_name ) {
62
		return current_theme_supports( $feature_name );
63
	}
64
65
	protected function get_theme_support( $feature_name ) {
66
		return get_theme_support( $feature_name );
67
	}
68
69
	public function get_updates() {
70
		return (array) Jetpack::get_updates();
71
	}
72
73
	function get_id() {
74
		return $this->platform->token->blog_id;
75
	}
76
77
	function has_videopress() {
78
		// 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...
79
		$videopress = Jetpack_Options::get_option( 'videopress', array() );
80
		if ( isset( $videopress['blog_id'] ) && $videopress['blog_id'] > 0 ) {
81
			return true;
82
		}
83
84
		return false;
85
	}
86
87
	function upgraded_filetypes_enabled() {
88
		return true;
89
	}
90
91
	function is_mapped_domain() {
92
		return true;
93
	}
94
95
	function is_redirect() {
96
		return false;
97
	}
98
99
	function is_following() {
100
		return false;
101
	}
102
103
	function has_wordads() {
104
		// 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...
105
		return false;
106
	}
107
108
	function get_frame_nonce() {
109
		return false;
110
	}
111
112
	function is_headstart_fresh() {
113
		return false;
114
	}
115
116
	function allowed_file_types() {
117
		$allowed_file_types = array();
118
119
		// http://codex.wordpress.org/Uploading_Files
120
		$mime_types = get_allowed_mime_types();
121
		foreach ( $mime_types as $type => $mime_type ) {
122
			$extras = explode( '|', $type );
123
			foreach ( $extras as $extra ) {
124
				$allowed_file_types[] = $extra;
125
			}
126
		}
127
128
		return $allowed_file_types;
129
	}
130
131
	function is_private() {
132
		return false;
133
	}
134
135
	function get_plan() {
136
		return false;
137
	}
138
139
	function get_subscribers_count() {
140
		return 0; // special magic fills this in on the WPCOM side
141
	}
142
143
	function get_capabilities() {
144
		return false;
145
	}
146
147
	function get_locale() {
148
		return get_bloginfo( 'language' );
149
	}
150
151
	function is_jetpack() {
152
		return true;
153
	}
154
155
	public function get_jetpack_version() {
156
		return JETPACK__VERSION;
157
	}
158
159
	function get_ak_vp_bundle_enabled() {}
160
161
	function get_jetpack_seo_front_page_description() {
162
		return Jetpack_SEO_Utils::get_front_page_meta_description();
163
	}
164
165
	function get_jetpack_seo_title_formats() {
166
		return Jetpack_SEO_Titles::get_custom_title_formats();
167
	}
168
169
	function get_verification_services_codes() {
170
		return get_option( 'verification_services_codes', null );
171
	}
172
173
	function get_podcasting_archive() {
174
		return null;
175
	}
176
177
	/**
178
	 * Post functions
179
	 */
180
181
	function wrap_post( $post, $context ) {
182
		return new Jetpack_Post( $this, $post, $context );
183
	}
184
185
}
186