id = $id; // Id
$this->name = $name; // Name
$this->label = isset( $atts['label'] ) && !empty( $atts['label'] ) ? $atts['label'] : ''; // Label
$this->options = isset( $atts['options'] ) && !empty( $atts['options'] ) ? $atts['options'] : array(); // Options
$this->default = isset( $atts['default'] ) && !empty( $atts['default'] ) ? $atts['default'] : ''; // Default
$this->value = $value; // Value
}
/**
* Output admin form field
*
* @since 1.0.0
* @return string Field output
*/
public function field() {
$html = '';
if ( empty( $this->name ) ) {
return $html;
}
if ( $this->label ) {
$html .= '';
}
// If value NULL (only first time before save) set default value if passed
$value = NULL === $this->value && '' !== $this->default ? $this->default : $this->value;
// Html output
$html .= '';
return $html;
}
if ( isset( $this->options['callable'] ) ) {
// Use function
if ( is_callable( $this->options['callable'] ) ) {
$select_options = call_user_func( $this->options['callable'] );
}
} else {
// Use static already created options
$select_options = $this->options;
}
// Output options
foreach ( $select_options as $option => $label ) {
$html .= '';
}
$html .= '';
return $html;
}
}