WordPress.org

Make WordPress Core

#23151 closed enhancement (duplicate)

get_attachment_template() doesn't follow the pattern of its get_{type}_template() siblings

Reported by: rulatir Owned by:
Milestone: Priority: normal
Severity: minor Version: 2.0
Component: Template Keywords: has-patch
Focuses: Cc:

Description

The get_attachment_template() function in template.php is implemented differently from most other get_{type}_template() functions.

Other functions build a list of candidates and pass it to get_query_template(), but get_attachment_template() checks the candidates by itself as it goes, and only calls get_query_template('archive') for the basic case.

I cannot see a reason for this, so I am tentatively filing this as a code quality issue.

(N.b. I am refactoring these functions as part of implementing #23142. In most of them the generation of the candidates list can be trivially factored out with demonstrable correctness, but get_attachment_template() is a harder case due to this inconsistency).

Attachments (1)

23151.patch (976 bytes) - added by SergeyBiryukov 18 months ago.

Download all attachments as: .zip

Change History (6)

comment:1 SergeyBiryukov18 months ago

  • Version changed from 3.5 to 2.0

Introduced as get_subpost_template() in [2958], renamed to get_attachment_template() in [3092].

SergeyBiryukov18 months ago

comment:2 follow-ups: SergeyBiryukov18 months ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.6
  • Type changed from defect (bug) to enhancement

comment:3 in reply to: ↑ 2 rulatir18 months ago

[nevermind; this comment made an observation that I later found to be incorrect]

Version 1, edited 18 months ago by rulatir (previous) (next) (diff)

comment:4 in reply to: ↑ 2 rulatir18 months ago

Replying to SergeyBiryukov:

Btw. that was the fastest anyone has ever implemented my enhancement request :)

comment:5 SergeyBiryukov18 months ago

  • Milestone 3.6 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Turned out to be a duplicate of #15337.

Note: See TracTickets for help on using tickets.