Make WordPress Core

Opened 15 years ago

Closed 14 years ago

Last modified 13 years ago

#9702 closed enhancement (fixed)

edit_post_link() ; edit_category_link() ; edit_tags_link()

Reported by: ramiy's profile ramiy Owned by: westi's profile 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)

9702.patch (3.0 KB) - added by ramiy 15 years ago.
edit_category_link() & get_edit_category_link()
9702-theme.patch (1.0 KB) - added by ramiy 15 years ago.
canges in the default theme
9702-new.patch (2.8 KB) - added by ramiy 15 years ago.
the latest version (for wp3)
edit_term_link.patch (1.1 KB) - added by joostdevalk 14 years ago.
Patch with new edit_term_link function
edit_term_link.2.patch (3.2 KB) - added by joostdevalk 14 years ago.
Updated patch for edit_term_link, adding get_edit_term_url

Download all attachments as: .zip

Change History (35)

#1 follow-up: @Denis-de-Bernardy
15 years ago

  • Component changed from Themes to Template
  • Keywords needs-patch added; edit link admin theme enhancement removed
  • Owner set to anonymous

#2 in reply to: ↑ 1 @ramiy
15 years ago

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.

#3 follow-up: @Denis-de-Bernardy
15 years ago

Haven't looked. But whatever there is or isn't, it'll need a patch.

#4 in reply to: ↑ 3 @ramiy
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?

#5 @Denis-de-Bernardy
15 years ago

http://svnbook.red-bean.com/

short version: in the shell, type "svn help" or "svn help diff"

#6 @filosofo
15 years ago

Here's a great tutorial.

@ramiy
15 years ago

edit_category_link() & get_edit_category_link()

@ramiy
15 years ago

canges in the default theme

#7 @ramiy
15 years ago

  • Keywords has-patch added; needs-patch removed

#8 @westi
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 @greenshady
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 @ramiy
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 @westi
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.

@ramiy
15 years ago

the latest version (for wp3)

#12 @mikeschinkel
14 years ago

  • Cc mikeschinkel@… added

#13 @ramiy
14 years ago

  • Cc ramiy added

#14 @joostdevalk
14 years ago

Got a working patch to get edit_term_link going, let me add it here.

@joostdevalk
14 years ago

Patch with new edit_term_link function

#15 follow-up: @joostdevalk
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 @scribu
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 @scribu
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.

@joostdevalk
14 years ago

Updated patch for edit_term_link, adding get_edit_term_url

#18 @joostdevalk
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.

#19 @scribu
14 years ago

  • Milestone changed from Future Release to 3.1

#20 @scribu
14 years ago

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

(In [15792]) Introduce edit_term_link() and get_term_url(). Props yoast. Fixes #9702

#21 @scribu
14 years ago

(In [15800]) get_edit_term_link() improvements:

  • add optional $object_type parameter
  • make $term_id and $taxonomy parameters mandatory
  • pass all relevant information to the filter
  • use in WP_Terms_Table

See #9702

#22 @nacin
14 years ago

Should get_edit_term_url() be get_edit_term_link()?

#23 @joostdevalk
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 @scribu
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 @nacin
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 @joostdevalk
14 years ago

Guys, I don't care to be honest, I'm fine with either, and I understand both paths of reasoning :)

#27 @scribu
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.

#28 @scribu
14 years ago

(In [15801]) Rename get_edit_term_url() to get_edit_term_link() for consistency. See #9702

#29 @mcdaniel.isaac
13 years ago

  • Cc mcdaniel.isaac added

Are there plans to incorporate this patch into a future version?

#30 @scribu
13 years 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().

Note: See TracTickets for help on using tickets.