root/trunk/wp-admin/edit-page-form.php

Revision 8697, 17.6 kB (checked in by azaozz, 21 hours ago)

Some css cleanup and fixes after the merge, see #7552

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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  */
14 if ( ! isset( $post_ID ) )
15     $post_ID = 0;
16
17 if ( isset($_GET['message']) )
18     $_GET['message'] = absint( $_GET['message'] );
19 $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'] : '') ) ) );
20 $messages[2] = __('Custom field updated.');
21 $messages[3] = __('Custom field deleted.');
22 $messages[4] = __('Page updated.');
23
24 if ( isset($_GET['revision']) )
25     $messages[5] = sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) );
26
27 $notice = false;
28 $notices[1] = __( 'There is an autosave of this page that is more recent than the version below.  <a href="%s">View the autosave</a>.' );
29
30 if ( 0 == $post_ID) {
31     $form_action = 'post';
32     $nonce_action = 'add-page';
33     $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
34     $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
35 } else {
36     $post_ID = (int) $post_ID;
37     $form_action = 'editpost';
38     $nonce_action = 'update-page_' . $post_ID;
39     $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
40     $autosave = wp_get_post_autosave( $post_id );
41     if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) )
42         $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
43 }
44
45 $temp_ID = (int) $temp_ID;
46 $user_ID = (int) $user_ID;
47 ?>
48
49 <form name="post" action="page.php" method="post" id="post">
50 <?php if ( $notice ) : ?>
51 <div id="notice" class="error"><p><?php echo $notice ?></p></div>
52 <?php endif; ?>
53 <?php if (isset($_GET['message'])) : ?>
54 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
55 <?php endif; ?>
56
57 <?php
58 function page_submit_meta_box($post) {
59     global $action;
60 ?>
61 <div class="submitbox" id="submitpage">
62
63 <div class="inside-submitbox">
64 <p><strong><label for='post_status'><?php _e('Publish Status') ?></label></strong></p>
65 <p>
66 <select name='post_status' tabindex='4' id='post_status'>
67 <?php // Show publish in dropdown if user can publish or if they can re-publish this page ('edit_published_pages')
68 // 'publish' option will be selected for published AND private posts (checkbox overrides dropdown)
69 if ( current_user_can('publish_pages') OR ( $post->post_status == 'publish' AND current_user_can('edit_page', $post->ID) ) ) :
70 ?>
71 <option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option>
72 <?php endif; ?>
73 <?php if ( 'future' == $post->post_status ) : ?>
74 <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Pending') ?></option>
75 <?php endif; ?>
76 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
77 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Unpublished') ?></option>
78 </select>
79 </p>
80 <?php if ( current_user_can( 'publish_posts' ) ) : ?>
81 <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>
82 <?php endif; ?>
83
84 <?php
85 if ( 0 != $post->ID ) {
86     if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
87         $stamp = __('Scheduled for:<br />%1$s at %2$s');
88     } else if ( 'publish' == $post->post_status ) { // already published
89         $stamp = __('Published on:<br />%1$s at %2$s');
90     } else if ( '0000-00-00 00:00:00' == $post->post_date ) { // draft, 1 or more saves, no date specified
91         $stamp = __('Publish immediately');
92     } else { // draft, 1 or more saves, date specified
93         $stamp = __('Publish on:<br />%1$s at %2$s');
94     }
95     $date = mysql2date(get_option('date_format'), $post->post_date);
96     $time = mysql2date(get_option('time_format'), $post->post_date);
97 } else { // draft (no saves, and thus no date specified)
98     $stamp = __('Publish immediately');
99     $date = mysql2date(get_option('date_format'), current_time('mysql'));
100     $time = mysql2date(get_option('time_format'), current_time('mysql'));
101 }
102 ?>
103 <p class="curtime"><?php printf($stamp, $date, $time); ?>
104 &nbsp;<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a></p>
105
106 <div id='timestampdiv' class='hide-if-js'><?php touch_time(($action == 'edit'),1,4); ?></div>
107
108 </div>
109
110 <p class="submit">
111 <?php do_action('page_submitbox_start'); ?>
112 <input type="submit" name="save" class="button button-highlighted" value="<?php _e('Save'); ?>" tabindex="4" />
113 <?php
114 if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post->ID ) {
115 ?>
116 <?php if ( current_user_can('publish_pages') ) : ?>
117     <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
118 <?php else : ?>
119     <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
120 <?php endif; ?>
121 <?php
122 }
123
124 if ( ('edit' == $action) && current_user_can('delete_page', $post->ID) )
125     echo "<a class='submitdelete' href='" . wp_nonce_url("page.php?action=delete&amp;post=$post->ID", 'delete-page_' . $post->ID) . "' onclick=\"if ( confirm('" . 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;\">" . __('Delete&nbsp;page') . "</a>";
126 ?>
127 <br class="clear" />
128
129 <!-- moved under the editor
130 <?php if ( 0 != $post->ID ) : ?>
131 <?php if ( $last_id = get_post_meta($post->ID, '_edit_last', true) ) {
132     $last_user = get_userdata($last_id);
133     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));
134 } else {
135     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));
136 }
137 ?>
138 <br class="clear" />
139 <?php endif; ?>
140 -->
141
142 </p>
143 </div>
144 <?php
145 }
146 add_meta_box('pagesubmitdiv', __('Publish'), 'page_submit_meta_box', 'page', 'side', 'core');
147
148 function page_custom_meta_box($post){
149 ?>
150 <div id="postcustomstuff">
151 <table cellpadding="3">
152 <?php
153 $metadata = has_meta($post->ID);
154 list_meta($metadata);
155 ?>
156
157 </table>
158 <?php
159     meta_form();
160 ?>
161 <div id="ajax-response"></div>
162 </div>
163 <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>
164 <?php
165 }
166 add_meta_box('pagecustomdiv', __('Custom Fields'), 'page_custom_meta_box', 'page', 'normal', 'core');
167
168 function page_comments_status_meta_box($post){
169 ?>
170 <input name="advanced_view" type="hidden" value="1" />
171 <p><label for="comment_status" class="selectit">
172 <input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> />
173 <?php _e('Allow Comments') ?></label></p>
174 <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>
175 <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>
176 <?php
177 }
178 add_meta_box('pagecommentstatusdiv', __('Comments &amp; Pings'), 'page_comments_status_meta_box', 'page', 'normal', 'core');
179
180 function page_password_meta_box($post){
181 ?>
182 <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 echo ( isset( $post->post_password ) ? attribute_escape( $post->post_password ) : '' ); ?>" /></p>
183 <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>
184 <?php
185 }
186 add_meta_box('pagepassworddiv', __('Password Protect This Page'), 'page_password_meta_box', 'page', 'normal', 'core');
187
188 function page_slug_meta_box($post){
189 ?>
190 <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 ); ?>" />
191 <?php
192 }
193 add_meta_box('pageslugdiv', __('Page Slug'), 'page_slug_meta_box', 'page', 'normal', 'core');
194
195 function page_parent_meta_box($post){
196 ?>
197 <label class="hidden" for="parent_id"><?php _e('Page Parent') ?></label>
198 <select name="parent_id" id="parent_id">
199 <option value='0'><?php _e('Main Page (no parent)'); ?></option>
200 <?php parent_dropdown($post->post_parent); ?>
201 </select>
202 <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>
203 <?php
204 }
205 add_meta_box('pageparentdiv', __('Page Parent'), 'page_parent_meta_box', 'page', 'normal', 'core');
206
207 if ( 0 != count( get_page_templates() ) ) {
208     function page_template_meta_box($post){
209 ?>
210 <label class="hidden" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
211 <option value='default'><?php _e('Default Template'); ?></option>
212 <?php page_template_dropdown($post->page_template); ?>
213 </select>
214 <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>
215 <?php
216     }
217     add_meta_box('pagetemplatediv', __('Page Template'), 'page_template_meta_box', 'page', 'normal', 'core');
218 }
219
220 function page_order_meta_box($post){
221 ?>
222 <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>
223 <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>
224 <?php
225 }
226 add_meta_box('pageorderdiv', __('Page Order'), 'page_order_meta_box', 'page', 'normal', 'core');
227
228
229 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
230 if ( $post->post_author && !in_array($post->post_author, $authors) )
231     $authors[] = $post->post_author;
232 if ( $authors && count( $authors ) > 1 ) {
233     function page_author_meta_box($post){
234         global $current_user, $user_ID;
235         $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
236         if ( $post->post_author && !in_array($post->post_author, $authors) )
237             $authors[] = $post->post_author;
238 ?>
239 <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) ); ?>
240 <?php
241     }
242     add_meta_box('pageauthordiv', __('Page Author'), 'page_author_meta_box', 'page', 'normal', 'core');
243 }
244
245
246 if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) :
247 function page_revisions_meta_box($post) {
248     wp_list_post_revisions();
249 }
250 add_meta_box('revisionsdiv', __('Page Revisions'), 'page_revisions_meta_box', 'page', 'normal', 'core');
251 endif;
252 ?>
253
254 <div class="wrap">
255 <h2><?php
256     if ( !isset($post_ID) || 0 == $post_ID )
257         printf( __( '<a href="%s">Pages</a> / Write New Page' ), 'edit-pages.php' );
258     else
259         printf( __( '<a href="%s">Pages</a> / Edit Page' ), 'edit-pages.php' );
260 ?></h2>
261
262 <div id="previewview">
263 <?php if ( 'publish' == $post->post_status ) { ?>
264 <a class="button" href="<?php echo clean_url(get_permalink($post->ID)); ?>" target="_blank"  tabindex="4"><?php _e('View this Page'); ?></a>
265 <?php } elseif ( 'edit' == $action ) { ?>
266 <a class="button" href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" target="_blank" tabindex="4"><?php _e('Preview this Page'); ?></a>
267 <?php } ?>
268 </div>
269
270 <?php
271 wp_nonce_field($nonce_action);
272
273 if (isset($mode) && 'bookmarklet' == $mode)
274     echo '<input type="hidden" name="mode" value="bookmarklet" />';
275 ?>
276 <input type="hidden" id="user-id" name="user_ID" value="<?php echo $user_ID ?>" />
277 <input type="hidden" id="hiddenaction" name="action" value='<?php echo $form_action ?>' />
278 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
279 <input type="hidden" id="post_author" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" />
280 <?php echo $form_extra ?>
281 <input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
282 <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status ?>" />
283 <input name="referredby" type="hidden" id="referredby" value="<?php echo clean_url(stripslashes(wp_get_referer())); ?>" />
284 <?php if ( 'draft' != $post->post_status ) wp_original_referer_field(true, 'previous'); ?>
285
286 <!-- TODO
287 <div class="inside">
288 <p><strong><label for='post_status'><?php _e('Publish Status') ?></label></strong></p>
289 <p>
290 <select name='post_status' tabindex='4' id='post_status'>
291 <?php // Show publish in dropdown if user can publish or if they can re-publish this page ('edit_published_pages')
292 // 'publish' option will be selected for published AND private posts (checkbox overrides dropdown)
293 if ( current_user_can('publish_pages') OR ( $post->post_status == 'publish' AND current_user_can('edit_page', $post->ID) ) ) :
294 ?>
295 <option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option>
296 <?php endif; ?>
297 <?php if ( 'future' == $post->post_status ) : ?>
298 <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Pending') ?></option>
299 <?php endif; ?>
300 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
301 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Unpublished') ?></option>
302 </select>
303 </p>
304 <?php if ( current_user_can( 'publish_posts' ) ) : ?> 
305 <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>
306 <?php endif; ?>
307
308 <h5><?php _e('Related') ?></h5>
309 <ul>
310 <?php if ($post_ID): ?>
311 <li><a href="edit-pages.php?page_id=<?php echo $post_ID ?>"><?php _e('See Comments on this Page') ?></a></li>
312 <?php endif; ?>
313 <li><a href="edit-comments.php"><?php _e('Manage All Comments') ?></a></li>
314 <li><a href="edit-pages.php"><?php _e('Manage All Pages') ?></a></li>
315 <?php do_action('page_relatedlinks_list'); ?>
316 </ul>
317
318 -->
319
320 <div id="poststuff">
321
322 <div id="side-info-column" class="inner-sidebar">
323
324 <?php
325
326 do_action('submitpage_box');
327 $side_meta_boxes = do_meta_boxes('page', 'side', $page);
328
329 ?>
330 </div>
331
332 <div id="post-body" class="<?php echo $side_meta_boxes ? 'has-sidebar' : ''; ?>">
333 <div id="post-body-content" class="has-sidebar-content">
334
335 <div id="titlediv">
336 <h3><label for="title"><?php _e('Title') ?></label></h3>
337 <div id="titlewrap">
338   <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" autocomplete="off" />
339 </div>
340 <div class="inside">
341 <?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?>
342     <div id="edit-slug-box">
343 <?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
344     echo $sample_permalink_html;
345 endif; ?>
346     </div>
347 </div>
348 </div>
349
350 <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
351
352 <div id="add-media-button"><a href="<?php echo clean_url( admin_url( 'media-upload.php?post_id=' . ( $post_ID ? $post_ID : $temp_ID ) . '&amp;type=image&amp;TB_iframe=true' ) ); ?>" class="thickbox button"><?php _e( 'Add Media' ); ?></a></div>
353
354 <h3><?php _e('Page') ?></h3>
355 <?php the_editor($post->post_content); ?>
356 <div id="post-status-info">
357     <span id="wp-word-count" class="alignleft"></span>
358     <span class="alignright">
359     <span id="autosave">&nbsp;</span>
360
361 <?php
362     if ($post_ID) {
363         if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
364             $last_user = get_userdata($last_id);
365             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));
366         } else {
367             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));
368         }
369     }
370 ?>
371     </span>
372     <br class="clear" />
373 </div>
374
375
376 <?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
377 <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
378 <?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
379 <?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
380 <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
381 </div>
382
383 <?php
384
385 do_meta_boxes('page', 'normal', $post);
386 do_action('edit_page_form');
387 do_meta_boxes('page', 'advanced', $post);
388
389 ?>
390
391 </div>
392 </div>
393 </div>
394
395 </div>
396 </form>
397
398 <script type="text/javascript">
399 try{document.post.title.focus();}catch(e){}
400 </script>
401
Note: See TracBrowser for help on using the browser.