AnsPress_Validation::sanitize_tags( string $field )

Description #

Santitize tags field

Parameters #

  • $field
    string (Required)

Changelog #

VersionDescription
2.0Introduced.

Source #

File: includes/class/validation.php

	private function sanitize_tags($field) {

		$this->fields[$field] = $this->fields[$field];

		$tags = $this->fields[$field];

		if ( ! is_array( $tags ) ) {
			$tags = explode( ',', $tags ); }

		$sanitized_tags = '';

		if ( is_array( $tags ) ) {
			$count = count( $tags );
			$i = 1;
			foreach ( $tags  as $tag ) {
				$sanitized_tags .= sanitize_text_field( $tag );

				if ( $count != $i ) {
					$sanitized_tags .= ','; }

				$i++;
			}
		}

		$this->fields[$field] = $sanitized_tags;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment