'valuespace', 'error' => $vasp_error ]; } // Check WordPress errors $wp_error = vasp_wordpress_last_error(); if ($wp_error) { $errors[] = [ 'integration_key' => 'wordpress', 'error' => $wp_error ]; } // Check WooCommerce errors $wc_error = vasp_woocommerce_last_error(); if ($wc_error) { $errors[] = [ 'integration_key' => 'woocommerce', 'error' => $wc_error ]; } if (empty($errors)) { return; } foreach ($errors as $error_info) { $error_data = $error_info['error']; // Format error for display $display = vasp_format_error_for_display($error_data); if (!$display) { continue; } // Skip if already connected (info message, not error) if (isset($error_data['category']) && $error_data['category'] === 'info') { continue; } $type = ($display['category'] ?? '') === VASP_USER_ERROR_CONNECTION ? 'warning' : 'error'; $suppress_key = 'integration_error_' . sanitize_key((string) $error_info['integration_key']) . '_' . substr(hash('sha256', implode(':', [ (string) ($display['technical_code'] ?? ''), (string) ($display['step'] ?? ''), (string) ($display['timestamp'] ?? 0), ])), 0, 12); if (vasp_is_notice_suppressed($suppress_key)) { continue; } $actions = [[ 'label' => __('More details', 'valuespace'), 'url' => admin_url('admin.php?page=valuespace-info'), 'style' => 'link', ]]; $affected_product = (array) ($display['affected_product'] ?? []); if (!empty($affected_product['label']) && !empty($affected_product['url'])) { array_unshift($actions, [ 'label' => (string) $affected_product['label'], 'url' => (string) $affected_product['url'], 'style' => 'link', ]); } echo wp_kses_post(vasp_show_notice( (string) $display['description'], $type, 0, $actions, $suppress_key, (string) ($display['hint'] ?? '') )); } } /** * Display denial notices * * @return void */ function vasp_display_integration_denials(): void { $denials = []; // Check ValueSpace denials if (vasp_valuespace_was_denied()) { $denials[] = [ 'integration' => 'ValueSpace', 'integration_key' => 'valuespace' ]; } // Check WordPress denials if (vasp_wordpress_was_denied()) { $denials[] = [ 'integration' => 'WordPress', 'integration_key' => 'wordpress' ]; } // Check WooCommerce denials if (vasp_woocommerce_was_denied()) { $denials[] = [ 'integration' => 'WooCommerce', 'integration_key' => 'woocommerce' ]; } if (empty($denials)) { return; } foreach ($denials as $denial_info) { echo wp_kses_post(vasp_show_notice( sprintf( /* translators: %s: Integration name. */ __('%s authorization was not completed.', 'valuespace'), $denial_info['integration'] ), 'warning', 0, [], '', __('Start the connection again when you are ready.', 'valuespace') )); } } /** * Display all integration notices * * @return void */ function vasp_display_integration_notices(): void { vasp_display_integration_denials(); vasp_display_integration_errors(); }