select( array(
'name' => $name,
'selected' => $selected,
'options' => $options,
'show_option_all' => false,
'show_option_none' => false
) );
return $output;
}
function month_dropdown( $name = 'month', $selected = 0 ) {
$month = 1;
$options = array();
$selected = empty( $selected ) ? date( 'n' ) : $selected;
while ( $month <= 12 ) {
$options[ absint( $month ) ] = edd_month_num_to_name( $month );
$month++;
}
$output = $this->select( array(
'name' => $name,
'selected' => $selected,
'options' => $options,
'show_option_all' => false,
'show_option_none' => false
) );
return $output;
}
function select( $args = array() ) {
$defaults = array(
'echo' => true,
'options' => array(),
'name' => null,
'class' => '',
'id' => '',
'selected' => array(),
'chosen' => false,
'placeholder' => null,
'multiple' => false,
'show_option_all' => _x( 'All', 'all dropdown items', 'import-users-from-csv-with-meta' ),
'show_option_none' => _x( 'None', 'no dropdown items', 'import-users-from-csv-with-meta' ),
'data' => array(),
'readonly' => false,
'disabled' => false,
'style' => ''
);
$args = wp_parse_args( $args, $defaults );
if( empty( $args['id'] ) )
$args['id'] = $args['name'];
$data_elements = '';
foreach ( $args['data'] as $key => $value ) {
$data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
}
if( $args['multiple'] ) {
$multiple = ' MULTIPLE';
} else {
$multiple = '';
}
if( $args['placeholder'] ) {
$placeholder = $args['placeholder'];
} else {
$placeholder = '';
}
if ( isset( $args['readonly'] ) && $args['readonly'] ) {
$readonly = ' readonly="readonly"';
} else {
$readonly = '';
}
if ( isset( $args['disabled'] ) && $args['disabled'] ) {
$disabled = ' disabled="disabled"';
} else {
$disabled = '';
}
$class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
if ( isset( $args['style'] ) && $args['style'] ) {
$style = ' style="' . safecss_filter_attr( $args['style'] ) . '"';
} else {
$style = '';
}
$output = '';
if( $args['echo'] )
echo $output;
return $output;
}
function checkbox( $args = array() ) {
$defaults = array(
'label' => '',
'echo' => true,
'array' => false,
'compare_value' => 1,
'name' => null,
'current' => 1,
'class' => '',
'options' => array(
'disabled' => false,
'readonly' => false
),
'description' => '',
);
$args = wp_parse_args( $args, $defaults );
$output = '';
$class = 'acui-checkbox ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
$options = '';
if ( ! empty( $args['options']['disabled'] ) ) {
$options .= ' disabled="disabled"';
} elseif ( ! empty( $args['options']['readonly'] ) ) {
$options .= ' readonly';
}
if( !empty( $args['label'] ) ){
$output .= '';
else
$output .= '';
if( !empty( $args['label'] ) )
$output .= '';
if( !empty( $args['description'] ) )
$output .= '
' . $args['description'] . '
';
if( $args['echo'] )
echo $output;
return $output;
}
function text( $args = array() ) {
$defaults = array(
'echo' => true,
'id' => '',
'name' => isset( $name ) ? $name : 'text',
'value' => isset( $value ) ? $value : null,
'label' => isset( $label ) ? $label : null,
'desc' => isset( $desc ) ? $desc : null,
'placeholder' => '',
'class' => 'regular-text',
'disabled' => false,
'autocomplete' => '',
'data' => false,
'type' => 'text',
'readonly' => false,
'required' => false,
'attributes' => array()
);
$args = wp_parse_args( $args, $defaults );
if( empty( $args['id'] ) )
$args['id'] = $args['name'];
if ( isset( $args['readonly'] ) && $args['readonly'] ) {
$readonly = ' readonly="readonly"';
} else {
$readonly = '';
}
if ( isset( $args['required'] ) && $args['required'] ) {
$required = ' required="required"';
} else {
$required = '';
}
$class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
$disabled = '';
if( $args['disabled'] ) {
$disabled = ' disabled="disabled"';
}
$data = '';
if ( ! empty( $args['data'] ) ) {
foreach ( $args['data'] as $key => $value ) {
$data .= 'data-' . $this->sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
}
}
$output = '';
if ( ! empty( $args['label'] ) ) {
$output .= '';
}
if ( ! empty( $args['desc'] ) ) {
$output .= '' . esc_html( $args['desc'] ) . '';
}
$output .= ' $value ){
$output .= ' ' . $key . '="' . $value . '"';
}
$output .= '/>';
$output .= '';
if( $args['echo'] )
echo $output;
return $output;
}
function textarea( $args = array() ) {
$defaults = array(
'echo' => true,
'name' => 'textarea',
'value' => null,
'label' => null,
'desc' => null,
'class' => 'large-text',
'disabled' => false,
'style' => '',
);
$args = wp_parse_args( $args, $defaults );
$class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
$disabled = '';
if( $args['disabled'] ) {
$disabled = ' disabled="disabled"';
}
if ( isset( $args['style'] ) && $args['style'] ) {
$style = ' style="' . safecss_filter_attr( $args['style'] ) . '"';
} else {
$style = '';
}
$output = '';
if ( ! empty( $args['label'] ) ) {
$output .= '';
}
$output .= '';
if ( ! empty( $args['desc'] ) ) {
$output .= '' . esc_html( $args['desc'] ) . '';
}
$output .= '';
if( $args['echo'] )
echo $output;
return $output;
}
}
function ACUIHTML(){
return ACUI_HTML::instance();
}