settings = $settings;
}
/**
* @return bool
*/
public function is_enabled() {
return (bool) $this->settings->enabled( 'enable_page_checks' );
}
/**
* Render the pass/warn rows and a one-line summary (section body). Reflects the
* saved post.
*
* @param \WP_Post $post Post being edited.
*/
public function render_meta_box( $post ) {
echo self::rows_html( $post ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- every field is escaped inside rows_html().
}
/**
* The section body as an HTML string — the pass/warn rows and the one-line
* summary. Pure given a post, so the meta box and the REST auto-refresh route
* ({@see EditorPanel::rest_page_check()}) render byte-identical markup.
*
* @param \WP_Post $post Post being edited.
* @return string
*/
public static function rows_html( $post ) {
$rows = PageCheck::analyze( $post );
$sum = PageCheck::summary( $rows );
// Offer the "Fix with AI" affordance only when a provider is actually configured.
// Resolved once here, not per row.
$ai = Assist::ai_available();
// The featured-image row's one-click Generate needs a longer chain — block
// editor, writes switch, image-capable provider, upload rights. Also once.
$genfeat = AssistantEditor::featured_one_click();
ob_start();
printf( '
';
foreach ( $rows as $r ) {
$status = in_array( $r['status'], array( 'pass', 'warn', 'fail' ), true ) ? $r['status'] : 'warn';
$mark = 'pass' === $status ? '✓' : '!';
// A "Fix with AI" button on the checks AI can draft (warn/fail only). The result
// is rendered into the sibling .agentimus-pc__fixout by the delegated handler in
// Assist's editor script.
$fix = '';
if ( $ai && in_array( $status, array( 'warn', 'fail' ), true ) && Assist::fixable( $r['id'] ) ) {
$fix = '';
}
// The featured-image row gets a one-click of its own — not a text
// suggestion but the assistant's generate-and-set-featured (bound by
// delegation in AssistantEditor's editor script). Its class is NOT
// agentimus-pc__fix, so the Fix-with-AI handler never catches it.
if ( $genfeat && 'featured_image' === $r['id'] && 'pass' !== $status ) {
$fix = '';
}
printf(
'