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

@@ 1730-1744 (lines=15) @@
1727
	 * @param string $context                'display' or 'edit'
1728
	 * @return bool
1729
	 */
1730
	function current_user_can_access_post_type( $post_type, $context = 'display' ) {
1731
		$post_type_object = get_post_type_object( $post_type );
1732
		if ( ! $post_type_object ) {
1733
			return false;
1734
		}
1735
1736
		switch ( $context ) {
1737
			case 'edit':
1738
				return current_user_can( $post_type_object->cap->edit_posts );
1739
			case 'display':
1740
				return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts );
1741
			default:
1742
				return false;
1743
		}
1744
	}
1745
1746
	function is_post_type_allowed( $post_type ) {
1747
		// if the post type is empty, that's fine, WordPress will default to post