wpseek.com
WordPress开发者和主题制作者的搜索引擎



maybe_serialize › WordPress Function

Since2.0.5
已弃用n/a
› maybe_serialize ( $data )
参数:
  • (string|array|object) $data Data that might be serialized.
    Required: Yes
返回:
  • (mixed) A scalar data.
定义在:
文档:

Serializes data, if needed.



源码

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;
}