Code Duplication    Length = 27-27 lines in 2 locations

class.json-api-endpoints.php 1 location

@@ 1702-1728 (lines=27) @@
1699
		}
1700
	}
1701
1702
	function is_post_type_allowed( $post_type ) {
1703
		// if the post type is empty, that's fine, WordPress will default to post
1704
		if ( empty( $post_type ) ) {
1705
			return true;
1706
		}
1707
1708
		// allow special 'any' type
1709
		if ( 'any' == $post_type ) {
1710
			return true;
1711
		}
1712
1713
		// check for allowed types
1714
		if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) {
1715
			return true;
1716
		}
1717
1718
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
1719
			if ( ! empty( $post_type_object->show_in_rest ) ) {
1720
				return $post_type_object->show_in_rest;
1721
			}
1722
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
1723
				return $post_type_object->publicly_queryable;
1724
			}
1725
		}
1726
1727
		return ! empty( $post_type_object->public );
1728
	}
1729
1730
	/**
1731
	 * Gets the whitelisted post types that JP should allow access to.

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

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