|
@@ 3749-3780 (lines=32) @@
|
| 3746 |
|
* @param int|string|array $page Optional. Page ID, title, slug, path, or array of such. Default empty. |
| 3747 |
|
* @return bool Whether the query is for an existing single page. |
| 3748 |
|
*/ |
| 3749 |
|
public function is_page( $page = '' ) { |
| 3750 |
|
if ( !$this->is_page ) |
| 3751 |
|
return false; |
| 3752 |
|
|
| 3753 |
|
if ( empty( $page ) ) |
| 3754 |
|
return true; |
| 3755 |
|
|
| 3756 |
|
$page_obj = $this->get_queried_object(); |
| 3757 |
|
|
| 3758 |
|
$page = array_map( 'strval', (array) $page ); |
| 3759 |
|
|
| 3760 |
|
if ( in_array( (string) $page_obj->ID, $page ) ) { |
| 3761 |
|
return true; |
| 3762 |
|
} elseif ( in_array( $page_obj->post_title, $page ) ) { |
| 3763 |
|
return true; |
| 3764 |
|
} elseif ( in_array( $page_obj->post_name, $page ) ) { |
| 3765 |
|
return true; |
| 3766 |
|
} else { |
| 3767 |
|
foreach ( $page as $pagepath ) { |
| 3768 |
|
if ( ! strpos( $pagepath, '/' ) ) { |
| 3769 |
|
continue; |
| 3770 |
|
} |
| 3771 |
|
$pagepath_obj = get_page_by_path( $pagepath ); |
| 3772 |
|
|
| 3773 |
|
if ( $pagepath_obj && ( $pagepath_obj->ID == $page_obj->ID ) ) { |
| 3774 |
|
return true; |
| 3775 |
|
} |
| 3776 |
|
} |
| 3777 |
|
} |
| 3778 |
|
|
| 3779 |
|
return false; |
| 3780 |
|
} |
| 3781 |
|
|
| 3782 |
|
/** |
| 3783 |
|
* Is the query for paged result and not for the first page? |
|
@@ 3842-3872 (lines=31) @@
|
| 3839 |
|
* @param int|string|array $post Optional. Post ID, title, slug, path, or array of such. Default empty. |
| 3840 |
|
* @return bool Whether the query is for an existing single post. |
| 3841 |
|
*/ |
| 3842 |
|
public function is_single( $post = '' ) { |
| 3843 |
|
if ( !$this->is_single ) |
| 3844 |
|
return false; |
| 3845 |
|
|
| 3846 |
|
if ( empty($post) ) |
| 3847 |
|
return true; |
| 3848 |
|
|
| 3849 |
|
$post_obj = $this->get_queried_object(); |
| 3850 |
|
|
| 3851 |
|
$post = array_map( 'strval', (array) $post ); |
| 3852 |
|
|
| 3853 |
|
if ( in_array( (string) $post_obj->ID, $post ) ) { |
| 3854 |
|
return true; |
| 3855 |
|
} elseif ( in_array( $post_obj->post_title, $post ) ) { |
| 3856 |
|
return true; |
| 3857 |
|
} elseif ( in_array( $post_obj->post_name, $post ) ) { |
| 3858 |
|
return true; |
| 3859 |
|
} else { |
| 3860 |
|
foreach ( $post as $postpath ) { |
| 3861 |
|
if ( ! strpos( $postpath, '/' ) ) { |
| 3862 |
|
continue; |
| 3863 |
|
} |
| 3864 |
|
$postpath_obj = get_page_by_path( $postpath, OBJECT, $post_obj->post_type ); |
| 3865 |
|
|
| 3866 |
|
if ( $postpath_obj && ( $postpath_obj->ID == $post_obj->ID ) ) { |
| 3867 |
|
return true; |
| 3868 |
|
} |
| 3869 |
|
} |
| 3870 |
|
} |
| 3871 |
|
return false; |
| 3872 |
|
} |
| 3873 |
|
|
| 3874 |
|
/** |
| 3875 |
|
* Is the query for an existing single post of any post type (post, attachment, page, |