edit_term_link

函式
edit_term_link ( $link = '', $before = '', $after = '', $term = null, $echo = true )
引數
  • (string) $link Optional. Anchor text. If empty, default is 'Edit This'. Default empty.
    Required:
    Default: (empty)
  • (string) $before Optional. Display before edit link. Default empty.
    Required:
    Default: (empty)
  • (string) $after Optional. Display after edit link. Default empty.
    Required:
    Default: (empty)
  • (int|WP_Term|null) $term Optional. Term ID or object. If null, the queried object will be inspected. Default null.
    Required:
    Default: null
  • (bool) $echo Optional. Whether or not to echo the return. Default true.
    Required:
    Default: true
返回值
  • (string|void) HTML content.
定義位置
相關方法
get_term_linkget_edit_term_linkedit_tag_linkedit_post_linkedit_link
引入
3.1.0
棄用
-

edit_term_link: 這個函式生成一個連結,用於在WordPress管理面板中編輯一個指定的術語,例如一個類別或標籤。

顯示或檢索帶有格式化的編輯術語連結。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = 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 ( $echo ) {
echo $link;
} else {
return $link;
}
}
function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = 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 ( $echo ) { echo $link; } else { return $link; } }
function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = 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 ( $echo ) {
		echo $link;
	} else {
		return $link;
	}
}

常見問題

FAQs
檢視更多 >