class.json-api-metadata.php 859 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Utility classes that don't necessarily have a home yet
  4. */
  5. class WPCOM_JSON_API_Metadata {
  6. public static function is_public( $key ) {
  7. if ( empty( $key ) )
  8. return false;
  9. // Default whitelisted meta keys.
  10. $whitelisted_meta = array( '_thumbnail_id' );
  11. // whitelist of metadata that can be accessed
  12. /** This filter is documented in json-endpoints/class.wpcom-json-api-post-endpoint.php */
  13. if ( in_array( $key, apply_filters( 'rest_api_allowed_public_metadata', $whitelisted_meta ) ) )
  14. return true;
  15. if ( 0 === strpos( $key, 'geo_' ) )
  16. return true;
  17. if ( 0 === strpos( $key, '_wpas_' ) )
  18. return true;
  19. return false;
  20. }
  21. public static function is_internal_only( $key ) {
  22. if ( 0 === strpos( $key, '_jetpack_') )
  23. return true;
  24. if ( 0 === strpos( $key, '_elasticsearch_') )
  25. return true;
  26. return false;
  27. }
  28. }