Code Duplication    Length = 27-27 lines in 2 locations

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
	/**

class.json-api-endpoints.php 1 location

@@ 1746-1772 (lines=27) @@
1743
		}
1744
	}
1745
1746
	function is_post_type_allowed( $post_type ) {
1747
		// if the post type is empty, that's fine, WordPress will default to post
1748
		if ( empty( $post_type ) ) {
1749
			return true;
1750
		}
1751
1752
		// allow special 'any' type
1753
		if ( 'any' == $post_type ) {
1754
			return true;
1755
		}
1756
1757
		// check for allowed types
1758
		if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) {
1759
			return true;
1760
		}
1761
1762
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
1763
			if ( ! empty( $post_type_object->show_in_rest ) ) {
1764
				return $post_type_object->show_in_rest;
1765
			}
1766
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
1767
				return $post_type_object->publicly_queryable;
1768
			}
1769
		}
1770
1771
		return ! empty( $post_type_object->public );
1772
	}
1773
1774
	/**
1775
	 * Gets the whitelisted post types that JP should allow access to.