maybe_serialize() – Serialize data, if needed.

You appear to be a bot. Output may be restricted

Description

Serialize data, if needed.

Usage

$mixed = maybe_serialize( $data );

Parameters

$data
( string|array|object ) required – Data that might be serialized.

Returns

mixed A scalar data.

Source

File name: wordpress/wp-includes/functions.php
Lines:

1 to 16 of 16
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;
}
 

 View on GitHub View on Trac