acf_maybe_unserialize()ACF 6.1

Maybe unserialize, but don't allow any classes.

No Hooks.

Returns

Mixed. The unserialized, or original data.

Usage

acf_maybe_unserialize( $data );
$data(string) (required)
String to be unserialized, if serialized.

Changelog

Since 6.1 Introduced.

acf_maybe_unserialize() code ACF 6.8.8

function acf_maybe_unserialize( $data ) {
	if ( is_serialized( $data ) ) { // Don't attempt to unserialize data that wasn't serialized going in.
		return @unserialize( trim( $data ), array( 'allowed_classes' => false ) ); //phpcs:ignore -- allowed classes is false.
	}

	return $data;
}