X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/a6f44f0edcda2471c5a33e4156c1c9488c7f3210..fa11948979fd6a4ea5705dc613b239699a459db3:/wp-admin/includes/post.php diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index f5324bff..7d074dd7 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -52,7 +52,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { if ( isset($post_data['trackback_url']) ) $post_data['to_ping'] = $post_data['trackback_url']; - $post_data['user_ID'] = $GLOBALS['user_ID']; + $post_data['user_ID'] = get_current_user_id(); if (!empty ( $post_data['post_author_override'] ) ) { $post_data['post_author'] = (int) $post_data['post_author_override']; @@ -178,6 +178,15 @@ function edit_post( $post_data = null ) { wp_die( __('You are not allowed to edit this post.' )); } + if ( post_type_supports( $ptype->name, 'revisions' ) ) { + $revisions = wp_get_post_revisions( $post_ID, array( 'order' => 'ASC', 'posts_per_page' => 1 ) ); + $revision = current( $revisions ); + + // Check if the revisions have been upgraded + if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) + _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); + } + $post_data = _wp_translate_postdata( true, $post_data ); if ( is_wp_error($post_data) ) wp_die( $post_data->get_error_message() ); @@ -261,12 +270,13 @@ function edit_post( $post_data = null ) { } $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array(); + /** This filter is documented in wp-admin/includes/media.php */ $post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data ); } add_meta( $post_ID ); - update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); + update_post_meta( $post_ID, '_edit_last', get_current_user_id() ); wp_update_post( $post_data ); @@ -324,7 +334,13 @@ function bulk_edit_posts( $post_data = null ) { $post_IDs = array_map( 'intval', (array) $post_data['post'] ); - $reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'tax_input', 'post_category', 'sticky' ); + $reset = array( + 'post_author', 'post_status', 'post_password', + 'post_parent', 'page_template', 'comment_status', + 'ping_status', 'keep_private', 'tax_input', + 'post_category', 'sticky', 'post_format', + ); + foreach ( $reset as $field ) { if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) unset($post_data[$field]); @@ -418,6 +434,9 @@ function bulk_edit_posts( $post_data = null ) { else unstick_post( $post_ID ); } + + if ( isset( $post_data['post_format'] ) ) + set_post_format( $post_ID, $post_data['post_format'] ); } return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked ); @@ -529,8 +548,6 @@ function post_exists($title, $content = '', $date = '') { * @return unknown */ function wp_write_post() { - global $user_ID; - if ( isset($_POST['post_type']) ) $ptype = get_post_type_object($_POST['post_type']); else @@ -741,15 +758,15 @@ function update_meta( $meta_id, $meta_key, $meta_value ) { * @since 2.3.0 * @access private * - * @param unknown_type $post_ID - * @return unknown + * @param int|object $post Post ID or post object. + * @return void|int|WP_Error Void if nothing fixed. 0 or WP_Error on update failure. The post ID on update success. */ -function _fix_attachment_links( $post_ID ) { - $post = get_post( $post_ID, ARRAY_A ); +function _fix_attachment_links( $post ) { + $post = get_post( $post, ARRAY_A ); $content = $post['post_content']; - // quick sanity check, don't run if no pretty permalinks or post is not published - if ( !get_option('permalink_structure') || $post['post_status'] != 'publish' ) + // Don't run if no pretty permalinks or post is not published, scheduled, or privately published. + if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) return; // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero) @@ -995,9 +1012,9 @@ function postbox_classes( $id, $page ) { * @return array With two entries of type string */ function get_sample_permalink($id, $title = null, $name = null) { - $post = get_post($id); - if ( !$post->ID ) - return array('', ''); + $post = get_post( $id ); + if ( ! $post ) + return array( '', '' ); $ptype = get_post_type_object($post->post_type); @@ -1057,8 +1074,9 @@ function get_sample_permalink($id, $title = null, $name = null) { * @return string The HTML of the sample permalink slug editor. */ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { - global $wpdb; - $post = get_post($id); + $post = get_post( $id ); + if ( ! $post ) + return ''; list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); @@ -1260,7 +1278,13 @@ function _admin_notice_post_locked() { ?>
ID, 64 ); ?>
-

display_name ) ); ?>

+

+ display_name ) ); + ?> +