diff options
Diffstat (limited to 'wp-admin/edit-form-advanced.php')
-rw-r--r-- | wp-admin/edit-form-advanced.php | 206 |
1 files changed, 119 insertions, 87 deletions
diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 7d1ff7d..e87945e 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -1,12 +1,35 @@ <?php -$action = isset($action)? $action : ''; + +$action = isset($action) ? $action : ''; if ( isset($_GET['message']) ) $_GET['message'] = absint( $_GET['message'] ); $messages[1] = sprintf( __( 'Post updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) ); $messages[2] = __('Custom field updated.'); $messages[3] = __('Custom field deleted.'); $messages[4] = __('Post updated.'); +$messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( $_GET['revision'], false ) ); + +$notice = false; +$notices[1] = __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>.' ); + +if ( !isset($post_ID) || 0 == $post_ID ) { + $form_action = 'post'; + $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() + $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />"; + $autosave = false; +} else { + $post_ID = (int) $post_ID; + $form_action = 'editpost'; + $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />"; + $autosave = wp_get_post_autosave( $post_id ); + if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) ) + $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) ); +} + ?> +<?php if ( $notice ) : ?> +<div id="notice" class="error"><p><?php echo $notice ?></p></div> +<?php endif; ?> <?php if (isset($_GET['message'])) : ?> <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div> <?php endif; ?> @@ -20,33 +43,15 @@ $messages[4] = __('Post updated.'); <h2><?php _e('Write Post') ?></h2> <?php -if (!isset($post_ID) || 0 == $post_ID) { - $form_action = 'post'; - $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() - $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />"; +if ( !isset($post_ID) || 0 == $post_ID) wp_nonce_field('add-post'); -} else { - $post_ID = (int) $post_ID; - $form_action = 'editpost'; - $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />"; +else wp_nonce_field('update-post_' . $post_ID); -} $form_pingback = '<input type="hidden" name="post_pingback" value="' . (int) get_option('default_pingback_flag') . '" id="post_pingback" />'; $form_prevstatus = '<input type="hidden" name="prev_status" value="' . attribute_escape( $post->post_status ) . '" />'; -$form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. attribute_escape( str_replace("\n", ' ', $post->to_ping) ) .'" />'; - -if ('' != $post->pinged) { - $pings = '<p>'. __('Already pinged:') . '</p><ul>'; - $already_pinged = explode("\n", trim($post->pinged)); - foreach ($already_pinged as $pinged_url) { - $pings .= "\n\t<li>" . wp_specialchars($pinged_url) . "</li>"; - } - $pings .= '</ul>'; -} - $saveasdraft = '<input name="save" type="submit" id="save" class="button" tabindex="3" value="' . attribute_escape( __('Save and Continue Editing') ) . '" />'; ?> @@ -83,10 +88,13 @@ else <div class="inside"> -<p><strong><?php _e('Publish Status') ?></strong></p> +<p><strong><label for='post_status'><?php _e('Publish Status') ?></label></strong></p> <p> -<select name='post_status' tabindex='4'> -<?php if ( current_user_can('publish_posts') ) : // Contributors only get "Unpublished" and "Pending Review" ?> +<select name='post_status' id='post_status' tabindex='4'> +<?php +// only show the publish menu item if they are allowed to publish posts or they are allowed to edit this post (accounts for 'edit_published_posts' capability) +if ( current_user_can('publish_posts') OR ( $post->post_status == 'publish' AND current_user_can('edit_post', $post->ID) ) ) : +?> <option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option> <?php if ( 'future' == $post->post_status ) : ?> <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option> @@ -156,6 +164,7 @@ if ( ( 'edit' == $action) && current_user_can('delete_post', $post_ID) ) <br class="clear" /> <?php endif; ?> <span id="autosave"></span> +<span id="wp-word-count"></span> </p> <div class="side-info"> @@ -172,6 +181,9 @@ if ( ( 'edit' == $action) && current_user_can('delete_post', $post_ID) ) <li><a href="edit.php?post_status=draft"><?php _e('View Drafts'); ?></a></li> <?php do_action('post_relatedlinks_list'); ?> </ul> + +<h5><?php _e('Shortcuts') ?></h5> +<p><?php _e('Drag-and-drop the following link to your bookmarks bar or right click it and add it to your favorites for a posting shortcut.') ?> <a href="<?php echo get_shortcut_link(); ?>" title="<?php echo attribute_escape(__('Press This')) ?>"><?php _e('Press This') ?></a></p> </div> <?php do_action('submitpost_box'); ?> @@ -179,7 +191,7 @@ if ( ( 'edit' == $action) && current_user_can('delete_post', $post_ID) ) <div id="post-body"> <div id="titlediv"> -<h3><?php _e('Title') ?></h3> +<h3><label for="title"><?php _e('Title') ?></label></h3> <div id="titlewrap"> <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape($post->post_title); ?>" id="title" autocomplete="off" /> </div> @@ -194,7 +206,7 @@ endif; ?> </div> <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea"> -<h3><?php _e('Post') ?></h3> +<h3><label for="content"><?php _e('Post') ?></label></h3> <?php the_editor($post->post_content); ?> <?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?> <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> @@ -205,23 +217,22 @@ endif; ?> <?php echo $form_pingback ?> <?php echo $form_prevstatus ?> -<div id="tagsdiv" class="postbox <?php echo postbox_classes('tagsdiv', 'post'); ?>"> -<h3><?php _e('Tags'); ?></h3> -<div class="inside"> -<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> +<?php +function post_tags_meta_box($post) { +?> +<p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><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> <div id="tagchecklist"></div> -</div> -</div> - -<div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv', 'post'); ?>"> -<h3><?php _e('Categories') ?></h3> -<div class="inside"> +<?php +} +add_meta_box('tagsdiv', __('Tags'), 'post_tags_meta_box', 'post', 'normal', 'core'); +function post_categories_meta_box($post) { +?> <div id="category-adder" class="wp-hidden-children"> <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4> <p id="category-add" class="wp-hidden-child"> - <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" /> - <?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?> + <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="true"/> + <label class="hidden" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?> <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" /> <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?> <span id="category-ajax-response"></span> @@ -244,9 +255,10 @@ endif; ?> <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?> </ul> </div> - -</div> -</div> +<?php +} +add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'normal', 'core'); +?> <?php do_meta_boxes('post', 'normal', $post); ?> @@ -254,32 +266,41 @@ endif; ?> <h2><?php _e('Advanced Options'); ?></h2> -<div id="postexcerpt" class="postbox <?php echo postbox_classes('postexcerpt', 'post'); ?>"> -<h3><?php _e('Excerpt') ?></h3> -<div class="inside"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea> +<?php +function post_excerpt_meta_box($post) { +?> +<label class="hidden" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea> <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> -</div> -</div> +<?php +} +add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'advanced', 'core'); + +function post_trackback_meta_box($post) { + $form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. attribute_escape( str_replace("\n", ' ', $post->to_ping) ) .'" />'; + if ('' != $post->pinged) { + $pings = '<p>'. __('Already pinged:') . '</p><ul>'; + $already_pinged = explode("\n", trim($post->pinged)); + foreach ($already_pinged as $pinged_url) { + $pings .= "\n\t<li>" . wp_specialchars($pinged_url) . "</li>"; + } + $pings .= '</ul>'; + } -<div id="trackbacksdiv" class="postbox <?php echo postbox_classes('trackbacksdiv', 'post'); ?>"> -<h3><?php _e('Trackbacks') ?></h3> -<div class="inside"> -<p><?php _e('Send trackbacks to:'); ?> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p> +?> +<p><label for="trackback"><?php _e('Send trackbacks to:'); ?></label> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p> <p><?php _e('Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress blogs they’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> <?php if ( ! empty($pings) ) echo $pings; -?> -</div> -</div> +} +add_meta_box('trackbacksdiv', __('Trackbacks'), 'post_trackback_meta_box', 'post', 'advanced', 'core'); -<div id="postcustom" class="postbox <?php echo postbox_classes('postcustom', 'post'); ?>"> -<h3><?php _e('Custom Fields') ?></h3> -<div class="inside"> +function post_custom_meta_box($post) { +?> <div id="postcustomstuff"> <table cellpadding="3"> <?php -$metadata = has_meta($post_ID); +$metadata = has_meta($post->ID); list_meta($metadata); ?> @@ -290,55 +311,66 @@ list_meta($metadata); <div id="ajax-response"></div> </div> <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> -</div> -</div> +<?php +} +add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'advanced', 'core'); -<?php do_action('dbx_post_advanced'); ?> +do_action('dbx_post_advanced'); -<div id="commentstatusdiv" class="postbox <?php echo postbox_classes('commentstatusdiv', 'post'); ?>"> -<h3><?php _e('Comments & Pings') ?></h3> -<div class="inside"> +function post_comment_status_meta_box($post) { +?> <input name="advanced_view" type="hidden" value="1" /> <p><label for="comment_status" class="selectit"> <input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e('Allow Comments') ?></label></p> <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> <p><?php _e('These settings apply to this post only. “Pings” are <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a>.'); ?></p> -</div> -</div> +<?php +} +add_meta_box('commentstatusdiv', __('Comments & Pings'), 'post_comment_status_meta_box', 'post', 'advanced', 'core'); -<div id="passworddiv" class="postbox <?php echo postbox_classes('passworddiv', 'post'); ?>"> -<h3><?php _e('Password Protect This Post') ?></h3> -<div class="inside"> -<p><input name="post_password" type="text" size="25" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></p> +function post_password_meta_box($post) { +?> +<p><label class="hidden" for="post_password"><?php _e('Password Protect This Post') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></p> <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> -</div> -</div> - -<div id="slugdiv" class="postbox <?php echo postbox_classes('slugdiv', 'post'); ?>"> -<h3><?php _e('Post Slug') ?></h3> -<div class="inside"> -<input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" /> -</div> -</div> +<?php +} +add_meta_box('passworddiv', __('Password Protect This Post'), 'post_password_meta_box', 'post', 'advanced', 'core'); +function post_slug_meta_box($post) { +?> +<label class="hidden" for="post_name"><?php _e('Post Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" /> <?php +} +add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'advanced', 'core'); + $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM if ( $post->post_author && !in_array($post->post_author, $authors) ) $authors[] = $post->post_author; if ( $authors && count( $authors ) > 1 ) : +function post_author_meta_box($post) { + global $current_user, $user_ID; + $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM + if ( $post->post_author && !in_array($post->post_author, $authors) ) + $authors[] = $post->post_author; ?> -<div id="authordiv" class="postbox <?php echo postbox_classes('authordiv', 'post'); ?>"> -<h3><?php _e('Post Author'); ?></h3> -<div class="inside"> -<?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?> -</div> -</div> -<?php endif; ?> +<label class="hidden" for="post_author_override"><?php _e('Post Author'); ?></label><?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?> +<?php +} +add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'advanced', 'core'); +endif; -<?php do_meta_boxes('post', 'advanced', $post); ?> +if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : +function post_revisions_meta_box($post) { + wp_list_post_revisions(); +} +add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'advanced', 'core'); +endif; -<?php do_action('dbx_post_sidebar'); ?> +do_meta_boxes('post', 'advanced', $post); + +do_action('dbx_post_sidebar'); +?> </div> </div> |