#9702 closed enhancement (fixed)
edit_post_link() ; edit_category_link() ; edit_tags_link()
Reported by: | ramiy | Owned by: | westi |
---|---|---|---|
Milestone: | 3.1 | Priority: | low |
Severity: | minor | Version: | 2.7.1 |
Component: | Template | Keywords: | has-patch |
Focuses: | Cc: |
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)
#1
follow-up:
↓ 2
@
15 years ago
- Component changed from Themes to Template
- Keywords needs-patch added; edit link admin theme enhancement removed
- Owner set to anonymous
#3
follow-up:
↓ 4
@
15 years ago
Haven't looked. But whatever there is or isn't, it'll need a patch.
#4
in reply to:
↑ 3
@
15 years ago
- 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?
#8
@
15 years ago
- 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
#9
@
15 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.
#10
@
15 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.
#11
@
15 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.
#15
follow-up:
↓ 16
@
14 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...
#16
in reply to:
↑ 15
@
14 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().
#17
@
14 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.
#18
@
14 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.
#23
@
14 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....
#24
@
14 years ago
Indeed. I think the correct step would be to deprecate get_edit_tag_link() and replace it with get_edit_tag_url().
#25
@
14 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.
#26
@
14 years ago
Guys, I don't care to be honest, I'm fine with either, and I understand both paths of reasoning :)
#27
@
14 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.
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.