From b137f4ce021b4022c56f452c2eafa7abfcef0a7c Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 17 Jul 2011 09:11:59 -0400 Subject: [PATCH 1/1] Wordpress 3.1.4 Signed-off-by: Edward Z. Yang --- readme.html | 2 +- wp-admin/custom-header.php | 3 +- wp-admin/includes/deprecated.php | 4 +- wp-admin/includes/media.php | 13 +++++ wp-admin/includes/post.php | 25 ++++++++- wp-admin/includes/update-core.php | 2 +- wp-admin/js/user-profile.dev.js | 56 ++++++++++--------- wp-admin/js/user-profile.js | 2 +- wp-admin/options-general.php | 2 +- .../themes/twentyten/languages/twentyten.pot | 12 +++- wp-includes/bookmark.php | 20 +++++-- wp-includes/formatting.php | 16 +++++- wp-includes/post.php | 42 ++++++++++++++ wp-includes/query.php | 16 ++++-- wp-includes/script-loader.php | 2 +- wp-includes/taxonomy.php | 6 ++ wp-includes/version.php | 2 +- wp-includes/wp-db.php | 1 + wp-settings.php | 2 +- 19 files changed, 175 insertions(+), 53 deletions(-) diff --git a/readme.html b/readme.html index 0939107c..4b4f36ce 100644 --- a/readme.html +++ b/readme.html @@ -8,7 +8,7 @@

WordPress -
Version 3.1.3 +
Version 3.1.4

Semantic Personal Publishing Platform

diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php index bf5f4157..cdd58fa9 100644 --- a/wp-admin/custom-header.php +++ b/wp-admin/custom-header.php @@ -596,7 +596,8 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> 'post_content' => $url, 'post_mime_type' => $type, 'guid' => $url, - 'context' => 'custom-header'); + 'context' => 'custom-header' + ); // Save the data $id = wp_insert_attachment($object, $file); diff --git a/wp-admin/includes/deprecated.php b/wp-admin/includes/deprecated.php index b91c64fc..a318f0ee 100644 --- a/wp-admin/includes/deprecated.php +++ b/wp-admin/includes/deprecated.php @@ -454,7 +454,7 @@ class WP_User_Search { function WP_User_Search ($search_term = '', $page = '', $role = '') { _deprecated_function( __FUNCTION__, '3.1', 'WP_User_Query' ); - $this->search_term = $search_term; + $this->search_term = stripslashes( $search_term ); $this->raw_page = ( '' == $page ) ? false : (int) $page; $this->page = (int) ( '' == $page ) ? 1 : $page; $this->role = $role; @@ -485,7 +485,7 @@ class WP_User_Search { $searches = array(); $search_sql = 'AND ('; foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) - $searches[] = $col . " LIKE '%$this->search_term%'"; + $searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' ); $search_sql .= implode(' OR ', $searches); $search_sql .= ')'; } diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 7e27ded1..99deac5a 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -228,6 +228,10 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override 'post_content' => $content, ), $post_data ); + // This should never be set as it would then overwrite an existing attachment. + if ( isset( $attachment['ID'] ) ) + unset( $attachment['ID'] ); + // Save the data $id = wp_insert_attachment($attachment, $file, $post_id); if ( !is_wp_error($id) ) { @@ -281,6 +285,10 @@ function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = 'post_content' => $content, ), $post_data ); + // This should never be set as it would then overwrite an existing attachment. + if ( isset( $attachment['ID'] ) ) + unset( $attachment['ID'] ); + // Save the attachment metadata $id = wp_insert_attachment($attachment, $file, $post_id); if ( !is_wp_error($id) ) @@ -419,6 +427,11 @@ function media_upload_form_handler() { if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { $post = $_post = get_post($attachment_id, ARRAY_A); + $post_type_object = get_post_type_object( $post[ 'post_type' ] ); + + if ( !current_user_can( $post_type_object->cap->edit_post, $attachment_id ) ) + continue; + if ( isset($attachment['post_content']) ) $post['post_content'] = $attachment['post_content']; if ( isset($attachment['post_title']) ) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index bb6f469f..3f4d6f11 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -135,6 +135,9 @@ function edit_post( $post_data = null ) { if ( empty($post_data) ) $post_data = &$_POST; + // Clear out any data in internal vars. + unset( $post_data['filter'] ); + $post_ID = (int) $post_data['post_ID']; $post = get_post( $post_ID ); $post_data['post_type'] = $post->post_type; @@ -341,7 +344,8 @@ function bulk_edit_posts( $post_data = null ) { continue; } - $tax_names = get_object_taxonomies( get_post($post_ID) ); + $post = get_post( $post_ID ); + $tax_names = get_object_taxonomies( $post ); foreach ( $tax_names as $tax_name ) { $taxonomy_obj = get_taxonomy($tax_name); if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) @@ -363,6 +367,9 @@ function bulk_edit_posts( $post_data = null ) { unset( $post_data['tax_input']['category'] ); } + $post_data['post_mime_type'] = $post->post_mime_type; + $post_data['guid'] = $post->guid; + $post_data['ID'] = $post_ID; $updated[] = wp_update_post( $post_data ); @@ -534,6 +541,9 @@ function wp_write_post() { $_POST['post_mime_type'] = ''; + // Clear out any data in internal vars. + unset( $_POST['filter'] ); + // Check for autosave collisions // Does this need to be updated? ~ Mark $temp_id = false; @@ -553,6 +563,15 @@ function wp_write_post() { } } + // Edit don't write if we have a post id. + if ( isset( $_POST['ID'] ) ) { + $_POST['post_ID'] = $_POST['ID']; + unset ( $_POST['ID'] ); + } + if ( isset( $_POST['post_ID'] ) ) { + return edit_post(); + } + $translated = _wp_translate_postdata( false ); if ( is_wp_error($translated) ) return $translated; @@ -997,9 +1016,9 @@ function wp_edit_attachments_query( $q = false ) { $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; $q['post_type'] = 'attachment'; $post_type = get_post_type_object( 'attachment' ); - $states = array( 'inherit' ); + $states = 'inherit'; if ( current_user_can( $post_type->cap->read_private_posts ) ) - $states[] = 'private'; + $states .= ',private'; $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states; $media_per_page = (int) get_user_option( 'upload_per_page' ); diff --git a/wp-admin/includes/update-core.php b/wp-admin/includes/update-core.php index 0673363b..6fceb8bd 100644 --- a/wp-admin/includes/update-core.php +++ b/wp-admin/includes/update-core.php @@ -294,7 +294,7 @@ function update_core($from, $to) { $mysql_version = $wpdb->db_version(); $required_php_version = '4.3'; $required_mysql_version = '4.1.2'; - $wp_version = '3.1.3'; + $wp_version = '3.1.4'; $php_compat = version_compare( $php_version, $required_php_version, '>=' ); $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' ); diff --git a/wp-admin/js/user-profile.dev.js b/wp-admin/js/user-profile.dev.js index 4a2f39d6..adffa951 100644 --- a/wp-admin/js/user-profile.dev.js +++ b/wp-admin/js/user-profile.dev.js @@ -29,37 +29,39 @@ } } - $(document).ready( function() { + $(document).ready(function() { $('#pass1').val('').keyup( check_pass_strength ); $('#pass2').val('').keyup( check_pass_strength ); $('#pass-strength-result').show(); - $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')}); - $('#nickname').blur(function(){ - var str = $(this).val() || $('#user_login').val(); - var select = $('#display_name'); - var sel = select.children('option:selected').attr('id'); - select.children('#display_nickname').remove(); - if ( ! select.children('option[value=' + str + ']').length ) - select.append(''); - $('#'+sel).attr('selected', 'selected'); - }); - $('#first_name, #last_name').blur(function(){ - var select = $('#display_name'); - var first = $('#first_name').val(), last = $('#last_name').val(); - var sel = select.children('option:selected').attr('id'); - $('#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst').remove(); - if ( first && ! select.children('option[value=' + first + ']').length ) - select.append(''); - if ( last && ! select.children('option[value=' + last + ']').length ) - select.append(''); - if ( first && last ) { - if ( ! select.children('option[value=' + first + ' ' + last + ']').length ) - select.append(''); - if ( ! select.children('option[value=' + last + ' ' + first + ']').length ) - select.append(''); + $('.color-palette').click(function(){$(this).siblings('input[name="admin_color"]').prop('checked', true)}); + $('#first_name, #last_name, #nickname').blur(function(){ + var select = $('#display_name'), current = select.find('option:selected').attr('id'), dub = [], + inputs = { + display_nickname : $('#nickname').val(), + display_username : $('#user_login').val(), + display_firstname : $('#first_name').val(), + display_lastname : $('#last_name').val() + }; + + if ( inputs.display_firstname && inputs.display_lastname ) { + inputs['display_firstlast'] = inputs.display_firstname + ' ' + inputs.display_lastname; + inputs['display_lastfirst'] = inputs.display_lastname + ' ' + inputs.display_firstname; } - $('#'+sel).attr('selected', 'selected'); + + $('option', select).remove(); + $.each(inputs, function( id, value ) { + var val = value.replace(/<\/?[a-z][^>]*>/gi, ''); + + if ( inputs[id].length && $.inArray( val, dub ) == -1 ) { + dub.push(val); + $('")}a("#"+d).attr("selected","selected")});a("#first_name, #last_name").blur(function(){var c=a("#display_name");var f=a("#first_name").val(),d=a("#last_name").val();var e=c.children("option:selected").attr("id");a("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(f&&!c.children("option[value="+f+"]").length){c.append('")}if(d&&!c.children("option[value="+d+"]").length){c.append('")}if(f&&d){if(!c.children("option[value="+f+" "+d+"]").length){c.append('")}if(!c.children("option[value="+d+" "+f+"]").length){c.append('")}}a("#"+e).attr("selected","selected")})})})(jQuery); \ No newline at end of file +(function(a){function b(){var e=a("#pass1").val(),d=a("#user_login").val(),c=a("#pass2").val(),f;a("#pass-strength-result").removeClass("short bad good strong");if(!e){a("#pass-strength-result").html(pwsL10n.empty);return}f=passwordStrength(e,d,c);switch(f){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:a("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){a("#pass1").val("").keyup(b);a("#pass2").val("").keyup(b);a("#pass-strength-result").show();a(".color-palette").click(function(){a(this).siblings('input[name="admin_color"]').prop("checked",true)});a("#first_name, #last_name, #nickname").blur(function(){var c=a("#display_name"),e=c.find("option:selected").attr("id"),f=[],d={display_nickname:a("#nickname").val(),display_username:a("#user_login").val(),display_firstname:a("#first_name").val(),display_lastname:a("#last_name").val()};if(d.display_firstname&&d.display_lastname){d.display_firstlast=d.display_firstname+" "+d.display_lastname;d.display_lastfirst=d.display_lastname+" "+d.display_firstname}a("option",c).remove();a.each(d,function(i,g){var h=g.replace(/<\/?[a-z][^>]*>/gi,"");if(d[i].length&&a.inArray(h,f)==-1){f.push(h);a("