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