Code Duplication    Length = 27-27 lines in 2 locations

class.json-api-endpoints.php 1 location

@@ 1759-1785 (lines=27) @@
1756
		}
1757
	}
1758
1759
	function is_post_type_allowed( $post_type ) {
1760
		// if the post type is empty, that's fine, WordPress will default to post
1761
		if ( empty( $post_type ) ) {
1762
			return true;
1763
		}
1764
1765
		// allow special 'any' type
1766
		if ( 'any' == $post_type ) {
1767
			return true;
1768
		}
1769
1770
		// check for allowed types
1771
		if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) {
1772
			return true;
1773
		}
1774
1775
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
1776
			if ( ! empty( $post_type_object->show_in_rest ) ) {
1777
				return $post_type_object->show_in_rest;
1778
			}
1779
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
1780
				return $post_type_object->publicly_queryable;
1781
			}
1782
		}
1783
1784
		return ! empty( $post_type_object->public );
1785
	}
1786
1787
	/**
1788
	 * Gets the whitelisted post types that JP should allow access to.

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

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