edit_term_link()
最后更新于:2021-11-26 04:01:16
edit_term_link( string$link=”, string$before=”, string$after=”, GC_Term$term=null, bool$echo=true)Displays or retrieves the edit term link with formatting.
参数
- $link
-
(string) (Optional) Anchor text. If empty, default is ‘Edit This’.
Default value: ”
- $before
-
(string) (Optional) Display before edit link.
Default value: ”
- $after
-
(string) (Optional) Display after edit link.
Default value: ”
- $term
-
(GC_Term) (Optional) Term object. If null, the queried object will be inspected.
Default value: null
- $echo
-
(bool) (Optional) Whether or not to echo the return.
Default value: true
响应
(string|void) HTML content.
源文件
文件: gc-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;
}
}