WordPress.org

Make WordPress Core

Opened 20 months ago

Last modified 17 months ago

#25879 new enhancement

Add filter to page_template_dropdown()

Reported by: meloniq Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.8
Component: Posts, Post Types Keywords: has-patch 3.9-early
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 (3)

25879.patch (1.2 KB) - added by meloniq 20 months ago.
Adds 'page_template_dropdown' filter
25879-2.patch (526 bytes) - added by meloniq 20 months ago.
Adds 'page_template_dropdown' filter (without selected() and docs changes)
25879-3.patch (760 bytes) - added by meloniq 20 months ago.
Renamed filter to 'page_template_dropdown_items', added inline filter doc

Download all attachments as: .zip

Change History (12)

@meloniq20 months ago

Adds 'page_template_dropdown' filter

comment:1 @meloniq20 months ago

  • Cc meloniq@… added

comment:2 @SergeyBiryukov20 months ago

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

Last edited 20 months ago by SergeyBiryukov (previous) (diff)

comment:3 @SergeyBiryukov20 months 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.

comment:4 @meloniq20 months 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.

@meloniq20 months ago

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

comment:5 @SergeyBiryukov20 months 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 20 months ago by SergeyBiryukov (previous) (diff)

@meloniq20 months ago

Renamed filter to 'page_template_dropdown_items', added inline filter doc

comment:7 @emzo20 months ago

  • Cc wordpress@… added

comment:8 @nacin19 months ago

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

comment:9 @nacin17 months ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added
Note: See TracTickets for help on using tickets.