get_opts_public()['enabled_post_types'];
$excluded_ids = get_option( 'aije_excluded_posts', array() );
$nonce_dash = wp_create_nonce( 'aije_dashboard_nonce' );
if ( isset( $_GET['reset_excluded'] ) ) {
delete_option( 'aije_excluded_posts' );
wp_safe_redirect( admin_url( 'tools.php?page=aije-lite&tab=dashboard' ) ); exit;
}
$query = new WP_Query( array( 'post_type' => $types, 'posts_per_page' => -1, 'post_status' => 'publish', 'post__not_in' => $excluded_ids ) );
$scores = array(); $distribution = array( 'ready' => 0, 'mid' => 0, 'low' => 0 );
$cat_totals = array( 'content' => 0, 'eeat' => 0, 'technical' => 0, 'linking' => 0 ); $post_count = 0;
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post(); $p = get_post(); $analysis = $this->calculate_ai_analysis( $p ); $score = $analysis['score'];
$scores[] = array( 'id' => get_the_ID(), 'title' => get_the_title(), 'score' => $score );
if ( $score >= 75 ) { $distribution['ready']++; } elseif ( $score >= 50 ) { $distribution['mid']++; } else { $distribution['low']++; }
foreach ( $cat_totals as $k => $_ ) { $cat_totals[ $k ] += $analysis['categories'][ $k ]['score'] ?? 0; }
$post_count++;
}
wp_reset_postdata();
}
$avg = $post_count ? round( array_sum( array_column( $scores, 'score' ) ) / $post_count ) : 0;
$cat_avgs = array();
foreach ( $cat_totals as $k => $total ) { $cat_avgs[ $k ] = $post_count ? round( $total / $post_count ) : 0; }
$avg_color = $avg >= 75 ? '#27ae60' : ( $avg >= 50 ? '#e67e22' : '#e74c3c' );
echo '
AI Readiness Dashboard ' . esc_html( $post_count ) . ' Artikel · Ø ' . esc_html( $avg ) . ' Punkte
';
echo '';
echo '
';
echo '
';
echo '
';
echo '';
// Filter-Counts
$filter_counts = array( 'no_image' => 0, 'no_meta' => 0, 'too_short' => 0, 'no_eeat' => 0, 'no_h2' => 0, 'no_internal' => 0 );
$filter_needles = array( 'no_image' => 'Beitragsbild', 'no_meta' => 'Meta-Description', 'too_short' => 'kurz', 'no_eeat' => 'Berufsbezeichnung', 'no_h2' => 'H2', 'no_internal' => 'Keine internen Links' );
$filter_labels = array( 'no_image' => '🖼 Kein Bild', 'no_meta' => '📝 Keine Meta', 'too_short' => '📏 Text zu kurz', 'no_eeat' => '🏅 Kein E-E-A-T', 'no_h2' => '📋 Kein H2', 'no_internal' => '🔗 Kein int. Linking' );
$all_posts_for_filter = get_posts( array( 'post_type' => $types, 'posts_per_page' => -1, 'post_status' => 'publish' ) );
foreach ( $all_posts_for_filter as $fp ) { $fa = $this->calculate_ai_analysis( $fp ); foreach ( $filter_counts as $fk => $_ ) { foreach ( $fa['issues'] as $iss ) { if ( mb_stripos( $iss['msg'], $filter_needles[ $fk ] ) !== false ) { $filter_counts[ $fk ]++; break; } } } }
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '
';
$excluded_count = count( get_option( 'aije_excluded_posts', array() ) );
echo '';
foreach ( $filter_labels as $fk => $fl ) {
if ( $filter_counts[ $fk ] > 0 ) { echo ''; }
}
if ( $excluded_count > 0 ) { echo ''; }
echo '
';
echo ''; $this->render_dashboard_list( 'bad' ); echo '
';
echo ''; $this->render_dashboard_list( 'medium' ); echo '
';
echo ''; $this->render_dashboard_list( 'good' ); echo '
';
foreach ( $filter_labels as $fk => $fl ) { echo '' . esc_html( $fl ) . ' – ' . (int)$filter_counts[ $fk ] . ' Artikel betroffen
'; $this->render_dashboard_list( 'filter', $fk ); echo '
'; }
$excluded_ids = get_option( 'aije_excluded_posts', array() );
echo '';
if ( empty( $excluded_ids ) ) { echo '
Keine ausgeschlossenen Artikel.
'; }
else { echo '
'; }
echo '
';
$this->render_exclude_js();