options = $options;
$this->values = $values;
}
/*
* Generate label settings tabs
* @return string
*/
public function generate_nav_tabs() {
if ( empty( $this->options ) ) {
return;
}
$tabs = AWL_Admin_Options::include_label_settings_tabs();
$html = '';
$html .= '
';
$html .= '
';
$html .= '
';
if ( ! empty( $tabs ) ) {
foreach ( $tabs as $tab_slug => $tab_name ) {
$class = $tab_slug === 'general' ? 'current' : '';
$html .= '- ';
$html .= '' . $tab_name . '';
$html .= '
';
}
}
$html .= '
';
$html .= '
';
$html .= '
';
return $html;
}
/*
* Generate options fields
* @return string
*/
public function generate_fields() {
if ( empty( $this->options ) ) {
return;
}
$html = '';
$html .= '';
return $html;
}
/*
* Get field name
* @return string
*/
private function get_field_name( $field ) {
return "awl_label_params[settings][" . $field['id'] . "]";
}
/*
* Get field value
* @return string
*/
private function get_field_value( $field ) {
$value = isset( $field['value'] ) ? $field['value'] : '';
$field_value = false;
if ( $this->values && ! empty( $this->values ) && isset( $this->values['settings'] ) ) {
$field_id = $field['id'];
if ( isset( $this->values['settings'][$field_id] ) ) {
$field_value = $this->values['settings'][$field_id];
$suboption = isset( $field['suboption'] ) ? $field['suboption'] : '';
if ( $suboption && isset( $field_value[$suboption] ) ) {
$field_value = $field_value[$suboption];
}
}
}
if ( is_string( $field_value ) ) {
$value = $field_value;
}
return $value;
}
/*
* Get field class names
* @return string
*/
private function get_field_classes( $field ) {
$classes = isset( $field['class'] ) && is_string( $field['class'] ) ? 'class="' . $field['class'] . '"' : '';
return $classes;
}
/*
* Get extra table class names
* @return string
*/
private function extra_classes() {
$classes = '';
$classes .= ( $this->get_field_value( array( 'id' => 'position_type' ) ) === 'on_image' ) ? ' awl-position-on-image' : ' awl-position-on-line';
$classes .= ( $this->get_field_value( array( 'id' => 'custom_styles' ) ) === 'true' ) ? '' : ' awl-disabled-styles';
return $classes;
}
/*
* Get field html markup
* @param field array Field params
* @return string
*/
private function get_field( $field ) {
$field_html = '';
if ( isset( $field['params'] ) && is_array( $field['params'] ) ) {
$field_html .= '';
foreach( $field['params'] as $name => $val ) {
$this->field_name = $this->get_field_name( $field ) . '[' . $name . ']';
$field['suboption'] = $name;
$field['value'] = $val;
$field_html .= '
' . $this->call_field( $field ) . '
';
}
$field_html .= '
';
} else {
$field_html .= $this->call_field( $field );
}
return $field_html;
}
/*
* Call field type method
* @param field array Field params
* @return string
*/
private function call_field( $field ) {
$this->field_value = $this->get_field_value( $field );
return call_user_func_array( array( $this, 'get_field_' . $field['type'] ), array( $field ) );
}
/*
* Select field html markup
* @return string
*/
private function get_field_select( $field ) {
$disabled = isset( $field['disabled'] ) && $field['disabled'] ? ' disabled' : '';
$html = '';
$html .= '';
return $html;
}
/*
* Text field html markup
* @return string
*/
private function get_field_text( $field ) {
$disabled = isset( $field['disabled'] ) && $field['disabled'] ? ' disabled' : '';
$html = '';
return $html;
}
/*
* Number field html markup
* @return string
*/
private function get_field_number( $field ) {
$disabled = isset( $field['disabled'] ) && $field['disabled'] ? ' disabled' : '';
$params = '';
$params .= isset( $field['step'] ) ? ' step="' . $field['step'] . '"' : '';
$params .= isset( $field['min'] ) ? ' min="' . $field['min'] . '"' : '';
$params .= isset( $field['max'] ) ? ' max="' . $field['max'] . '"' : '';
$html = '';
return $html;
}
/*
* Textarea field html markup
* @return string
*/
private function get_field_textarea( $field ) {
$disabled = isset( $field['disabled'] ) && $field['disabled'] ? ' disabled' : '';
$html = '';
return $html;
}
/*
* Color field html markup
* @return string
*/
private function get_field_color( $field ) {
$params = isset( $field['alpha'] ) && $field['alpha'] ? 'data-alpha="true"' : '';
$html = '';
return $html;
}
/*
* Checkbox field html markup
* @return string
*/
private function get_field_checkbox( $field ) {
$disabled = isset( $field['disabled'] ) && $field['disabled'] ? ' disabled' : '';
$html = '';
$html .= 'field_value, '1', false ) . $disabled . '>';
return $html;
}
/*
* Checkbox field html markup
* @return string
*/
private function get_field_checkbox2( $field ) {
$html = '';
$html .= '';
return $html;
}
/*
* Upload button field html markup
* @return string
*/
private function get_field_upload( $field ) {
$html = '';
return $html;
}
/*
* Template field html markup
* @return string
*/
private function get_field_template( $field ) {
$template_type = $this->get_field_value( array( 'id' => 'type', 'value' => 'text' ) );
$image_url = isset( $field['choices'][$template_type] ) && isset( $field['choices'][$template_type][$this->field_value] ) ? $field['choices'][$template_type][$this->field_value] : $field['choices']['text']['standard'];
// custom uploaded image
if ( ! $image_url ) {
$image_url = $this->field_value;
$field['choices']['image'] = array( $this->field_value => $this->field_value ) + $field['choices']['image'];
}
$html = '';
$html .= '';
$html .= '
';
$html .= '
';
$html .= '
';
$html .= '
';
foreach ( $field['choices'] as $template_group => $template_group_items ) {
$html .= '
';
foreach( $template_group_items as $template_val => $template_img ) {
$is_active = ( $this->field_value === $template_val ) ? ' awl-active' : '';
$pro_only = strpos( $template_val, '-pro' ) !== false ? ' awl-pro-template' : '';
$html .= '- ';
$html .= '';
$html .= '
';
}
$html .= '
';
}
$html .= '
';
$html .= '
';
$html .= '
';
return $html;
}
}
endif;