[ Index ]

PHP Cross Reference of WordPress 3.0 beta 1

[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/wp-admin/ -> edit-form-advanced.php (source)

   1  <?php
   2  /**
   3   * Post advanced form for inclusion in the administration panels.
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  // don't load directly
  10  if ( !defined('ABSPATH') )
  11      die('-1');
  12  
  13  /**
  14   * Post ID global
  15   * @name $post_ID
  16   * @var int
  17   */
  18  $post_ID = isset($post_ID) ? (int) $post_ID : 0;
  19  $temp_ID = isset($temp_ID) ? (int) $temp_ID : 0;
  20  $user_ID = isset($user_ID) ? (int) $user_ID : 0;
  21  $action = isset($action) ? $action : '';
  22  
  23  $messages = array();
  24  $messages['post'] = array(
  25      '',
  26      sprintf( __('Post updated. <a href="%s">View post</a>'), get_permalink($post_ID) ),
  27      __('Custom field updated.'),
  28      __('Custom field deleted.'),
  29      __('Post updated.'),
  30      /* translators: %s: date and time of the revision */
  31      isset($_GET['revision']) ? sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
  32      sprintf( __('Post published. <a href="%s">View post</a>'), get_permalink($post_ID) ),
  33      __('Post saved.'),
  34      sprintf( __('Post submitted. <a target="_blank" href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ),
  35      sprintf( __('Post scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview post</a>'),
  36          // translators: Publish box date format, see http://php.net/date
  37          date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), get_permalink($post_ID) ),
  38      sprintf( __('Post draft updated. <a target="_blank" href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) )
  39  );
  40  $messages['page'] = array(
  41      '',
  42      sprintf( __('Page updated. <a href="%s">View page</a>'), get_permalink($post_ID) ),
  43      __('Custom field updated.'),
  44      __('Custom field deleted.'),
  45      __('Page updated.'),
  46      isset($_GET['revision']) ? sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
  47      sprintf( __('Page published. <a href="%s">View page</a>'), get_permalink($post_ID) ),
  48      sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ),
  49      sprintf( __('Page scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview page</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), get_permalink($post_ID) ),
  50      sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) )
  51  );
  52  
  53  $message = false;
  54  if ( isset($_GET['message']) ) {
  55      $_GET['message'] = absint( $_GET['message'] );
  56      if ( isset($messages[$post_type][$_GET['message']]) )
  57          $message = $messages[$post_type][$_GET['message']];
  58      elseif ( !isset($messages[$post_type]) && isset($messages['post'][$_GET['message']]) )
  59          $message = $messages['post'][$_GET['message']];
  60  }
  61  
  62  $notice = false;
  63  $form_extra = '';
  64  if ( 'auto-draft' == $post->post_status ) {
  65      if ( 'edit' == $action )
  66          $post->post_title = '';
  67      $autosave = false;
  68      $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
  69  } else {
  70      $autosave = wp_get_post_autosave( $post_ID );
  71  }
  72  
  73  $form_action = 'editpost';
  74  $nonce_action = 'update-' . $post_type . '_' . $post_ID;
  75  $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />";
  76  
  77  // Detect if there exists an autosave newer than the post and if that autosave is different than the post
  78  if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
  79      foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
  80          if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
  81              $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below.  <a href="%s">View the autosave</a>' ), get_edit_post_link( $autosave->ID ) );
  82              break;
  83          }
  84      }
  85      unset($autosave_field, $_autosave_field);
  86  }
  87  
  88  $post_type_object = get_post_type_object($post_type);
  89  
  90  // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
  91  require_once ('includes/meta-boxes.php');
  92  
  93  add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $post_type, 'side', 'core');
  94  
  95  // all taxonomies
  96  foreach ( get_object_taxonomies($post_type) as $tax_name ) {
  97      $taxonomy = get_taxonomy($tax_name);
  98      if ( ! $taxonomy->show_ui )
  99          continue;
 100  
 101      $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name;
 102  
 103      if ( !is_taxonomy_hierarchical($tax_name) )
 104          add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', $post_type, 'side', 'core');
 105      else
 106          add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', $post_type, 'side', 'core', array( 'taxonomy' => $tax_name ));
 107  }
 108  
 109  if ( post_type_supports($post_type, 'page-attributes') )
 110      add_meta_box('pageparentdiv', __('Attributes'), 'page_attributes_meta_box', $post_type, 'side', 'core');
 111  
 112  if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports($post_type, 'thumbnail') )
 113      add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', $post_type, 'side', 'low');
 114  
 115  if ( post_type_supports($post_type, 'excerpt') )
 116      add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core');
 117  
 118  if ( post_type_supports($post_type, 'trackbacks') )
 119      add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', $post_type, 'normal', 'core');
 120  
 121  if ( post_type_supports($post_type, 'custom-fields') )
 122      add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', $post_type, 'normal', 'core');
 123  
 124  do_action('dbx_post_advanced');
 125  if ( post_type_supports($post_type, 'comments') )
 126      add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', $post_type, 'normal', 'core');
 127  
 128  if ( ('publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') )
 129      add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core');
 130  
 131  if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) )
 132      add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');
 133  
 134  if ( post_type_supports($post_type, 'author') ) {
 135      $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
 136      if ( $post->post_author && !in_array($post->post_author, $authors) )
 137          $authors[] = $post->post_author;
 138      if ( $authors && count( $authors ) > 1 )
 139          add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
 140  }
 141  
 142  if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
 143      add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core');
 144  
 145  do_action('add_meta_boxes', $post_type, $post);
 146  do_action('add_meta_boxes_' . $post_type, $post);
 147  
 148  do_action('do_meta_boxes', $post_type, 'normal', $post);
 149  do_action('do_meta_boxes', $post_type, 'advanced', $post);
 150  do_action('do_meta_boxes', $post_type, 'side', $post);
 151  
 152  add_contextual_help($current_screen, drag_drop_help());
 153  
 154  require_once ('admin-header.php');
 155  ?>
 156  
 157  <div class="wrap">
 158  <?php screen_icon(); ?>
 159  <h2><?php echo esc_html( $title ); ?></h2>
 160  <?php if ( $notice ) : ?>
 161  <div id="notice" class="error"><p><?php echo $notice ?></p></div>
 162  <?php endif; ?>
 163  <?php if ( $message ) : ?>
 164  <div id="message" class="updated"><p><?php echo $message; ?></p></div>
 165  <?php endif; ?>
 166  <form name="post" action="post.php" method="post" id="post">
 167  <?php wp_nonce_field($nonce_action); ?>
 168  <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
 169  <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action) ?>" />
 170  <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" />
 171  <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
 172  <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post_type) ?>" />
 173  <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($post->post_status) ?>" />
 174  <input name="referredby" type="hidden" id="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" />
 175  <?php
 176  if ( 'draft' != $post->post_status )
 177      wp_original_referer_field(true, 'previous');
 178  
 179  echo $form_extra ?>
 180  
 181  <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
 182  <div id="side-info-column" class="inner-sidebar">
 183  
 184  <?php
 185  ('page' == $post_type) ? do_action('submitpage_box') : do_action('submitpost_box');
 186  $side_meta_boxes = do_meta_boxes($post_type, 'side', $post);
 187  ?>
 188  </div>
 189  
 190  <div id="post-body">
 191  <div id="post-body-content">
 192  <?php if ( post_type_supports($post_type, 'title') ) { ?>
 193  <div id="titlediv">
 194  <div id="titlewrap">
 195      <label class="screen-reader-text" for="title"><?php _e('Title') ?></label>
 196      <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off" />
 197  </div>
 198  <div class="inside">
 199  <?php
 200  $sample_permalink_html = get_sample_permalink_html($post->ID);
 201  $shortlink = wp_get_shortlink($post->ID, 'post');
 202  if ( !empty($shortlink) )
 203      $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
 204  
 205  if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) ) { ?>
 206      <div id="edit-slug-box">
 207      <?php
 208          if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status )
 209              echo $sample_permalink_html;
 210      ?>
 211      </div>
 212  <?php
 213  }
 214  ?>
 215  </div>
 216  </div>
 217  <?php } ?>
 218  
 219  <?php if ( post_type_supports($post_type, 'editor') ) { ?>
 220  <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
 221  
 222  <?php the_editor($post->post_content); ?>
 223  
 224  <table id="post-status-info" cellspacing="0"><tbody><tr>
 225      <td id="wp-word-count"></td>
 226      <td class="autosave-info">
 227      <span id="autosave">&nbsp;</span>
 228  <?php
 229      if ( 'auto-draft' != $post->post_status ) {
 230          echo '<span id="last-edit">';
 231          if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
 232              $last_user = get_userdata($last_id);
 233              printf(__('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
 234          } else {
 235              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));
 236          }
 237          echo '</span>';
 238      } ?>
 239      </td>
 240  </tr></tbody></table>
 241  
 242  <?php
 243  wp_nonce_field( 'autosave', 'autosavenonce', false );
 244  wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
 245  wp_nonce_field( 'getpermalink', 'getpermalinknonce', false );
 246  wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
 247  wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
 248  </div>
 249  
 250  <?php
 251  }
 252  
 253  do_meta_boxes($post_type, 'normal', $post);
 254  
 255  ( 'page' == $post_type ) ? do_action('edit_page_form') : do_action('edit_form_advanced');
 256  
 257  do_meta_boxes($post_type, 'advanced', $post);
 258  
 259  do_action('dbx_post_sidebar'); ?>
 260  
 261  </div>
 262  </div>
 263  <br class="clear" />
 264  </div><!-- /poststuff -->
 265  </form>
 266  </div>
 267  
 268  <?php wp_comment_reply(); ?>
 269  
 270  <?php if ((isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message'])) : ?>
 271  <script type="text/javascript">
 272  try{document.post.title.focus();}catch(e){}
 273  </script>
 274  <?php endif; ?>


Generated: Mon Apr 5 14:26:09 2010 Cross-referenced by PHPXref 0.7