tec_events_pro_maybe_unserialize( mixed $data, bool|array $allowed_classes = false )

Unserializes data only if it was serialized.


Parameters

$data

(mixed) (Required) Data that might be unserialized.

$allowed_classes

(bool|array) (Optional) Array of classes that are allowed to be unserialized.

Default value: false


Top ↑

Return

(mixed) Unserialized data can be any type.


Top ↑

Source

File: src/functions/template-tags/general.php

	function tec_events_pro_maybe_unserialize( $data, $allowed_classes = false ) {
		if ( is_serialized( $data ) ) { // Don't attempt to unserialize data that wasn't serialized going in.
			return @unserialize( trim( $data ), [ 'allowed_classes' => $allowed_classes ] );  // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
		}

		return $data;
	}

Top ↑

Changelog

Changelog
Version Description
7.0.3 Introduced.