Code Duplication    Length = 15-15 lines in 2 locations

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

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

class.json-api-endpoints.php 1 location

@@ 1710-1724 (lines=15) @@
1707
	 * @param string $context                'display' or 'edit'
1708
	 * @return bool
1709
	 */
1710
	function current_user_can_access_post_type( $post_type, $context = 'display' ) {
1711
		$post_type_object = get_post_type_object( $post_type );
1712
		if ( ! $post_type_object ) {
1713
			return false;
1714
		}
1715
1716
		switch ( $context ) {
1717
			case 'edit':
1718
				return current_user_can( $post_type_object->cap->edit_posts );
1719
			case 'display':
1720
				return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts );
1721
			default:
1722
				return false;
1723
		}
1724
	}
1725
1726
	function is_post_type_allowed( $post_type ) {
1727
		// if the post type is empty, that's fine, WordPress will default to post