'manage_woocommerce'); } public function registerMenu(): void { add_submenu_page( 'woocommerce', __('Durabix EU Guarantees', 'durabix'), __('EU Legal Guarantee', 'durabix'), 'manage_woocommerce', self::PAGE_SLUG, [$this, 'renderPage'] ); } public function registerSettings(): void { register_setting(self::PAGE_SLUG, GuaranteeService::OPTION, [ 'type' => 'array', 'sanitize_callback' => [$this, 'sanitizeSettings'], 'default' => GuaranteeService::defaults(), ]); } /** * @param mixed $input * @return array */ public function sanitizeSettings($input): array { $input = is_array($input) ? $input : []; $sanitized = []; $sanitized['enabled'] = ! empty($input['enabled']) ? '1' : '0'; $sanitized['notice_position'] = ($input['notice_position'] ?? '') === 'tab' ? 'tab' : 'single_summary'; $sanitized['notice_checkout'] = ! empty($input['notice_checkout']) ? '1' : '0'; $sanitized['notice_email'] = ! empty($input['notice_email']) ? '1' : '0'; return $sanitized; } public function renderPage(): void { if (! current_user_can('manage_woocommerce')) { return; } $settings = GuaranteeService::settings(); ?>


renderCompanionCard(); ?>

→