Make WordPress Core

Opened 14 years ago

Closed 11 years ago

Last modified 11 years ago

#23162 closed enhancement (fixed)

Allow to call parent_dropdown() for an arbitrary post

Reported by: charliespider Owned by: wonderboymusic
Priority: normal Milestone: 4.4
Component: Posts, Post Types Version: 1.5
Severity: normal Keywords: has-patch
Cc: Focuses: administration

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.

Attachments (1)

23162.diff (1.7 KB ) - added by wonderboymusic 11 years ago.

Download all attachments as: .zip

Change History (8)

#1 @charliespider
14 years ago

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

#2 @charliespider
14 years ago

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

#3 @SergeyBiryukov
14 years ago

  • Component Warnings/NoticesAdministration
  • Summary parent_dropdown() breaks because of recent changes. It should except WP Post object as additional argumentAllow 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.

#4 @nacin
13 years ago

  • Component AdministrationPosts, Post Types
  • Focuses administration added

#5 @wonderboymusic
11 years ago

  • Keywords has-patch added
  • Milestone Awaiting Review4.4
  • Version1.5

#6 @wonderboymusic
11 years ago

  • Owner set to wonderboymusic
  • Resolutionfixed
  • Status newclosed

In 34111:

Add an argument to parent_dropdown(), $post, to allow it to be called for an arbitrary post.

Fixes #23162.

#7 @wonderboymusic
11 years ago

In 34113:

Add sanity checks in map_meta_cap(), return 'do_not_allow' when posts don't exist.

Adds unit test.

Props ocean90, nerrad, filosofo.
Fixes #23162.

Note: See TracTickets for help on using tickets.