WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 14 months ago

#12721 new enhancement

Allow post_type's _edit_link to be outside of the admin.

Reported by: prettyboymp Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch tested
Focuses: Cc:

Description

get_edit_post_link runs the post_type's _edit_link through admin_url() always forcing the edit page to be within wp-admin. There are times where this isn't desired. I'm submitting a patch to check that the url of the _edit_link doesn't begin with http(s?): before running it through admin_url

Attachments (1)

12721.diff (786 bytes) - added by prettyboymp 5 years ago.

Download all attachments as: .zip

Change History (12)

@prettyboymp5 years ago

comment:1 @chrisscott5 years ago

  • Keywords tested added

Confirmed this is working against r13818. Edit post links in the admin still work and calling get_edit_post_link() from a theme file works.

comment:2 @prettyboymp5 years ago

  • Keywords commit added

comment:3 @scribu5 years ago

  • Keywords commit removed

Could you provide a use-case scenario?

comment:4 @prettyboymp5 years ago

I've built several sites that allow user generated content, but don't allow normal users into the admin area. For those it would be nice not to have to filter the edit post link when I'm already setting up an _edit_link for the post_type.

comment:5 @scribu5 years ago

I don't think you should mix the backend links with ones meant to enable frontend editing.

comment:6 @prettyboymp5 years ago

What says the edit link is strict to backend? It is a link to where the content should be edited and in my case, I want it to be on a front end page. I don't understand your issue with this ticket.

comment:7 @prettyboymp5 years ago

  • Keywords commit added

comment:8 @dd325 years ago

The attached patch requires that the _edit_link be set to the absolute URL. IMO, thats not going to be a flexible method.

There is nothing preventing you from filtering the link, Which is exactly what i do, Filtering the link allows for a much higher flexibility of the link created.

I for example, am using /wordpress/<post-name-here>/edit/<edit_revision_here>/ to handle my post edits, that would be next to impossible with the proposed solution as it can only insert the ID, I'd still have to filter it.

If the default admin link isnt powerful enough, filter it, there is no way you can create a complex link using that function for every use-case, so to me, it doesnt make sense here.

comment:9 @prettyboymp5 years ago

  • Keywords commit removed

The absolute path is based off of the assumption that you would use site_url() to create the link when you pass it into the register_post_type method, so it is no less flexible than the current handling which is based on the path of wp-admin.

After some thought, to cut down on the slight performance hit of the regex running for each get_edit_post_link, I think the patch should be changed to add the admin_url or keep the absolute url during post_type registration instead. I'll submit a patch as soon as I know the entire ticket isn't getting shot down first.

comment:10 @markjaquith5 years ago

  • Milestone changed from 3.0 to Future Release

Sounds like there is uncertainty about how to proceed. Punting.

comment:11 @nacin14 months ago

  • Component changed from General to Post Types
Note: See TracTickets for help on using tickets.