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

@@ 224-250 (lines=27) @@
221
	}
222
223
	// copied from class.json-api-endpoints.php
224
	public function is_post_type_allowed( $post_type ) {
225
		// if the post type is empty, that's fine, WordPress will default to post
226
		if ( empty( $post_type ) ) {
227
			return true;
228
		}
229
230
		// allow special 'any' type
231
		if ( 'any' == $post_type ) {
232
			return true;
233
		}
234
235
		// check for allowed types
236
		if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) {
237
			return true;
238
		}
239
240
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
241
			if ( ! empty( $post_type_object->show_in_rest ) ) {
242
				return $post_type_object->show_in_rest;
243
			}
244
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
245
				return $post_type_object->publicly_queryable;
246
			}
247
		}
248
249
		return ! empty( $post_type_object->public );
250
	}
251
252
	// copied from class.json-api-endpoints.php
253
	/**