From c9be4ceb39d6312ca6fd6f60439005aed0306edb Mon Sep 17 00:00:00 2001 From: Terence Ong Date: Mon, 6 Apr 2026 14:19:15 +0700 Subject: [PATCH] Fix pre-existing syntax errors in analytics and REST API classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - analytics.php line 38: mismatched quotes on session_id array key - analytics.php line 246: invalid escape before concatenation operator - analytics.php line 250: COuNT typo → COUNT - analytics.php line 252: NULIF typo → NULLIF - rest-api.php line 54: stray # commenting out foreach variable These bugs predate the content filter feature but were caught by the new CI pipeline's PHP lint job. Co-Authored-By: Claude Opus 4.6 --- includes/class-peptide-news-analytics.php | 8 ++++---- includes/class-peptide-news-rest-api.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/class-peptide-news-analytics.php b/includes/class-peptide-news-analytics.php index b258ffb..946a16d 100644 --- a/includes/class-peptide-news-analytics.php +++ b/includes/class-peptide-news-analytics.php @@ -35,7 +35,7 @@ class Peptide_News_Analytics { 'user_agent' => sanitize_text_field( isset( $meta['user_agent'] ) ? $meta['user_agent'] : '' ), 'referrer_url' => esc_url_raw( isset( $meta['referrer'] ) ? $meta['referrer'] : '' ), 'page_url' => esc_url_raw( isset( $meta['page_url'] ) ? $meta['page_url'] : '' ), - "session_id' => sanitize_text_field( isset( $meta['session_id'] ) ? $meta['session_id'] : '' ), + 'session_id' => sanitize_text_field( isset( $meta['session_id'] ) ? $meta['session_id'] : '' ), 'user_id' => is_user_logged_in() ? get_current_user_id() : null, 'device_type' => sanitize_text_field( self::detect_device( isset( $meta['user_agent'] ) ? $meta['user_agent'] : '' ) ), ); @@ -243,13 +243,13 @@ class Peptide_News_Analytics { global $wpdb; $stats_table = $wpdb->prefix . 'peptide_news_daily_stats'; - $articles_table = $wpdb->prefix \. 'peptide_news_articles'; + $articles_table = $wpdb->prefix . 'peptide_news_articles'; return $wpdb->get_results( $wpdb->prepare( "SELECT a.source, - COuNT(DISTINCT a.id) AS article_count, + COUNT(DISTINCT a.id) AS article_count, SUM(s.click_count) AS total_clicks, - ROUND(IFNULL(SUM(s.click_count) / NULIF(COUNT(DISTINCT a.id), 0), 0), 1) AS avg_clicks_per_article + ROUND(IFNULL(SUM(s.click_count) / NULLIF(COUNT(DISTINCT a.id), 0), 0), 1) AS avg_clicks_per_article FROM {$stats_table} s INNER JOIN {$articles_table} a ON a.id = s.article_id WHERE s.stat_date BETWEEN %s AND %s diff --git a/includes/class-peptide-news-rest-api.php b/includes/class-peptide-news-rest-api.php index 21ba616..e0c468e 100644 --- a/includes/class-peptide-news-rest-api.php +++ b/includes/class-peptide-news-rest-api.php @@ -51,7 +51,7 @@ class Peptide_News_Rest_API { '/analytics/export' => 'get_export', ); - foreach( #$analytics_routes as $route => $callback ) { + foreach ( $analytics_routes as $route => $callback ) { register_rest_route( self::API_NAMESPACE, $route, array( 'methods' => 'GET', 'callback' => array( $this, $callback ),