|
@@ 4509-4540 (lines=32) @@
|
| 4506 |
|
* @param int|string|array $page Optional. Page ID, title, slug, path, or array of such. Default empty. |
| 4507 |
|
* @return bool Whether the query is for an existing single page. |
| 4508 |
|
*/ |
| 4509 |
|
public function is_page( $page = '' ) { |
| 4510 |
|
if ( !$this->is_page ) |
| 4511 |
|
return false; |
| 4512 |
|
|
| 4513 |
|
if ( empty( $page ) ) |
| 4514 |
|
return true; |
| 4515 |
|
|
| 4516 |
|
$page_obj = $this->get_queried_object(); |
| 4517 |
|
|
| 4518 |
|
$page = array_map( 'strval', (array) $page ); |
| 4519 |
|
|
| 4520 |
|
if ( in_array( (string) $page_obj->ID, $page ) ) { |
| 4521 |
|
return true; |
| 4522 |
|
} elseif ( in_array( $page_obj->post_title, $page ) ) { |
| 4523 |
|
return true; |
| 4524 |
|
} elseif ( in_array( $page_obj->post_name, $page ) ) { |
| 4525 |
|
return true; |
| 4526 |
|
} else { |
| 4527 |
|
foreach ( $page as $pagepath ) { |
| 4528 |
|
if ( ! strpos( $pagepath, '/' ) ) { |
| 4529 |
|
continue; |
| 4530 |
|
} |
| 4531 |
|
$pagepath_obj = get_page_by_path( $pagepath ); |
| 4532 |
|
|
| 4533 |
|
if ( $pagepath_obj && ( $pagepath_obj->ID == $page_obj->ID ) ) { |
| 4534 |
|
return true; |
| 4535 |
|
} |
| 4536 |
|
} |
| 4537 |
|
} |
| 4538 |
|
|
| 4539 |
|
return false; |
| 4540 |
|
} |
| 4541 |
|
|
| 4542 |
|
/** |
| 4543 |
|
* Is the query for paged result and not for the first page? |
|
@@ 4602-4632 (lines=31) @@
|
| 4599 |
|
* @param int|string|array $post Optional. Post ID, title, slug, path, or array of such. Default empty. |
| 4600 |
|
* @return bool Whether the query is for an existing single post. |
| 4601 |
|
*/ |
| 4602 |
|
public function is_single( $post = '' ) { |
| 4603 |
|
if ( !$this->is_single ) |
| 4604 |
|
return false; |
| 4605 |
|
|
| 4606 |
|
if ( empty($post) ) |
| 4607 |
|
return true; |
| 4608 |
|
|
| 4609 |
|
$post_obj = $this->get_queried_object(); |
| 4610 |
|
|
| 4611 |
|
$post = array_map( 'strval', (array) $post ); |
| 4612 |
|
|
| 4613 |
|
if ( in_array( (string) $post_obj->ID, $post ) ) { |
| 4614 |
|
return true; |
| 4615 |
|
} elseif ( in_array( $post_obj->post_title, $post ) ) { |
| 4616 |
|
return true; |
| 4617 |
|
} elseif ( in_array( $post_obj->post_name, $post ) ) { |
| 4618 |
|
return true; |
| 4619 |
|
} else { |
| 4620 |
|
foreach ( $post as $postpath ) { |
| 4621 |
|
if ( ! strpos( $postpath, '/' ) ) { |
| 4622 |
|
continue; |
| 4623 |
|
} |
| 4624 |
|
$postpath_obj = get_page_by_path( $postpath, OBJECT, $post_obj->post_type ); |
| 4625 |
|
|
| 4626 |
|
if ( $postpath_obj && ( $postpath_obj->ID == $post_obj->ID ) ) { |
| 4627 |
|
return true; |
| 4628 |
|
} |
| 4629 |
|
} |
| 4630 |
|
} |
| 4631 |
|
return false; |
| 4632 |
|
} |
| 4633 |
|
|
| 4634 |
|
/** |
| 4635 |
|
* Is the query for an existing single post of any post type (post, attachment, page, ... )? |