X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/256a3b381f63716209b3527d0a14442ae570c283..refs/tags/wordpress-4.0:/wp-admin/edit-form-advanced.php diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 7970b8c5..ebda7a3f 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -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. Preview post'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 9 => sprintf( __('Post scheduled for: %1$s. Preview post'), - // 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. Preview post'), 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 = '

' . __('Title - Enter a title for your post. After you enter a title, you’ll see the permalink below, which you can edit.') . '

'; $title_and_editor .= '

' . __('Post editor - 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.') . '

'; + $title_and_editor .= '

' . __( 'Keyboard users: When you’re working in the visual editor, you can use Alt + F10 to access the toolbar.' ) . '

'; get_current_screen()->add_help_tab( array( 'id' => 'title-post-editor', @@ -268,7 +291,7 @@ if ( 'post' == $post_type ) { '

' . sprintf(__('You can also create posts with the Press This bookmarklet.'), 'options-writing.php') . '

' . '

' . __('For more information:') . '

' . '

' . __('Documentation on Writing and Editing Posts') . '

' . - '

' . __('Support Forums') . '

' + '

' . __('Support Forums') . '

' ); } elseif ( 'page' == $post_type ) { $about_pages = '

' . __('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 “Parent” of the other, creating a group of Pages.') . '

' . @@ -284,7 +307,7 @@ if ( 'post' == $post_type ) { '

' . __('For more information:') . '

' . '

' . __('Documentation on Adding New Pages') . '

' . '

' . __('Documentation on Editing Pages') . '

' . - '

' . __('Support Forums') . '

' + '

' . __('Support Forums') . '

' ); } 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( '

' . __('For more information:') . '

' . '

' . __('Documentation on Edit Media') . '

' . - '

' . __('Support Forums') . '

' + '

' . __('Support Forums') . '

' ); } @@ -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') ) { ?> -
+
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, + ), ) ); ?> - +
+
0' ); ?>   @@ -499,6 +527,7 @@ if ( post_type_supports($post_type, 'editor') ) { echo ''; } ?>