Code Duplication    Length = 20-22 lines in 4 locations

src/wp-includes/query.php 4 locations

@@ 4209-4230 (lines=22) @@
4206
	 * @param mixed $attachment Attachment ID, title, slug, or array of such.
4207
	 * @return bool
4208
	 */
4209
	public function is_attachment( $attachment = '' ) {
4210
		if ( ! $this->is_attachment ) {
4211
			return false;
4212
		}
4213
4214
		if ( empty( $attachment ) ) {
4215
			return true;
4216
		}
4217
4218
		$attachment = array_map( 'strval', (array) $attachment );
4219
4220
		$post_obj = $this->get_queried_object();
4221
4222
		if ( in_array( (string) $post_obj->ID, $attachment ) ) {
4223
			return true;
4224
		} elseif ( in_array( $post_obj->post_title, $attachment ) ) {
4225
			return true;
4226
		} elseif ( in_array( $post_obj->post_name, $attachment ) ) {
4227
			return true;
4228
		}
4229
		return false;
4230
	}
4231
4232
	/**
4233
	 * Is the query for an existing author archive page?
@@ 4243-4262 (lines=20) @@
4240
	 * @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames
4241
	 * @return bool
4242
	 */
4243
	public function is_author( $author = '' ) {
4244
		if ( !$this->is_author )
4245
			return false;
4246
4247
		if ( empty($author) )
4248
			return true;
4249
4250
		$author_obj = $this->get_queried_object();
4251
4252
		$author = array_map( 'strval', (array) $author );
4253
4254
		if ( in_array( (string) $author_obj->ID, $author ) )
4255
			return true;
4256
		elseif ( in_array( $author_obj->nickname, $author ) )
4257
			return true;
4258
		elseif ( in_array( $author_obj->user_nicename, $author ) )
4259
			return true;
4260
4261
		return false;
4262
	}
4263
4264
	/**
4265
	 * Is the query for an existing category archive page?
@@ 4275-4294 (lines=20) @@
4272
	 * @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs.
4273
	 * @return bool
4274
	 */
4275
	public function is_category( $category = '' ) {
4276
		if ( !$this->is_category )
4277
			return false;
4278
4279
		if ( empty($category) )
4280
			return true;
4281
4282
		$cat_obj = $this->get_queried_object();
4283
4284
		$category = array_map( 'strval', (array) $category );
4285
4286
		if ( in_array( (string) $cat_obj->term_id, $category ) )
4287
			return true;
4288
		elseif ( in_array( $cat_obj->name, $category ) )
4289
			return true;
4290
		elseif ( in_array( $cat_obj->slug, $category ) )
4291
			return true;
4292
4293
		return false;
4294
	}
4295
4296
	/**
4297
	 * Is the query for an existing tag archive page?
@@ 4307-4326 (lines=20) @@
4304
	 * @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs.
4305
	 * @return bool
4306
	 */
4307
	public function is_tag( $tag = '' ) {
4308
		if ( ! $this->is_tag )
4309
			return false;
4310
4311
		if ( empty( $tag ) )
4312
			return true;
4313
4314
		$tag_obj = $this->get_queried_object();
4315
4316
		$tag = array_map( 'strval', (array) $tag );
4317
4318
		if ( in_array( (string) $tag_obj->term_id, $tag ) )
4319
			return true;
4320
		elseif ( in_array( $tag_obj->name, $tag ) )
4321
			return true;
4322
		elseif ( in_array( $tag_obj->slug, $tag ) )
4323
			return true;
4324
4325
		return false;
4326
	}
4327
4328
	/**
4329
	 * Is the query for an existing taxonomy archive page?