setField($field_array['field_type'], $field_array['field_data']); } } } public function setField( $type = '', $fields=array() ){ if( '' == $type ) { return false; } if( !empty($fields) ){ if ( isset($fields['class']) ) { if ( $type != 'section_start' && $type != 'section_end' && $type != 'main_section_start' && $type != 'main_section_end' && $type != 'sub_section_start' && $type != 'sub_section_end') { $fields['class'] .= ' amp-ux-field'; } $this->class = $fields['class']; } else{ $this->class = ''; } if ( isset($fields['parent-class']) ) { $this->parent_class = $fields['parent-class']; } else{ $this->parent_class = ''; } if ( isset($fields['title']) ) { $this->title = $fields['title']; } else{ $this->title = ''; } if ( isset($fields['element-class']) ) { $this->element_class = $fields['element-class']; } else{ $this->element_class = ''; } if ( isset($fields['id']) ) { $this->id = $fields['id']; } else{ $this->id = ''; } if ( isset($fields['default']) ) { $this->default = $fields['default']; } else{ $this->default = ''; } if ( isset($fields['required']) ) { $this->required = $fields['required']; } else{ $this->required = ''; } if ( isset($fields['options']) && is_array($fields['options']) ){ $this->options = $fields['options']; } else{ $this->options = ''; } if ( isset($fields['data-href']) ) { $this->data_href = ' data-href='.esc_url($fields['data-href']); } else{ $this->data_href = ''; } if ( isset($fields['data-url']) ) { $this->data_url = ' data-url='.esc_url($fields['data-url']); } else{ $this->data_url = ''; } if ( isset($fields['data-secure']) ) { $this->data_secure = ' data-secure='.esc_attr($fields['data-secure']); } else{ $this->data_secure = ''; } if ( isset($fields['data-text']) ) { $this->data_text = ' data-text='.esc_attr($fields['data-text']); } else{ $this->data_text = ''; } if ( isset($fields['desc']) ) { $this->desc = $fields['desc']; } else{ $this->desc = ''; } } // Select if ( 'select' == $type ) { $this->ampforwp_field_select($fields); //$this->loading(); } // Text if ( 'text' == $type ) { $this->ampforwp_field_text($fields); } // Checkbox if ( 'checkbox' == $type ) { $this->ampforwp_field_checkbox($fields); } // Upload if ( 'media' == $type ) { $this->ampforwp_field_media($fields); } // Color if ( 'color' == $type ) { $this->ampforwp_field_color($fields); } // Switch if ( 'switch' == $type ) { $this->ampforwp_field_switch($fields); } // Notification if ( 'notification' == $type ) { $this->ampforwp_field_notification($fields); } // Loader if ( 'loader' == $type ) { $this->ampforwp_field_loader($fields); } // Label if ( 'footer' == $type ) { $this->ampforwp_field_footer($fields); } // Main section if ( 'main_section_start' == $type ) { $this->main_section_start($fields); } if ( 'main_section_end' == $type ) { $this->main_section_end($fields); } // Section Start if ( 'section_start' == $type ) { $this->section_start($fields); } // Section end if ( 'section_end' == $type ) { $this->section_end($fields); } // Sub Section Start if ( 'sub_section_start' == $type ) { $this->sub_section_start($fields); } // Sub Section end if ( 'sub_section_end' == $type ) { $this->sub_section_end($fields); } // Sub Section end if ( 'heading' == $type ) { $this->ampforwp_field_heading($fields); } } public function ampforwp_field_heading($fields = array()){ echo '

'.esc_html($this->title).'

'; } public function ampforwp_field_loader($fields = array()){ echo '
Saved
'; } // Main Section public function main_section_start($fields = array() ) { if ( isset($fields['class']) ) { $this->class = $fields['class']; } if ( isset($fields['id']) ) { $this->id = $fields['id']; } echo '
'; } public function main_section_end($fields = array() ) { echo '
'; } // Section Start public function section_start($fields = array()){ if ( isset($fields['class']) ) { $this->class = $fields['class']; } if ( isset($fields['id']) ) { $this->id = $fields['id']; } $dcls = 'drawer'; if($this->class=='ampforwp-ux-sub-section'){ $dcls = ''; } echo '
'; } // Sub Section Start public function sub_section_start($fields = array()){ if ( isset($fields['class']) ) { $this->class = $fields['class']; } if ( isset($fields['id']) ) { $this->id = $fields['id']; } $hide = ''; if ( isset($fields['default']) && $fields['default']==0) { $hide = 'hide'; } $data_href = ""; if ( isset($fields['data-href'])) { $data_href = 'data-href='.esc_attr($fields['data-href']); } echo '
'; if(isset($fields['closable']) && $fields['closable']==1){ echo '
X
'; } } // Section End public function sub_section_end(){ echo '
'; } // Section End public function section_end(){ echo '
'; } public function ampforwp_field_select($fields){ $required = $hide = $hrf_id = ''; $data_num = 1; if ( !empty($this->required) ) { $required = 'required='.esc_attr($this->required[0]); $hide = ' hide'; } $output = '
'; if ( !empty($this->title) ) { $output .= '

'.esc_html__($this->title).'

'; } $output .= ''; if(isset($fields['data-value']) && isset($fields['data-value-id'])){ $hide = ''; if($this->default!="Other"){ $hide = 'hide'; } $output .= '

Mention the type of your site

'; } if( $this->data_href ){ if ( isset($fields['data-href-id']) ) { $hrf_id = $fields['data-href-id']; } $output .= ''; } if($this->id=="ampforwp-ux-analytics-more"){ $output .= ''; } $output .= '
'; echo $output; } public function ampforwp_field_checkbox($fields){ $required = $hide = $checked = ''; if ( !empty($fields['required']) ) { $required = 'required='.esc_attr($this->required[0]); $hide = 'hide'; } if ( isset($fields['default']) && '1' == $fields['default'] ){ $checked = 'checked'; } $lbl_cls = ''; if(isset($fields['label-class'])){ $lbl_cls = 'class="'.esc_attr($fields['label-class']).'"'; } $output = '
'; echo $output; } public function ampforwp_field_switch($fields){ $required = ''; $output = ''; $hide = ''; if ( !empty($this->required) ) { $required = 'required='.$this->required[0]; $this->class .= ' hide'; $hide = ' hide'; } if($this->id == 'amp-ux-ext-ssd'){ $output .= '

Recommended Plugins

'; } $output .= '
'; if ( !empty($this->title) ) { $output .= '

'.esc_html__($this->title, 'accelerated-mobile-pages').'

'; } if ( 1 == $this->default ) { $this->selected = 'checked'; } else{ $this->selected = ''; } if(isset($fields['data-url']) && $fields['data-url']!="" && 2 == $this->default){ $output .= '
'; }else{ $output .= '
'; } if( $this->desc ){ $output .= '

'.esc_html($this->desc).'

'; } $output .= '
'; echo $output; } public function ampforwp_field_media(){ $output = '
'; $id = $url = $width = $height = ''; if ( !empty($this->title) ) { $output .= '

'.esc_html($this->title).'

'; } if ( is_array($this->default) ) { $id = $this->default['id']; $url = $this->default['url']; $width = $this->default['width']; $height = $this->default['height']; $hide = 'hide'; } $opt_med_url = ampforwp_get_setting('opt-media','url'); $but_name = "Add Logo"; $logo_css = ""; if($opt_med_url!=""){ $hide = ''; $but_name = "Change Logo"; $logo_css = "amp-ux-chng-lg"; } $output .= '
'.esc_attr($but_name).' (Recommended Size: 120 x 90)
'; $output .= '
'; echo $output; } public function ampforwp_field_color(){ $output = '
'; if ( !empty($this->title) ) { $output .= '

'.esc_html($this->title).'

'; } $this->selected = $this->default ? 'value='.esc_attr($this->default) : ""; $output .= 'selected).'>'; $output .= '
'; echo $output; } public function ampforwp_field_text($fields){ $required = ''; $hide = ''; if ( !empty($this->required) ) { $required = 'required="'.esc_attr($this->required[0]).'"'; $hide .= ' hide'; } $output = '
'; if ( !empty($this->title) ) { $output .= '

'.esc_html($this->title).'

'; } $output .= 'data_text).' value="'.esc_attr($this->default).'">
'; echo $output; } public function loading(){ $output = '

'; echo $output; } public function ampforwp_field_notification($fields){ $required = $hide = $hrf_id = ''; $data_num = 1; if ( !empty($this->required) ) { $required = 'required='.esc_attr($this->required[0]); $hide = ' hide'; } $class = ""; if($fields['type']=="warning"){ $class = "warning"; } else if($fields['type']=="notice"){ $class = "warning-red"; } else if($fields['type']=="success"){ $class = "success"; } if($this->default==1){ $hide = ""; } $output = '
'; if ( !empty($this->desc) ) { $output .= '

'.$this->desc.'

'; // xss ok for $this->desc } $output .= '
'; echo $output; // xss ok for $output } public function ampforwp_field_footer($fields){ $output = ''; echo $output; // xss ok for $output } }?>