Opened 14 years ago
Closed 12 years ago
#18504 closed enhancement (fixed)
Allow filtering of "Add New [Post Type]" URL on edit.php
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | trivial | Version: | 3.2.1 |
Component: | Administration | Keywords: | has-patch |
Focuses: | Cc: |
Description
I've recently attempted to use add_filter('admin_url','filter_function'), only to discover that there are many URLs in the admin area that are not passed through the admin_url() function. While there may be a good reason for that to happen, I figured it wouldn't hurt to check the possibility of changing one of them.
The one URL I haven't been able to find a workaround to is the "Add New [Post Type]" button on the edit.php screen, on top the post table, which also appears when editing an existing post. From what I gather, it is generated in the following file/line http://core.trac.wordpress.org/browser/trunk/wp-admin/edit.php#L189 for the first case, and on this one http://core.trac.wordpress.org/browser/trunk/wp-admin/edit-form-advanced.php#L198 for the second case.
Fixing this, assuming it's possible without compromising a functionality I'm not aware of, would be as simple as replacing this:
<a href="<?php echo $post_new_file ?>" ...
And this:
<a href="<?php echo esc_url( $post_new_file ) ?>" ...
With this:
<a href="<?php echo admin_url($post_new_file); ?>" ...
And this:
<a href="<?php echo esc_url( admin_url($post_new_file) ) ?>" ...
Attachments (2)
Change History (13)
#3
@
14 years ago
$post_new_file
is set around http://core.trac.wordpress.org/browser/trunk/wp-admin/edit.php#L38, so assuming we trust the post type slug is valid since it's in get_post_types()
, the esc_url()
instance is the incorrect one.
#9
@
12 years ago
Patch still applies cleanly in src. Would esc_url( admin_url() )
be overkill here?
Sidenote: esc_url() is either necessary or it isn't, so one of the usages is incorrect.
Otherwise, using admin_url() there seems like a good idea.