[wp-trac] [WordPress Trac] #61604: Split `wp_insert_post` in two
WordPress Trac
noreply at wordpress.org
Tue Jul 9 13:28:40 UTC 2024
#61604: Split `wp_insert_post` in two
------------------------------+-----------------------------
Reporter: drzraf | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version:
Severity: minor | Keywords:
Focuses: coding-standards |
------------------------------+-----------------------------
I suggest to split this function in two, after the `wp_insert_post_data`
filter (before the `if ( $update ) {` clause)
This key function is huge and its first half is idempotent but does handy
processing on a post array (filtering/sanitation/defaults).
If could be named something like `preprocess_post_data()`
By splitting it in two, the first half would become a dedicated routine a
developer could rely on in order to go from "raw" post-data to an
insertable one.
In my use-case I need to insert temporary posts (inside a temporary table
sharing the structure of wp_posts). The first half of `wp_insert_post` is
exactly how I would like to process my data but I've currently no way to
reuse that code.
Another benefit would be more granular and easier-to-test interfaces.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61604>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list