Code Duplication    Length = 15-15 lines in 2 locations

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

@@ 219-233 (lines=15) @@
216
		return $post;
217
	}
218
219
	public function current_user_can_access_post_type( $post_type, $context ) {
220
		$post_type_object = $this->get_post_type_object( $post_type );
221
		if ( ! $post_type_object ) {
222
			return false;
223
		}
224
225
		switch( $context ) {
226
			case 'edit':
227
				return current_user_can( $post_type_object->cap->edit_posts );
228
			case 'display':
229
				return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts );
230
			default:
231
				return false;
232
		}
233
	}
234
235
	protected function get_post_type_object( $post_type ) {
236
		return get_post_type_object( $post_type );

class.json-api-endpoints.php 1 location

@@ 1734-1748 (lines=15) @@
1731
	 * @param string $context                'display' or 'edit'
1732
	 * @return bool
1733
	 */
1734
	function current_user_can_access_post_type( $post_type, $context = 'display' ) {
1735
		$post_type_object = get_post_type_object( $post_type );
1736
		if ( ! $post_type_object ) {
1737
			return false;
1738
		}
1739
1740
		switch ( $context ) {
1741
			case 'edit':
1742
				return current_user_can( $post_type_object->cap->edit_posts );
1743
			case 'display':
1744
				return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts );
1745
			default:
1746
				return false;
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