getPageName(), $this->getSettingName(), array( 'sanitize_callback' => array($this, 'handle'), 'default' => $this->getDefaults() )); add_settings_section($this->getSettingName(), __('Main settings', 'admitadtracking'), array($this, 'renderSection') , $this->getPageName()); foreach ($this->getSettings() as $id => $row) { $row['id'] = $row['label_for'] = $id; $label = isset($row['label']) ? $row['label'] : ''; $callback = isset($row['callback']) ? $row['callback'] : array($this, 'display_settings'); add_settings_field($id, $label, $callback, $this->getPageName(), $this->getSettingName(), $row); } } protected function getDefaults() { return array(); } protected function getSettings() { return array(); } public function handle($options) { if (isset($_POST['reset'])) { update_option('admitadtracking_auth', array('campaign_code' => '', 'postback_key' => '')); } return $options; } public function renderSection() { } public function render() { settings_fields( $this->getPageName() ); do_settings_sections( $this->getPageName() ); submit_button(); } public function getPageName() { return 'admitadtracking-' . $this->name . '-page'; } public function getSettingName() { return 'admitadtracking_' . $this->name; } public function display_settings($args) { extract( $args ); $option_name = $this->getSettingName(); $o = get_option( $option_name ); switch ( $type ) { case 'text': $value = !empty($o[$id]) ? esc_attr( stripslashes($o[$id]) ) : (isset($default) ? $default : null); $name = isset($name) ? $name : $option_name . '[' . $id . ']'; echo ""; echo (isset($args['desc'])) ? '
'.$args['desc'].'' : ""; break; case 'textarea': $o[$id] = esc_attr( stripslashes($o[$id]) ); echo ""; echo (isset($args['desc'])) ? '
'.$args['desc'].'' : ""; break; case 'checkbox': $checked = ($o[$id] == 'on') ? " checked='checked'" : ''; echo ""; break; case 'checkbox-group': echo '