LLMS_Events::sanitize_raw_event( array $raw )

Recursively sanitize event data.


Parameters Parameters

$raw

(array) (Required) Event information array.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/class-llms-events.php

311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
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.