args = $args; $this->id = $args['label_for']; $this->class = !empty($args['class']) ?$args['class'] : ''; $this->name = $args['option_name'] . '[' . $this->id . ']'; $this->current_value = isset($options[$this->id]) ? $options[$this->id] : ''; $this->placeholder = isset($args['placeholder']) ? $args['placeholder'] : ''; $this->min = isset($args['min']) ? (int) $args['min'] : null; $this->max = isset($args['max']) ? (int) $args['max'] : null; $this->step = isset($args['step']) ? $args['step'] : null; $this->minlength = isset($args['minlength']) ? (int) $args['minlength'] : null; $this->maxlength = isset($args['maxlength']) ? (int) $args['maxlength'] : null; $this->rows = isset($args['rows']) ? (int) $args['rows'] : null; $this->readonly = isset($args['readonly']) ? 'readonly' : ''; $this->mask = !empty($args['mask']) ? true : false; $this->constant = !empty($args['constant']) ? $args['constant'] : null; $this->desc = !empty($args['desc']) ? $args['desc'] : ''; $this->field_options = !empty($args['field_options']) ? $args['field_options'] : [ 'No field options' => 'No field options' ]; $this->checked_options = !empty($args['checked_options']) ? $args['checked_options'] : []; $this->disabled_options = !empty($args['disabled_options']) ? $args['disabled_options'] : []; } public function render($callback) { if ( is_string($callback) && class_exists($callback) && method_exists($callback, 'render') ) { return $callback::render( $this->args ); } if (method_exists($this, $callback)) { return $this->{$callback}(); } return '
Invalid field callback: ' . htmlspecialchars($callback) . '
'; } private function text() { ob_start(); ?> minlength !== null ? 'minlength="' . esc_attr($this->minlength) . '"' : ''; ?> maxlength !== null ? 'maxlength="' . esc_attr($this->maxlength) . '"' : ''; ?>>desc, Sanitiser::allowedFieldTags() ); ?>
placeholder; switch( true ) { case $this->constant !== null: $placeholder_value = defined($this->constant) ? constant($this->constant) : 'Undefined'; break; } if( $placeholder_value !== '' && $placeholder_value !== 'Undefined' && $this->mask !== false ){ $placeholder_value = str_repeat('*', strlen($placeholder_value)); } ?> readonly); ?>>desc, Sanitiser::allowedFieldTags() ); ?>
class ? 'regular-text' : $this->class; ?> readonly); ?>>desc, Sanitiser::allowedFieldTags() ); ?>
step !== null ? 'step="' . esc_attr($this->step) . '"' : ''; ?> min !== null ? 'min="' . esc_attr($this->min) . '"' : ''; ?> max !== null ? 'max="' . esc_attr($this->max) . '"' : ''; ?> placeholder !== null ? 'placeholder="' . esc_attr($this->placeholder) . '"' : ''; ?> readonly); ?>>desc, Sanitiser::allowedFieldTags() ); ?>
desc, Sanitiser::allowedFieldTags() ); ?>
field_options ) === range( 0, count( $this->field_options ) - 1 ); ?>desc, Sanitiser::allowedFieldTags() ); ?>
field_options as $value => $display_value ): $i++; $id_for = $this->id . "-$i"; ?>current_value), false ); ?>>
desc, Sanitiser::allowedFieldTags() ); ?>
current_value; $name = $this->name . '[]'; $i = 0; ?> field_options as $value => $display_value) { $i++; $id_for = $this->id . "-$i"; if( is_array($current_value) && in_array( $value, $current_value ) ) { $is_checked = true; } else { $is_checked = in_array( '_all', $this->checked_options ) || in_array( $value, $this->checked_options ) ? true : false; } $is_disabled = in_array( $value, $this->disabled_options ) ? true : false; ?>>
desc, Sanitiser::allowedFieldTags() ); ?>
field_options as $value => $display_value) { $is_checked = in_array( '_all', $this->checked_options ) || in_array( $value, $this->checked_options ) ? true : false; ob_start(); ?>>
desc, Sanitiser::allowedFieldTags() ); ?>