| @@ -44,9 +44,15 @@ | ||
| 44 | 44 | /** |
| 45 | 45 | * Initially Invoked when initialized. |
| 46 | 46 | */ |
| 47 | 47 | public function __construct() { |
| 48 | - add_action('plugins_loaded', [$this, 'plugins_loaded']); | |
| 48 | + // Runs on `init`, not `plugins_loaded`: migrate_posts() re-arms each | |
| 49 | + // notification's cron through Cron::set_cron(), and wp_schedule_event() | |
| 50 | + // -> wp_get_schedules() fires the `cron_schedules` filter, whose | |
| 51 | + // callbacks (NX Free/Pro, WooCommerce, ...) translate their interval | |
| 52 | + // labels. Doing that before `init` triggers WordPress' | |
| 53 | + // _load_textdomain_just_in_time "called too early" notice (WP 6.7+). | |
| 54 | + add_action('init', [$this, 'plugins_loaded'], 1); | |
| 49 | 55 | } |
| 50 | 56 | |
| 51 | 57 | public function plugins_loaded() { |
| 52 | 58 | // @todo check version. |
| @@ -107,8 +113,9 @@ | ||
| 107 | 113 | global $wpdb; |
| 108 | 114 | $posts = []; |
| 109 | 115 | $post_meta = []; |
| 110 | 116 | $query = "SELECT * FROM $wpdb->posts WHERE post_type = 'notificationx'"; // AND ID = $id |
| 117 | + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared -- False positive: the query is prepared via $this->wpdb->prepare(), which this sniff does not recognise, and only $wpdb->prefix table names are interpolated. Audited 2026-07-16. | |
| 111 | 118 | $_posts = $wpdb->get_results($query, ARRAY_A); |
| 112 | 119 | // $nx_ids = array_column($_posts, 'ID'); |
| 113 | 120 | |
| 114 | 121 | if(empty($_posts)) return false; |
| @@ -1208,8 +1215,9 @@ | ||
| 1208 | 1215 | ]; |
| 1209 | 1216 | $ext->update_notification($_entry); |
| 1210 | 1217 | } |
| 1211 | 1218 | } else { |
| 1219 | + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- deliberate failure logging, not debug output. | |
| 1212 | 1220 | error_log("$source not found"); |
| 1213 | 1221 | } |
| 1214 | 1222 | } |
| 1215 | 1223 | } |
| @@ -1249,9 +1257,9 @@ | ||
| 1249 | 1257 | $data = [ |
| 1250 | 1258 | 'nx_id' => $nx_id, |
| 1251 | 1259 | 'clicks' => !empty($value['clicks']) ? $value['clicks'] : 0, |
| 1252 | 1260 | 'views' => !empty($value['impressions']) ? $value['impressions'] : 0, |
| 1253 | - 'created_at' => date(Analytics::$date_format, strtotime($date)), | |
| 1261 | + 'created_at' => gmdate(Analytics::$date_format, strtotime($date)), | |
| 1254 | 1262 | ]; |
| 1255 | 1263 | $stats[] = $data; |
| 1256 | 1264 | } |
| 1257 | 1265 | } |