Code Duplication    Length = 20-28 lines in 3 locations

json-endpoints/class.wpcom-json-api-post-endpoint.php 1 location

@@ 68-95 (lines=28) @@
65
		parent::__construct( $args );
66
	}
67
68
	function is_metadata_public( $key ) {
69
		if ( empty( $key ) )
70
			return false;
71
72
		// Default whitelisted meta keys.
73
		$whitelisted_meta = array( '_thumbnail_id' );
74
75
		/**
76
		 * Filters the meta keys accessible by the REST API.
77
		 * @see https://developer.wordpress.com/2013/04/26/custom-post-type-and-metadata-support-in-the-rest-api/
78
		 *
79
		 * @module json-api
80
		 *
81
		 * @since 2.2.3
82
		 *
83
		 * @param array $whitelisted_meta Array of metadata that is accessible by the REST API.
84
		 */
85
 		if ( in_array( $key, apply_filters( 'rest_api_allowed_public_metadata', $whitelisted_meta ) ) )
86
			return true;
87
88
		if ( 0 === strpos( $key, 'geo_' ) )
89
			return true;
90
91
		if ( 0 === strpos( $key, '_wpas_' ) )
92
			return true;
93
94
 		return false;
95
 	}
96
97
	function the_password_form() {
98
		return __( 'This post is password protected.', 'jetpack' );

json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php 1 location

@@ 69-88 (lines=20) @@
66
		parent::__construct( $args );
67
	}
68
69
	function is_metadata_public( $key ) {
70
		if ( empty( $key ) )
71
			return false;
72
73
		// Default whitelisted meta keys.
74
		$whitelisted_meta = array( '_thumbnail_id' );
75
76
		// whitelist of metadata that can be accessed
77
		/** This filter is documented in json-endpoints/class.wpcom-json-api-post-endpoint.php */
78
		if ( in_array( $key, apply_filters( 'rest_api_allowed_public_metadata', $whitelisted_meta ) ) )
79
			return true;
80
81
		if ( 0 === strpos( $key, 'geo_' ) )
82
			return true;
83
84
		if ( 0 === strpos( $key, '_wpas_' ) )
85
			return true;
86
87
		return false;
88
	}
89
90
	function the_password_form() {
91
		return __( 'This post is password protected.', 'jetpack' );

sal/class.json-api-metadata.php 1 location

@@ 8-27 (lines=20) @@
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