WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 14 months ago

#23162 new enhancement

Allow to call parent_dropdown() for an arbitrary post

Reported by: charliespider Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: administration Cc:

Description

parent_dropdown() can no longer be used outside of the loop, such as within the wp-admin, because an E_NOTICE will be emitted in template.php:683 since $post is null.

A simple fix is to change the function argument declarations from

function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {

to:

function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = array() ) {

and then also change:

$post = get_post();

to

	if ( empty( $post )) {
		$post = get_post();
	}	

which would allow a WP post object to be passed into the function.

Sorry I am unable to provide an SVN patch.

Change History (4)

comment:1 @charliespider2 years ago

  • Summary changed from parent_dropdown() should except WP Post object as additional argument to parent_dropdown() breaks becuause of recent changes. It should except WP Post object as additional argument

comment:2 @charliespider2 years ago

  • Summary changed from parent_dropdown() breaks becuause of recent changes. It should except WP Post object as additional argument to parent_dropdown() breaks because of recent changes. It should except WP Post object as additional argument

comment:3 @SergeyBiryukov2 years ago

  • Component changed from Warnings/Notices to Administration
  • Summary changed from parent_dropdown() breaks because of recent changes. It should except WP Post object as additional argument to Allow to call parent_dropdown() for an arbitrary post

an E_NOTICE will be emitted in template.php:683 since $post is null.

#23026 would fix the notice introduced in [21735].

Renaming the ticket to better reflect its purpose.

comment:4 @nacin14 months ago

  • Component changed from Administration to Posts, Post Types
  • Focuses administration added
Note: See TracTickets for help on using tickets.