describedby( $field, $form_id );
$choices = $this->get_choices( $field );
$base_id = $this->input_id( $field, $form_id );
$ukupno = count( $choices );
// After a failed send the visitor's order comes back instead of the one
// the owner wrote the options in.
$sticky = $this->sticky_value( $field, $form_id );
?>
allowed_values( $field );
$out = array();
foreach ( $value as $kljuc => $mesto ) {
$kljuc = sanitize_text_field( (string) $kljuc );
if ( ! in_array( $kljuc, $dozvoljene, true ) ) {
continue;
}
$out[ $kljuc ] = absint( $mesto );
}
asort( $out );
return $out;
}
/**
* Validation.
*
* @param mixed $value The value.
* @param array $field The field settings.
*
* @return string
*/
public function validate( $value, $field ) {
if ( ! empty( $field['required'] ) && ! $value ) {
return $this->required_message( $field );
}
return '';
}
/**
* The value for the email and for the list: the order, one per line.
*
* @param mixed $value The value.
* @param array $field The field settings.
*
* @return string
*/
public function format_value( $value, $field ) {
if ( ! is_array( $value ) ) {
return '';
}
$imena = array();
foreach ( $this->get_choices( $field ) as $choice ) {
$imena[ $choice['value'] ] = $choice['label'];
}
$redovi = array();
$mesto = 1;
foreach ( $value as $kljuc => $broj ) {
$redovi[] = $mesto . '. ' . ( isset( $imena[ $kljuc ] ) ? $imena[ $kljuc ] : $kljuc );
$mesto++;
}
return implode( "\n", $redovi );
}
}