| @@ -263,8 +263,14 @@ | ||
| 263 | 263 | // 2026-05-13). REST routes use the separate `nonce` field |
| 264 | 264 | // above with action `wp_rest` — they live in different |
| 265 | 265 | // namespaces, so a single shared nonce won't work. |
| 266 | 266 | 'consentExportNonce' => wp_create_nonce( 'doi_consent_export' ), |
| 267 | + // Setup wizard state for the dashboard card. Null on sites that | |
| 268 | + // were installed before the wizard existed. | |
| 269 | + 'setup' => $this->setupState(), | |
| 270 | + // Installed form plugins, so the forms page offers only add-ons | |
| 271 | + // for plugins this site actually runs. | |
| 272 | + 'formPlugins' => $this->formPlugins(), | |
| 267 | 273 | ); |
| 268 | 274 | |
| 269 | 275 | /** |
| 270 | 276 | * Filter the admin SPA configuration data. |
| @@ -291,8 +297,40 @@ | ||
| 291 | 297 | * |
| 292 | 298 | * @param string $from Entry point recorded on the link. |
| 293 | 299 | * @param string $fallback Used when core/feedback.php is not loaded. |
| 294 | 300 | */ |
| 301 | + /** | |
| 302 | + * @return array<int, array{id: string, name: string, addonLoaded: bool, productUrl: string}> | |
| 303 | + */ | |
| 304 | + private function formPlugins(): array { | |
| 305 | + $plugins = array(); | |
| 306 | + foreach ( ( new \Forge12\DoubleOptIn\Setup\FormPluginDetector() )->installed() as $plugin ) { | |
| 307 | + $plugins[] = array( | |
| 308 | + 'id' => $plugin['id'], | |
| 309 | + 'name' => $plugin['name'], | |
| 310 | + 'addonLoaded' => $plugin['addonLoaded'], | |
| 311 | + 'productUrl' => $this->productUrl( 'forms-detected-' . $plugin['id'], '' ), | |
| 312 | + ); | |
| 313 | + } | |
| 314 | + return $plugins; | |
| 315 | + } | |
| 316 | + | |
| 317 | + /** | |
| 318 | + * @return array{status: string, step: int, steps: int}|null | |
| 319 | + */ | |
| 320 | + private function setupState(): ?array { | |
| 321 | + $state = new \Forge12\DoubleOptIn\Setup\SetupState(); | |
| 322 | + if ( ! $state->exists() ) { | |
| 323 | + return null; | |
| 324 | + } | |
| 325 | + $current = $state->get(); | |
| 326 | + return array( | |
| 327 | + 'status' => $current['status'], | |
| 328 | + 'step' => $current['step'], | |
| 329 | + 'steps' => \Forge12\DoubleOptIn\Setup\SetupState::STEPS, | |
| 330 | + ); | |
| 331 | + } | |
| 332 | + | |
| 295 | 333 | private function productUrl( string $from, string $fallback ): string { |
| 296 | 334 | $fn = '\\forge12\\contactform7\\CF7DoubleOptIn\\get_product_url'; |
| 297 | 335 | |
| 298 | 336 | return function_exists( $fn ) ? esc_url_raw( $fn( $from ) ) : $fallback; |