Projects : mp-wp : mp-wp_genesis

mp-wp/wp-admin/edit-page-form.php

Dir - Raw

1<?php
2/**
3 * Edit page form for inclusion in the administration panels.
4 *
5 * @package WordPress
6 * @subpackage Administration
7 */
8
9/**
10 * Post ID global.
11 * @name $post_ID
12 * @var int
13 */
14if ( ! isset( $post_ID ) )
15 $post_ID = 0;
16if ( ! isset( $temp_ID ) )
17 $temp_ID = 0;
18
19if ( isset($_GET['message']) )
20 $_GET['message'] = absint( $_GET['message'] );
21$messages[1] = sprintf( __( 'Page updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( ( isset( $_GET['_wp_original_http_referer'] ) ? $_GET['_wp_original_http_referer'] : '') ) ) );
22$messages[2] = __('Custom field updated.');
23$messages[3] = __('Custom field deleted.');
24$messages[4] = __('Page updated.');
25$messages[5] = sprintf(__('Page published. <a href="%s">View page</a>'), get_permalink($post_ID));
26$messages[6] = sprintf(__('Page submitted. <a href="%s">Preview page</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
27
28if ( isset($_GET['revision']) )
29 $messages[5] = sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) );
30
31$notice = false;
32$notices[1] = __( 'There is an autosave of this page that is more recent than the version below. <a href="%s">View the autosave</a>.' );
33
34if ( 0 == $post_ID) {
35 $form_action = 'post';
36 $nonce_action = 'add-page';
37 $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
38 $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
39} else {
40 $post_ID = (int) $post_ID;
41 $form_action = 'editpost';
42 $nonce_action = 'update-page_' . $post_ID;
43 $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
44 $autosave = wp_get_post_autosave( $post_ID );
45 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) )
46 $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
47}
48
49$temp_ID = (int) $temp_ID;
50$user_ID = (int) $user_ID;
51
52/**
53 * Display submit form fields.
54 *
55 * @since 2.7.0
56 *
57 * @param object $post
58 */
59function page_submit_meta_box($post) {
60 global $action;
61
62 $can_publish = current_user_can('publish_pages');
63?>
64<div class="submitbox" id="submitpage">
65
66<div id="minor-publishing">
67
68<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
69<div style="display:none;">
70<input type="submit" name="save" value="<?php echo attribute_escape( __('Save') ); ?>" />
71</div>
72
73<div id="minor-publishing-actions">
74<div id="save-action">
75<?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
76<input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save Draft') ); ?>" tabindex="4" class="button button-highlighted" />
77<?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
78<input type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save as Pending') ); ?>" tabindex="4" class="button button-highlighted" />
79<?php } ?>
80</div>
81
82<div id="preview-action">
83<?php $preview_link = 'publish' == $post->post_status ? clean_url(get_permalink($post->ID)) : clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>
84
85<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php _e('Preview'); ?></a>
86<input type="hidden" name="wp-preview" id="wp-preview" value="" />
87</div>
88
89<div class="clear"></div>
90</div><?php // /minor-publishing-actions ?>
91
92<div id="misc-publishing-actions">
93
94<div class="misc-pub-section<?php if ( !$can_publish ) { echo ' misc-pub-section-last'; } ?>"><label for="post_status"><?php _e('Status:') ?></label>
95<b><span id="post-status-display">
96<?php
97switch ( $post->post_status ) {
98 case 'private':
99 _e('Privately Published');
100 break;
101 case 'publish':
102 _e('Published');
103 break;
104 case 'future':
105 _e('Scheduled');
106 break;
107 case 'pending':
108 _e('Pending Review');
109 break;
110 case 'draft':
111 _e('Draft');
112 break;
113}
114?>
115</span></b>
116<?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
117<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>
118
119<div id="post-status-select" class="hide-if-js">
120<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo $post->post_status; ?>" />
121<select name='post_status' id='post_status' tabindex='4'>
122<?php if ( 'publish' == $post->post_status ) : ?>
123<option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
124<?php elseif ( 'private' == $post->post_status ) : ?>
125<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
126<?php elseif ( 'future' == $post->post_status ) : ?>
127<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
128<?php endif; ?>
129<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
130<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
131</select>
132
133 <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
134 <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
135</div>
136
137<?php } ?>
138</div><?php // /misc-pub-section ?>
139
140<div class="misc-pub-section " id="visibility">
141<?php _e('Visibility:'); ?> <b><span id="post-visibility-display"><?php
142
143if ( 'private' == $post->post_status ) {
144 $post->post_password = '';
145 $visibility = 'private';
146 $visibility_trans = __('Private');
147} elseif ( !empty( $post->post_password ) ) {
148 $visibility = 'password';
149 $visibility_trans = __('Password protected');
150} else {
151 $visibility = 'public';
152 $visibility_trans = __('Public');
153}
154
155?><?php echo wp_specialchars( $visibility_trans ); ?></span></b> <?php if ( $can_publish ) { ?> <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
156
157<div id="post-visibility-select" class="hide-if-js">
158<input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo attribute_escape($post->post_password); ?>" />
159<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo attribute_escape( $visibility ); ?>" />
160
161
162<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 />
163<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 />
164<span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo attribute_escape($post->post_password); ?>" /><br /></span>
165<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 />
166
167<p>
168 <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
169 <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
170</p>
171</div>
172<?php } ?>
173
174</div><?php // /misc-pub-section ?>
175
176<?php
177$datef = _c( 'M j, Y @ G:i|Publish box date format');
178if ( 0 != $post->ID ) {
179 if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
180 $stamp = __('Scheduled for: <b>%1$s</b>');
181 } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
182 $stamp = __('Published on: <b>%1$s</b>');
183 } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
184 $stamp = __('Publish <b>immediately</b>');
185 } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
186 $stamp = __('Schedule for: <b>%1$s</b>');
187 } else { // draft, 1 or more saves, date specified
188 $stamp = __('Publish on: <b>%1$s</b>');
189 }
190 $date = date_i18n( $datef, strtotime( $post->post_date ) );
191} else { // draft (no saves, and thus no date specified)
192 $stamp = __('Publish <b>immediately</b>');
193 $date = date_i18n( $datef, strtotime( current_time('mysql') ) );
194}
195?>
196<?php if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
197<div class="misc-pub-section curtime misc-pub-section-last">
198 <span id="timestamp">
199 <?php printf($stamp, $date); ?></span>
200 <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
201 <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div>
202</div><?php // /misc-pub-section ?>
203<?php endif; ?>
204
205</div>
206<div class="clear"></div>
207</div>
208
209<div id="major-publishing-actions">
210<?php do_action('post_submitbox_start'); ?>
211<div id="delete-action">
212<?php
213if ( ( 'edit' == $action ) && current_user_can('delete_page', $post->ID) ) { ?>
214<a class="submitdelete deletion" href="<?php echo wp_nonce_url("page.php?action=delete&amp;post=$post->ID", 'delete-page_' . $post->ID); ?>" onclick="if ( confirm('<?php echo js_escape(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>
215<?php } ?>
216</div>
217
218<div id="publishing-action">
219<?php
220if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { ?>
221<?php if ( $can_publish ) : ?>
222 <?php if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
223 <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Schedule') ?>" />
224 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Schedule') ?>" />
225 <?php else : ?>
226 <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Publish') ?>" />
227 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
228 <?php endif; ?>
229<?php else : ?>
230 <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Submit for Review') ?>" />
231 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
232<?php endif; ?>
233<?php } else { ?>
234 <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Update Page') ?>" />
235 <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Update Page') ?>" />
236<?php } ?>
237</div>
238<div class="clear"></div>
239</div>
240</div>
241<?php
242}
243add_meta_box('pagesubmitdiv', __('Publish'), 'page_submit_meta_box', 'page', 'side', 'core');
244
245/**
246 * Display page password form fields.
247 *
248 * @since 2.6.0
249 *
250 * @param object $post
251 */
252function page_password_meta_box($post){
253?>
254<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>
255<h4><?php _e( 'Page Password' ); ?></h4>
256<p><label class="hidden" 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>
257<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>
258<?php
259}
260// add_meta_box('pagepassworddiv', __('Privacy Options'), 'page_password_meta_box', 'page', 'side', 'core');
261
262/**
263 * Display page attributes form fields.
264 *
265 * @since 2.7.0
266 *
267 * @param object $post
268 */
269function page_attributes_meta_box($post){
270?>
271<h5><?php _e('Parent') ?></h5>
272<label class="hidden" for="parent_id"><?php _e('Page Parent') ?></label>
273<?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')); ?>
274<p><?php _e('You can arrange your pages in hierarchies, for example you could have an &#8220;About&#8221; page that has &#8220;Life Story&#8221; and &#8220;My Dog&#8221; pages under it. There are no limits to how deeply nested you can make pages.'); ?></p>
275<?php
276 if ( 0 != count( get_page_templates() ) ) {
277?>
278<h5><?php _e('Template') ?></h5>
279<label class="hidden" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
280<option value='default'><?php _e('Default Template'); ?></option>
281<?php page_template_dropdown($post->page_template); ?>
282</select>
283<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&#8217;ll see them above.'); ?></p>
284<?php
285 }
286?>
287<h5><?php _e('Order') ?></h5>
288<p><label class="hidden" for="menu_order"><?php _e('Page Order') ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $post->menu_order ?>" /></p>
289<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&#8217;ll be better in future releases.)'); ?></p>
290<?php
291}
292add_meta_box('pageparentdiv', __('Attributes'), 'page_attributes_meta_box', 'page', 'side', 'core');
293
294/**
295 * Display custom field for page form fields.
296 *
297 * @since 2.6.0
298 *
299 * @param object $post
300 */
301function page_custom_meta_box($post){
302?>
303<div id="postcustomstuff">
304<?php
305$metadata = has_meta($post->ID);
306list_meta($metadata);
307meta_form();
308?>
309<div id="ajax-response"></div>
310</div>
311<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>
312<?php
313}
314add_meta_box('pagecustomdiv', __('Custom Fields'), 'page_custom_meta_box', 'page', 'normal', 'core');
315
316/**
317 * Display comments status form fields.
318 *
319 * @since 2.6.0
320 *
321 * @param object $post
322 */
323function page_comments_status_meta_box($post){
324?>
325<input name="advanced_view" type="hidden" value="1" />
326<p><label for="comment_status" class="selectit">
327<input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> />
328<?php _e('Allow Comments') ?></label></p>
329<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>
330<p><?php _e('These settings apply to this page only. &#8220;Pings&#8221; are <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a>.'); ?></p>
331<?php
332}
333add_meta_box('pagecommentstatusdiv', __('Discussion'), 'page_comments_status_meta_box', 'page', 'normal', 'core');
334
335/**
336 * Display page slug form fields.
337 *
338 * @since 2.6.0
339 *
340 * @param object $post
341 */
342function page_slug_meta_box($post){
343?>
344<label class="hidden" for="post_name"><?php _e('Page Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" />
345<?php
346}
347add_meta_box('pageslugdiv', __('Page Slug'), 'page_slug_meta_box', 'page', 'normal', 'core');
348
349$authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM
350if ( $post->post_author && !in_array($post->post_author, $authors) )
351 $authors[] = $post->post_author;
352if ( $authors && count( $authors ) > 1 ) {
353 /**
354 * Display page author form fields, when more than one author exists.
355 *
356 * @since 2.6.0
357 *
358 * @param object $post
359 */
360 function page_author_meta_box($post){
361 global $current_user, $user_ID;
362 $authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM
363 if ( $post->post_author && !in_array($post->post_author, $authors) )
364 $authors[] = $post->post_author;
365?>
366<label class="hidden" 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) ); ?>
367<?php
368 }
369 add_meta_box('pageauthordiv', __('Page Author'), 'page_author_meta_box', 'page', 'normal', 'core');
370}
371
372if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) :
373/**
374 * Display list of page revisions.
375 *
376 * @since 2.6.0
377 *
378 * @param object $post
379 */
380function page_revisions_meta_box($post) {
381 wp_list_post_revisions();
382}
383add_meta_box('revisionsdiv', __('Page Revisions'), 'page_revisions_meta_box', 'page', 'normal', 'core');
384endif;
385
386do_action('do_meta_boxes', 'page', 'normal', $post);
387do_action('do_meta_boxes', 'page', 'advanced', $post);
388do_action('do_meta_boxes', 'page', 'side', $post);
389
390require_once('admin-header.php');
391?>
392
393<div class="wrap">
394<?php screen_icon(); ?>
395<h2><?php echo wp_specialchars( $title ); ?></h2>
396
397<form name="post" action="page.php" method="post" id="post">
398<?php if ( $notice ) : ?>
399<div id="notice" class="error"><p><?php echo $notice ?></p></div>
400<?php endif; ?>
401<?php if (isset($_GET['message'])) : ?>
402<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
403<?php endif; ?>
404
405<?php
406wp_nonce_field($nonce_action);
407
408if (isset($mode) && 'bookmarklet' == $mode)
409 echo '<input type="hidden" name="mode" value="bookmarklet" />';
410?>
411<input type="hidden" id="user-id" name="user_ID" value="<?php echo $user_ID ?>" />
412<input type="hidden" id="hiddenaction" name="action" value='<?php echo $form_action ?>' />
413<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
414<input type="hidden" id="post_author" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" />
415<?php echo $form_extra ?>
416<input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
417<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status ?>" />
418<input name="referredby" type="hidden" id="referredby" value="<?php echo clean_url(stripslashes(wp_get_referer())); ?>" />
419<?php if ( 'draft' != $post->post_status ) wp_original_referer_field(true, 'previous'); ?>
420
421<div id="poststuff" class="metabox-holder">
422
423<div id="side-info-column" class="inner-sidebar">
424
425<?php
426
427do_action('submitpage_box');
428$side_meta_boxes = do_meta_boxes('page', 'side', $post);
429
430?>
431</div>
432
433<div id="post-body" class="<?php echo $side_meta_boxes ? 'has-sidebar' : ''; ?>">
434<div id="post-body-content" class="has-sidebar-content">
435
436<div id="titlediv">
437<div id="titlewrap">
438 <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" autocomplete="off" />
439</div>
440<div class="inside">
441<?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?>
442 <div id="edit-slug-box">
443<?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
444 echo $sample_permalink_html;
445endif; ?>
446 </div>
447</div>
448</div>
449
450<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
451
452<?php the_editor($post->post_content); ?>
453<div id="post-status-info">
454 <span id="wp-word-count" class="alignleft"></span>
455 <span class="alignright">
456 <span id="autosave">&nbsp;</span>
457
458<?php
459 if ($post_ID) {
460 if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
461 $last_user = get_userdata($last_id);
462 printf(__('Last edited by %1$s on %2$s at %3$s'), wp_specialchars( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
463 } else {
464 printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
465 }
466 }
467?>
468 </span>
469 <br class="clear" />
470</div>
471
472<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
473<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
474<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
475<?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
476<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
477</div>
478
479<?php
480
481do_meta_boxes('page', 'normal', $post);
482do_action('edit_page_form');
483do_meta_boxes('page', 'advanced', $post);
484
485?>
486
487</div>
488</div>
489</div>
490
491</form>
492</div>
493
494<script type="text/javascript">
495try{document.post.title.focus();}catch(e){}
496</script>