Fix pre-existing syntax errors in analytics and REST API classes
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 ),
|
||||
|
||||
Reference in New Issue
Block a user