public static function meta( $post_id, $saved, $field ) {
/**
* For special fields like 'divider', 'heading' which don't have ID, just return empty string
* to prevent notice error when displaying fields
*/
if ( empty( $field['id'] ) ) {
return '';
}
// Get raw meta
$meta = self::call( $field, 'raw_meta', $post_id );
// Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run)
$meta = ! $saved ? $field['std'] : $meta;
// Escape attributes
$meta = self::call( $field, 'esc_meta', $meta );
// Make sure meta value is an array for clonable and multiple fields
if ( $field['clone'] || $field['multiple'] ) {
if ( empty( $meta ) || ! is_array( $meta ) ) {
/**
* Note: if field is clonable, $meta must be an array with values
* so that the foreach loop in self::show() runs properly
*
* @see self::show()
*/
$meta = $field['clone'] ? array( '' ) : array();
}
}
return $meta;
}