'manage_woocommerce'); } public function registerMenu(): void { add_submenu_page( 'woocommerce', __('Pasporto DPP', 'pasporto'), __('Product Passport (DPP)', 'pasporto'), 'manage_woocommerce', self::PAGE_SLUG, [$this, 'renderPage'] ); } public function registerSettings(): void { register_setting(self::PAGE_SLUG, PassportService::OPTION, [ 'type' => 'array', 'sanitize_callback' => [$this, 'sanitizeSettings'], 'default' => PassportService::DEFAULTS, ]); } /** * @param mixed $input Whatever reached update_option(); not always an array. * @return array */ public function sanitizeSettings($input): array { $input = is_array($input) ? $input : []; $sanitized = []; $sanitized['enabled'] = ! empty($input['enabled']) ? '1' : '0'; $sanitized['dpp_position'] = ($input['dpp_position'] ?? '') === 'summary' ? 'summary' : 'tab'; return $sanitized; } public function renderPage(): void { if (! current_user_can('manage_woocommerce')) { return; } $settings = PassportService::settings(); ?>