X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/76aea3697c6043c1613370f172395b4f65ee71f0..e3ff8f35458a959c1879c0a4976701ed8dcfe651:/wp-admin/edit-form-advanced.php diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 983bc27d..803300f4 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -1,388 +1,756 @@ go back.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) ); -$messages[2] = __('Custom field updated.'); -$messages[3] = __('Custom field deleted.'); -$messages[4] = __('Post updated.'); -if ( isset($_GET['revision']) ) - $messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ); +if ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) { + add_action( 'edit_form_after_title', '_wp_posts_page_notice' ); + remove_post_type_support( $post_type, 'editor' ); +} -$notice = false; -$notices[1] = __( 'There is an autosave of this post that is more recent than the version below. View the autosave.' ); +$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); +if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) { + if ( wp_attachment_is( 'audio', $post ) ) { + $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); + } elseif ( wp_attachment_is( 'video', $post ) ) { + $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); + } +} + +if ( $thumbnail_support ) { + add_thickbox(); + wp_enqueue_media( array( 'post' => $post_ID ) ); +} + +// Add the local autosave notice HTML +add_action( 'admin_footer', '_local_storage_notice' ); + +/* + * @todo Document the $messages array(s). + */ +$permalink = get_permalink( $post_ID ); +if ( ! $permalink ) { + $permalink = ''; +} + +$messages = array(); + +$preview_post_link_html = $scheduled_post_link_html = $view_post_link_html = ''; +$preview_page_link_html = $scheduled_page_link_html = $view_page_link_html = ''; + +$preview_url = get_preview_post_link( $post ); + +$viewable = is_post_type_viewable( $post_type_object ); + +if ( $viewable ) { + + // Preview post link. + $preview_post_link_html = sprintf( ' %2$s', + esc_url( $preview_url ), + __( 'Preview post' ) + ); + + // Scheduled post preview link. + $scheduled_post_link_html = sprintf( ' %2$s', + esc_url( $permalink ), + __( 'Preview post' ) + ); + + // View post link. + $view_post_link_html = sprintf( ' %2$s', + esc_url( $permalink ), + __( 'View post' ) + ); -if ( !isset($post_ID) || 0 == $post_ID ) { - $form_action = 'post'; - $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() - $form_extra = ""; + // Preview page link. + $preview_page_link_html = sprintf( ' %2$s', + esc_url( $preview_url ), + __( 'Preview page' ) + ); + + // Scheduled page preview link. + $scheduled_page_link_html = sprintf( ' %2$s', + esc_url( $permalink ), + __( 'Preview page' ) + ); + + // View page link. + $view_page_link_html = sprintf( ' %2$s', + esc_url( $permalink ), + __( 'View page' ) + ); + +} + +/* translators: Publish box date format, see https://secure.php.net/date */ +$scheduled_date = date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) ); + +$messages['post'] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => __( 'Post updated.' ) . $view_post_link_html, + 2 => __( 'Custom field updated.' ), + 3 => __( 'Custom field deleted.' ), + 4 => __( 'Post updated.' ), + /* translators: %s: date and time of the revision */ + 5 => isset($_GET['revision']) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => __( 'Post published.' ) . $view_post_link_html, + 7 => __( 'Post saved.' ), + 8 => __( 'Post submitted.' ) . $preview_post_link_html, + 9 => sprintf( __( 'Post scheduled for: %s.' ), '' . $scheduled_date . '' ) . $scheduled_post_link_html, + 10 => __( 'Post draft updated.' ) . $preview_post_link_html, +); +$messages['page'] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => __( 'Page updated.' ) . $view_page_link_html, + 2 => __( 'Custom field updated.' ), + 3 => __( 'Custom field deleted.' ), + 4 => __( 'Page updated.' ), + /* translators: %s: date and time of the revision */ + 5 => isset($_GET['revision']) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => __( 'Page published.' ) . $view_page_link_html, + 7 => __( 'Page saved.' ), + 8 => __( 'Page submitted.' ) . $preview_page_link_html, + 9 => sprintf( __( 'Page scheduled for: %s.' ), '' . $scheduled_date . '' ) . $scheduled_page_link_html, + 10 => __( 'Page draft updated.' ) . $preview_page_link_html, +); +$messages['attachment'] = array_fill( 1, 10, __( 'Media file updated.' ) ); // Hack, for now. + +/** + * Filters the post updated messages. + * + * @since 3.0.0 + * + * @param array $messages Post updated messages. For defaults @see $messages declarations above. + */ +$messages = apply_filters( 'post_updated_messages', $messages ); + +$message = false; +if ( isset($_GET['message']) ) { + $_GET['message'] = absint( $_GET['message'] ); + if ( isset($messages[$post_type][$_GET['message']]) ) + $message = $messages[$post_type][$_GET['message']]; + elseif ( !isset($messages[$post_type]) && isset($messages['post'][$_GET['message']]) ) + $message = $messages['post'][$_GET['message']]; +} + +$notice = false; +$form_extra = ''; +if ( 'auto-draft' == $post->post_status ) { + if ( 'edit' == $action ) + $post->post_title = ''; $autosave = false; + $form_extra .= ""; } else { - $post_ID = (int) $post_ID; - $form_action = 'editpost'; - $form_extra = ""; - $autosave = wp_get_post_autosave( $post_id ); - - // Detect if there exists an autosave newer than the post and if that autosave is different than the post - if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) ) { - foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) { - if ( wp_text_diff( $autosave->$autosave_field, $post->$autosave_field ) ) { - $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) ); - break; - } + $autosave = wp_get_post_autosave( $post_ID ); +} + +$form_action = 'editpost'; +$nonce_action = 'update-post_' . $post_ID; +$form_extra .= ""; + +// Detect if there exists an autosave newer than the post and if that autosave is different than the post +if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { + foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) { + if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { + $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below. View the autosave' ), get_edit_post_link( $autosave->ID ) ); + break; } - unset($autosave_field, $_autosave_field); } + // If this autosave isn't different from the current post, begone. + if ( ! $notice ) + wp_delete_post_revision( $autosave->ID ); + unset($autosave_field, $_autosave_field); } -?> - -