%s %s';
foreach ( $field['options'] as $key => $label ) {
$value = isset( $meta[ $key ] ) ? $meta[ $key ] : '';
$field['attributes']['name'] = $field['field_name'] . "[{$key}]";
$html[] = sprintf( $tpl, $label, parent::html( $value, $field ) );
}
$out = '' . ( $field['desc'] ? '' . $field['desc'] . ' ' : '' ) . implode( ' ', $html ) . ' ';
return $out;
}
protected static function input_description( array $field ) : string {
return '';
}
protected static function label_description( array $field ) : string {
return '';
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field['multiple'] = false;
$field['attributes']['id'] = false;
$field['attributes']['type'] = 'text';
return $field;
}
/**
* Format value for the helper functions.
*
* @param array $field Field parameters.
* @param string|array $value The field meta value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_value( $field, $value, $args, $post_id ) {
$output = '';
foreach ( $field['options'] as $label ) {
$output .= "$label ";
}
$output .= ' ';
if ( ! $field['clone'] ) {
$output .= self::format_single_value( $field, $value, $args, $post_id );
} else {
foreach ( $value as $subvalue ) {
$output .= self::format_single_value( $field, $subvalue, $args, $post_id );
}
}
$output .= '
';
return $output;
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param array $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
$output = '';
foreach ( $value as $subvalue ) {
$output .= "$subvalue ";
}
$output .= ' ';
return $output;
}
}