LLMS_Events::sanitize_raw_event( array $raw )

Recursively sanitize event data.


Description Description


Parameters Parameters

$raw

(array) (Required) Event information array.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/class-llms-events.php

	protected function sanitize_raw_event( $raw ) {

		$clean = array();

		foreach ( $raw as $key => $val ) {

			// This will recursively handle any metadata submitted.
			if ( is_array( $val ) ) {
				$val = $this->sanitize_raw_event( $val );
			} elseif ( in_array( $key, array( 'actor_id', 'object_id' ), true ) ) {
				// cast id fields to int.
				$val = absint( $val );
			} else {
				// everything else is a text field.
				$val = sanitize_text_field( $val );
			}

			// Sanitize the key. This will ensure no dirty keys are submitted in metadata.
			$key = is_numeric( $key ) ? $key : sanitize_text_field( $key );

			$clean[ $key ] = $val;

		}

		return $clean;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.36.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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