Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#30082 closed enhancement (fixed)

Add "class" argument to "wp_dropdown_pages()"

Reported by: ramiy's profile ramiy Owned by: boonebgorges's profile boonebgorges
Milestone: 4.3 Priority: normal
Severity: normal Version: 2.1
Component: Posts, Post Types Keywords: has-patch
Focuses: administration, template Cc:


I've created a plugin that is using wp_dropdown_pages() function to show a <select> box with all the site pages.

The next step was to create a sidebar widget with a few <select> box's and a page dropdown. Now, in order to give my widget a smote WordPress style i use class="widefat". But wp_dropdown_pages() don't accept "class" argument, so my widget have a few full-wide select boxes and one regular select box.

I would like to be able to add classes to wp_dropdown_pages(). By the way, wp_dropdown_categories() and wp_dropdown_users() both accept "class" argument.

This is a simple fix. I'm attaching a patch.

Attachments (2)

add-class-argument-to-wp_dropdown_pages.patch (890 bytes) - added by ramiy 9 years ago.
30082.diff (1.2 KB) - added by voldemortensen 9 years ago.

Download all attachments as: .zip

Change History (9)

9 years ago

#1 @voldemortensen
9 years ago

  • Keywords has-patch added

Updated patch to coding standards and to make code more readable.

#2 @jeremyfelt
9 years ago

  • Type changed from defect (bug) to enhancement

#3 @helen
9 years ago

  • Version changed from trunk to 2.1

#4 @leec87
9 years ago

Along these lines, is it possible to also add an anchor argument in the array, to append an anchor tag to the end of the values?

#5 @leec87
9 years ago

What's holding this up being included in the next update?

I've just had to re-edit my existing code (I've already applied this patch once).

#6 @boonebgorges
9 years ago

  • Milestone changed from Awaiting Review to 4.3

Change looks fine, though I'm going to modify it slightly so that an empty string for class doesn't generate an empty "class" attribute - this might mess with people using the 'wp_dropdown_pages' filter.

#7 @boonebgorges
9 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 32727:

Introduce class argument to wp_dropdown_pages().

This new argument allows devs to specify the 'class' attribute of the select

Props ramiy, voldemortensen.
Fixes #30082.

Note: See TracTickets for help on using tickets.