[wp-trac] [WordPress Trac] #21963: Consolidate post insertion APIs
WordPress Trac
wp-trac at lists.automattic.com
Sat Sep 22 03:46:24 UTC 2012
#21963: Consolidate post insertion APIs
-------------------+--------------------------
Reporter: nacin | Type: defect (bug)
Status: new | Priority: normal
Milestone: 3.5 | Component: Post Types
Version: | Severity: normal
Keywords: |
-------------------+--------------------------
In wp-includes, we have:
* wp_insert_post()
* wp_insert_attachment()
* wp_update_post()
* wp_publish_post()
For saving from the admin, we have:
* edit_post()
* wp_write_post()
* write_post()
'''wp_publish_post()''' is, as of [21942], now wraps wp_insert_post().
'''wp_update_post()''' is a fairly mundane wrapper of wp_insert_post(),
but we really should eliminate the differences between the two functions
and make it a straight-up wrapper.
'''wp_insert_attachment()''' was a fork of wp_insert_post(), and
wp_insert_post() has gotten a lot of improvements that haven't reached
wp_insert_attachment(). It doesn't take much to merge these two, though,
and make wp_insert_attachment() a wrapper.
'''wp_write_post()''' calls edit_post() if it has a post ID. And since we
have had a post ID since the days of auto-drafts, this function is dead
code. It's wrapper, '''write_post()''', can also be deprecated.
I'm attaching a patch that takes care of wp_insert_post(),
wp_write_post(), and write_post(). wp_update_post() will require a bit
more concentration.
Needs testing and unit tests.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21963>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list