Code Duplication    Length = 31-32 lines in 2 locations

wp-includes/query.php 2 locations

@@ 4562-4593 (lines=32) @@
4559
	 * @param int|string|array $page Optional. Page ID, title, slug, path, or array of such. Default empty.
4560
	 * @return bool Whether the query is for an existing single page.
4561
	 */
4562
	public function is_page( $page = '' ) {
4563
		if ( !$this->is_page )
4564
			return false;
4565
4566
		if ( empty( $page ) )
4567
			return true;
4568
4569
		$page_obj = $this->get_queried_object();
4570
4571
		$page = array_map( 'strval', (array) $page );
4572
4573
		if ( in_array( (string) $page_obj->ID, $page ) ) {
4574
			return true;
4575
		} elseif ( in_array( $page_obj->post_title, $page ) ) {
4576
			return true;
4577
		} elseif ( in_array( $page_obj->post_name, $page ) ) {
4578
			return true;
4579
		} else {
4580
			foreach ( $page as $pagepath ) {
4581
				if ( ! strpos( $pagepath, '/' ) ) {
4582
					continue;
4583
				}
4584
				$pagepath_obj = get_page_by_path( $pagepath );
4585
4586
				if ( $pagepath_obj && ( $pagepath_obj->ID == $page_obj->ID ) ) {
4587
					return true;
4588
				}
4589
			}
4590
		}
4591
4592
		return false;
4593
	}
4594
4595
	/**
4596
	 * Is the query for paged result and not for the first page?
@@ 4655-4685 (lines=31) @@
4652
	 * @param int|string|array $post Optional. Post ID, title, slug, path, or array of such. Default empty.
4653
	 * @return bool Whether the query is for an existing single post.
4654
	 */
4655
	public function is_single( $post = '' ) {
4656
		if ( !$this->is_single )
4657
			return false;
4658
4659
		if ( empty($post) )
4660
			return true;
4661
4662
		$post_obj = $this->get_queried_object();
4663
4664
		$post = array_map( 'strval', (array) $post );
4665
4666
		if ( in_array( (string) $post_obj->ID, $post ) ) {
4667
			return true;
4668
		} elseif ( in_array( $post_obj->post_title, $post ) ) {
4669
			return true;
4670
		} elseif ( in_array( $post_obj->post_name, $post ) ) {
4671
			return true;
4672
		} else {
4673
			foreach ( $post as $postpath ) {
4674
				if ( ! strpos( $postpath, '/' ) ) {
4675
					continue;
4676
				}
4677
				$postpath_obj = get_page_by_path( $postpath, OBJECT, $post_obj->post_type );
4678
4679
				if ( $postpath_obj && ( $postpath_obj->ID == $post_obj->ID ) ) {
4680
					return true;
4681
				}
4682
			}
4683
		}
4684
		return false;
4685
	}
4686
4687
	/**
4688
	 * Is the query for an existing single post of any post type (post, attachment, page, ... )?