#9702 closed enhancement (fixed)
edit_post_link() ; edit_category_link() ; edit_tags_link()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | low | Milestone: | 3.1 |
| Component: | Template | Version: | 2.7.1 |
| Severity: | minor | Keywords: | has-patch |
| Cc: | r_a_m_i@…, mikeschinkel@…, ramiy, mcdaniel.isaac |
Description
Just like edit_post_link(), i suggest to add edit_category_link() and edit_tags_link(). Those function will be used in themes. They will make an aesy access to admin tag/category edit panel. And link edit_post_link(), only users that have the right authorization will see the links.
Link to edit Categories like the link to edit posts
function edit_category_link($id, $link = 'Edit This', $before = , $after = ) {
global $post;
if ( is_category() ) {
if ( ! current_user_can('manage_categories', $id) )
return;
$location = get_settings('siteurl') . "/wp-admin/categories.php?action=edit&cat_ID=$id";
}
echo $before . "<a href=\"$location\">$link</a>" . $after;
}
Link to edit Tags like the link to edit posts
function edit_tags_link($id, $link = 'Edit This', $before = , $after = ) {
global $post;
if ( is_tag() ) {
if ( ! current_user_can('manage_categories', $id) )
return;
$location = get_settings('siteurl') . "/wp-admin/edit-tags.php?action=edit&tag_ID=$id";
}
echo $before . "<a href=\"$location\">$link</a>" . $after;
}
Attachments (5)
Change History (35)
comment:1
follow-up:
↓ 2
Denis-de-Bernardy — 4 years ago
- Component changed from Themes to Template
- Keywords needs-patch added; edit link admin theme enhancement removed
- Owner set to anonymous
comment:3
follow-up:
↓ 4
Denis-de-Bernardy — 4 years ago
Haven't looked. But whatever there is or isn't, it'll need a patch.
- Milestone changed from 2.9 to 2.8
I found in wp-includes/link-template.php several edit_*_link() functions but no edit_category_link(). i can write a patch, but i never sent code to wp-track before, is there a manual?
short version: in the shell, type "svn help" or "svn help diff"
- Milestone changed from 2.8 to 2.9
- Owner changed from anonymous to westi
- Status changed from new to reviewing
Nice idea.
Not for 2.8 though, moving to 2.9
comment:9
greenshady — 4 years ago
Shouldn't we just go with edit_term_link() and get_edit_term_link() with a taxonomy parameter? Something like:
edit_term_link( $term_id = 0, $taxonomy = 'post_tag' );
Also, the get_edit_tag_link() function already allows the input of a taxonomy (it'll handle categories as well), but the edit_tag_link() function does not.
comment:10
ramiy — 4 years ago
There are no edit_term_link() function.
If you examine the wp-includes/link-template.php file, you see that there are many functions of this kind:
- get_edit_tag_link()
- get_edit_post_link()
- get_edit_comment_link()
- get_edit_bookmark_link()
But no get_edit_category_link(). This patch addes the cat edit link function.
comment:11
westi — 4 years ago
- Milestone changed from 2.9 to Future Release
I still think this is a nice idea.
But not for 2.9 now we are in feature freeze.
comment:12
mikeschinkel — 3 years ago
- Cc mikeschinkel@… added
comment:13
ramiy — 3 years ago
- Cc ramiy added
comment:14
joostdevalk — 3 years ago
Got a working patch to get edit_term_link going, let me add it here.
comment:15
follow-up:
↓ 16
joostdevalk — 3 years ago
So this adds edit_term_link, which would basically work with post_tag and category too, so we could (and should) probably clean up edit_tag_link and make it use this...
comment:16
in reply to:
↑ 15
scribu — 3 years ago
Replying to joostdevalk:
So this adds edit_term_link, which would basically work with post_tag and category too, so we could (and should) probably clean up edit_tag_link and make it use this...
Patch looks good and yes, edit_tag_link() should use edit_term_link().
comment:17
scribu — 3 years ago
Although, I think we should stick to $term_id, $taxonomy instead of $term to be consistent with the rest of the taxonomy API.
comment:18
joostdevalk — 3 years ago
Updated the patch, now using get_edit_term_url and cleaned up edit_tag_link and get_edit_tag_link to use these new functions.
comment:19
scribu — 3 years ago
- Milestone changed from Future Release to 3.1
comment:20
scribu — 3 years ago
- Resolution set to fixed
- Status changed from reviewing to closed
comment:21
scribu — 3 years ago
comment:22
nacin — 3 years ago
Should get_edit_term_url() be get_edit_term_link()?
comment:23
joostdevalk — 3 years ago
It returns a URL not a link, I had originally named it _link but scribu suggested _url, and I think he's right since that's what it returns....
comment:24
scribu — 3 years ago
Indeed. I think the correct step would be to deprecate get_edit_tag_link() and replace it with get_edit_tag_url().
comment:25
nacin — 3 years ago
We use _link() all over, though, for these kinds of links -- terms, posts, etc. edit_post_link(), edit_comment_link(), and a few dozen others. The only _url() functions in link-template are site_url() and its many friends.
comment:26
joostdevalk — 3 years ago
Guys, I don't care to be honest, I'm fine with either, and I understand both paths of reasoning :)
comment:27
scribu — 3 years ago
I now saw that in the changeset I used get_edit_term_link() by mistake. So, it's pretty clear that convention trumpets correctness in this case.
I'll rename it.
comment:28
scribu — 3 years ago
- Cc mcdaniel.isaac added
Are there plans to incorporate this patch into a future version?
comment:30
scribu — 16 months ago
This patch was already commited in version 3.1, except there's a single set of functions: edit_term_link() and get_edit_term_link().

it seems like there is a function for the tags at wp-includes/link-template.php function edit_tag_link() added in wp2.7 but no such function for categories.