WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 2 years ago

Last modified 2 years ago

#18480 closed enhancement (wontfix)

get_sidebar should be able to accept an array of names as parameter.

Reported by: gxxaxx Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: Template Keywords: has-patch
Focuses: Cc:

Description

get_sidebar uses load_template to do the work of template loading.
load_template will accept an array of template names for loading.
load_template will then load the first existing template from that array.

Seems like get_sidebar should also accept an array of names that can be searched in declining order.

This would allow a theme to specify a first choice, second choice, etc. for the sidebar.

Attachments (2)

general-template.php (77.0 KB) - added by gxxaxx 4 years ago.
Patch to general-template.php modify get_sidebar to accept array as parameter
general-template.patch (1.5 KB) - added by gxxaxx 4 years ago.
proper patch version of the file.

Download all attachments as: .zip

Change History (8)

@gxxaxx4 years ago

Patch to general-template.php modify get_sidebar to accept array as parameter

comment:1 @gxxaxx4 years ago

  • Keywords has-patch get_sidebar theme added

comment:2 @scribu4 years ago

  • Keywords 2nd-opinion added; get_sidebar theme removed

The fact that load_template() accepts an array is not a good reason for changing get_sidebar().

Related: #18331

PS: http://core.trac.wordpress.org/wiki#HowtoSubmitPatches

comment:3 @gxxaxx4 years ago

I totally agree that just because load_template() accepts an array is not sufficient justification.

In a theme I am developing I ran ran into a situation where I needed the functionality.

I'm definitely not trolling the codex looking for things to change. This came about as one possible answer for a theme situation.

But, I see that other -- wider sweeping -- changes are afoot in #18331. Thanks for the info.

PS: I was using http://funcdoc.wordpress.com/2008/01/21/how-to-patch-the-wordpress-core/
I appreciate your more up-to-date link.

@gxxaxx4 years ago

proper patch version of the file.

comment:4 @c3mdigital2 years ago

  • Keywords close added; has-patch 2nd-opinion removed
  • Resolution set to wontfix
  • Status changed from new to closed

If we allow this it will be abused by theme developers. Because load_template accepts an array is not a valid argument for changing get_sidebar.

comment:5 @ocean902 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted

get_header and get_footer doesn't accept an array either.

comment:6 @SergeyBiryukov2 years ago

  • Keywords has-patch added
Note: See TracTickets for help on using tickets.