Ticket #6709: edit-form-advanced.php

File edit-form-advanced.php, 18.2 kB (added by jabecker, 3 months ago)

modified edit-form-advanced.php

Line 
1 <?php
2 $action = isset($action)? $action : '';
3 if ( isset($_GET['message']) )
4     $_GET['message'] = absint( $_GET['message'] );
5 $messages[1] = sprintf( __( 'Post updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) );
6 $messages[2] = __('Custom field updated.');
7 $messages[3] = __('Custom field deleted.');
8 $messages[4] = __('Post updated.');
9 ?>
10 <?php if (isset($_GET['message'])) : ?>
11 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
12 <?php endif; ?>
13
14 <form name="post" action="post.php" method="post" id="post">
15 <?php if ( (isset($mode) && 'bookmarklet' == $mode) || isset($_GET['popupurl']) ): ?>
16 <input type="hidden" name="mode" value="bookmarklet" />
17 <?php endif; ?>
18
19 <div class="wrap">
20 <h2><?php _e('Write Post') ?></h2>
21
22 <div id="rightnowpost">
23
24 <?php if ( $can_edit_posts = current_user_can( 'edit_posts' ) ) : ?>
25 <?php endif; if ( $can_edit_pages = current_user_can( 'edit_pages' ) ) : ?>
26 <?php endif; ?>
27
28 <?php
29 $num_posts = wp_count_posts( 'post' );
30
31 $post_type_texts = array();
32
33 if ( $can_edit_posts && !empty($num_posts->draft) ) {
34     $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>';
35 }
36 if ( $can_edit_posts && !empty($num_posts->future) ) {
37     $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>';
38 }
39
40 if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) {
41     $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 ) );
42 } else {
43     $pending_text = '';
44 }
45
46 $post_type_text = implode(', ', $post_type_texts);
47
48 if ( $can_edit_posts && (!empty($num_posts->draft) || !empty($num_posts->future) || !empty($num_posts->pending) )) {
49     $sentence = sprintf( __( 'You have %1$s. %2$s' ), $post_type_text, $pending_text );
50     $sentence = apply_filters( 'dashboard_count_sentence', $sentence, $post_type_text, $cats_text, $tags_text, $pending_text );
51 }
52 ?>
53 <p class="youhave"><?php echo $sentence; ?></p>
54
55 <?php
56 $my_drafts = get_users_drafts($user_ID);
57
58 $drafts_posts_limit = 3;
59
60 if ( !empty($my_drafts) ) {
61
62     $i = 0;
63      foreach ( $my_drafts as $draft ) {
64         $i++;
65         echo '<a href="post.php?action=edit&amp;post=' . $draft->ID . '">';
66         echo $draft->post_title;
67         echo '</a>';
68         if ( $i < $num_posts->draft )
69             echo ', ';
70         if ( $i == $drafts_posts_limit ) {
71             printf(__('and <a href="edit.php?post_status=draft">%d more</a>'), $num_posts->draft - $drafts_posts_limit);
72             break;
73         }
74     }
75 }
76 ?>
77
78 </div><!-- rightnow -->
79
80 <?php
81
82 if (!isset($post_ID) || 0 == $post_ID) {
83     $form_action = 'post';
84     $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
85     $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
86     wp_nonce_field('add-post');
87 } else {
88     $post_ID = (int) $post_ID;
89     $form_action = 'editpost';
90     $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
91     wp_nonce_field('update-post_' $post_ID);
92 }
93
94 $form_pingback = '<input type="hidden" name="post_pingback" value="' . (int) get_option('default_pingback_flag') . '" id="post_pingback" />';
95
96 $form_prevstatus = '<input type="hidden" name="prev_status" value="' . attribute_escape( $post->post_status ) . '" />';
97
98 $form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. attribute_escape( str_replace("\n", ' ', $post->to_ping) ) .'" />';
99
100 if ('' != $post->pinged) {
101     $pings = '<p>'. __('Already pinged:') . '</p><ul>';
102     $already_pinged = explode("\n", trim($post->pinged));
103     foreach ($already_pinged as $pinged_url) {
104         $pings .= "\n\t<li>" . wp_specialchars($pinged_url) . "</li>";
105     }
106     $pings .= '</ul>';
107 }
108
109 $saveasdraft = '<input name="save" type="submit" id="save" class="button" tabindex="3" value="' . attribute_escape( __('Save and Continue Editing') ) . '" />';
110
111 ?>
112
113 <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
114 <input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" />
115 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
116 <input type="hidden" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" />
117 <input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
118 <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status ?>" />
119 <input name="referredby" type="hidden" id="referredby" value="<?php
120 if ( !empty($_REQUEST['popupurl']) )
121     echo clean_url(stripslashes($_REQUEST['popupurl']));
122 else if ( url_to_postid(wp_get_referer()) == $post_ID && strpos( wp_get_referer(), '/wp-admin/' ) === false )
123     echo 'redo';
124 else
125     echo clean_url(stripslashes(wp_get_referer()));
126 ?>" />
127 <?php if ( 'draft' != $post->post_status ) wp_original_referer_field(true, 'previous'); ?>
128
129 <?php echo $form_extra ?>
130
131 <div id="poststuff">
132
133 <div class="submitbox" id="submitpost">
134
135     <div id="previewview">
136     <?php if ( 'publish' == $post->post_status ) { ?>
137     <a href="<?php echo clean_url(get_permalink($post->ID)); ?>" target="_blank" tabindex="4"><?php _e('View this Post'); ?></a>
138     <?php } elseif ( 'edit' == $action ) { ?>
139     <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 Post'); ?></a>
140     <?php } ?>
141     </div>
142
143 <div id="categorywrap">
144 <div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv', 'post'); ?>">
145 <h3><?php _e('Categories') ?></h3>
146     <div class="inside">
147
148         <div id="category-adder" class="wp-hidden-children">
149             <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
150             <p id="category-add" class="wp-hidden-child">
151                 <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" />
152                 <?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
153                 <input type="button" id="category-add-sumbit" class="add:categorychecklist:categorydiv button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
154                 <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
155                 <span id="category-ajax-response"></span>
156             </p>
157         </div>
158
159         <ul id="category-tabs">
160             <li class="ui-tabs-selected"><a href="#categories-all" tabindex="3"><?php _e( 'All Categories' ); ?></a></li>
161             <li class="wp-no-js-hidden"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
162         </ul>
163
164         <div id="categories-all" class="ui-tabs-panel">
165             <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
166                 <?php dropdown_categories(); ?>
167             </ul>
168         </div>
169
170         <div id="categories-pop" class="ui-tabs-panel" style="display: none;">
171             <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
172                 <?php wp_popular_terms_checklist('category'); ?>
173             </ul>
174         </div>
175
176     </div>
177 </div>
178
179 <div id="commentstatusdiv" class="postbox <?php echo postbox_classes('commentstatusdiv', 'post'); ?>">
180 <h3><?php _e('Comments &amp; Pings') ?></h3>
181 <div class="inside">
182 <input name="advanced_view" type="hidden" value="1" />
183 <p><label for="comment_status" class="selectit">
184 <input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> />
185 <?php _e('Allow Comments') ?></label></p>
186 <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>
187 <p><?php _e('These settings apply to this post only. &#8220;Pings&#8221; are <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a>.'); ?></p>
188 </div>
189 </div>
190
191 <div id="tagsdiv" class="postbox <?php echo postbox_classes('tagsdiv', 'post'); ?>">
192 <h3><?php _e('Tags'); ?></h3>
193 <div class="inside">
194 <p id="jaxtag"><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post_ID ); ?>" /></p>
195 <div id="tagchecklist"></div>
196 </div>
197 </div>
198
199 <?php
200 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
201 if ( $post->post_author && !in_array($post->post_author, $authors) )
202     $authors[] = $post->post_author;
203 if ( $authors && count( $authors ) > 1 ) :
204 ?>
205 <div id="authordiv" class="postbox <?php echo postbox_classes('authordiv', 'post'); ?>">
206 <h3><?php _e('Post Author'); ?></h3>
207 <div class="inside">
208 <?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?>
209 </div>
210 </div>
211 <?php endif; ?>
212
213 <div id="passworddiv" class="postbox <?php echo postbox_classes('passworddiv', 'post'); ?>">
214 <h3><?php _e('Password Protect') ?></h3>
215 <div class="inside">
216 <p><input name="post_password" type="text" size="25" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></p>
217 <p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this post and its comments.'); ?></p>
218 </div>
219 </div>
220
221 </div>
222
223     <div class="inside">
224
225     <p><strong><?php _e('Publish Status') ?></strong></p>
226     <p>
227     <select name='post_status' tabindex='4'>
228     <?php if ( current_user_can('publish_posts') ) : // Contributors only get "Unpublished" and "Pending Review" ?>
229     <option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option>
230     <?php if ( 'future' == $post->post_status ) : ?>
231     <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
232     <?php endif; ?>
233     <?php endif; ?>
234     <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
235     <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Unpublished') ?></option>
236     </select>
237     </p>
238
239     <?php if ( current_user_can( 'publish_posts' ) ) : ?>
240     <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 post private') ?></label></p>
241     <?php endif; ?>
242     <?php
243 if ($post_ID) {
244     if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
245         $stamp = __('Scheduled for:<br />%1$s at %2$s');
246     } else if ( 'publish' == $post->post_status ) { // already published
247         $stamp = __('Published on:<br />%1$s at %2$s');
248     } else if ( '0000-00-00 00:00:00' == $post->post_date ) { // draft, 1 or more saves, no date specified
249         $stamp = __('Publish immediately');
250     } else { // draft, 1 or more saves, date specified
251         $stamp = __('Publish on:<br />%1$s at %2$s');
252     }
253     $date = mysql2date(get_option('date_format'), $post->post_date);
254     $time = mysql2date(get_option('time_format'), $post->post_date);
255 } else { // draft (no saves, and thus no date specified)
256     $stamp = __('Publish immediately');
257     $date = mysql2date(get_option('date_format'), current_time('mysql'));
258     $time = mysql2date(get_option('time_format'), current_time('mysql'));
259 }
260 ?>
261 <?php if ( current_user_can( 'publish_posts' ) ) : // Contributors don't get to choose the date of publish ?>
262 <p class="curtime"><?php printf($stamp, $date, $time); ?>
263 &nbsp;<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a></p>
264
265 <div id='timestampdiv' class='hide-if-js'><?php touch_time(($action == 'edit'),1,4); ?></div>
266 <?php endif; ?>
267 </div>
268
269 <p class="submit">
270 <input type="submit" name="save" id="save-post" value="<?php _e('Save'); ?>" tabindex="4" class="button button-highlighted" />
271 <?php
272 if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post_ID ) {
273 ?>
274 <?php if ( current_user_can('publish_posts') ) : ?>
275     <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
276 <?php else : ?>
277     <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
278 <?php endif; ?>
279 <?php
280 }
281
282 if ( ( 'edit' == $action) && current_user_can('delete_post', $post_ID) )
283     echo "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post_ID", 'delete-post_' . $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 post '%s'\n  'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete&nbsp;post') . "</a>";
284 ?>
285 <br class="clear" />
286 <?php if ($post_ID): ?>
287 <?php if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
288     $last_user = get_userdata($last_id);
289     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));
290 } else {
291     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));
292 }
293 ?>
294 <br class="clear" />
295 <?php endif; ?>
296 <span id="autosave"></span>
297 </p>
298
299 <div class="side-info">
300 <h5><?php _e('Related') ?></h5>
301
302 <ul>
303 <?php if ($post_ID): ?>
304 <li><a href="edit.php?p=<?php echo $post_ID ?>"><?php _e('See Comments on this Post') ?></a></li>
305 <?php endif; ?>
306 <li><a href="edit-comments.php"><?php _e('Manage All Comments') ?></a></li>
307 <li><a href="edit.php"><?php _e('Manage All Posts') ?></a></li>
308 <li><a href="categories.php"><?php _e('Manage All Categories') ?></a></li>
309 <li><a href="edit-tags.php"><?php _e('Manage All Tags') ?></a></li>
310 <li><a href="edit.php?post_status=draft"><?php _e('View Drafts'); ?></a></li>
311 <?php do_action('post_relatedlinks_list'); ?>
312 </ul>
313 </div>
314
315 <?php do_action('submitpost_box'); ?>
316 </div>
317
318 <div id="post-body">
319 <div id="titlediv">
320 <h3><?php _e('Title') ?></h3>
321 <div id="titlewrap">
322     <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape($post->post_title); ?>" id="title" autocomplete="off" />
323 </div>
324 <div class="inside">
325 <?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?>
326     <div id="edit-slug-box">
327 <?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
328     echo $sample_permalink_html;
329 endif; ?>
330     </div>
331 </div>
332 </div>
333
334 <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
335 <h3><?php _e('Post') ?></h3>
336 <?php the_editor($post->post_content); ?>
337 <?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
338 <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
339 <?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
340 <?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
341 </div>
342
343 <?php echo $form_pingback ?>
344 <?php echo $form_prevstatus ?>
345
346 <div id="postcustom" class="postbox <?php echo postbox_classes('postcustom', 'post'); ?>">
347 <h3><?php _e('Custom Fields') ?></h3>
348 <div class="inside">
349 <div id="postcustomstuff">
350 <table cellpadding="3">
351 <?php
352 $metadata = has_meta($post_ID);
353 list_meta($metadata);
354 ?>
355
356 </table>
357 <?php
358     meta_form();
359 ?>
360 <div id="ajax-response"></div>
361 </div>
362 <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>
363 </div>
364 </div>
365
366 <?php do_meta_boxes('post', 'normal', $post); ?>
367
368 <?php do_action('edit_form_advanced'); ?>
369 <div id="postexcerpt" class="postbox <?php echo postbox_classes('postexcerpt', 'post'); ?>">
370 <h3><?php _e('Excerpt') ?></h3>
371 <div class="inside"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea>
372 <p><?php _e('Excerpts are optional hand-crafted summaries of your content. You can <a href="http://codex.wordpress.org/Template_Tags/the_excerpt" target="_blank">use them in your template</a>'); ?></p>
373 </div>
374 </div>
375
376 <div id="trackbacksdiv" class="postbox <?php echo postbox_classes('trackbacksdiv', 'post'); ?>">
377 <h3><?php _e('Trackbacks') ?></h3>
378 <div class="inside">
379 <p><?php _e('Send trackbacks to:'); ?> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p>
380 <p><?php _e('Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. If you link other WordPress blogs they&#8217;ll be notified automatically using <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">pingbacks</a>, no other action necessary.'); ?></p>
381 <?php
382 if ( ! empty($pings) )
383     echo $pings;
384 ?>
385 </div>
386 </div>
387
388 <?php do_action('dbx_post_advanced'); ?>
389
390 <div id="slugdiv" class="postbox <?php echo postbox_classes('slugdiv', 'post'); ?>">
391 <h3><?php _e('Post Slug') ?></h3>
392 <div class="inside">
393 <input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" />
394 </div>
395 </div>
396
397 <?php do_meta_boxes('post', 'advanced', $post); ?>
398
399 <?php do_action('dbx_post_sidebar'); ?>
400 </div>
401 </div>
402
403 </div>
404
405 </form>
406
407 <?php if ((isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message'])) : ?>
408 <script type="text/javascript">
409 try{document.post.title.focus();}catch(e){}
410 </script>
411 <?php endif; ?>