Code Duplication    Length = 15-15 lines in 2 locations

class.json-api-endpoints.php 1 location

@@ 1559-1573 (lines=15) @@
1556
	* @param string $context                'display' or 'edit'
1557
	* @return bool
1558
	*/
1559
	function current_user_can_access_post_type( $post_type, $context='display' ) {
1560
		$post_type_object = get_post_type_object( $post_type );
1561
		if ( ! $post_type_object ) {
1562
			return false;
1563
		}
1564
1565
		switch( $context ) {
1566
			case 'edit':
1567
				return current_user_can( $post_type_object->cap->edit_posts );
1568
			case 'display':
1569
				return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts );
1570
			default:
1571
				return false;
1572
		}
1573
	}
1574
1575
	function is_post_type_allowed( $post_type ) {
1576
		// if the post type is empty, that's fine, WordPress will default to post

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

@@ 159-173 (lines=15) @@
156
		return $post;
157
	}
158
159
	public function current_user_can_access_post_type( $post_type, $context ) {
160
		$post_type_object = $this->get_post_type_object( $post_type );
161
		if ( ! $post_type_object ) {
162
			return false;
163
		}
164
165
		switch( $context ) {
166
			case 'edit':
167
				return current_user_can( $post_type_object->cap->edit_posts );
168
			case 'display':
169
				return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts );
170
			default:
171
				return false;
172
		}
173
	}
174
175
	protected function get_post_type_object( $post_type ) {
176
		return get_post_type_object( $post_type );