Automator_Utilities::automator_sanitize_array( $data )

Recursively calls itself if children has arrays as well


Parameters Parameters

$data

(Required)


Top ↑

Return Return

(mixed)


Source Source

File: src/core/lib/utilities/class-automator-utilities.php

	public function automator_sanitize_array( $data ) {
		foreach ( $data as $k => $v ) {
			$k = esc_attr( $k );
			if ( is_array( $v ) ) {
				$data[ $k ] = $this->automator_sanitize( $v, 'array' );
			} else {
				switch ( $k ) {
					case 'EMAILFROM':
					case 'EMAILTO':
					case 'EMAILCC':
					case 'EMAILBCC':
					case 'WPCPOSTAUTHOR':
						$regex = '/[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})/';
						if ( preg_match( $regex, $v, $email_is ) ) {
							$data[ $k ] = sanitize_email( $v );
						} else {
							$data[ $k ] = sanitize_text_field( $v );
						}
						break;
					case 'EMAILBODY':
					case 'WPCPOSTCONTENT':
						$data[ $k ] = wp_kses_post( $v );
						break;
					default:
						$data[ $k ] = sanitize_text_field( $v );
						break;
				}
			}
		}

		return $data;
	}