Code Duplication    Length = 27-27 lines in 2 locations

projects/plugins/jetpack/class.json-api-endpoints.php 1 location

@@ 1770-1796 (lines=27) @@
1767
		}
1768
	}
1769
1770
	function is_post_type_allowed( $post_type ) {
1771
		// if the post type is empty, that's fine, WordPress will default to post
1772
		if ( empty( $post_type ) ) {
1773
			return true;
1774
		}
1775
1776
		// allow special 'any' type
1777
		if ( 'any' == $post_type ) {
1778
			return true;
1779
		}
1780
1781
		// check for allowed types
1782
		if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) {
1783
			return true;
1784
		}
1785
1786
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
1787
			if ( ! empty( $post_type_object->show_in_rest ) ) {
1788
				return $post_type_object->show_in_rest;
1789
			}
1790
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
1791
				return $post_type_object->publicly_queryable;
1792
			}
1793
		}
1794
1795
		return ! empty( $post_type_object->public );
1796
	}
1797
1798
	/**
1799
	 * Gets the whitelisted post types that JP should allow access to.

projects/plugins/jetpack/sal/class.json-api-site-base.php 1 location

@@ 258-284 (lines=27) @@
255
	}
256
257
	// copied from class.json-api-endpoints.php
258
	public function is_post_type_allowed( $post_type ) {
259
		// if the post type is empty, that's fine, WordPress will default to post
260
		if ( empty( $post_type ) ) {
261
			return true;
262
		}
263
264
		// allow special 'any' type
265
		if ( 'any' == $post_type ) {
266
			return true;
267
		}
268
269
		// check for allowed types
270
		if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) {
271
			return true;
272
		}
273
274
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
275
			if ( ! empty( $post_type_object->show_in_rest ) ) {
276
				return $post_type_object->show_in_rest;
277
			}
278
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
279
				return $post_type_object->publicly_queryable;
280
			}
281
		}
282
283
		return ! empty( $post_type_object->public );
284
	}
285
286
	// copied from class.json-api-endpoints.php
287
	/**