Opened 9 years ago
Closed 9 years ago
#38136 closed defect (bug) (fixed)
The docs for get_pages() - the post_status argument can also be an array
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.7 | Priority: | normal |
| Severity: | normal | Version: | 4.7 |
| Component: | General | Keywords: | has-patch |
| Focuses: | docs | Cc: |
Description
The documentation for get_pages() says:
* @type string $post_status A comma-separated list of post statuses types to include.
but the post_status argument can also be an array according to this part of get_pages():
// Make sure we have a valid post status.
if ( ! is_array( $post_status ) ) {
$post_status = explode( ',', $post_status );
}
if ( array_diff( $post_status, get_post_stati() ) ) {
return false;
}
... cut ...
if ( 1 == count( $post_status ) ) {
$where_post_type = $wpdb->prepare( "post_type = %s AND post_status = %s", $r['post_type'], reset( $post_status ) );
} else {
$post_status = implode( "', '", $post_status );
$where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN ('$post_status')", $r['post_type'] );
}
ps: I also adjusted the defaults array of get_pages() for better readability.
Attachments (2)
Change History (8)
#2
@
9 years ago
- Milestone changed from Awaiting Review to 4.7
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
#3
@
9 years ago
@SergeyBiryukov
Yes it's the same with wp_list_pages().
I guess I could address that as well.
Not sure if I should use the same ticket, create a new one or if there's a special ticket for docs improvements in 4.7?
@
9 years ago
Adds fix for wp_list_pages() and fixes some spacing/tab inconsistencies in the default argument fixes.
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
9 years ago
#5
@
9 years ago
@desrosj: 38136.diff has a couple of issues:
- It removes
$post_typeentry forwp_list_pages()and creates a duplicate$post_statusentry. - No need for additional tab before
function(or in the preceding docblock).
Will handle on commit :)
Note: See
TracTickets for help on using
tickets.
wp_list_pages()docs have the same issue and should also be corrected.