Code Duplication    Length = 27-27 lines in 2 locations

class.json-api-endpoints.php 1 location

@@ 1735-1761 (lines=27) @@
1732
		}
1733
	}
1734
1735
	function is_post_type_allowed( $post_type ) {
1736
		// if the post type is empty, that's fine, WordPress will default to post
1737
		if ( empty( $post_type ) ) {
1738
			return true;
1739
		}
1740
1741
		// allow special 'any' type
1742
		if ( 'any' == $post_type ) {
1743
			return true;
1744
		}
1745
1746
		// check for allowed types
1747
		if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) {
1748
			return true;
1749
		}
1750
1751
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
1752
			if ( ! empty( $post_type_object->show_in_rest ) ) {
1753
				return $post_type_object->show_in_rest;
1754
			}
1755
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
1756
				return $post_type_object->publicly_queryable;
1757
			}
1758
		}
1759
1760
		return ! empty( $post_type_object->public );
1761
	}
1762
1763
	/**
1764
	 * Gets the whitelisted post types that JP should allow access to.

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

@@ 240-266 (lines=27) @@
237
	}
238
239
	// copied from class.json-api-endpoints.php
240
	public function is_post_type_allowed( $post_type ) {
241
		// if the post type is empty, that's fine, WordPress will default to post
242
		if ( empty( $post_type ) ) {
243
			return true;
244
		}
245
246
		// allow special 'any' type
247
		if ( 'any' == $post_type ) {
248
			return true;
249
		}
250
251
		// check for allowed types
252
		if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) {
253
			return true;
254
		}
255
256
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
257
			if ( ! empty( $post_type_object->show_in_rest ) ) {
258
				return $post_type_object->show_in_rest;
259
			}
260
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
261
				return $post_type_object->publicly_queryable;
262
			}
263
		}
264
265
		return ! empty( $post_type_object->public );
266
	}
267
268
	// copied from class.json-api-endpoints.php
269
	/**