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
if ( !function_exists( 'edit_term_link' ) ) { require_once ABSPATH . WPINC . '/link-template.php'; } // Optional. Anchor text. Default empty. $link = ''; // Optional. Display before edit link. Default empty. $before = ''; // Optional. Display after edit link. Default empty. $after = ''; // Optional. Term object. If null, the queried object will be inspected. Default null. $term = null; // Optional. Whether or not to echo the return. Default true. $echo = true; // NOTICE! Understand what this does before running. $result = edit_term_link($link, $before, $after, $term, $echo);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/link-template.php
- function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) {
- if ( is_null( $term ) )
- $term = get_queried_object();
- if ( ! $term )
- return;
- $tax = get_taxonomy( $term->taxonomy );
- if ( ! current_user_can( 'edit_term', $term->term_id ) ) {
- return;
- }
- if ( empty( $link ) )
- $link = __('Edit This');
- $link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>';
- /**
- * Filters the anchor tag for the edit link of a term.
- *
- * @since 3.1.0
- *
- * @param string $link The anchor tag for the edit link.
- * @param int $term_id Term ID.
- */
- $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after;
- if ( $echo )
- echo $link;
- else
- return $link;
- }