id = 'test'; $this->label = 'Test page'; $this->plugin_prefix = 'test'; $this->init(); } public function init() { add_filter( $this->plugin_prefix . '_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_action( $this->plugin_prefix . '_settings_sections_' . $this->id, array( $this, 'output_sections' ) ); add_action( $this->plugin_prefix . '_settings_' . $this->id, array( $this, 'output' ) ); add_action( $this->plugin_prefix . '_settings_save_' . $this->id, array( $this, 'save' ) ); } public function get_sections() { $sections = array( '' => __( 'Section 1' ), 'test' => __( 'Section 2' ), ); return $sections; } public function get_settings() { $section = $this->get_current_section(); if( $section == 'test' ) { $settings = array( array( 'label' => 'Text Field', 'name' => 'test_field_new', 'desc' => 'this is the description of this field', 'type' => 'text', ), ); } else { $settings = array( array( 'label' => 'General Options', 'type' => 'title', ), array( 'label' => 'Text Field', 'name' => 'test_field', 'desc' => 'this is the description of this field', 'type' => 'text', ), array( 'label' => 'Text Field', 'name' => 'test_field_select2', 'desc' => 'this is the description of this field', 'type' => 'select', 'options' => array( 'test' => 't', 'test2' => 't2' ) ), array( 'label' => 'Text Field', 'name' => 'test_field_radio2', 'desc' => 'this is the description of this field', 'type' => 'radio', 'options' => array( 'test' => 't', 'test2' => 't2' ) ), array( 'label' => 'Textarea Field', 'name' => 'test_field2', 'desc' => 'this is the description of this field', 'type' => 'textarea', 'attributes' => array( 'rows' => 10, 'cols' => 50 ) ), array( 'label' => 'Text Field', 'name' => 'test_field33', 'desc' => 'this is the description of this field', 'type' => 'number', ), array( 'label' => 'Text Field', 'name' => 'test_field_check', 'desc' => 'this is the description of this field', 'type' => 'checkbox', ), ); } return $settings; } public function save() { $settings = $this->get_settings(); call_user_func( array( __NAMESPACE__ .'\\Settings_Manager', 'save_fields' ), $settings ); } } return new Settings_Test();