Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This code is working fine, just want to make sure I'm ok with hardcoding the href to the category edit screen with...

"edit-tags.php?action=edit&taxonomy=category&post_type=post&tag_ID='.$cat_id.'"

Or is there a method I should call to get the category edit link dynamically (in case the call ever gets changed)?

//add the filter in order to add custom columns to the category manager 
add_filter('manage_category_custom_column', 'display_cat_columns', 10, 3);

//This function outputs the custom category image onto each row of the category manager grid.
function display_cat_columns($arg1, $column_name, $cat_id){
  if ('ce4_cat_image' == $column_name) {
  return '<a href="edit-tags.php?action=edit&taxonomy=category&post_type=post&tag_ID='.$cat_id.'">get_category_thumbnail_admin($cat_id, 'thumbnail').'</a>';}
}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

The function which is used internally (since 3.1) is get_edit_term_link( $term_id, $taxonomy, $object_type = '' ). Source view here.

There's also a function called edit_term_link that will format the link output for you.

The built-in functions are probably better to use, because they check for user capabilities, etc., and are better for future compatability. That said, I think you're safe using the hardcoded url for backwards compatability. I don't know how it was done in previous versions, and I think those links might have been hardcoded like you're doing...

Edit: I was curious what was done before that function was introduced, so I looked through the source. Prior to 3.1, get_edit_tag_link( $tag_id, $taxonomy = 'post_tag' ) did the same thing - now it's just rewritten to use get_edit_term_link internally. So if you want to support all recent versions of WordPress, use this function:

//add the filter in order to add custom columns to the category manager 
add_filter('manage_category_custom_column', 'display_cat_columns', 10, 3);

//This function outputs the custom category image onto each row of the category manager grid.
function display_cat_columns($arg1, $column_name, $cat_id){
  if ('ce4_cat_image' == $column_name) {
      if (function_exists ('edit_term_link'))
        return edit_term_link( get_category_thumbnail_admin($cat_id, 'thumbnail'),
                '', '', $cat_id, false );
      else return '<a href="'.get_edit_tag_link($cat_id, 'category').'">'.
                get_category_thumbnail_admin($cat_id, 'thumbnail').'</a>';
  }
}
share|improve this answer
    
+1 Excellent answer. Thanks very much GA! –  Scott B Feb 1 '11 at 13:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.