wpseek.com
A WordPress-centric search engine for devs and theme authors
sanitize_term › WordPress Function
Since2.3.0
Deprecatedn/a
› sanitize_term ( $term, $taxonomy, $context = 'display' )
| Parameters: (3) |
|
| Returns: |
|
| Defined at: |
|
| Codex: |
Sanitizes all term fields.
Relies on sanitize_term_field() to sanitize the term. The difference is that this function will sanitize all fields. The context is based on sanitize_term_field(). The$term is expected to be either an array or an object.Source
function sanitize_term( $term, $taxonomy, $context = 'display' ) {
$fields = array( 'term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id', 'object_id' );
$do_object = is_object( $term );
$term_id = $do_object ? $term->term_id : ( isset( $term['term_id'] ) ? $term['term_id'] : 0 );
foreach ( (array) $fields as $field ) {
if ( $do_object ) {
if ( isset( $term->$field ) ) {
$term->$field = sanitize_term_field( $field, $term->$field, $term_id, $taxonomy, $context );
}
} else {
if ( isset( $term[ $field ] ) ) {
$term[ $field ] = sanitize_term_field( $field, $term[ $field ], $term_id, $taxonomy, $context );
}
}
}
if ( $do_object ) {
$term->filter = $context;
} else {
$term['filter'] = $context;
}
return $term;
}