sanitize_term_field [ WordPress Function ]
| Parameters: |
|
| Uses: |
|
| Returns: |
|
| Defined at: |
|
Cleanse the field value in the term based on the context.
Passing a term field value through the function should be assumed to have cleansed the value for whatever context the term field is going to be used.
If no context or an unsupported context is given, then default filters will be applied.
There are enough filters for each context to support a custom filtering without creating your own filter function. Simply create a function that hooks into the filter you need.
Source
<?php
function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) {
if ( 'parent' == $field || 'term_id' == $field || 'count' == $field || 'term_group' == $field ) {
$value = (int) $value;
if ( $value < 0 )
$value = 0;
}
if ( 'raw' == $context )
return $value;
if ( 'edit' == $context ) {
$value = apply_filters("edit_term_{$field}", $value, $term_id, $taxonomy);
$value = apply_filters("edit_{$taxonomy}_{$field}", $value, $term_id);
if ( 'description' == $field )
$value = esc_html($value); // textarea_escaped
else
$value = esc_attr($value);
} else if ( 'db' == $context ) {
$value = apply_filters("pre_term_{$field}", $value, $taxonomy);
$value = apply_filters("pre_{$taxonomy}_{$field}", $value);
// Back compat filters
if ( 'slug' == $field )
$value = apply_filters('pre_category_nicename', $value);
} else if ( 'rss' == $context ) {
$value = apply_filters("term_{$field}_rss", $value, $taxonomy);
$value = apply_filters("{$taxonomy}_{$field}_rss", $value);
} else {
// Use display filters by default.
$value = apply_filters("term_{$field}", $value, $term_id, $taxonomy, $context);
$value = apply_filters("{$taxonomy}_{$field}", $value, $term_id, $context);
}
if ( 'attribute' == $context )
$value = esc_attr($value);
else if ( 'js' == $context )
$value = esc_js($value);
return $value;
}
?>
Examples [ wp-snippets.com ]
Top Google Search Results
- Function Reference/sanitize term field « WordPress Codex
Description. Cleanse the field value in the term based on the context. Passing a term field value through the function should be assumed to have cleansed the ...
codex.wordpress.org - PHPXRef 0.7 : WordPress : Function Reference: sanitize_term_field()
Function and Method Cross Reference. sanitize_term_field(). Defined at: /wp- includes/taxonomy.php -> line 1587. Referenced 12 times: /wp-includes/query. php ...
phpxref.ftwr.co.uk - Docs for page functions.wp-taxonomy.php
void sanitize_term_field ( $field, $value, $term_id, $taxonomy, $context). $field; $ value; $term_id; $taxonomy; $context. update_object_term_cache (line 157) ...
phpdoc.ftwr.co.uk - sanitize_term_field() - Альтернативный взгляд на WordPress
17 май 2012 ... Подготавливает (очищает) значение поля термина (рубрики) для его использования в тексте.
wp-kama.ru