| @@ -286,13 +286,28 @@ | ||
| 286 | 286 | $metadata, |
| 287 | 287 | $score_options |
| 288 | 288 | ); |
| 289 | 289 | |
| 290 | - // Add readability_score and content_quality from frontend if provided | |
| 291 | - if (!empty($readability_score)) { | |
| 290 | + // Add readability_score and content_quality from frontend if | |
| 291 | + // provided. `!== null`, not `!empty()`: 0 is a legitimate score and | |
| 292 | + // empty() discarded it, so a post the editor scored as 0 kept | |
| 293 | + // whatever the calculator had produced instead (#394). Both params | |
| 294 | + // already default to null above, so null means "not sent". | |
| 295 | + // | |
| 296 | + // Only when the editor actually measured something, though. Inside a | |
| 297 | + // page builder there is no editor content to read, so Refresh sent an | |
| 298 | + // empty `live_content` along with the two labels derived from that | |
| 299 | + // empty string — the literal words "No content" — and they were | |
| 300 | + // applied over the correct server-side analysis this request had just | |
| 301 | + // run, then persisted by save_score(). That is what put "No content" | |
| 302 | + // on the dashboard for a page with a valid score (#778). With nothing | |
| 303 | + // measured, the analysis above is the better answer. | |
| 304 | + $editor_measured = '' !== trim((string) $live_content); | |
| 305 | + | |
| 306 | + if ($editor_measured && null !== $readability_score) { | |
| 292 | 307 | $score_data['readability_score'] = $readability_score; |
| 293 | 308 | } |
| 294 | - if (!empty($content_quality)) { | |
| 309 | + if ($editor_measured && null !== $content_quality) { | |
| 295 | 310 | $score_data['content_quality'] = $content_quality; |
| 296 | 311 | } |
| 297 | 312 | |
| 298 | 313 | // Save score if requested |