get_var( "SELECT COUNT(DISTINCT post_id) FROM {$wpdb->postmeta} WHERE meta_key = '_ai_explainer_scanned_date'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching $human = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT post_id) FROM {$wpdb->postmeta} WHERE meta_key = '_ai_explainer_human_score' AND CAST(meta_value AS DECIMAL(5,3)) >= %f", 0.7 ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching $ai = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT post_id) FROM {$wpdb->postmeta} WHERE meta_key = '_ai_explainer_human_score' AND CAST(meta_value AS DECIMAL(5,3)) < %f", 0.4 ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching $last = $wpdb->get_var( "SELECT MAX(meta_value) FROM {$wpdb->postmeta} WHERE meta_key = '_ai_explainer_scanned_date'" ); $mixed = max( 0, $total - $human - $ai ); $pct_h = $total > 0 ? round( ( $human / $total ) * 100 ) : 0; $pct_a = $total > 0 ? round( ( $ai / $total ) * 100 ) : 0; $pct_m = $total > 0 ? round( ( $mixed / $total ) * 100 ) : 0; $grade = self::grade_from_pct( $pct_h ); return compact( 'total', 'human', 'ai', 'mixed', 'pct_h', 'pct_a', 'pct_m', 'grade', 'last' ); } private static function grade_from_pct( $pct ) { if ( $pct >= 90 ) { return 'A+'; } if ( $pct >= 80 ) { return 'A'; } if ( $pct >= 70 ) { return 'B'; } if ( $pct >= 60 ) { return 'C'; } if ( $pct >= 50 ) { return 'D'; } return 'F'; } private static function render_page() { $stats = self::build_stats(); $name = get_bloginfo( 'name' ); $home = home_url(); $last = $stats['last'] ? wp_date( 'F j, Y', strtotime( $stats['last'] ) ) : __( 'never', 'ai-explainer-pro' ); status_header( 200 ); nocache_headers(); header( 'Content-Type: text/html; charset=utf-8' ); ?> <?php /* translators: %s: site name. */ echo esc_html( sprintf( __( '%s — Content Authenticity', 'ai-explainer-pro' ), $name ) ); ?>

%

0 ) : ?>

$name, 'url' => $url, 'grade' => $stats['grade'], 'pct_h' => $stats['pct_h'], 'total' => $stats['total'], ]; $json = wp_json_encode( $payload ); ?> (function(){ var data = ; var color = data.grade.charAt(0)==='A' ? '#10B981' : (data.grade==='B' ? '#3B82F6' : (data.grade==='F' ? '#EF4444' : '#F59E0B')); // Inject the badge stylesheet as a on the host page rather // than an inline