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

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