'flamingo_inbound', 'post_status' => ['flamingo-spam', 'flamingo-inbound', 'publish'], 'posts_per_page' => 5, 'orderby' => 'date', 'order' => 'DESC', 'date_query' => [[ 'after' => gmdate('Y-m-d H:i:s', time() - 30), 'inclusive' => true, ]], ]); if (!$posts) return null; // Prefer the first (most recent) — Flamingo writes one row per submission. return (int)$posts[0]->ID; } /** * Extract fields from a Flamingo inbound post. * * @return array */ public static function extract_fields(\WP_Post $post): array { $fields = get_post_meta($post->ID, '_fields', true); if (is_array($fields)) return $fields; // Fallback: meta stored under Flamingo's structure $meta = get_post_meta($post->ID); $out = []; foreach ($meta as $key => $values) { if (strpos($key, '_field_') === 0) { $out[substr($key, strlen('_field_'))] = maybe_unserialize($values[0] ?? ''); } } return $out; } public static function extract_reason(\WP_Post $post): string { $log = (string)get_post_meta($post->ID, '_akismet', true); if ($log !== '') return 'Akismet'; return 'Неизвестно'; } }