44 $form_action = 'editpost'; |
65 $form_action = 'editpost'; |
45 $nonce_action = 'update-page_' . $post_ID; |
66 $nonce_action = 'update-page_' . $post_ID; |
46 $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />"; |
67 $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />"; |
47 $autosave = wp_get_post_autosave( $post_ID ); |
68 $autosave = wp_get_post_autosave( $post_ID ); |
48 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) |
69 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) |
49 $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) ); |
70 $notice = sprintf( __( 'There is an autosave of this page that is more recent than the version below. <a href="%s">View the autosave</a>.' ), get_edit_post_link( $autosave->ID ) ); |
50 } |
71 } |
51 |
72 |
52 $temp_ID = (int) $temp_ID; |
73 $temp_ID = (int) $temp_ID; |
53 $user_ID = (int) $user_ID; |
74 $user_ID = (int) $user_ID; |
54 |
75 |
55 /** |
76 require_once('includes/meta-boxes.php'); |
56 * Display submit form fields. |
|
57 * |
|
58 * @since 2.7.0 |
|
59 * |
|
60 * @param object $post |
|
61 */ |
|
62 function page_submit_meta_box($post) { |
|
63 global $action; |
|
64 |
77 |
65 $can_publish = current_user_can('publish_pages'); |
78 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'page', 'side', 'core'); |
66 ?> |
|
67 <div class="submitbox" id="submitpage"> |
|
68 |
|
69 <div id="minor-publishing"> |
|
70 |
|
71 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?> |
|
72 <div style="display:none;"> |
|
73 <input type="submit" name="save" value="<?php esc_attr_e('Save'); ?>" /> |
|
74 </div> |
|
75 |
|
76 <div id="minor-publishing-actions"> |
|
77 <div id="save-action"> |
|
78 <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> |
|
79 <input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" tabindex="4" class="button button-highlighted" /> |
|
80 <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?> |
|
81 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" tabindex="4" class="button button-highlighted" /> |
|
82 <?php } ?> |
|
83 </div> |
|
84 |
|
85 <div id="preview-action"> |
|
86 <?php |
|
87 if ( 'publish' == $post->post_status ) { |
|
88 $preview_link = esc_url(get_permalink($post->ID)); |
|
89 $preview_button = __('Preview Changes'); |
|
90 } else { |
|
91 $preview_link = esc_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); |
|
92 $preview_button = __('Preview'); |
|
93 } |
|
94 ?> |
|
95 <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php echo $preview_button; ?></a> |
|
96 <input type="hidden" name="wp-preview" id="wp-preview" value="" /> |
|
97 </div> |
|
98 |
|
99 <div class="clear"></div> |
|
100 </div><?php // /minor-publishing-actions ?> |
|
101 |
|
102 <div id="misc-publishing-actions"> |
|
103 |
|
104 <div class="misc-pub-section<?php if ( !$can_publish ) { echo ' misc-pub-section-last'; } ?>"><label for="post_status"><?php _e('Status:') ?></label> |
|
105 <span id="post-status-display"> |
|
106 <?php |
|
107 switch ( $post->post_status ) { |
|
108 case 'private': |
|
109 _e('Privately Published'); |
|
110 break; |
|
111 case 'publish': |
|
112 _e('Published'); |
|
113 break; |
|
114 case 'future': |
|
115 _e('Scheduled'); |
|
116 break; |
|
117 case 'pending': |
|
118 _e('Pending Review'); |
|
119 break; |
|
120 case 'draft': |
|
121 _e('Draft'); |
|
122 break; |
|
123 } |
|
124 ?> |
|
125 </span> |
|
126 <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?> |
|
127 <a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a> |
|
128 |
|
129 <div id="post-status-select" class="hide-if-js"> |
|
130 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr($post->post_status); ?>" /> |
|
131 <select name='post_status' id='post_status' tabindex='4'> |
|
132 <?php if ( 'publish' == $post->post_status ) : ?> |
|
133 <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option> |
|
134 <?php elseif ( 'private' == $post->post_status ) : ?> |
|
135 <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option> |
|
136 <?php elseif ( 'future' == $post->post_status ) : ?> |
|
137 <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option> |
|
138 <?php endif; ?> |
|
139 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> |
|
140 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option> |
|
141 </select> |
|
142 |
|
143 <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a> |
|
144 <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a> |
|
145 </div> |
|
146 |
|
147 <?php } ?> |
|
148 </div><?php // /misc-pub-section ?> |
|
149 |
|
150 <div class="misc-pub-section " id="visibility"> |
|
151 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php |
|
152 |
|
153 if ( 'private' == $post->post_status ) { |
|
154 $post->post_password = ''; |
|
155 $visibility = 'private'; |
|
156 $visibility_trans = __('Private'); |
|
157 } elseif ( !empty( $post->post_password ) ) { |
|
158 $visibility = 'password'; |
|
159 $visibility_trans = __('Password protected'); |
|
160 } else { |
|
161 $visibility = 'public'; |
|
162 $visibility_trans = __('Public'); |
|
163 } |
|
164 |
|
165 echo esc_html( $visibility_trans ); ?></span> |
|
166 <?php if ( $can_publish ) { ?> |
|
167 <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a> |
|
168 |
|
169 <div id="post-visibility-select" class="hide-if-js"> |
|
170 <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" /> |
|
171 <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" /> |
|
172 |
|
173 <input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br /> |
|
174 <input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br /> |
|
175 <span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" /><br /></span> |
|
176 <input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br /> |
|
177 |
|
178 <p><a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a> |
|
179 <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a></p> |
|
180 </div> |
|
181 <?php } ?> |
|
182 |
|
183 </div><?php // /misc-pub-section ?> |
|
184 |
|
185 <?php |
|
186 // translators: Publish box date formt, see http://php.net/date |
|
187 $datef = __( 'M j, Y @ G:i' ); |
|
188 if ( 0 != $post->ID ) { |
|
189 if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date |
|
190 $stamp = __('Scheduled for: <b>%1$s</b>'); |
|
191 } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published |
|
192 $stamp = __('Published on: <b>%1$s</b>'); |
|
193 } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified |
|
194 $stamp = __('Publish <b>immediately</b>'); |
|
195 } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified |
|
196 $stamp = __('Schedule for: <b>%1$s</b>'); |
|
197 } else { // draft, 1 or more saves, date specified |
|
198 $stamp = __('Publish on: <b>%1$s</b>'); |
|
199 } |
|
200 $date = date_i18n( $datef, strtotime( $post->post_date ) ); |
|
201 } else { // draft (no saves, and thus no date specified) |
|
202 $stamp = __('Publish <b>immediately</b>'); |
|
203 $date = date_i18n( $datef, strtotime( current_time('mysql') ) ); |
|
204 } |
|
205 |
|
206 if ( $can_publish ) : // Contributors don't get to choose the date of publish ?> |
|
207 <div class="misc-pub-section curtime misc-pub-section-last"> |
|
208 <span id="timestamp"><?php printf($stamp, $date); ?></span> |
|
209 <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a> |
|
210 <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div> |
|
211 </div><?php // /misc-pub-section |
|
212 endif; ?> |
|
213 |
|
214 </div> |
|
215 <div class="clear"></div> |
|
216 </div> |
|
217 |
|
218 <div id="major-publishing-actions"> |
|
219 <?php do_action('post_submitbox_start'); ?> |
|
220 <div id="delete-action"> |
|
221 <?php |
|
222 if ( ( 'edit' == $action ) && current_user_can('delete_page', $post->ID) ) { ?> |
|
223 <a class="submitdelete deletion" href="<?php echo wp_nonce_url("page.php?action=delete&post=$post->ID", 'delete-page_' . $post->ID); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a> |
|
224 <?php } ?> |
|
225 </div> |
|
226 |
|
227 <div id="publishing-action"> |
|
228 <?php |
|
229 if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { ?> |
|
230 <?php |
|
231 if ( $can_publish ) : |
|
232 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> |
|
233 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" /> |
|
234 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Schedule') ?>" /> |
|
235 <?php else : ?> |
|
236 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" /> |
|
237 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Publish') ?>" /> |
|
238 <?php endif; |
|
239 else : ?> |
|
240 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" /> |
|
241 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Submit for Review') ?>" /> |
|
242 <?php |
|
243 endif; |
|
244 } else { ?> |
|
245 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update Page') ?>" /> |
|
246 <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Update Page') ?>" /> |
|
247 <?php |
|
248 } ?> |
|
249 </div> |
|
250 <div class="clear"></div> |
|
251 </div> |
|
252 </div> |
|
253 <?php |
|
254 } |
|
255 add_meta_box('pagesubmitdiv', __('Publish'), 'page_submit_meta_box', 'page', 'side', 'core'); |
|
256 |
|
257 /** |
|
258 * Display page password form fields. |
|
259 * |
|
260 * @since 2.6.0 |
|
261 * |
|
262 * @param object $post |
|
263 */ |
|
264 function page_password_meta_box($post){ |
|
265 ?> |
|
266 <p><label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="checkbox" value="private" <?php checked($post->post_status, 'private'); ?> tabindex='4' /> <?php _e('Keep this page private') ?></label></p> |
|
267 <h4><?php _e( 'Page Password' ); ?></h4> |
|
268 <p><label class="screen-reader-text" for="post_password"><?php _e('Password Protect This Page') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php the_post_password(); ?>" /></p> |
|
269 <p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this page and its comments.'); ?></p> |
|
270 <?php |
|
271 } |
|
272 // add_meta_box('pagepassworddiv', __('Privacy Options'), 'page_password_meta_box', 'page', 'side', 'core'); |
|
273 |
|
274 /** |
|
275 * Display page attributes form fields. |
|
276 * |
|
277 * @since 2.7.0 |
|
278 * |
|
279 * @param object $post |
|
280 */ |
|
281 function page_attributes_meta_box($post){ |
|
282 ?> |
|
283 <h5><?php _e('Parent') ?></h5> |
|
284 <label class="screen-reader-text" for="parent_id"><?php _e('Page Parent') ?></label> |
|
285 <?php wp_dropdown_pages(array('exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('Main Page (no parent)'), 'sort_column'=> 'menu_order, post_title')); ?> |
|
286 <p><?php _e('You can arrange your pages in hierarchies, for example you could have an “About” page that has “Life Story” and “My Dog” pages under it. There are no limits to how deeply nested you can make pages.'); ?></p> |
|
287 <?php |
|
288 if ( 0 != count( get_page_templates() ) ) { ?> |
|
289 <h5><?php _e('Template') ?></h5> |
|
290 <label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template"> |
|
291 <option value='default'><?php _e('Default Template'); ?></option> |
|
292 <?php page_template_dropdown($post->page_template); ?> |
|
293 </select> |
|
294 <p><?php _e('Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them above.'); ?></p> |
|
295 <?php |
|
296 } ?> |
|
297 <h5><?php _e('Order') ?></h5> |
|
298 <p><label class="screen-reader-text" for="menu_order"><?php _e('Page Order') ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr($post->menu_order) ?>" /></p> |
|
299 <p><?php _e('Pages are usually ordered alphabetically, but you can put a number above to change the order pages appear in. (We know this is a little janky, it’ll be better in future releases.)'); ?></p> |
|
300 <?php |
|
301 } |
|
302 add_meta_box('pageparentdiv', __('Attributes'), 'page_attributes_meta_box', 'page', 'side', 'core'); |
79 add_meta_box('pageparentdiv', __('Attributes'), 'page_attributes_meta_box', 'page', 'side', 'core'); |
303 |
80 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'page', 'normal', 'core'); |
304 /** |
81 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'page', 'normal', 'core'); |
305 * Display custom field for page form fields. |
82 add_meta_box('slugdiv', __('Page Slug'), 'post_slug_meta_box', 'page', 'normal', 'core'); |
306 * |
83 if ( current_theme_supports( 'post-thumbnails', 'page' ) ) |
307 * @since 2.6.0 |
84 add_meta_box('postimagediv', __('Page Image'), 'post_thumbnail_meta_box', 'page', 'side', 'low'); |
308 * |
|
309 * @param object $post |
|
310 */ |
|
311 function page_custom_meta_box($post){ |
|
312 ?> |
|
313 <div id="postcustomstuff"> |
|
314 <?php |
|
315 $metadata = has_meta($post->ID); |
|
316 list_meta($metadata); |
|
317 meta_form(); ?> |
|
318 <div id="ajax-response"></div> |
|
319 </div> |
|
320 <p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p> |
|
321 <?php |
|
322 } |
|
323 add_meta_box('pagecustomdiv', __('Custom Fields'), 'page_custom_meta_box', 'page', 'normal', 'core'); |
|
324 |
|
325 /** |
|
326 * Display comments status form fields. |
|
327 * |
|
328 * @since 2.6.0 |
|
329 * |
|
330 * @param object $post |
|
331 */ |
|
332 function page_comments_status_meta_box($post){ |
|
333 ?> |
|
334 <input name="advanced_view" type="hidden" value="1" /> |
|
335 <p><label for="comment_status" class="selectit"> |
|
336 <input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> |
|
337 <?php _e('Allow Comments') ?></label></p> |
|
338 <p><label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label></p> |
|
339 <p><?php _e('These settings apply to this page only. “Pings” are <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a>.'); ?></p> |
|
340 <?php |
|
341 } |
|
342 add_meta_box('pagecommentstatusdiv', __('Discussion'), 'page_comments_status_meta_box', 'page', 'normal', 'core'); |
|
343 |
|
344 /** |
|
345 * Display page slug form fields. |
|
346 * |
|
347 * @since 2.6.0 |
|
348 * |
|
349 * @param object $post |
|
350 */ |
|
351 function page_slug_meta_box($post){ |
|
352 ?> |
|
353 <label class="screen-reader-text" for="post_name"><?php _e('Page Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( $post->post_name ); ?>" /> |
|
354 <?php |
|
355 } |
|
356 add_meta_box('pageslugdiv', __('Page Slug'), 'page_slug_meta_box', 'page', 'normal', 'core'); |
|
357 |
85 |
358 $authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM |
86 $authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM |
359 if ( $post->post_author && !in_array($post->post_author, $authors) ) |
87 if ( $post->post_author && !in_array($post->post_author, $authors) ) |
360 $authors[] = $post->post_author; |
88 $authors[] = $post->post_author; |
361 if ( $authors && count( $authors ) > 1 ) { |
89 if ( $authors && count( $authors ) > 1 ) |
362 /** |
90 add_meta_box('pageauthordiv', __('Page Author'), 'post_author_meta_box', 'page', 'normal', 'core'); |
363 * Display page author form fields, when more than one author exists. |
|
364 * |
|
365 * @since 2.6.0 |
|
366 * |
|
367 * @param object $post |
|
368 */ |
|
369 function page_author_meta_box($post){ |
|
370 global $current_user, $user_ID; |
|
371 $authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM |
|
372 if ( $post->post_author && !in_array($post->post_author, $authors) ) |
|
373 $authors[] = $post->post_author; |
|
374 ?> |
|
375 <label class="screen-reader-text" for="post_author_override"><?php _e('Page Author'); ?></label><?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?> |
|
376 <?php |
|
377 } |
|
378 add_meta_box('pageauthordiv', __('Page Author'), 'page_author_meta_box', 'page', 'normal', 'core'); |
|
379 } |
|
380 |
91 |
381 if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : |
92 if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) |
382 /** |
93 add_meta_box('revisionsdiv', __('Page Revisions'), 'post_revisions_meta_box', 'page', 'normal', 'core'); |
383 * Display list of page revisions. |
|
384 * |
|
385 * @since 2.6.0 |
|
386 * |
|
387 * @param object $post |
|
388 */ |
|
389 function page_revisions_meta_box($post) { |
|
390 wp_list_post_revisions(); |
|
391 } |
|
392 add_meta_box('revisionsdiv', __('Page Revisions'), 'page_revisions_meta_box', 'page', 'normal', 'core'); |
|
393 endif; |
|
394 |
94 |
395 do_action('do_meta_boxes', 'page', 'normal', $post); |
95 do_action('do_meta_boxes', 'page', 'normal', $post); |
396 do_action('do_meta_boxes', 'page', 'advanced', $post); |
96 do_action('do_meta_boxes', 'page', 'advanced', $post); |
397 do_action('do_meta_boxes', 'page', 'side', $post); |
97 do_action('do_meta_boxes', 'page', 'side', $post); |
398 |
98 |