setting = $setting; if(isset( $this->setting['default'] )){ $this->saved_value = get_option($this->setting['field'], $this->setting['default']); }else{ $this->saved_value = get_option($this->setting['field']); } if(isset( $this->setting['pro'] )){ if($this->setting['pro']){ $this->pro = ' free-version '; //$this->setting['desc'] = 'Workes in Pro version only / Without PRO version this setting will have no effect'; }else{ $this->pro = ' paid-version '; } }else{ $this->pro = ""; } $this->check_field_type(); } function check_field_type(){ if(isset($this->setting['type'])): switch ($this->setting['type']){ case 'select': $this->select_box(); break; case 'number': $this->number_box(); break; case 'text': $this->text_box(); break; case 'textarea': $this->textarea_box(); break; case 'multiselect': $this->multiselect_box(); break; case 'color': $this->color_box(); break; case 'hidden': $this->hidden_box(); break; case 'switch': $this->switch_display(); break; case 'setting_category': $this->setting_category(); break; case 'image': $this->image(); break; } endif; } function bootstrap($label, $field, $desc = ""){ if($this->setting['type'] != 'hidden'){ ?>
setting['field'].'">'.$this->setting['label'].''; $desc = (isset($this->setting['desc'])) ? '
'.$this->setting['desc'].'' : ""; $field = ''; $this->bootstrap($label, $field, $desc); } /* Field type: select box */ function multiselect_box(){ $label = ''; $desc = ((isset($this->setting['desc'])) ? '
'.$this->setting['desc'].'' : ""); $field = ''; $this->bootstrap($label, $field, $desc); } /* Field type: Number box */ function number_box(){ $label = ''; $desc = (isset($this->setting['desc'])) ? '
'.$this->setting['desc'].'' : ""; $field = 'setting['min']) ? ' min="'.$this->setting['min'].'"': '') .(isset($this->setting['max']) ? ' max="'.$this->setting['max'].'"': '') .(isset($this->setting['step']) ? ' step="'.$this->setting['step'].'"': '') .(isset($this->setting['required']) ? ' required="'.$this->setting['required'].'"': '') .(isset($this->setting['readonly']) ? ' readonly="'.$this->setting['readonly'].'"': '') .'>'; $this->bootstrap($label, $field, $desc); } /* Field type: Number box */ function text_box(){ $label = ''; $desc = (isset($this->setting['desc'])) ? '
'.$this->setting['desc'].'' : ""; $field = 'setting['required']) ? ' required="'.$this->setting['required'].'"': '') .(isset($this->setting['readonly']) ? ' readonly="'.$this->setting['readonly'].'"': '') .'>'; $this->bootstrap($label, $field, $desc); } /* Textarea field */ function textarea_box(){ $label = ''; $desc = (isset($this->setting['desc'])) ? '
'.$this->setting['desc'].'' : ""; $field = ''; $this->bootstrap($label, $field, $desc); } /* Field type: color */ function color_box(){ wp_enqueue_style( 'wp-color-picker'); wp_enqueue_script( 'wp-color-picker'); wp_add_inline_script('wp-color-picker',' jQuery(document).ready(function($) { $(".color-picker").wpColorPicker(); }); '); $label = ''; $desc = (isset($this->setting['desc'])) ? '
'.$this->setting['desc'].'' : ""; $field = 'setting['required']) ? ' required="'.$this->setting['required'].'"': '') .(isset($this->setting['readonly']) ? ' readonly="'.$this->setting['readonly'].'"': '') .'>'; $this->bootstrap($label, $field, $desc); } function hidden_box(){ $label = ''; $desc = (isset($this->setting['desc'])) ? '
'.$this->setting['desc'].'' : ""; $field ='setting['required']) ? ' required="'.$this->setting['required'].'"': '') .(isset($this->setting['readonly']) ? ' readonly="'.$this->setting['readonly'].'"': '') .'>'; $this->bootstrap($label, $field, $desc); } /* Field type: switch */ function switch_display(){ $label = ''; $desc = (isset($this->setting['desc'])) ? '
'.$this->setting['desc'].'' : ""; $field = '
saved_value == true) ? "checked='checked'": "").' >
'; $this->bootstrap($label, $field, $desc); } /** * Category: is to devide setting in different part */ function setting_category(){ if(isset($this->setting['label']) && $this->setting['label'] != ""): ?>
">

">setting['label']; ?>

setting['field'].'">'.$this->setting['label'].''; $desc = (isset($this->setting['desc'])) ? '
'.$this->setting['desc'].'' : ""; $field = '
saved_value > 0 ? 'src="'.wp_get_attachment_url( get_option( $this->setting['field'] ) ).'"': '').' width="100" height="100" style="max-height: 100px; width: 100px;">
'; $this->bootstrap($label, $field, $desc); } function media_selector_scripts(){ $my_saved_attachment_post_id = get_option($this->setting['field'], 0 ); ?>