Outil de recherche WordPress pour les développeurs et auteurs de thèmes



maybe_serialize ›

Depuis2.0.5
Dépréciéen/a
maybe_serialize ( $data )
Paramètres:
  • (string|array|object) $data Data that might be serialized.
    Requis: Oui
Retourne:
  • (mixed) A scalar data
Défini(e) dans:
Codex:

Serialize data, if needed.



Source

function maybe_serialize( $data ) {
	if ( is_array( $data ) || is_object( $data ) ) {
		return serialize( $data );
	}

	// Double serialization is required for backward compatibility.
	// See https://core.trac.wordpress.org/ticket/12930
	// Also the world will end. See WP 3.6.1.
	if ( is_serialized( $data, false ) ) {
		return serialize( $data );
	}

	return $data;
}