Code Duplication    Length = 27-27 lines in 2 locations

class.json-api-endpoints.php 1 location

@@ 1729-1755 (lines=27) @@
1726
		}
1727
	}
1728
1729
	function is_post_type_allowed( $post_type ) {
1730
		// if the post type is empty, that's fine, WordPress will default to post
1731
		if ( empty( $post_type ) ) {
1732
			return true;
1733
		}
1734
1735
		// allow special 'any' type
1736
		if ( 'any' == $post_type ) {
1737
			return true;
1738
		}
1739
1740
		// check for allowed types
1741
		if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) {
1742
			return true;
1743
		}
1744
1745
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
1746
			if ( ! empty( $post_type_object->show_in_rest ) ) {
1747
				return $post_type_object->show_in_rest;
1748
			}
1749
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
1750
				return $post_type_object->publicly_queryable;
1751
			}
1752
		}
1753
1754
		return ! empty( $post_type_object->public );
1755
	}
1756
1757
	/**
1758
	 * Gets the whitelisted post types that JP should allow access to.

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

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