Make WordPress Core

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#25879 closed enhancement (fixed)

Add filter to page_template_dropdown()

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

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 10 years ago.
Adds 'page_template_dropdown' filter
25879-2.patch (526 bytes) - added by meloniq 10 years ago.
Adds 'page_template_dropdown' filter (without selected() and docs changes)
25879-3.patch (760 bytes) - added by meloniq 10 years ago.
Renamed filter to 'page_template_dropdown_items', added inline filter doc
25879.diff (865 bytes) - added by iamfriendly 9 years ago.
Refreshed the patch

Download all attachments as: .zip

Change History (17)

@meloniq
10 years ago

Adds 'page_template_dropdown' filter

#1 @meloniq
10 years ago

  • Cc meloniq@… added

#2 @SergeyBiryukov
10 years ago

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

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

#3 @SergeyBiryukov
10 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
10 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
10 years ago

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

#5 @SergeyBiryukov
10 years ago

  • Milestone changed from Awaiting Review to 3.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 10 years ago by SergeyBiryukov (previous) (diff)

@meloniq
10 years ago

Renamed filter to 'page_template_dropdown_items', added inline filter doc

#7 @emzo
10 years ago

  • Cc wordpress@… added

#8 @nacin
10 years ago

  • Keywords 3.9-early added
  • Milestone changed from 3.8 to Future Release

#9 @nacin
10 years ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added

#10 @chriscct7
9 years ago

  • Keywords needs-refresh added; 3.9-early removed

@iamfriendly
9 years ago

Refreshed the patch

#11 @iamfriendly
9 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
9 years ago

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

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
9 years ago

  • Milestone changed from Future Release to 4.4
Note: See TracTickets for help on using tickets.