Advertisements

sanitize_term_field

Definition:
function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) {}

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.

Parameters

  • string $field: Term field to sanitize
  • string $value: Search for this term value
  • int $term_id: Term ID
  • string $taxonomy: Taxonomy Name
  • string $context: Either edit, db, display, attribute, or js.

Return values

returns:sanitized field

Defined filters

  • edit_term_{$field}
    apply_filters("edit_term_{$field}", $value, $term_id, $taxonomy)
  • edit_{$taxonomy}_{$field}
    apply_filters("edit_{$taxonomy}_{$field}", $value, $term_id)

Source code

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);

2787

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: