| @@ -83,10 +83,13 @@ | ||
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * GET /email-report/config |
| 86 | 86 | * |
| 87 | - * Returns the resolved config (on/off, frequency, recipients, sections) | |
| 88 | - * along with the section catalog and the next scheduled run. | |
| 87 | + * Returns the resolved config (on/off, frequency, recipients, sections, | |
| 88 | + * last skip reason) along with the section catalog, the next scheduled | |
| 89 | + * run and the readiness of the data sources — whether Search Console is | |
| 90 | + * connected, so the panel can say a report is paused rather than let it | |
| 91 | + * look healthy (#742). | |
| 89 | 92 | */ |
| 90 | 93 | public function get_config(WP_REST_Request $request): WP_REST_Response { |
| 91 | 94 | $manager = $this->resolve_manager(); |
| 92 | 95 | if ($manager === null) { |
| @@ -95,11 +98,12 @@ | ||
| 95 | 98 | ], 500); |
| 96 | 99 | } |
| 97 | 100 | |
| 98 | 101 | return new WP_REST_Response([ |
| 99 | - 'config' => $manager->config()->get(), | |
| 100 | - 'sections' => $manager->registry()->describe_for_ui(), | |
| 101 | - 'next_run' => $manager->scheduler()->next_run_iso(), | |
| 102 | + 'config' => $manager->config()->get(), | |
| 103 | + 'sections' => $manager->registry()->describe_for_ui(), | |
| 104 | + 'next_run' => $manager->scheduler()->next_run_iso(), | |
| 105 | + 'readiness' => $manager->data_provider()->readiness(), | |
| 102 | 106 | ]); |
| 103 | 107 | } |
| 104 | 108 | |
| 105 | 109 | /** |
| @@ -121,11 +125,12 @@ | ||
| 121 | 125 | |
| 122 | 126 | $saved = $manager->config()->save($input); |
| 123 | 127 | |
| 124 | 128 | return new WP_REST_Response([ |
| 125 | - 'success' => true, | |
| 126 | - 'config' => $saved, | |
| 127 | - 'next_run' => $manager->scheduler()->next_run_iso(), | |
| 129 | + 'success' => true, | |
| 130 | + 'config' => $saved, | |
| 131 | + 'next_run' => $manager->scheduler()->next_run_iso(), | |
| 132 | + 'readiness' => $manager->data_provider()->readiness(), | |
| 128 | 133 | ]); |
| 129 | 134 | } |
| 130 | 135 | |
| 131 | 136 | /** |
| @@ -143,10 +148,13 @@ | ||
| 143 | 148 | $result = $manager->generator()->generate_test(); |
| 144 | 149 | |
| 145 | 150 | $status = !empty($result['success']) ? 200 : 400; |
| 146 | 151 | return new WP_REST_Response([ |
| 147 | - 'success' => (bool) ($result['success'] ?? false), | |
| 148 | - 'result' => $result, | |
| 152 | + 'success' => (bool) ($result['success'] ?? false), | |
| 153 | + // True when the test went out as the "connect Search Console" | |
| 154 | + // email rather than a report, so the panel can say so. | |
| 155 | + 'not_connected' => !empty($result['not_connected']), | |
| 156 | + 'result' => $result, | |
| 149 | 157 | ], $status); |
| 150 | 158 | } |
| 151 | 159 | |
| 152 | 160 | /** |