Opened 4 years ago

Closed 3 years ago

Last modified 16 months ago

#9702 closed enhancement (fixed)

edit_post_link() ; edit_category_link() ; edit_tags_link()

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

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

Download all attachments as: .zip

Change History (35)

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

comment:2 in reply to: ↑ 1   ramiy4 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.

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

comment:4 in reply to: ↑ 3   ramiy4 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?

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

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

Here's a great tutorial.

ramiy4 years ago

edit_category_link() & get_edit_category_link()

ramiy4 years ago

canges in the default theme

  • Keywords has-patch added; needs-patch removed
  • 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

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.

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.

  • 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.

ramiy3 years ago

the latest version (for wp3)

  • Cc mikeschinkel@… added
  • Cc ramiy added

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

Patch with new edit_term_link function

comment:15 follow-up: ↓ 16   joostdevalk3 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   scribu3 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().

Although, I think we should stick to $term_id, $taxonomy instead of $term to be consistent with the rest of the taxonomy API.

Updated patch for edit_term_link, adding get_edit_term_url

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.

  • Milestone changed from Future Release to 3.1
  • Resolution set to fixed
  • Status changed from reviewing to closed

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

(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

Should get_edit_term_url() be get_edit_term_link()?

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....

Indeed. I think the correct step would be to deprecate get_edit_tag_link() and replace it with get_edit_tag_url().

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.

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

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.

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

  • Cc mcdaniel.isaac added

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

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.