// includes/logging.php class Campaign_Logger { private static $log = []; private static $campaign_id; public static function init($campaign_id) { self::$campaign_id = $campaign_id; self::$log = []; } public static function add($message, $type = 'info') { $log_entry = [ 'timestamp' => current_time('mysql'), 'type' => $type, 'message' => $message ]; self::$log[] = $log_entry; update_post_meta( self::$campaign_id, '_campaign_logs', array_slice(array_merge(self::$log, (array)get_post_meta(self::$campaign_id, '_campaign_logs', true)), 0, 50) ); } public static function get_logs() { return get_post_meta(self::$campaign_id, '_campaign_logs', true); } public static function clear_logs() { delete_post_meta(self::$campaign_id, '_campaign_logs'); } }