X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/baca9ce86a38dc54c4574890ee2d352fd81f78b2..61343b82c4f0da4c68e4c6373daafff4a81efdd1:/wp-admin/edit-form-advanced.php diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index fdf21139..f3a65e52 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -29,6 +29,9 @@ if ( post_type_supports($post_type, 'editor') || post_type_supports($post_type, wp_enqueue_media( array( 'post' => $post_ID ) ); } +// Add the local autosave notice HTML +add_action( 'admin_footer', '_local_storage_notice' ); + $messages = array(); $messages['post'] = array( 0 => '', // Unused. Messages start at index 1. @@ -95,6 +98,9 @@ if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql break; } } + // If this autosave isn't different from the current post, begone. + if ( ! $notice ) + wp_delete_post_revision( $autosave->ID ); unset($autosave_field, $_autosave_field); } @@ -103,13 +109,30 @@ $post_type_object = get_post_type_object($post_type); // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). require_once('./includes/meta-boxes.php'); + +$publish_callback_args = null; +if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) { + $revisions = wp_get_post_revisions( $post_ID ); + + // Check if the revisions have been upgraded + if ( ! empty( $revisions ) && _wp_get_post_revision_version( end( $revisions ) ) < 1 ) + _wp_upgrade_revisions_of_post( $post, $revisions ); + + // We should aim to show the revisions metabox only when there are revisions. + if ( count( $revisions ) > 1 ) { + reset( $revisions ); // Reset pointer for key() + $publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) ); + add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core'); + } +} + if ( 'attachment' == $post_type ) { wp_enqueue_script( 'image-edit' ); wp_enqueue_style( 'imgareaselect' ); add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' ); add_action( 'edit_form_after_title', 'edit_form_image_editor' ); } else { - add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core' ); + add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args ); } if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) @@ -132,8 +155,15 @@ foreach ( get_object_taxonomies( $post ) as $tax_name ) { if ( post_type_supports($post_type, 'page-attributes') ) add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', null, 'side', 'core'); -if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ) ) - add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', null, 'side', 'low'); +$audio_post_support = $video_post_support = false; +$theme_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); +if ( 'attachment' === $post_type && ! empty( $post->post_mime_type ) ) { + $audio_post_support = 0 === strpos( $post->post_mime_type, 'audio/' ) && current_theme_supports( 'post-thumbnails', 'attachment:audio' ) && post_type_supports( 'attachment:audio', 'thumbnail' ); + $video_post_support = 0 === strpos( $post->post_mime_type, 'video/' ) && current_theme_supports( 'post-thumbnails', 'attachment:video' ) && post_type_supports( 'attachment:video', 'thumbnail' ); +} + +if ( $theme_support || $audio_post_support || $video_post_support ) + add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', null, 'side', 'low'); if ( post_type_supports($post_type, 'excerpt') ) add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core'); @@ -159,9 +189,6 @@ if ( post_type_supports($post_type, 'author') ) { add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core'); } -if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) - add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core'); - do_action('add_meta_boxes', $post_type, $post); do_action('add_meta_boxes_' . $post_type, $post); @@ -291,11 +318,17 @@ if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create echo ' ' . esc_html( $post_type_object->labels->add_new ) . ''; ?> -

+

+ +
> @@ -304,7 +337,7 @@ if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create - +
-
+
@@ -336,10 +369,12 @@ $shortlink = wp_get_shortlink($post->ID, 'post'); if ( !empty($shortlink) ) $sample_permalink_html .= '' . __('Get Shortlink') . ''; -if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?> +if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { + $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status; +?>
post_status ) + if ( $has_sample_permalink ) echo $sample_permalink_html; ?>
@@ -358,10 +393,13 @@ do_action( 'edit_form_after_title', $post ); if ( post_type_supports($post_type, 'editor') ) { ?> -
- -post_content, 'content', array('dfw' => true, 'tabfocus_elements' => 'sample-permalink,post-preview', 'editor_height' => 360) ); ?> +
+post_content, 'content', array( + 'dfw' => true, + 'tabfocus_elements' => 'insert-media-button,save-post', + 'editor_height' => 360, +) ); ?>
0' ); ?> @@ -381,9 +419,10 @@ if ( post_type_supports($post_type, 'editor') ) {
- + +do_action( 'edit_form_after_editor', $post ); +?>