WordPress.org

Make WordPress Core

Ticket #6709: edit-page-form.php

File edit-page-form.php, 14.7 KB (added by jabecker, 10 years ago)

modified edit-form-page.php

Line 
1<?php
2if ( isset($_GET['message']) )
3        $_GET['message'] = absint( $_GET['message'] );
4$messages[1] = sprintf( __( 'Page updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) );
5$messages[2] = __('Custom field updated.');
6$messages[3] = __('Custom field deleted.');
7$messages[4] = __('Page updated.');
8?>
9<?php if (isset($_GET['message'])) : ?>
10<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
11<?php endif;
12
13if (!isset($post_ID) || 0 == $post_ID) {
14        $form_action = 'post';
15        $nonce_action = 'add-page';
16        $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
17        $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
18} else {
19        $post_ID = (int) $post_ID;
20        $form_action = 'editpost';
21        $nonce_action = 'update-page_' . $post_ID;
22        $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
23}
24
25$temp_ID = (int) $temp_ID;
26$user_ID = (int) $user_ID;
27
28$sendto = clean_url(stripslashes(wp_get_referer()));
29
30if ( 0 != $post_ID && $sendto == get_permalink($post_ID) )
31        $sendto = 'redo';
32?>
33
34<form name="post" action="page.php" method="post" id="post">
35<div class="wrap">
36<h2><?php _e('Write Page') ?></h2>
37<div id="rightnowpost">
38
39<?php if ( $can_edit_posts = current_user_can( 'edit_posts' ) ) : ?>
40<?php endif; if ( $can_edit_pages = current_user_can( 'edit_pages' ) ) : ?>
41<?php endif; ?>
42
43<?php
44$num_posts = wp_count_posts( 'post' );
45$num_pages = wp_count_posts( 'page' );
46
47$num_cats  = wp_count_terms('category');
48
49$num_tags = wp_count_terms('post_tag');
50
51$post_type_texts = array();
52
53if ( $can_edit_posts && !empty($num_posts->draft) ) {
54        $post_type_texts[] = '<a href="edit.php?post_status=draft">'.sprintf( __ngettext( '%s draft', '%s drafts', $num_posts->draft ), number_format_i18n( $num_posts->draft ) ).'</a>';
55}
56if ( $can_edit_posts && !empty($num_posts->future) ) {
57        $post_type_texts[] = 'and <a href="edit.php?post_status=future">'.sprintf( __ngettext( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).'</a>';
58}
59
60if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) {
61        $pending_text = sprintf( __ngettext( 'There is <a href="%1$s">%2$s post</a> pending your review.', 'There are <a href="%1$s">%2$s posts</a> pending your review.', $num_posts->pending ), 'edit.php?post_status=pending', number_format_i18n( $num_posts->pending ) );
62} else {
63        $pending_text = '';
64}
65
66$post_type_text = implode(', ', $post_type_texts);
67
68// There is always a category
69$sentence = sprintf( __( 'You have %1$s. %4$s' ), $post_type_text, $cats_text, $tags_text, $pending_text );
70$sentence = apply_filters( 'dashboard_count_sentence', $sentence, $post_type_text, $cats_text, $tags_text, $pending_text );
71
72?>
73<p class="youhave"><?php echo $sentence; ?></p>
74
75<?php do_action( 'rightnow_end' ); ?>
76<?php do_action( 'activity_box_end' ); ?>
77</div><!-- rightnow -->
78
79
80<?php
81wp_nonce_field($nonce_action);
82
83if (isset($mode) && 'bookmarklet' == $mode)
84        echo '<input type="hidden" name="mode" value="bookmarklet" />';
85?>
86<input type="hidden" id="user-id" name="user_ID" value="<?php echo $user_ID ?>" />
87<input type="hidden" id="hiddenaction" name="action" value='<?php echo $form_action ?>' />
88<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
89<?php echo $form_extra ?>
90<input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
91<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status ?>" />
92<input name="referredby" type="hidden" id="referredby" value="<?php
93if ( url_to_postid(wp_get_referer()) == $post_ID && strpos( wp_get_referer(), '/wp-admin/' ) === false )
94        echo 'redo';
95else
96        echo clean_url(stripslashes(wp_get_referer()));
97?>" />
98<?php if ( 'draft' != $post->post_status ) wp_original_referer_field(true, 'previous'); ?>
99
100<div id="poststuff">
101
102<div class="submitbox" id="submitpage">
103
104<div id="previewview">
105<?php if ( 'publish' == $post->post_status ) { ?>
106<a href="<?php echo clean_url(get_permalink($post->ID)); ?>" target="_blank"  tabindex="4"><?php _e('View this Page'); ?></a>
107<?php } elseif ( 'edit' == $action ) { ?>
108<a 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>
109<?php } ?>
110</div>
111
112<div class="inside">
113
114<div id="pagewrap">
115
116<div id="pageparentdiv" class="postbox <?php echo postbox_classes('pageparentdiv', 'page'); ?>">
117<h3><?php _e('Page Parent') ?></h3>
118<div class="inside">
119<select name="parent_id">
120<option value='0'><?php _e('Main Page (no parent)'); ?></option>
121<?php parent_dropdown($post->post_parent); ?>
122</select>
123<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>
124</div>
125</div>
126
127<?php if ( 0 != count( get_page_templates() ) ) { ?>
128<div id="pagetemplatediv" class="postbox <?php echo postbox_classes('pagetemplatediv', 'page'); ?>">
129<h3><?php _e('Page Template') ?></h3>
130<div class="inside">
131<select name="page_template">
132<option value='default'><?php _e('Default Template'); ?></option>
133<?php page_template_dropdown($post->page_template); ?>
134</select>
135<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>
136</div>
137</div>
138
139<div id="pagecommentstatusdiv" class="postbox <?php echo postbox_classes('pagecommentstatusdiv', 'page'); ?>">
140<h3><?php _e('Comments &amp; Pings') ?></h3>
141<div class="inside">
142<input name="advanced_view" type="hidden" value="1" />
143<p><label for="comment_status" class="selectit">
144<input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> />
145<?php _e('Allow Comments') ?></label></p>
146<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>
147<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>
148</div>
149</div>
150
151<?php } ?>
152<div id="pagepassworddiv" class="postbox <?php echo postbox_classes('pagepassworddiv', 'page'); ?>">
153<h3><?php _e('Password Protect') ?></h3>
154<div class="inside">
155<p><input name="post_password" type="text" size="25" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></p>
156<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>
157</div>
158</div>
159
160<div id="pageorderdiv" class="postbox <?php echo postbox_classes('pageorderdiv', 'page'); ?>">
161<h3><?php _e('Page Order') ?></h3>
162<div class="inside">
163<p><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $post->menu_order ?>" /></p>
164<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>
165</div>
166</div>
167</div>
168
169<p><strong><?php _e('Publish Status') ?></strong></p>
170<p>
171<select name='post_status' tabindex='4'>
172<?php if ( current_user_can('publish_posts') ) : ?>
173<option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option>
174<?php else: ?>
175<option<?php selected( $post->post_status, 'private' ); ?> value='private'><?php _e('Published') ?></option>
176<?php endif; ?>
177<?php if ( 'future' == $post->post_status ) : ?>
178<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Pending') ?></option>
179<?php endif; ?>
180<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
181<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Unpublished') ?></option>
182</select>
183</p>
184
185<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>
186<?php
187if ($post_ID) {
188        if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
189                $stamp = __('Scheduled for:<br />%1$s at %2$s');
190        } else if ( 'publish' == $post->post_status ) { // already published
191                $stamp = __('Published on:<br />%1$s at %2$s');
192        } else if ( '0000-00-00 00:00:00' == $post->post_date ) { // draft, 1 or more saves, no date specified
193                $stamp = __('Publish immediately');
194        } else { // draft, 1 or more saves, date specified
195                $stamp = __('Publish on:<br />%1$s at %2$s');
196        }
197        $date = mysql2date(get_option('date_format'), $post->post_date);
198        $time = mysql2date(get_option('time_format'), $post->post_date);
199} else { // draft (no saves, and thus no date specified)
200        $stamp = __('Publish immediately');
201        $date = mysql2date(get_option('date_format'), current_time('mysql'));
202        $time = mysql2date(get_option('time_format'), current_time('mysql'));
203}
204?>
205<p class="curtime"><?php printf($stamp, $date, $time); ?>
206&nbsp;<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a></p>
207
208<div id='timestampdiv' class='hide-if-js'><?php touch_time(($action == 'edit'),1,4); ?></div>
209
210</div>
211
212<p class="submit">
213<input type="submit" name="save" class="button button-highlighted" value="<?php _e('Save'); ?>" tabindex="4" />
214<?php
215if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post_ID ) {
216?>
217<?php if ( current_user_can('publish_pages') ) : ?>
218        <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
219<?php else : ?>
220        <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
221<?php endif; ?>
222<?php
223}
224
225if ( ('edit' == $action) && current_user_can('delete_page', $post_ID) )
226        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>";
227?>
228<br class="clear" />
229<?php if ($post_ID): ?>
230<?php if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
231        $last_user = get_userdata($last_id);
232        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));
233} else {
234        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));
235}
236?>
237<br class="clear" />
238<?php endif; ?>
239<span id="autosave"></span>
240</p>
241
242<div class="side-info">
243<h5><?php _e('Related') ?></h5>
244
245<ul>
246<?php if ($post_ID): ?>
247<li><a href="edit-pages.php?page_id=<?php echo $post_ID ?>"><?php _e('See Comments on this Page') ?></a></li>
248<?php endif; ?>
249<li><a href="edit-comments.php"><?php _e('Manage All Comments') ?></a></li>
250<li><a href="edit-pages.php"><?php _e('Manage All Pages') ?></a></li>
251<?php do_action('page_relatedlinks_list'); ?>
252</ul>
253</div>
254<?php do_action('submitpage_box'); ?>
255</div>
256
257<div id="post-body">
258<div id="titlediv">
259<h3><?php _e('Title') ?></h3>
260<div id="titlewrap">
261  <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" autocomplete="off" />
262</div>
263<div class="inside">
264<?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?>
265        <div id="edit-slug-box">
266<?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
267        echo $sample_permalink_html;
268endif; ?>
269        </div>
270</div>
271</div>
272
273<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
274<h3><?php _e('Page') ?></h3>
275<?php the_editor($post->post_content); ?>
276<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
277<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
278<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
279<?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
280</div>
281
282<?php do_meta_boxes('page', 'normal', $post); ?>
283
284<?php do_action('edit_page_form'); ?>
285
286<div id="pageslugdiv" class="postbox <?php echo postbox_classes('pageslugdiv', 'page'); ?>">
287<h3><?php _e('Page Slug') ?></h3>
288<div class="inside">
289<input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" />
290</div>
291</div>
292
293<div id="pagepostcustom" class="postbox <?php echo postbox_classes('pagepostcustom', 'page'); ?>">
294<h3><?php _e('Custom Fields') ?></h3>
295<div class="inside">
296<div id="postcustomstuff">
297<table cellpadding="3">
298<?php
299$metadata = has_meta($post_ID);
300list_meta($metadata);
301?>
302
303</table>
304<?php
305        meta_form();
306?>
307<div id="ajax-response"></div>
308</div>
309<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>
310</div>
311</div>
312
313<?php
314$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
315if ( $post->post_author && !in_array($post->post_author, $authors) )
316        $authors[] = $post->post_author;
317if ( $authors && count( $authors ) > 1 ) :
318?>
319<div id="pageauthordiv" class="postbox <?php echo postbox_classes('pageauthordiv', 'page'); ?>">
320<h3><?php _e('Page Author'); ?></h3>
321<div class="inside">
322<?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?>
323</div>
324</div>
325<?php endif; ?>
326
327<?php do_meta_boxes('page', 'advanced', $post); ?>
328
329</div>
330</div>
331
332</div>
333
334</form>
335
336<script type="text/javascript">
337try{document.post.title.focus();}catch(e){}
338</script>