Ryan slays the dragon. (Some of these return WP_Error objects.)
git-svn-id: http://svn.automattic.com/wordpress/trunk@5089 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -115,8 +115,8 @@ case 'add-category' : // On the Fly
|
||||
$cat_name = trim($cat_name);
|
||||
if ( !$category_nicename = sanitize_title($cat_name) )
|
||||
die('0');
|
||||
if ( !$cat_id = (int) category_exists( $cat_name ) )
|
||||
$cat_id = (int) wp_create_category( $cat_name );
|
||||
if ( !$cat_id = category_exists( $cat_name ) )
|
||||
$cat_id = wp_create_category( $cat_name );
|
||||
$cat_name = wp_specialchars(stripslashes($cat_name));
|
||||
$x->add( array(
|
||||
'what' => 'category',
|
||||
@@ -156,13 +156,13 @@ case 'add-meta' :
|
||||
die('-1');
|
||||
if ( $id < 0 ) {
|
||||
$now = current_time('timestamp', 1);
|
||||
if ( $pid = (int) wp_insert_post( array(
|
||||
if ( $pid = wp_insert_post( array(
|
||||
'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now))
|
||||
) ) )
|
||||
$mid = (int) add_meta( $pid );
|
||||
$mid = add_meta( $pid );
|
||||
else
|
||||
die('0');
|
||||
} else if ( !$mid = (int) add_meta( $id ) ) {
|
||||
} else if ( !$mid = add_meta( $id ) ) {
|
||||
die('0');
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ case 'add-user' :
|
||||
if ( !current_user_can('edit_users') )
|
||||
die('-1');
|
||||
require_once(ABSPATH . WPINC . '/registration.php');
|
||||
if ( !$user_id = (int) add_user() )
|
||||
if ( !$user_id = add_user() )
|
||||
die('0');
|
||||
elseif ( is_wp_error( $user_id ) ) {
|
||||
foreach( $user_id->get_error_messages() as $message )
|
||||
@@ -230,8 +230,8 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
|
||||
|
||||
if($_POST['post_ID'] < 0) {
|
||||
$_POST['temp_ID'] = $_POST['post_ID'];
|
||||
$id = (int) wp_write_post();
|
||||
if(is_wp_error($id))
|
||||
$id = wp_write_post();
|
||||
if( is_wp_error($id) )
|
||||
die($id->get_error_message());
|
||||
else
|
||||
die("$id");
|
||||
|
||||
@@ -562,9 +562,9 @@ function edit_user( $user_id = 0 ) {
|
||||
return $errors;
|
||||
|
||||
if ( $update ) {
|
||||
$user_id = (int) wp_update_user( get_object_vars( $user ));
|
||||
$user_id = wp_update_user( get_object_vars( $user ));
|
||||
} else {
|
||||
$user_id = (int) wp_insert_user( get_object_vars( $user ));
|
||||
$user_id = wp_insert_user( get_object_vars( $user ));
|
||||
wp_new_user_notification( $user_id );
|
||||
}
|
||||
return $user_id;
|
||||
@@ -1969,7 +1969,7 @@ function wp_import_handle_upload() {
|
||||
);
|
||||
|
||||
// Save the data
|
||||
$id = (int) wp_insert_attachment( $object, $file );
|
||||
$id = wp_insert_attachment( $object, $file );
|
||||
|
||||
return array( 'file' => $file, 'id' => $id );
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ Event.observe( window, 'load', hide_text );
|
||||
'guid' => $url);
|
||||
|
||||
// Save the data
|
||||
$id = (int) wp_insert_attachment($object, $file);
|
||||
$id = wp_insert_attachment($object, $file);
|
||||
|
||||
$upload = array('file' => $file, 'id' => $id);
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ class WP_Import {
|
||||
if ( empty($parent) )
|
||||
$category_parent = '0';
|
||||
else
|
||||
$category_parent = (int) category_exists($parent);
|
||||
$category_parent = category_exists($parent);
|
||||
|
||||
$catarr = compact('category_nicename', 'category_parent', 'posts_private', 'links_private', 'posts_private', 'cat_name');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user