wpseek.com
A WordPress-centric search engine for devs and theme authors



edit_term_link › WordPress Function

Since3.1.0
Deprecatedn/a
edit_term_link ( $link = '', $before = '', $after = '', $term = null, $display = true )
Parameters: (5)
  • (string) $link Optional. Anchor text. If empty, default is 'Edit This'. Default empty.
    Required: No
    Default: (empty)
  • (string) $before Optional. Display before edit link. Default empty.
    Required: No
    Default: (empty)
  • (string) $after Optional. Display after edit link. Default empty.
    Required: No
    Default: (empty)
  • (int|WP_Term|null) $term Optional. Term ID or object. If null, the queried object will be inspected. Default null.
    Required: No
    Default: null
  • (bool) $display Optional. Whether or not to echo the return. Default true.
    Required: No
    Default: true
Returns:
  • (string|void) HTML content.
Defined at:
Codex:

Displays or retrieves the edit term link with formatting.



Source

function edit_term_link( $link = '', $before = '', $after = '', $term = null, $display = true ) {
	if ( is_null( $term ) ) {
		$term = get_queried_object();
	} else {
		$term = get_term( $term );
	}

	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 ( $display ) {
		echo $link;
	} else {
		return $link;
	}
}