get_term_to_edit

函式
get_term_to_edit ( $id, $taxonomy )
引數
  • (int|object) $id Term ID or object.
    Required:
  • (string) $taxonomy Taxonomy name.
    Required:
返回值
  • (string|int|null|WP_Error) Will return empty string if $term is not an object.
定義位置
相關方法
get_terms_to_editget_user_to_editget_category_to_editget_tags_to_editget_post_to_edit
引入
2.3.0
棄用
-

get_term_to_edit:該函式為編輯目的檢索一個術語(類別、標籤等)物件。它需要一個引數:術語物件或ID。它返回術語物件。

對編輯用的術語進行Sanitize。

返回值是sanitize_term(),用法是對編輯用的術語進行Sanitize。編輯: 該函式是為了簡化上下文。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_term_to_edit( $id, $taxonomy ) {
$term = get_term( $id, $taxonomy );
if ( is_wp_error( $term ) ) {
return $term;
}
if ( ! is_object( $term ) ) {
return '';
}
return sanitize_term( $term, $taxonomy, 'edit' );
}
function get_term_to_edit( $id, $taxonomy ) { $term = get_term( $id, $taxonomy ); if ( is_wp_error( $term ) ) { return $term; } if ( ! is_object( $term ) ) { return ''; } return sanitize_term( $term, $taxonomy, 'edit' ); }
function get_term_to_edit( $id, $taxonomy ) {
	$term = get_term( $id, $taxonomy );

	if ( is_wp_error( $term ) ) {
		return $term;
	}

	if ( ! is_object( $term ) ) {
		return '';
	}

	return sanitize_term( $term, $taxonomy, 'edit' );
}

常見問題

FAQs
檢視更多 >