Completed
Push — add/sal-post ( 4a4572 )
by
unknown
10:34
created

WPCOM_JSON_API_Metadata::is_public()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 20
Code Lines 11

Duplication

Lines 20
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 20
loc 20
rs 8.8571
cc 5
eloc 11
nc 5
nop 1
1
<?php
2
3
/**
4
 * Utility classes that don't necessarily have a home yet
5
 */
6
7
class WPCOM_JSON_API_Metadata {
8 View Code Duplication
	public static function is_public( $key ) {
9
		if ( empty( $key ) )
10
			return false;
11
12
		// Default whitelisted meta keys.
13
		$whitelisted_meta = array( '_thumbnail_id' );
14
15
		// whitelist of metadata that can be accessed
16
		/** This filter is documented in json-endpoints/class.wpcom-json-api-post-endpoint.php */
17
		if ( in_array( $key, apply_filters( 'rest_api_allowed_public_metadata', $whitelisted_meta ) ) )
18
			return true;
19
20
		if ( 0 === strpos( $key, 'geo_' ) )
21
			return true;
22
23
		if ( 0 === strpos( $key, '_wpas_' ) )
24
			return true;
25
26
		return false;
27
	}
28
29
	public static function is_internal_only( $key ) {
30
31
		if ( 0 === strpos( $key, '_jetpack_') )
32
			return true;
33
34
		if ( 0 === strpos( $key, '_elasticsearch_') )
35
			return true;
36
37
		return false;
38
	}
39
}