Code Duplication    Length = 27-27 lines in 2 locations

class.json-api-endpoints.php 1 location

@@ 1685-1711 (lines=27) @@
1682
		}
1683
	}
1684
1685
	function is_post_type_allowed( $post_type ) {
1686
		// if the post type is empty, that's fine, WordPress will default to post
1687
		if ( empty( $post_type ) ) {
1688
			return true;
1689
		}
1690
1691
		// allow special 'any' type
1692
		if ( 'any' == $post_type ) {
1693
			return true;
1694
		}
1695
1696
		// check for allowed types
1697
		if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) {
1698
			return true;
1699
		}
1700
1701
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
1702
			if ( ! empty( $post_type_object->show_in_rest ) ) {
1703
				return $post_type_object->show_in_rest;
1704
			}
1705
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
1706
				return $post_type_object->publicly_queryable;
1707
			}
1708
		}
1709
1710
		return ! empty( $post_type_object->public );
1711
	}
1712
1713
	/**
1714
	 * Gets the whitelisted post types that JP should allow access to.

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

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