Allow wp_update_post() to accept the same second argument as wp_insert_post(), allowing for WP_Error return values on failure. props scribu, mikeschinkel. fixes #15036.

git-svn-id: http://core.svn.wordpress.org/trunk@21213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2012-07-05 19:21:57 +00:00
parent 813ca40b2f
commit 60b88004a6
1 changed files with 4 additions and 3 deletions

View File

@ -2710,9 +2710,10 @@ function wp_insert_post($postarr, $wp_error = false) {
* @since 1.0.0 * @since 1.0.0
* *
* @param array|object $postarr Post data. Arrays are expected to be escaped, objects are not. * @param array|object $postarr Post data. Arrays are expected to be escaped, objects are not.
* @return int 0 on failure, Post ID on success. * @param bool $wp_error Optional. Allow return of WP_Error on failure.
* @return int|WP_Error The value 0 or WP_Error on failure. The post ID on success.
*/ */
function wp_update_post($postarr = array()) { function wp_update_post( $postarr = array(), $wp_error = false ) {
if ( is_object($postarr) ) { if ( is_object($postarr) ) {
// non-escaped post was passed // non-escaped post was passed
$postarr = get_object_vars($postarr); $postarr = get_object_vars($postarr);
@ -2750,7 +2751,7 @@ function wp_update_post($postarr = array()) {
if ($postarr['post_type'] == 'attachment') if ($postarr['post_type'] == 'attachment')
return wp_insert_attachment($postarr); return wp_insert_attachment($postarr);
return wp_insert_post($postarr); return wp_insert_post( $postarr, $wp_error );
} }
/** /**