Code Duplication    Length = 15-15 lines in 2 locations

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

@@ 189-203 (lines=15) @@
186
		return $post;
187
	}
188
189
	public function current_user_can_access_post_type( $post_type, $context ) {
190
		$post_type_object = $this->get_post_type_object( $post_type );
191
		if ( ! $post_type_object ) {
192
			return false;
193
		}
194
195
		switch( $context ) {
196
			case 'edit':
197
				return current_user_can( $post_type_object->cap->edit_posts );
198
			case 'display':
199
				return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts );
200
			default:
201
				return false;
202
		}
203
	}
204
205
	protected function get_post_type_object( $post_type ) {
206
		return get_post_type_object( $post_type );

class.json-api-endpoints.php 1 location

@@ 1686-1700 (lines=15) @@
1683
	* @param string $context                'display' or 'edit'
1684
	* @return bool
1685
	*/
1686
	function current_user_can_access_post_type( $post_type, $context='display' ) {
1687
		$post_type_object = get_post_type_object( $post_type );
1688
		if ( ! $post_type_object ) {
1689
			return false;
1690
		}
1691
1692
		switch( $context ) {
1693
			case 'edit':
1694
				return current_user_can( $post_type_object->cap->edit_posts );
1695
			case 'display':
1696
				return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts );
1697
			default:
1698
				return false;
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