Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#33625 closed feature request (fixed)

Add Edit link to page template meta box

Reported by: sgrant's profile sgrant Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.4
Component: Editor Keywords: has-patch
Focuses: Cc:

Description

This patch adds an edit link beside the Template text on the page editor, similar to the Status/Visibility links. This feature was mentioned as a possibility by @matt in a recent WordCamp Q&A session. I tested this on a number of themes locally, but would love some feedback. Thanks!

Attachments (5)

edit_template_link_meta.diff (1.1 KB) - added by sgrant 9 years ago.
Adds an Edit link for templates in the page editor
template_filter.diff (781 bytes) - added by sgrant 9 years ago.
Add a hook after Template on the page editor
template_filter_docs.diff (1.1 KB) - added by sgrant 9 years ago.
Add docstring
template_action.diff (979 bytes) - added by sgrant 9 years ago.
Action instead of filter
33625.diff (756 bytes) - added by DrewAPicture 9 years ago.
+ $post

Download all attachments as: .zip

Change History (19)

@sgrant
9 years ago

Adds an Edit link for templates in the page editor

#1 @SergeyBiryukov
9 years ago

  • Milestone changed from Awaiting Review to 4.4

#2 @MikeHansenMe
9 years ago

  • Keywords has-patch added

#3 @helen
9 years ago

As much as I am against removing the file editor, I also don't think it's something that we should encourage using past a certain point. Adding a link here in a frequent-use screen by default would IMO imply that this is a suggested action, not just a possible one.

#4 @sgrant
9 years ago

@helen I definitely see your point. I was hoping to tackle this with a plugin, but there's no hook here. What do you think about adding a filter into the meta box instead?

#5 @helen
9 years ago

@sgrant What would a general purpose hook here look like and what else could it be used for? Not against adding one, but I am wary of things that might only serve one real purpose. As a hacky way to do this, you can use the gettext filter to "translate" Template into another string (untested though).

@sgrant
9 years ago

Add a hook after Template on the page editor

#6 @sgrant
9 years ago

@helen Good and fair question! I guess the only use case I'd thought of immediately was adding the edit link. As precedent, preview_post_link is filtered earlier in meta-boxes.php, and is used in some cases to "repair" a bad preview URL. Although this is different, I suppose general use-cases here might be adding a link to the template file or adding a link to reset to the default template. Do you think this filter might be too speculative?

#7 @wonderboymusic
9 years ago

  • Keywords needs-docs added

Filters need docs

@sgrant
9 years ago

Add docstring

#8 @sgrant
9 years ago

Updated the patch--thanks for taking a look!

#9 @SergeyBiryukov
9 years ago

This should probably be an action instead of a filter.

@sgrant
9 years ago

Action instead of filter

#10 @sgrant
9 years ago

Action does seem cleaner, patch attached. Thanks!

#11 @wonderboymusic
9 years ago

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

In 34340:

In page_attributes_meta_box(), add an action, 'page_attributes_meta_box_template' to allow callbacks to be performed and HTML to be inserted after the title of the Template section.

Props sgrant.
Fixes #33625.

#12 @DrewAPicture
9 years ago

In 34349:

Docs: Use standardized vernacular in the hook doc summary for the page_attributes_meta_box_template filter, introduced in [34340].

See #33625.

@DrewAPicture
9 years ago

+ $post

#13 @DrewAPicture
9 years ago

  • Keywords needs-docs removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Seems like it might be good to also pass the current post here. This is done in 33625.diff.

#14 @SergeyBiryukov
9 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 34350:

Pass the current post object to 'page_attributes_meta_box_template' action added in [34340].

Props DrewAPicture.
Fixes #33625.

Note: See TracTickets for help on using tickets.