42 wp_enqueue_script( 'post' ); |
42 wp_enqueue_script( 'post' ); |
43 |
43 |
44 $_wp_editor_expand = false; |
44 $_wp_editor_expand = false; |
45 $_content_editor_dfw = false; |
45 $_content_editor_dfw = false; |
46 |
46 |
47 /** |
47 if ( post_type_supports( $post_type, 'editor' ) |
48 * Filters whether to enable the 'expand' functionality in the post editor. |
48 && ! wp_is_mobile() |
49 * |
49 && ! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) ) |
50 * @since 4.0.0 |
50 ) { |
51 * @since 4.1.0 Added the `$post_type` parameter. |
51 /** |
52 * |
52 * Filters whether to enable the 'expand' functionality in the post editor. |
53 * @param bool $expand Whether to enable the 'expand' functionality. Default true. |
53 * |
54 * @param string $post_type Post type. |
54 * @since 4.0.0 |
55 */ |
55 * @since 4.1.0 Added the `$post_type` parameter. |
56 if ( post_type_supports( $post_type, 'editor' ) && ! wp_is_mobile() && |
56 * |
57 ! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) ) && |
57 * @param bool $expand Whether to enable the 'expand' functionality. Default true. |
58 apply_filters( 'wp_editor_expand', true, $post_type ) ) { |
58 * @param string $post_type Post type. |
59 |
59 */ |
60 wp_enqueue_script( 'editor-expand' ); |
60 if ( apply_filters( 'wp_editor_expand', true, $post_type ) ) { |
61 $_content_editor_dfw = true; |
61 wp_enqueue_script( 'editor-expand' ); |
62 $_wp_editor_expand = ( 'on' === get_user_setting( 'editor_expand', 'on' ) ); |
62 $_content_editor_dfw = true; |
|
63 $_wp_editor_expand = ( 'on' === get_user_setting( 'editor_expand', 'on' ) ); |
|
64 } |
63 } |
65 } |
64 |
66 |
65 if ( wp_is_mobile() ) { |
67 if ( wp_is_mobile() ) { |
66 wp_enqueue_script( 'jquery-touch-punch' ); |
68 wp_enqueue_script( 'jquery-touch-punch' ); |
67 } |
69 } |
74 */ |
76 */ |
75 $post_ID = isset( $post_ID ) ? (int) $post_ID : 0; |
77 $post_ID = isset( $post_ID ) ? (int) $post_ID : 0; |
76 $user_ID = isset( $user_ID ) ? (int) $user_ID : 0; |
78 $user_ID = isset( $user_ID ) ? (int) $user_ID : 0; |
77 $action = isset( $action ) ? $action : ''; |
79 $action = isset( $action ) ? $action : ''; |
78 |
80 |
79 if ( (int) get_option( 'page_for_posts' ) === $post_ID && empty( $post->post_content ) ) { |
81 if ( (int) get_option( 'page_for_posts' ) === $post->ID && empty( $post->post_content ) ) { |
80 add_action( 'edit_form_after_title', '_wp_posts_page_notice' ); |
82 add_action( 'edit_form_after_title', '_wp_posts_page_notice' ); |
81 remove_post_type_support( $post_type, 'editor' ); |
83 remove_post_type_support( $post_type, 'editor' ); |
82 } |
84 } |
83 |
85 |
84 $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); |
86 $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); |
90 } |
92 } |
91 } |
93 } |
92 |
94 |
93 if ( $thumbnail_support ) { |
95 if ( $thumbnail_support ) { |
94 add_thickbox(); |
96 add_thickbox(); |
95 wp_enqueue_media( array( 'post' => $post_ID ) ); |
97 wp_enqueue_media( array( 'post' => $post->ID ) ); |
96 } |
98 } |
97 |
99 |
98 // Add the local autosave notice HTML. |
100 // Add the local autosave notice HTML. |
99 add_action( 'admin_footer', '_local_storage_notice' ); |
101 add_action( 'admin_footer', '_local_storage_notice' ); |
100 |
102 |
101 /* |
103 /* |
102 * @todo Document the $messages array(s). |
104 * @todo Document the $messages array(s). |
103 */ |
105 */ |
104 $permalink = get_permalink( $post_ID ); |
106 $permalink = get_permalink( $post->ID ); |
105 if ( ! $permalink ) { |
107 if ( ! $permalink ) { |
106 $permalink = ''; |
108 $permalink = ''; |
107 } |
109 } |
108 |
110 |
109 $messages = array(); |
111 $messages = array(); |
167 } |
169 } |
168 |
170 |
169 $scheduled_date = sprintf( |
171 $scheduled_date = sprintf( |
170 /* translators: Publish box date string. 1: Date, 2: Time. */ |
172 /* translators: Publish box date string. 1: Date, 2: Time. */ |
171 __( '%1$s at %2$s' ), |
173 __( '%1$s at %2$s' ), |
172 /* translators: Publish box date format, see https://www.php.net/date */ |
174 /* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */ |
173 date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $post->post_date ) ), |
175 date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $post->post_date ) ), |
174 /* translators: Publish box time format, see https://www.php.net/date */ |
176 /* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */ |
175 date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $post->post_date ) ) |
177 date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $post->post_date ) ) |
176 ); |
178 ); |
177 |
179 |
178 $messages['post'] = array( |
180 $messages['post'] = array( |
179 0 => '', // Unused. Messages start at index 1. |
181 0 => '', // Unused. Messages start at index 1. |
233 $post->post_title = ''; |
235 $post->post_title = ''; |
234 } |
236 } |
235 $autosave = false; |
237 $autosave = false; |
236 $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />"; |
238 $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />"; |
237 } else { |
239 } else { |
238 $autosave = wp_get_post_autosave( $post_ID ); |
240 $autosave = wp_get_post_autosave( $post->ID ); |
239 } |
241 } |
240 |
242 |
241 $form_action = 'editpost'; |
243 $form_action = 'editpost'; |
242 $nonce_action = 'update-post_' . $post_ID; |
244 $nonce_action = 'update-post_' . $post->ID; |
243 $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post_ID ) . "' />"; |
245 $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post->ID ) . "' />"; |
244 |
246 |
245 // Detect if there exists an autosave newer than the post and if that autosave is different than the post. |
247 // Detect if there exists an autosave newer than the post and if that autosave is different than the post. |
246 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { |
248 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { |
247 foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) { |
249 foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) { |
248 if ( normalize_whitespace( $autosave->$autosave_field ) !== normalize_whitespace( $post->$autosave_field ) ) { |
250 if ( normalize_whitespace( $autosave->$autosave_field ) !== normalize_whitespace( $post->$autosave_field ) ) { |
617 <td class="autosave-info"> |
619 <td class="autosave-info"> |
618 <span class="autosave-message"> </span> |
620 <span class="autosave-message"> </span> |
619 <?php |
621 <?php |
620 if ( 'auto-draft' !== $post->post_status ) { |
622 if ( 'auto-draft' !== $post->post_status ) { |
621 echo '<span id="last-edit">'; |
623 echo '<span id="last-edit">'; |
622 $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ); |
624 $last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) ); |
623 if ( $last_user ) { |
625 if ( $last_user ) { |
624 /* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time. */ |
626 /* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time. */ |
625 printf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) ); |
627 printf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) ); |
626 } else { |
628 } else { |
627 /* translators: 1: Post edited date, 2: Post edited time. */ |
629 /* translators: 1: Post edited date, 2: Post edited time. */ |