edit_term_link

Displays or retrieves the edit term link with formatting.

Description

(string|void) edit_term_link( (string) $link = '', (string) $before = '', (string) $after = '', (constant) $term = null, (bool) $echo = true ); 

Returns (string|void)

HTML content.

Parameters (5)

0. $link — Optional. (string) => ''
Anchor text. Default empty.
1. $before — Optional. (string) => ''
Display before edit link. Default empty.
2. $after — Optional. (string) => ''
Display after edit link. Default empty.
3. $term — Optional. (constant) => null
Term object. If null, the queried object will be inspected. Default null.
4. $echo — Optional. (bool) => true
Whether or not to echo the return. Default true.

Usage

  1. if ( !function_exists( 'edit_term_link' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // Optional. Anchor text. Default empty. 
  5. $link = ''; 
  6.  
  7. // Optional. Display before edit link. Default empty. 
  8. $before = ''; 
  9.  
  10. // Optional. Display after edit link. Default empty. 
  11. $after = ''; 
  12.  
  13. // Optional. Term object. If null, the queried object will be inspected. Default null. 
  14. $term = null; 
  15.  
  16. // Optional. Whether or not to echo the return. Default true. 
  17. $echo = true; 
  18.  
  19. // NOTICE! Understand what this does before running. 
  20. $result = edit_term_link($link, $before, $after, $term, $echo); 
  21.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/link-template.php  
  1. function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) { 
  2. if ( is_null( $term ) ) 
  3. $term = get_queried_object(); 
  4.  
  5. if ( ! $term ) 
  6. return; 
  7.  
  8. $tax = get_taxonomy( $term->taxonomy ); 
  9. if ( ! current_user_can( 'edit_term', $term->term_id ) ) { 
  10. return; 
  11.  
  12. if ( empty( $link ) ) 
  13. $link = __('Edit This'); 
  14.  
  15. $link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>'; 
  16.  
  17. /** 
  18. * Filters the anchor tag for the edit link of a term. 
  19. * @since 3.1.0 
  20. * @param string $link The anchor tag for the edit link. 
  21. * @param int $term_id Term ID. 
  22. */ 
  23. $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; 
  24.  
  25. if ( $echo ) 
  26. echo $link; 
  27. else 
  28. return $link;