]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/edit-form-advanced.php
WordPress 4.0
[autoinstalls/wordpress.git] / wp-admin / edit-form-advanced.php
index 7970b8c5af66efb880f77bfd89c357349f73f2e5..ebda7a3f69d2b4f0741f1ce48a7972beeddf99ed 100644 (file)
@@ -11,6 +11,22 @@ if ( !defined('ABSPATH') )
        die('-1');
 
 wp_enqueue_script('post');
+$_wp_editor_expand = false;
+
+/**
+ * Filter whether to enable the 'expand' functionality in the post editor.
+ *
+ * @since 4.0.0
+ *
+ * @param bool $expand Whether to enable the 'expand' functionality. Default true.
+ */
+if ( post_type_supports( $post_type, 'editor' ) && ! wp_is_mobile() &&
+        ! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) ) &&
+        apply_filters( 'wp_editor_expand', true ) ) {
+
+       wp_enqueue_script('editor-expand');
+       $_wp_editor_expand = ( get_user_setting( 'editor_expand', 'on' ) === 'on' );
+}
 
 if ( wp_is_mobile() )
        wp_enqueue_script( 'jquery-touch-punch' );
@@ -24,7 +40,16 @@ $post_ID = isset($post_ID) ? (int) $post_ID : 0;
 $user_ID = isset($user_ID) ? (int) $user_ID : 0;
 $action = isset($action) ? $action : '';
 
-if ( post_type_supports($post_type, 'editor') || post_type_supports($post_type, 'thumbnail') ) {
+$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 ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
+               $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
+       } elseif ( 0 === strpos( $post->post_mime_type, 'video/' ) ) {
+               $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 ) );
 }
@@ -48,7 +73,7 @@ $messages['post'] = array(
         7 => __('Post saved.'),
         8 => sprintf( __('Post submitted. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
         9 => sprintf( __('Post scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview post</a>'),
-               // translators: Publish box date format, see http://php.net/date
+               /* translators: Publish box date format, see http://php.net/date */
                date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
        10 => sprintf( __('Post draft updated. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
 );
@@ -137,6 +162,10 @@ if ( 'attachment' == $post_type ) {
        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' );
+
+       if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
+               add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core' );
+       }
 } else {
        add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args );
 }
@@ -163,14 +192,7 @@ 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');
 
-$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 )
+if ( $thumbnail_support && current_user_can( 'upload_files' ) )
        add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', null, 'side', 'low');
 
 if ( post_type_supports($post_type, 'excerpt') )
@@ -257,6 +279,7 @@ if ( 'post' == $post_type ) {
 
        $title_and_editor  = '<p>' . __('<strong>Title</strong> - Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.') . '</p>';
        $title_and_editor .= '<p>' . __('<strong>Post editor</strong> - Enter the text for your post. There are two modes of editing: Visual and Text. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The Text mode allows you to enter HTML along with your post text. Line breaks will be converted to paragraphs automatically. You can insert media files by clicking the icons above the post editor and following the directions. You can go to the distraction-free writing screen via the Fullscreen icon in Visual mode (second to last in the top row) or the Fullscreen button in Text mode (last in the row). Once there, you can make buttons visible by hovering over the top area. Exit Fullscreen back to the regular post editor.') . '</p>';
+       $title_and_editor .= '<p>' . __( 'Keyboard users: When you&#8217;re working in the visual editor, you can use <kbd>Alt + F10</kbd> to access the toolbar.' ) . '</p>';
 
        get_current_screen()->add_help_tab( array(
                'id'      => 'title-post-editor',
@@ -268,7 +291,7 @@ if ( 'post' == $post_type ) {
                        '<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'options-writing.php') . '</p>' .
                        '<p><strong>' . __('For more information:') . '</strong></p>' .
                        '<p>' . __('<a href="http://codex.wordpress.org/Posts_Add_New_Screen" target="_blank">Documentation on Writing and Editing Posts</a>') . '</p>' .
-                       '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+                       '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
        );
 } elseif ( 'page' == $post_type ) {
        $about_pages = '<p>' . __('Pages are similar to Posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest Pages under other Pages by making one the &#8220;Parent&#8221; of the other, creating a group of Pages.') . '</p>' .
@@ -284,7 +307,7 @@ if ( 'post' == $post_type ) {
                        '<p><strong>' . __('For more information:') . '</strong></p>' .
                        '<p>' . __('<a href="http://codex.wordpress.org/Pages_Add_New_Screen" target="_blank">Documentation on Adding New Pages</a>') . '</p>' .
                        '<p>' . __('<a href="http://codex.wordpress.org/Pages_Screen#Editing_Individual_Pages" target="_blank">Documentation on Editing Pages</a>') . '</p>' .
-                       '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+                       '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
        );
 } elseif ( 'attachment' == $post_type ) {
        get_current_screen()->add_help_tab( array(
@@ -300,7 +323,7 @@ if ( 'post' == $post_type ) {
        get_current_screen()->set_help_sidebar(
        '<p><strong>' . __('For more information:') . '</strong></p>' .
        '<p>' . __('<a href="http://codex.wordpress.org/Media_Add_New_Screen#Edit_Media" target="_blank">Documentation on Edit Media</a>') . '</p>' .
-       '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+       '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
        );
 }
 
@@ -402,7 +425,6 @@ if ( 'draft' != get_post_status( $post ) )
 
 echo $form_extra;
 
-wp_nonce_field( 'autosave', 'autosavenonce', false );
 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
 ?>
@@ -477,14 +499,20 @@ do_action( 'edit_form_after_title', $post );
 
 if ( post_type_supports($post_type, 'editor') ) {
 ?>
-<div id="postdivrich" class="postarea edit-form-section">
+<div id="postdivrich" class="postarea<?php if ( $_wp_editor_expand ) { echo ' wp-editor-expand'; } ?>">
 
 <?php wp_editor( $post->post_content, 'content', array(
        'dfw' => true,
+       'drag_drop_upload' => true,
        'tabfocus_elements' => 'insert-media-button,save-post',
-       'editor_height' => 360,
+       'editor_height' => 300,
+       'tinymce' => array(
+               'resize' => false,
+               'wp_autoresize_on' => $_wp_editor_expand,
+               'add_unload_trigger' => false,
+       ),
 ) ); ?>
-<table id="post-status-info" cellspacing="0"><tbody><tr>
+<table id="post-status-info"><tbody><tr>
        <td id="wp-word-count"><?php printf( __( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?></td>
        <td class="autosave-info">
        <span class="autosave-message">&nbsp;</span>
@@ -499,6 +527,7 @@ if ( post_type_supports($post_type, 'editor') ) {
                echo '</span>';
        } ?>
        </td>
+       <td id="content-resize-handle" class="hide-if-no-js"><br /></td>
 </tr></tbody></table>
 
 </div>