Code Duplication    Length = 20-22 lines in 4 locations

wp-includes/query.php 4 locations

@@ 4262-4283 (lines=22) @@
4259
	 * @param mixed $attachment Attachment ID, title, slug, or array of such.
4260
	 * @return bool
4261
	 */
4262
	public function is_attachment( $attachment = '' ) {
4263
		if ( ! $this->is_attachment ) {
4264
			return false;
4265
		}
4266
4267
		if ( empty( $attachment ) ) {
4268
			return true;
4269
		}
4270
4271
		$attachment = array_map( 'strval', (array) $attachment );
4272
4273
		$post_obj = $this->get_queried_object();
4274
4275
		if ( in_array( (string) $post_obj->ID, $attachment ) ) {
4276
			return true;
4277
		} elseif ( in_array( $post_obj->post_title, $attachment ) ) {
4278
			return true;
4279
		} elseif ( in_array( $post_obj->post_name, $attachment ) ) {
4280
			return true;
4281
		}
4282
		return false;
4283
	}
4284
4285
	/**
4286
	 * Is the query for an existing author archive page?
@@ 4296-4315 (lines=20) @@
4293
	 * @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames
4294
	 * @return bool
4295
	 */
4296
	public function is_author( $author = '' ) {
4297
		if ( !$this->is_author )
4298
			return false;
4299
4300
		if ( empty($author) )
4301
			return true;
4302
4303
		$author_obj = $this->get_queried_object();
4304
4305
		$author = array_map( 'strval', (array) $author );
4306
4307
		if ( in_array( (string) $author_obj->ID, $author ) )
4308
			return true;
4309
		elseif ( in_array( $author_obj->nickname, $author ) )
4310
			return true;
4311
		elseif ( in_array( $author_obj->user_nicename, $author ) )
4312
			return true;
4313
4314
		return false;
4315
	}
4316
4317
	/**
4318
	 * Is the query for an existing category archive page?
@@ 4328-4347 (lines=20) @@
4325
	 * @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs.
4326
	 * @return bool
4327
	 */
4328
	public function is_category( $category = '' ) {
4329
		if ( !$this->is_category )
4330
			return false;
4331
4332
		if ( empty($category) )
4333
			return true;
4334
4335
		$cat_obj = $this->get_queried_object();
4336
4337
		$category = array_map( 'strval', (array) $category );
4338
4339
		if ( in_array( (string) $cat_obj->term_id, $category ) )
4340
			return true;
4341
		elseif ( in_array( $cat_obj->name, $category ) )
4342
			return true;
4343
		elseif ( in_array( $cat_obj->slug, $category ) )
4344
			return true;
4345
4346
		return false;
4347
	}
4348
4349
	/**
4350
	 * Is the query for an existing tag archive page?
@@ 4360-4379 (lines=20) @@
4357
	 * @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs.
4358
	 * @return bool
4359
	 */
4360
	public function is_tag( $tag = '' ) {
4361
		if ( ! $this->is_tag )
4362
			return false;
4363
4364
		if ( empty( $tag ) )
4365
			return true;
4366
4367
		$tag_obj = $this->get_queried_object();
4368
4369
		$tag = array_map( 'strval', (array) $tag );
4370
4371
		if ( in_array( (string) $tag_obj->term_id, $tag ) )
4372
			return true;
4373
		elseif ( in_array( $tag_obj->name, $tag ) )
4374
			return true;
4375
		elseif ( in_array( $tag_obj->slug, $tag ) )
4376
			return true;
4377
4378
		return false;
4379
	}
4380
4381
	/**
4382
	 * Is the query for an existing custom taxonomy archive page?