data = &$args; if( $this->add_in_menu() ) { add_action( 'admin_menu', array( $this, 'add_menu_in_admin_menu' ), 12 ); } add_action( 'admin_init', array( $this, 'display_fields' ), 12 ); add_filter( 'whitelist_options', array( $this, 'whitelist_options' ), 99, 1 ); } public function add_menu_in_admin_menu(){ if( "main" == $this->get_menu_type() ) { add_theme_page( $this->get_menu_name(), $this->get_menu_title(), $this->get_capability(), $this->get_menu_slug(), array( $this, 'display_function' ), $this->get_menu_icon() ); } if( "sub" == $this->get_menu_type() ) { add_submenu_page($this->data['cpt_menu'], $this->get_menu_title(), $this->get_menu_title(), $this->get_capability(), $this->get_menu_slug(), array( $this, 'display_function' )); } } public function section_callback( $section ) { $section_id = $section['id']; //var_dump($section_id); $data = isset( $section['callback'][0]->data ) ? $section['callback'][0]->data : array(); //$description = $section['description']; $description = $section['id'] ; echo '
'; } public function display_fields() { foreach ($this->get_pages() as $panelsIndex=>$panels): //var_dump($panelsIndex); foreach ($panels['page_settings'] as $sectionIndex=>$sections): add_settings_section( $sectionIndex, isset( $sections['title'] ) ? $sections['title'] : "", array( $this, 'section_callback'), $panelsIndex ); foreach( $sections['options'] as $option ) : add_settings_field( $option['id'], $option['title'], array($this,'field_generator'), $panelsIndex, $sectionIndex, $option ); endforeach; endforeach; endforeach; } public function field_generator( $option ) { $id = isset( $option['id'] ) ? $option['id'] : ""; $type = isset( $option['type'] ) ? $option['type'] : ""; $details = isset( $option['details'] ) ? $option['details'] : ""; if( empty( $id ) ) return; $FormFieldsGenerator = array(); $prent_option_name = $this->get_option_name(); $FormFieldsGenerator = new FormFieldsGenerator(); if(!empty($prent_option_name)): $field_name = $prent_option_name.'['.$id.']'; $option['field_name'] = $field_name; $prent_option_value = get_option( $prent_option_name ); $option['value'] = isset($prent_option_value[$id]) ? $prent_option_value[$id] : ''; else: $option['field_name'] = $id; $option['value'] = get_option( $id ); endif; ?> field_text($option); } elseif( isset($option['type']) && $option['type'] === 'text_multi' ){ echo $FormFieldsGenerator->field_text_multi($option); } elseif( isset($option['type']) && $option['type'] === 'textarea' ){ echo $FormFieldsGenerator->field_textarea($option); } elseif( isset($option['type']) && $option['type'] === 'checkbox' ){ echo $FormFieldsGenerator->field_checkbox($option); } elseif( isset($option['type']) && $option['type'] === 'checkbox_multi' ){ echo $FormFieldsGenerator->field_checkbox_multi($option); } elseif( isset($option['type']) && $option['type'] === 'radio' ){ echo $FormFieldsGenerator->field_radio($option); } elseif( isset($option['type']) && $option['type'] === 'select' ){ echo $FormFieldsGenerator->field_select($option); } elseif( isset($option['type']) && $option['type'] === 'range' ){ echo $FormFieldsGenerator->field_range($option); } elseif( isset($option['type']) && $option['type'] === 'range_input' ){ echo $FormFieldsGenerator->field_range_input($option); } elseif( isset($option['type']) && $option['type'] === 'switch' ){ echo $FormFieldsGenerator->field_switch($option); } elseif( isset($option['type']) && $option['type'] === 'switch_multi' ){ echo $FormFieldsGenerator->field_switch_multi($option); } elseif( isset($option['type']) && $option['type'] === 'switch_img' ){ echo $FormFieldsGenerator->field_switch_img($option); } elseif( isset($option['type']) && $option['type'] === 'time_format' ){ echo $FormFieldsGenerator->field_time_format($option); } elseif( isset($option['type']) && $option['type'] === 'date_format' ){ echo $FormFieldsGenerator->field_date_format($option); } elseif( isset($option['type']) && $option['type'] === 'datepicker' ){ echo $FormFieldsGenerator->field_datepicker($option); } elseif( isset($option['type']) && $option['type'] === 'color_sets' ){ echo $FormFieldsGenerator->field_color_sets($option); } elseif( isset($option['type']) && $option['type'] === 'colorpicker' ){ echo $FormFieldsGenerator->field_colorpicker($option); } elseif( isset($option['type']) && $option['type'] === 'colorpicker_multi' ){ echo $FormFieldsGenerator->field_colorpicker_multi($option); } elseif( isset($option['type']) && $option['type'] === 'link_color' ){ echo $FormFieldsGenerator->field_link_color($option); } elseif( isset($option['type']) && $option['type'] === 'icon' ){ echo $FormFieldsGenerator->field_icon($option); } elseif( isset($option['type']) && $option['type'] === 'icon_multi' ){ echo $FormFieldsGenerator->field_icon_multi($option); } elseif( isset($option['type']) && $option['type'] === 'dimensions' ){ echo $FormFieldsGenerator->field_dimensions($option); } elseif( isset($option['type']) && $option['type'] === 'wp_editor' ){ echo $FormFieldsGenerator->field_wp_editor($option); } elseif( isset($option['type']) && $option['type'] === 'select2' ){ echo $FormFieldsGenerator->field_select2($option); } elseif( isset($option['type']) && $option['type'] === 'faq' ){ echo $FormFieldsGenerator->field_faq($option); } elseif( isset($option['type']) && $option['type'] === 'grid' ){ echo $FormFieldsGenerator->field_grid($option); } elseif( isset($option['type']) && $option['type'] === 'color_palette' ){ echo $FormFieldsGenerator->field_color_palette($option); } elseif( isset($option['type']) && $option['type'] === 'color_palette_multi' ){ echo $FormFieldsGenerator->field_color_palette_multi($option); } elseif( isset($option['type']) && $option['type'] === 'media' ){ echo $FormFieldsGenerator->field_media($option); } elseif( isset($option['type']) && $option['type'] === 'media_multi' ){ echo $FormFieldsGenerator->field_media_multi($option); } elseif( isset($option['type']) && $option['type'] === 'repeatable' ){ echo $FormFieldsGenerator->field_repeatable($option); } elseif( isset($option['type']) && $option['type'] === 'user' ){ echo $FormFieldsGenerator->field_user($option); } elseif( isset($option['type']) && $option['type'] === 'margin' ){ echo $FormFieldsGenerator->field_margin($option); } elseif( isset($option['type']) && $option['type'] === 'padding' ){ echo $FormFieldsGenerator->field_padding($option); } elseif( isset($option['type']) && $option['type'] === 'border' ){ echo $FormFieldsGenerator->field_border($option); } elseif( isset($option['type']) && $option['type'] === 'switcher' ){ echo $FormFieldsGenerator->field_switcher($option); } elseif( isset($option['type']) && $option['type'] === 'password' ){ echo $FormFieldsGenerator->field_password($option); } elseif( isset($option['type']) && $option['type'] === 'post_objects' ){ echo $FormFieldsGenerator->field_post_objects($option); } elseif( isset($option['type']) && $option['type'] === 'google_map' ){ echo $FormFieldsGenerator->field_google_map($option); } elseif( isset($option['type']) && $option['type'] === $type ){ do_action( "wp_theme_settings_field_$type", $option ); } if( !empty( $details ) ) echo "$details
"; } public function whitelist_options( $whitelist_options ){ $prent_option_name = $this->get_option_name(); if($prent_option_name): $whitelist_options[$this->get_menu_slug()][] = $prent_option_name; else: foreach( $this->get_pages() as $page_id => $page ): foreach( $page['page_settings'] as $section ): foreach( $section['options'] as $option ): $whitelist_options[$this->get_menu_slug()][] = $option['id']; endforeach; endforeach; endforeach; endif; update_option('whitelist_options',$whitelist_options ); return $whitelist_options; } public function display_function(){ ?>