Code Duplication    Length = 3-5 lines in 3 locations

json-endpoints/class.wpcom-json-api-get-post-counts-v1-1-endpoint.php 1 location

@@ 111-113 (lines=3) @@
108
			return $blog_id;
109
		}
110
111
		if ( ! in_array( $post_type, array( 'post', 'revision', 'page', 'any' ) ) && defined( 'IS_WPCOM' ) && IS_WPCOM ) {
112
			$this->load_theme_functions();
113
		}
114
115
		if ( ! post_type_exists( $post_type ) ) {
116
			return new WP_Error( 'unknown_post_type', __( 'Unknown post type requested.', 'jetpack' ), 404 );

json-endpoints/class.wpcom-json-api-list-posts-v1-1-endpoint.php 1 location

@@ 90-94 (lines=5) @@
87
			return new WP_Error( 'invalid_number', 'The NUMBER parameter must be less than or equal to 100.', 400 );
88
		}
89
90
		if ( isset( $args['type'] ) &&
91
			   ! in_array( $args['type'], array( 'post', 'revision', 'page', 'any' ) ) &&
92
			   defined( 'IS_WPCOM' ) && IS_WPCOM ) {
93
			$this->load_theme_functions();
94
		}
95
96
		if ( isset( $args['type'] ) && ! $site->is_post_type_allowed( $args['type'] ) ) {
97
			return new WP_Error( 'unknown_post_type', 'Unknown post type', 404 );

json-endpoints/class.wpcom-json-api-list-posts-v1-2-endpoint.php 1 location

@@ 82-84 (lines=3) @@
79
80
		if ( isset( $args['type'] ) ) {
81
			// load all types on WPCOM, unless only built-in ones are requested
82
			if ( defined( 'IS_WPCOM' ) && IS_WPCOM && ! in_array( $args['type'], array( 'post', 'revision', 'page' ) ) ) {
83
				$this->load_theme_functions();
84
			}
85
86
			if ( ! $site->is_post_type_allowed( $args['type'] ) ) {
87
				return new WP_Error( 'unknown_post_type', 'Unknown post type', 404 );