PostInsert final readonly class
Minn\Runtime\PostInsert · public/minn/src/Minn/Runtime/PostInsert.php · 168 lines
The decisions behind wp_insert_post: which columns a postarr fills, when the post counts as empty, the status a publish request lands in, the dates and the slug, the categories a new post gets. The rows are written by Content\PostWriter; the facade fires the hooks around each step.
Constants and properties
| private | COLUMNS = array ( 0 => 'post_author', 1 => 'post_date', 2 => 'post_date_gmt', 3 => 'post_content', 4 => 'post_title', 5 => 'post_excerpt', 6 => 'post_status', 7 => 'comment_status', 8 => 'ping_status', 9 => 'post_password', 10 => 'post_name', 11 => 'to_ping', 12 => 'pinged', 13 => 'post_modified', 14 => 'post_modified_gmt', 15 => 'post_content_filtered', 16 => 'post_parent', 17 => 'guid', 18 => 'menu_order', 19 => 'post_type', 20 => 'post_mime_type', ) | |
| private | readonly Minn\Content\PostWriter $writer | Promoted from the constructor. |
| private | readonly int $userId | Promoted from the constructor. |
| private | readonly Closure $discussion | Promoted from the constructor. |
| private | readonly Closure $supports | Promoted from the constructor. |
| private | readonly Closure $canPublish | Promoted from the constructor. |
| private | readonly Closure $gmtFromDate | Promoted from the constructor. |
| private | readonly Closure $now | Promoted from the constructor. |
Public
| new | __construct(Minn\Content\PostWriter $writer, int $userId, Closure $discussion, Closure $supports, Closure $canPublish, Closure $gmtFromDate, Closure $now)# |
| |||||||||||||||
| method | columns(array $postarr, ?array $existing): array# | The columns the posts table takes, filled from a postarr, with a new post's defaults. @param array<string, mixed>|null $existing @return array<string, string>
| |||||||||||||||
| method | isEmpty(array $columns, ?array $existing): bool# | A post with nothing in title, content, and excerpt is empty when its type supports all three. @param array<string, mixed>|null $existing
| |||||||||||||||
| method | resolve(array $columns, ?array $existing): array# | The columns as they will be written: the status a request lands in (attachments inherit, unprivileged publishes pend, a future date schedules), the dates, the slug (sanitized; not yet free), and the integer columns.
@return array<string, string> | |||||||||||||||
| method | persist(array $columns, ?int $existingId, Closure $guid): int# | Writes the resolved columns; a new post without a guid gets the ?p= form. @return int the post id | |||||||||||||||
| static | categories(array $postarr, string $type, string $status, bool $update, array $taxonomies, int $default): ?array# | The categories a saved post should carry: the ones given, or the default for a new post of a type that has categories; null when nothing should change.
@return list<int>|null |
Internals 1
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | type(array $columns, ?array $existing): string# |
Nothing matches.