Ticket #42335: 42335.diff
File 42335.diff, 9.4 KB (added by , 7 years ago) |
---|
-
src/wp-includes/class-wp-query.php
3427 3427 3428 3428 $post_obj = $this->get_queried_object(); 3429 3429 3430 if ( in_array( (string) $post_obj->ID, $attachment ) ) { 3431 return true; 3432 } elseif ( in_array( $post_obj->post_title, $attachment ) ) { 3433 return true; 3434 } elseif ( in_array( $post_obj->post_name, $attachment ) ) { 3435 return true; 3430 if ( $post_obj ) { 3431 if ( in_array( (string) $post_obj->ID, $attachment ) ) { 3432 return true; 3433 } elseif ( in_array( $post_obj->post_title, $attachment ) ) { 3434 return true; 3435 } elseif ( in_array( $post_obj->post_name, $attachment ) ) { 3436 return true; 3437 } 3436 3438 } 3439 3437 3440 return false; 3438 3441 } 3439 3442 … … 3457 3460 3458 3461 $author_obj = $this->get_queried_object(); 3459 3462 3460 $author = array_map( 'strval', (array) $author ); 3463 if ( $author_obj ) { 3464 $author = array_map( 'strval', (array) $author ); 3461 3465 3462 if ( in_array( (string) $author_obj->ID, $author ) ) 3463 return true; 3464 elseif ( in_array( $author_obj->nickname, $author ) ) 3465 return true; 3466 elseif ( in_array( $author_obj->user_nicename, $author ) ) 3467 return true; 3466 if ( in_array( (string) $author_obj->ID, $author ) ) { 3467 return true; 3468 } elseif ( in_array( $author_obj->nickname, $author ) ) { 3469 return true; 3470 } elseif ( in_array( $author_obj->user_nicename, $author ) ) { 3471 return true; 3472 } 3473 } 3468 3474 3469 3475 return false; 3470 3476 } … … 3489 3495 3490 3496 $cat_obj = $this->get_queried_object(); 3491 3497 3492 $category = array_map( 'strval', (array) $category ); 3498 if ( $cat_obj ) { 3499 $category = array_map( 'strval', (array) $category ); 3493 3500 3494 if ( in_array( (string) $cat_obj->term_id, $category ) ) 3495 return true; 3496 elseif ( in_array( $cat_obj->name, $category ) ) 3497 return true; 3498 elseif ( in_array( $cat_obj->slug, $category ) ) 3499 return true; 3501 if ( in_array( (string) $cat_obj->term_id, $category ) ) { 3502 return true; 3503 } elseif ( in_array( $cat_obj->name, $category ) ) { 3504 return true; 3505 } elseif ( in_array( $cat_obj->slug, $category ) ) { 3506 return true; 3507 } 3508 } 3500 3509 3501 3510 return false; 3502 3511 } … … 3521 3530 3522 3531 $tag_obj = $this->get_queried_object(); 3523 3532 3524 $tag = array_map( 'strval', (array) $tag ); 3533 if ( $tag_obj ) { 3534 $tag = array_map( 'strval', (array) $tag ); 3525 3535 3526 if ( in_array( (string) $tag_obj->term_id, $tag ) ) 3527 return true; 3528 elseif ( in_array( $tag_obj->name, $tag ) ) 3529 return true; 3530 elseif ( in_array( $tag_obj->slug, $tag ) ) 3531 return true; 3536 if ( in_array( (string) $tag_obj->term_id, $tag ) ) { 3537 return true; 3538 } elseif ( in_array( $tag_obj->name, $tag ) ) { 3539 return true; 3540 } elseif ( in_array( $tag_obj->slug, $tag ) ) { 3541 return true; 3542 } 3543 } 3532 3544 3533 3545 return false; 3534 3546 } … … 3561 3573 return true; 3562 3574 3563 3575 $queried_object = $this->get_queried_object(); 3564 $tax_array = array_intersect( array_keys( $wp_taxonomies ), (array) $taxonomy );3565 $term_array = (array) $term;3566 3576 3567 // Check that the taxonomy matches.3568 if ( ! ( isset( $queried_object->taxonomy ) && count( $tax_array ) && in_array( $queried_object->taxonomy, $tax_array ) ) )3569 return false;3577 if ( $queried_object ) { 3578 $tax_array = array_intersect( array_keys( $wp_taxonomies ), (array) $taxonomy ); 3579 $term_array = (array) $term; 3570 3580 3571 // Only a Taxonomy provided. 3572 if ( empty( $term ) ) 3573 return true; 3581 // Check that the taxonomy matches. 3582 if ( ! ( isset( $queried_object->taxonomy ) && count( $tax_array ) && in_array( $queried_object->taxonomy, $tax_array ) ) ) { 3583 return false; 3584 } 3574 3585 3575 return isset( $queried_object->term_id ) && 3576 count( array_intersect( 3577 array( $queried_object->term_id, $queried_object->name, $queried_object->slug ), 3578 $term_array 3579 ) ); 3586 // Only a Taxonomy provided. 3587 if ( empty( $term ) ) { 3588 return true; 3589 } 3590 3591 return isset( $queried_object->term_id ) && 3592 count( array_intersect( 3593 array( $queried_object->term_id, $queried_object->name, $queried_object->slug ), 3594 $term_array 3595 ) ); 3596 } 3597 3598 return false; 3580 3599 } 3581 3600 3582 3601 /** … … 3723 3742 3724 3743 $page_obj = $this->get_queried_object(); 3725 3744 3726 $page = array_map( 'strval', (array) $page ); 3745 if ( $page_obj ) { 3746 $page = array_map( 'strval', (array) $page ); 3727 3747 3728 if ( in_array( (string) $page_obj->ID, $page ) ) {3729 return true;3730 } elseif ( in_array( $page_obj->post_title, $page ) ) {3731 return true;3732 } elseif ( in_array( $page_obj->post_name, $page ) ) {3733 return true;3734 } else {3735 foreach ( $page as $pagepath ) {3736 if ( ! strpos( $pagepath, '/' ) ) {3737 continue;3738 }3739 $pagepath_obj = get_page_by_path( $pagepath );3748 if ( in_array( (string) $page_obj->ID, $page ) ) { 3749 return true; 3750 } elseif ( in_array( $page_obj->post_title, $page ) ) { 3751 return true; 3752 } elseif ( in_array( $page_obj->post_name, $page ) ) { 3753 return true; 3754 } else { 3755 foreach ( $page as $pagepath ) { 3756 if ( ! strpos( $pagepath, '/' ) ) { 3757 continue; 3758 } 3759 $pagepath_obj = get_page_by_path( $pagepath ); 3740 3760 3741 if ( $pagepath_obj && ( $pagepath_obj->ID == $page_obj->ID ) ) { 3742 return true; 3761 if ( $pagepath_obj && ( $pagepath_obj->ID == $page_obj->ID ) ) { 3762 return true; 3763 } 3743 3764 } 3744 3765 } 3745 3766 } … … 3816 3837 3817 3838 $post_obj = $this->get_queried_object(); 3818 3839 3819 $post = array_map( 'strval', (array) $post ); 3840 if ( $post_obj ) { 3841 $post = array_map( 'strval', (array) $post ); 3820 3842 3821 if ( in_array( (string) $post_obj->ID, $post ) ) {3822 return true;3823 } elseif ( in_array( $post_obj->post_title, $post ) ) {3824 return true;3825 } elseif ( in_array( $post_obj->post_name, $post ) ) {3826 return true;3827 } else {3828 foreach ( $post as $postpath ) {3829 if ( ! strpos( $postpath, '/' ) ) {3830 continue;3831 }3832 $postpath_obj = get_page_by_path( $postpath, OBJECT, $post_obj->post_type );3843 if ( in_array( (string) $post_obj->ID, $post ) ) { 3844 return true; 3845 } elseif ( in_array( $post_obj->post_title, $post ) ) { 3846 return true; 3847 } elseif ( in_array( $post_obj->post_name, $post ) ) { 3848 return true; 3849 } else { 3850 foreach ( $post as $postpath ) { 3851 if ( ! strpos( $postpath, '/' ) ) { 3852 continue; 3853 } 3854 $postpath_obj = get_page_by_path( $postpath, OBJECT, $post_obj->post_type ); 3833 3855 3834 if ( $postpath_obj && ( $postpath_obj->ID == $post_obj->ID ) ) { 3835 return true; 3856 if ( $postpath_obj && ( $postpath_obj->ID == $post_obj->ID ) ) { 3857 return true; 3858 } 3836 3859 } 3837 3860 } 3838 3861 } 3862 3839 3863 return false; 3840 3864 } 3841 3865 … … 3860 3884 3861 3885 $post_obj = $this->get_queried_object(); 3862 3886 3863 return in_array( $post_obj->post_type, (array) $post_types ); 3887 if ( $post_obj ) { 3888 return in_array( $post_obj->post_type, (array) $post_types ); 3889 } 3890 3891 return false; 3892 3864 3893 } 3865 3894 3866 3895 /** -
tests/qunit/fixtures/wp-api-generated.js
470 470 }, 471 471 "template": { 472 472 "required": false, 473 "enum": [474 ""475 ],476 473 "description": "The theme file to use to display the object.", 477 474 "type": "string" 478 475 }, … … 653 650 }, 654 651 "template": { 655 652 "required": false, 656 "enum": [657 ""658 ],659 653 "description": "The theme file to use to display the object.", 660 654 "type": "string" 661 655 }, … … 1058 1052 }, 1059 1053 "template": { 1060 1054 "required": false, 1061 "enum": [1062 ""1063 ],1064 1055 "description": "The theme file to use to display the object.", 1065 1056 "type": "string" 1066 1057 } … … 1213 1204 }, 1214 1205 "template": { 1215 1206 "required": false, 1216 "enum": [1217 ""1218 ],1219 1207 "description": "The theme file to use to display the object.", 1220 1208 "type": "string" 1221 1209 } … … 1577 1565 }, 1578 1566 "template": { 1579 1567 "required": false, 1580 "enum": [1581 ""1582 ],1583 1568 "description": "The theme file to use to display the object.", 1584 1569 "type": "string" 1585 1570 }, … … 1717 1702 }, 1718 1703 "template": { 1719 1704 "required": false, 1720 "enum": [1721 ""1722 ],1723 1705 "description": "The theme file to use to display the object.", 1724 1706 "type": "string" 1725 1707 },