Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
PUM_Newsletters::sanitization( array $values = array() )

Provides basic field sanitization.


Description Description


Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Parameters Parameters

$values

(Optional)

Default value: array()


Top ↑

Return Return

(array)


Top ↑

Source Source

File: classes/Newsletters.php

	public static function sanitization( $values = array() ) {
		$values = wp_parse_args( $values, array(
			'provider'     => pum_get_option( 'newsletter_default_provider', 'none' ),
			'consent'      => 'no',
			'consent_args' => array(),
		) );

		$values['provider'] = sanitize_text_field( $values['provider'] );

		$values['provider'] = sanitize_text_field( $values['provider'] );

		if ( ! empty( $values['consent_args'] ) && is_string( $values['consent_args'] ) ) {
			if ( strpos( $values['consent_args'], '\"' ) >= 0 ) {
				$values['consent_args'] = stripslashes( $values["consent_args"] );
			}

			$values['consent_args'] = (array) json_decode( $values['consent_args'] );
		}


		$values['consent_args'] = wp_parse_args( $values['consent_args'], array(
			'enabled'  => 'no',
			'required' => false,
			'text'     => '',
		) );


		// Anonymize the data if they didn't consent and privacy is enabled.
		if ( $values['consent_args']['enabled'] === 'yes' && ! $values['consent_args']['required'] && $values['consent'] === 'no' ) {
			$values['uuid']    = '';
			$values['user_id'] = 0;
			$values['name']    = '';
			$values['fname']   = '';
			$values['lname']   = '';
			$values['email']   = function_exists( 'wp_privacy_anonymize_data' ) ? wp_privacy_anonymize_data( 'email', $values['email'] ) : '[email protected]';
		}

		// Split name into fname & lname or vice versa.
		if ( isset( $values['name'] ) ) {
			$values['name'] = trim( sanitize_text_field( $values["name"] ) );

			//Creates last name
			$name = explode( " ", $values['name'] );
			if ( ! isset( $name[1] ) ) {
				$name[1] = '';
			}

			$values['fname'] = trim( $name[0] );
			$values['lname'] = trim( $name[1] );
		} else {
			$values['fname'] = isset( $values["fname"] ) ? sanitize_text_field( $values["fname"] ) : '';
			$values['lname'] = isset( $values["lname"] ) ? sanitize_text_field( $values["lname"] ) : '';

			$values['name'] = trim( $values['fname'] . ' ' . $values['lname'] );
		}

		$values['email']      = sanitize_email( $values["email"] );
		$values['email_hash'] = md5( $values['email'] );

		return $values;
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.