Make WordPress Core

Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#25879 closed enhancement (fixed)

Add filter to page_template_dropdown()

Reported by: meloniq Owned by: DrewAPicture
Priority: normal Milestone: 4.4
Component: Posts, Post Types Version: 3.8
Severity: normal Keywords: has-patch
Cc: Focuses: template

Description

page_template_dropdown() is used in 'Page Attributes' metabox to list available page templates. The filter hook will give ability to adjust what's displayed in this box.

Our issue:
We use many custom templates to perform some specific tasks like building frontend dashboards, submit/edit forms, login pages, etc.
As far it works well, but the 'Page Attributes' metabox fulfill with page templates that in most of cases are not intended for any other use, and some administrators get confused seeing full list of available templates while creating a new page.

Attachments (4)

25879.patch (1.2 KB ) - added by meloniq 13 years ago.
Adds 'page_template_dropdown' filter
25879-2.patch (526 bytes ) - added by meloniq 13 years ago.
Adds 'page_template_dropdown' filter (without selected() and docs changes)
25879-3.patch (760 bytes ) - added by meloniq 13 years ago.
Renamed filter to 'page_template_dropdown_items', added inline filter doc
25879.diff (865 bytes ) - added by iamfriendly 11 years ago.
Refreshed the patch

Download all attachments as: .zip

Change History (17)

@meloniq
13 years ago

Adds 'page_template_dropdown' filter

#1 @meloniq
13 years ago

  • Cc meloniq@… added

#2 @SergeyBiryukov
13 years ago

Appears to be a duplicate of #13265 and #21891.

Last edited 13 years ago by SergeyBiryukov (previous) (diff)

#3 @SergeyBiryukov
13 years ago

The move to selected() looks good though, touch_time() and parent_dropdown() would benefit from that as well. I'd suggest creating a new ticket for that.

#4 @meloniq
13 years ago

Created separate ticket for the selected() use, and documenting this functions, see: #25889

Referenced tickets touches similar item (filtering page templates) but on lower level, using that filter to change items in dropdown could cause unexpected issues, as it will remove templates from all places, and not only from mentioned dropdown.

@meloniq
13 years ago

Adds 'page_template_dropdown' filter (without selected() and docs changes)

#5 @SergeyBiryukov
13 years ago

  • Milestone Awaiting Review3.8

My only concern with 'page_template_dropdown' filter name is that filters of the same name as the function are generally used to filter the actual result of that function. I'd suggest 'page_template_dropdown_items'.

Last edited 13 years ago by SergeyBiryukov (previous) (diff)

@meloniq
13 years ago

Renamed filter to 'page_template_dropdown_items', added inline filter doc

#7 @emzo
13 years ago

  • Cc wordpress@… added

#8 @nacin
13 years ago

  • Keywords 3.9-early added
  • Milestone 3.8Future Release

#9 @nacin
12 years ago

  • Component TemplatePosts, Post Types
  • Focuses template added

#10 @chriscct7
11 years ago

  • Keywords needs-refresh added; 3.9-early removed

@iamfriendly
11 years ago

Refreshed the patch

#11 @iamfriendly
11 years ago

  • Keywords needs-refresh removed

Refreshed the patch as the function has moved locations to template-functions.php and also updated the docs to reflect this would be for 4.4.0

#12 @DrewAPicture
11 years ago

  • Owner set to DrewAPicture
  • Resolutionfixed
  • Status newclosed

In 34995:

Template: Make it possible to both add and remove items from the page templates list using the theme_page_templates filter.

The theme_page_templates hook was originally added in [27297] as page_templates, and later renamed in [27470]. Previously, it was only possible to remove or rename page templates via this hook.

Fixes #13265. Fixes #25879.

#13 @SergeyBiryukov
11 years ago

  • Milestone Future Release4.4
Note: See TracTickets for help on using tickets.