WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#32432 closed enhancement (fixed)

Allow wp_dropdown_languages() to return, instead of output, the markup.

Reported by: leewillis77 Owned by: SergeyBiryukov
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.2
Component: I18N Keywords: has-patch
Focuses: Cc:
PR Number:

Description

This allows the markup created by wp_dropdown_languages() to be re-used by other code without having to resort to output-buffering hacks.

Attachments (5)

32432.diff (1.4 KB) - added by leewillis77 4 years ago.
Proposed patch.
32432.2.diff (2.2 KB) - added by leewillis77 4 years ago.
Revised patch. Introduces get_dropdown_languages(). Makes wp_dropdown_languages() use this to do the heavy lifting.
32432-3.patch (1015 bytes) - added by juliobox 4 years ago.
32432.3.diff (1.5 KB) - added by leewillis77 4 years ago.
32432.4.patch (1.5 KB) - added by juliobox 4 years ago.

Download all attachments as: .zip

Change History (17)

@leewillis77
4 years ago

Proposed patch.

#1 @obenland
4 years ago

We should probably create a get_ function for that, rather than introducing another argument.

#2 @leewillis77
4 years ago

Thanks for the feedback. Any suggestions on how to achieve that without duplicating huge wedges of code or using output_buffering (Or is the use of output buffering acceptable?)

#3 @obenland
4 years ago

You could let wp_dropdown_languages() display whatever the get_ function returns.

#4 @obenland
4 years ago

@ocean90 might want to weigh in here as well.

@leewillis77
4 years ago

Revised patch. Introduces get_dropdown_languages(). Makes wp_dropdown_languages() use this to do the heavy lifting.

#5 @ocean90
4 years ago

  • Keywords has-patch needs-refresh added
  • Version changed from trunk to 4.2

Related: #29362

I'm fine with adding an argument for returning the dropdown,I don't see the need for a get_ function here. We can use the existing $args argument and use echo as the key which is false per default. @leewillis77 do you want to make a new patch for this? For inspiration take a look at wp_dropdown_pages() or wp_dropdown_categories().

@juliobox
4 years ago

#6 @juliobox
4 years ago

Hello,

i just added my patch using a new array entry named "echo".

See you ;)

@leewillis77
4 years ago

#7 follow-up: @leewillis77
4 years ago

Updates the docblock in @juliobox's patch to add the new arg.

Thanks

#8 in reply to: ↑ 7 @juliobox
4 years ago

My bad, thanks

Replying to leewillis77:

Updates the docblock in @juliobox's patch to add the new arg.

Thanks

#9 @SergeyBiryukov
4 years ago

I don't think we need strict comparison in line 960, if ( $args['echo'] ) (like in wp_dropdown_pages()) should be enough.

@juliobox
4 years ago

#11 @SergeyBiryukov
4 years ago

  • Keywords needs-refresh removed
  • Milestone changed from Awaiting Review to 4.3

#12 @SergeyBiryukov
4 years ago

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

In 32510:

Allow wp_dropdown_languages() to return the markup instead of displaying.

props leewillis77, juliobox.
fixes #32432.

Note: See TracTickets for help on using tickets.