diff --git a/includes/collector/class-prv-ai-visibility-collector.php b/includes/collector/class-prv-ai-visibility-collector.php index 852aa90..3e808de 100644 --- a/includes/collector/class-prv-ai-visibility-collector.php +++ b/includes/collector/class-prv-ai-visibility-collector.php @@ -64,7 +64,7 @@ class PRV_Ai_Visibility_Collector implements PRV_Data_Collector { $table = PRV_Table_Manager::get_table_name(); // ── Trendline: one score per run_id ──────────────────────────── - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $run_rows = $wpdb->get_results( "SELECT run_id, MIN(captured_at) AS captured_at, SUM(cited) AS cited_count, @@ -76,11 +76,12 @@ class PRV_Ai_Visibility_Collector implements PRV_Data_Collector { LIMIT 52", ARRAY_A ); + // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $trendline = array(); foreach ( (array) $run_rows as $row ) { $trendline[] = array( - 'run_id' => (string) $row['run_id'], + 'run_id' => (string) $row['run_id'], 'captured_at' => (string) $row['captured_at'], 'score' => $this->compute_score( (int) $row['cited_count'], @@ -102,11 +103,12 @@ class PRV_Ai_Visibility_Collector implements PRV_Data_Collector { WHERE run_id = (SELECT run_id FROM {$table} ORDER BY captured_at DESC LIMIT 1) GROUP BY peptide_slug, peptide_label", ARRAY_A - ); // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + ); + // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $standings = array(); foreach ( (array) $standing_rows as $row ) { - $top_domains = $this->extract_top_domains( (string) ( $row['domains_json_list'] ?? '' ) ); + $top_domains = $this->extract_top_domains( (string) ( $row['domains_json_list'] ?? '' ) ); // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.NotSameWarning $standings[ (string) $row['peptide_slug'] ] = array( 'label' => (string) $row['peptide_label'], 'cited' => (bool) (int) $row['cited'], @@ -118,7 +120,8 @@ class PRV_Ai_Visibility_Collector implements PRV_Data_Collector { // ── Run metadata ──────────────────────────────────────────────── // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching - $last_run = $wpdb->get_var( "SELECT MAX(captured_at) FROM {$table}" ); // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + $last_run = $wpdb->get_var( "SELECT MAX(captured_at) FROM {$table}" ); + // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching return array( 'trendline' => $trendline, @@ -151,8 +154,8 @@ class PRV_Ai_Visibility_Collector implements PRV_Data_Collector { if ( 0 === $total_count ) { return 0.0; } - $base_score = $cited_count / $total_count; - $position_bonus = $position_sum / $total_count; + $base_score = $cited_count / $total_count; + $position_bonus = $position_sum / $total_count; return round( ( $base_score + $position_bonus ) / 2.0, 4 ); } @@ -168,7 +171,7 @@ class PRV_Ai_Visibility_Collector implements PRV_Data_Collector { return array(); } - $all = array(); + $all = array(); $chunks = explode( '|||', $domains_json_list ); foreach ( $chunks as $chunk ) { $decoded = json_decode( $chunk, true ); diff --git a/includes/core/class-prv-admin-page.php b/includes/core/class-prv-admin-page.php index f13e6db..29d73af 100644 --- a/includes/core/class-prv-admin-page.php +++ b/includes/core/class-prv-admin-page.php @@ -129,10 +129,10 @@ class PRV_Admin_Page { $redirect = add_query_arg( array( - 'page' => self::MENU_SLUG, + 'page' => self::MENU_SLUG, 'prv_run_done' => 1, - 'prv_probed' => (int) $counts['probed'], - 'prv_skipped' => (int) ( $counts['skipped_budget'] + $counts['skipped_error'] ), + 'prv_probed' => (int) $counts['probed'], + 'prv_skipped' => (int) ( $counts['skipped_budget'] + $counts['skipped_error'] ), ), admin_url( 'admin.php' ) ); diff --git a/includes/providers/class-prv-citation-detector.php b/includes/providers/class-prv-citation-detector.php index eaf4a44..2d24a1b 100644 --- a/includes/providers/class-prv-citation-detector.php +++ b/includes/providers/class-prv-citation-detector.php @@ -49,8 +49,8 @@ class PRV_Citation_Detector { $host = (string) wp_parse_url( $url, PHP_URL_HOST ); if ( '' !== $host ) { - $bare = str_starts_with( $host, 'www.' ) ? substr( $host, 4 ) : $host; - $domains[] = strtolower( $bare ); + $bare = str_starts_with( $host, 'www.' ) ? substr( $host, 4 ) : $host; + $domains[] = strtolower( $bare ); } } diff --git a/includes/providers/class-prv-gateway-client.php b/includes/providers/class-prv-gateway-client.php index 6b5855a..e71ddc9 100644 --- a/includes/providers/class-prv-gateway-client.php +++ b/includes/providers/class-prv-gateway-client.php @@ -61,9 +61,9 @@ class PRV_Gateway_Client { * @throws \RuntimeException On permanent HTTP failure or parse error. */ public function post_to_gateway( string $provider_slug, array $body, string $api_key, string $endpoint = '/chat/completions' ): array { - $base_url = $this->build_base_url( $provider_slug ); - $url = $base_url . $endpoint; - $base_host = (string) wp_parse_url( $base_url, PHP_URL_HOST ); + $base_url = \$this->build_base_url( \$provider_slug ); + $url = \$base_url . \$endpoint; + $base_host = (string) wp_parse_url( \$base_url, PHP_URL_HOST ); $headers = array( 'Authorization' => 'Bearer ' . $api_key,