| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Utility classes that don't necessarily have a home yet |
| 5 |
*/ |
| 6 |
|
| 7 |
class WPCOM_JSON_API_Metadata { |
| 8 |
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 |
} |