diff --git a/wp-admin/async-upload.php b/wp-admin/async-upload.php index 4c225c4fda..8ee85fc1f8 100644 --- a/wp-admin/async-upload.php +++ b/wp-admin/async-upload.php @@ -25,7 +25,7 @@ if ( !current_user_can('upload_files') ) wp_die(__('You do not have permission to upload files.')); // just fetch the detail form for that attachment -if ( ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) { +if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) { if ( 2 == $_REQUEST['fetch'] ) { add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2); echo get_media_item($id, array( 'send' => false, 'delete' => false )); diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php index d1b88ec73b..6bbeeb080c 100644 --- a/wp-admin/edit-link-form.php +++ b/wp-admin/edit-link-form.php @@ -343,12 +343,7 @@ require_once ('admin-header.php');

-

' . __('Link added.') . '

' : ''; -?> - - +

diff --git a/wp-admin/includes/bookmark.php b/wp-admin/includes/bookmark.php index 8ee7d39b21..88bd03035c 100644 --- a/wp-admin/includes/bookmark.php +++ b/wp-admin/includes/bookmark.php @@ -34,7 +34,7 @@ function edit_link( $link_id = '' ) { $_POST['link_name'] = wp_specialchars( $_POST['link_name'] ); $_POST['link_image'] = wp_specialchars( $_POST['link_image'] ); $_POST['link_rss'] = clean_url($_POST['link_rss']); - if ( 'N' != $_POST['link_visible'] ) + if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] ) $_POST['link_visible'] = 'Y'; if ( !empty( $link_id ) ) { @@ -176,7 +176,7 @@ function wp_insert_link( $linkdata, $wp_error = false ) { $link_rel = ''; // Make sure we set a valid category - if ( 0 == count( $link_category ) || !is_array( $link_category ) ) { + if ( ! isset( $link_category ) ||0 == count( $link_category ) || !is_array( $link_category ) ) { $link_category = array( get_option( 'default_link_category' ) ); } @@ -265,4 +265,4 @@ function wp_update_link( $linkdata ) { return wp_insert_link( $linkdata ); } -?> \ No newline at end of file +?> diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index cd621cfd68..51ddbbf0d2 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -177,11 +177,13 @@ function wp_dashboard_right_now() { echo "\n\t".''; // Posts - $num = number_format_i18n( $num_posts->publish ); + $num = isset($num_posts->publish) ? number_format_i18n( $num_posts->publish ) : 0; if ( current_user_can( 'edit_posts' ) ) - $num = "$num"; - echo ''.$num.''; - echo '' . __ngettext( 'Post', 'Posts', $num_posts->publish ) . ''; + $text = "$num"; + else + $text = $num; + echo '' . $text . ''; + echo '' . __ngettext( 'Post', 'Posts', $num ) . ''; /* TODO: Show status breakdown on hover if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds. Don't show if !current_user_can $post_type_texts[] = ''.sprintf( __ngettext( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).''; diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index a0cf49a54f..9c8ec0b620 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -224,6 +224,9 @@ function wp_handle_upload( &$file, $overrides = false, $time = null ) { // You may define your own function and pass the name in $overrides['upload_error_handler'] $upload_error_handler = 'wp_handle_upload_error'; + // You may define your own function and pass the name in $overrides['unique_filename_callback'] + $unique_filename_callback = null; + // $_POST['action'] must be set and its value must equal $overrides['action'] or this: $action = 'wp_handle_upload'; diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 6e123d566d..551720a7b9 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -209,7 +209,7 @@ function media_handle_upload($file_id, $post_id, $post_data = array()) { ), $post_data ); // Save the data - $id = wp_insert_attachment($attachment, $file, $post_parent); + $id = wp_insert_attachment($attachment, $file, $post_id); if ( !is_wp_error($id) ) { wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); } @@ -989,10 +989,8 @@ function get_media_items( $post_id, $errors ) { $attachments[$attachment->ID] = $attachment; } - if ( empty($attachments) ) - return ''; - - foreach ( $attachments as $id => $attachment ) + $output = ''; + foreach ( (array) $attachments as $id => $attachment ) if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) ) $output .= "\n
$item\n
"; @@ -1039,6 +1037,7 @@ function get_media_item( $attachment_id, $args = null ) { $tags = attribute_escape(join(', ', $tags)); } + $type = ''; if ( isset($post_mime_types) ) { $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type)); $type = array_shift($keys); diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 62ed101302..7c44c40d92 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -153,18 +153,20 @@ function edit_post( $post_data = null ) { if ( is_wp_error($post_data) ) wp_die( $post_data->get_error_message() ); - switch ( $post_data['visibility'] ) { - case 'public' : - unset( $post_data['post_password'] ); - break; - case 'password' : - unset( $post_data['sticky'] ); - break; - case 'private' : - $post_data['post_status'] = 'private'; - $post_data['post_password'] = ''; - unset( $post_data['sticky'] ); - break; + if ( isset($post_data['visibility']) ) { + switch ( $post_data['visibility'] ) { + case 'public' : + unset( $post_data['post_password'] ); + break; + case 'password' : + unset( $post_data['sticky'] ); + break; + case 'private' : + $post_data['post_status'] = 'private'; + $post_data['post_password'] = ''; + unset( $post_data['sticky'] ); + break; + } } // Meta Stuff @@ -337,6 +339,7 @@ function get_default_post_to_edit() { $post->post_name = ''; $post->post_author = ''; $post->post_date = ''; + $post->post_password = ''; $post->post_status = 'draft'; $post->post_type = 'post'; $post->to_ping = ''; @@ -456,18 +459,20 @@ function wp_write_post() { if ( is_wp_error($translated) ) return $translated; - switch ( $_POST['visibility'] ) { - case 'public' : - $_POST['post_password'] = ''; - break; - case 'password' : - unset( $_POST['sticky'] ); - break; - case 'private' : - $_POST['post_status'] = 'private'; - $_POST['post_password'] = ''; - unset( $_POST['sticky'] ); - break; + if ( isset($_POST['visibility']) ) { + switch ( $_POST['visibility'] ) { + case 'public' : + $_POST['post_password'] = ''; + break; + case 'password' : + unset( $_POST['sticky'] ); + break; + case 'private' : + $_POST['post_status'] = 'private'; + $_POST['post_password'] = ''; + unset( $_POST['sticky'] ); + break; + } } // Create the post. diff --git a/wp-admin/user-new.php b/wp-admin/user-new.php index 126e10d09f..5fc5f60326 100644 --- a/wp-admin/user-new.php +++ b/wp-admin/user-new.php @@ -22,12 +22,12 @@ if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) { wp_die(__('You can’t create users.')); $user_id = add_user(); - $update = 'add'; - if ( is_wp_error( $user_id ) ) + + if ( is_wp_error( $user_id ) ) { $add_user_errors = $user_id; - else { + } else { $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true)); - $redirect = add_query_arg( array('usersearch' => urlencode($new_user_login), 'update' => $update), $redirect ); + $redirect = 'users.php?usersearch='. urlencode($new_user_login) . '&update=add'; wp_redirect( $redirect . '#user-' . $user_id ); die(); } @@ -78,6 +78,15 @@ if ( ! empty($messages) ) { ?>
+ 'login', 'first_name' => 'firstname', 'last_name' => 'lastname', + 'email' => 'email', 'url' => 'uri', 'role' => 'role') as $post_field => $var ) { + $var = "new_user_$var"; + if ( ! isset($$var) ) + $$var = isset($_POST[$post_field]) ? stripslashes($_POST[$post_field]) : ''; +} +?> @@ -114,7 +123,7 @@ if ( ! empty($messages) ) {
@@ -122,7 +131,6 @@ if ( ! empty($messages) ) {

-

diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php index c16721d9f8..4a031ee5b4 100644 --- a/wp-includes/bookmark.php +++ b/wp-includes/bookmark.php @@ -265,15 +265,22 @@ function sanitize_bookmark($bookmark, $context = 'display') { 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_updated', 'link_rel', 'link_notes', 'link_rss', ); - $do_object = false; - if ( is_object($bookmark) ) + if ( is_object($bookmark) ) { $do_object = true; + $link_id = $bookmark->link_id; + } else { + $do_object = false; + $link_id = $bookmark['link_id']; + } foreach ( $fields as $field ) { - if ( $do_object ) - $bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context); - else - $bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $bookmark['link_id'], $context); + if ( $do_object ) { + if ( isset($bookmark->$field) ) + $bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $link_id, $context); + } else { + if ( isset($bookmark[$field]) ) + $bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $link_id, $context); + } } return $bookmark; diff --git a/wp-includes/post.php b/wp-includes/post.php index 8d64004b65..f72c44fc22 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1677,6 +1677,7 @@ function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) { if ( empty($tags) ) $tags = array(); $tags = (is_array($tags)) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") ); + $tags = array_map('trim', $tags); //Trim whitespace from around the tags. wp_set_object_terms($post_id, $tags, 'post_tag', $append); } @@ -2158,8 +2159,10 @@ function &get_pages($args = '') { $pages = $wpdb->get_results($query); - if ( empty($pages) ) - return apply_filters('get_pages', array(), $r); + if ( empty($pages) ) { + $page = apply_filters('get_pages', array(), $r); + return $pages; + } // Update cache. update_page_cache($pages); @@ -2261,7 +2264,7 @@ function wp_insert_attachment($object, $file = false, $parent = 0) { extract($object, EXTR_SKIP); // Make sure we set a valid category - if (0 == count($post_category) || !is_array($post_category)) { + if ( !isset($post_category) || 0 == count($post_category) || !is_array($post_category)) { $post_category = array(get_option('default_category')); } @@ -2272,10 +2275,12 @@ function wp_insert_attachment($object, $file = false, $parent = 0) { $post_status = 'inherit'; // Are we updating or creating? - $update = false; if ( !empty($ID) ) { $update = true; $post_ID = (int) $ID; + } else { + $update = false; + $post_ID = 0; } // Create a valid post name. @@ -3241,8 +3246,8 @@ function _wp_post_revision_fields( $post = null, $autosave = false ) { $return['post_status'] = 'inherit'; $return['post_type'] = 'revision'; $return['post_name'] = $autosave ? "$post[ID]-autosave" : "$post[ID]-revision"; - $return['post_date'] = $post['post_modified']; - $return['post_date_gmt'] = $post['post_modified_gmt']; + $return['post_date'] = isset($post['post_modified']) ? $post['post_modified'] : ''; + $return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : ''; return $return; } diff --git a/wp-includes/registration.php b/wp-includes/registration.php index 591aa9691c..aee3ae149f 100644 --- a/wp-includes/registration.php +++ b/wp-includes/registration.php @@ -164,6 +164,15 @@ function wp_insert_user($userdata) { if ( empty($use_ssl) ) $use_ssl = 0; + if ( empty($jabber) ) + $jabber = ''; + + if ( empty($aim) ) + $aim = ''; + + if ( empty($yim) ) + $yim = ''; + if ( empty($user_registered) ) $user_registered = gmdate('Y-m-d H:i:s'); diff --git a/wp-includes/rss.php b/wp-includes/rss.php index e3ffb19266..0d70fba2c6 100644 --- a/wp-includes/rss.php +++ b/wp-includes/rss.php @@ -459,7 +459,7 @@ function fetch_rss ($url) { // setup headers if ( $cache_status == 'STALE' ) { $rss = $cache->get( $url ); - if ( $rss->etag and $rss->last_modified ) { + if ( isset($rss->etag) and $rss->last_modified ) { $request_headers['If-None-Match'] = $rss->etag; $request_headers['If-Last-Modified'] = $rss->last_modified; } @@ -564,7 +564,7 @@ function _response_to_rss ($resp) { $rss = new MagpieRSS( $resp->results ); // if RSS parsed successfully - if ( $rss && !$rss->ERROR) { + if ( $rss && (!isset($rss->ERROR) || !$rss->ERROR) ) { // find Etag, and Last-Modified foreach( (array) $resp->headers as $h) { diff --git a/wp-login.php b/wp-login.php index 6dc6d769f2..a59463ca30 100644 --- a/wp-login.php +++ b/wp-login.php @@ -294,16 +294,19 @@ case 'retrievepassword' : } } - if ( 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.')); + if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.')); do_action('lost_password'); login_header(__('Lost Password'), '

' . __('Please enter your username or e-mail address. You will receive a new password via e-mail.') . '

', $errors); + + $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; + ?>

+