From a6a03da7f5481cdf4332d6549bb22718793d3486 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 14 Sep 2015 03:19:59 +0000 Subject: [PATCH] Add an argument to `parent_dropdown()`, `$post`, to allow it to be called for an arbitrary post. Fixes #23162. git-svn-id: https://develop.svn.wordpress.org/trunk@34111 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/template.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index 6f0e7bc9ab..ef015390a3 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -767,7 +767,7 @@ function meta_form( $post = null ) { function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { global $wp_locale; $post = get_post(); - + if ( $for_post ) $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); @@ -860,18 +860,20 @@ function page_template_dropdown( $default = '' ) { * Print out option HTML elements for the page parents drop-down. * * @since 1.5.0 + * @since 4.4.0 `$post` argument was added. * * @global wpdb $wpdb * - * @param int $default Optional. The default page ID to be pre-selected. Default 0. - * @param int $parent Optional. The parent page ID. Default 0. - * @param int $level Optional. Page depth level. Default 0. + * @param int $default Optional. The default page ID to be pre-selected. Default 0. + * @param int $parent Optional. The parent page ID. Default 0. + * @param int $level Optional. Page depth level. Default 0. + * @param int|WP_Post $post Post ID or WP_Post object. * * @return null|false Boolean False if page has no children, otherwise print out html elements */ -function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { +function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = null ) { global $wpdb; - $post = get_post(); + $post = get_post( $post ); $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) ); if ( $items ) {