Ticket #9674: 9674.14.diff
| File 9674.14.diff, 19.1 KB (added by , 16 years ago) |
|---|
-
wp-admin/edit-page-form.php
1 <?php2 /**3 * Edit page form for inclusion in the administration panels.4 *5 * @package WordPress6 * @subpackage Administration7 */8 9 // don't load directly10 if ( !defined('ABSPATH') )11 die('-1');12 13 /**14 * Post ID global.15 * @name $post_ID16 * @var int17 */18 if ( ! isset( $post_ID ) )19 $post_ID = 0;20 if ( ! isset( $temp_ID ) )21 $temp_ID = 0;22 23 $message = false;24 if ( isset($_GET['message']) ) {25 $_GET['message'] = absint( $_GET['message'] );26 27 switch ( $_GET['message'] ) {28 case 1:29 $message = sprintf( __('Page updated. <a href="%s">View page</a>'), get_permalink($post_ID) );30 break;31 case 2:32 $message = __('Custom field updated.');33 break;34 case 3:35 $message = __('Custom field deleted.');36 break;37 case 4:38 $message = sprintf( __('Page published. <a href="%s">View page</a>'), get_permalink($post_ID) );39 break;40 case 5:41 if ( isset($_GET['revision']) )42 $message = sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) );43 break;44 case 6:45 $message = sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );46 break;47 case 7:48 // translators: Publish box date formt, see http://php.net/date - Same as in meta-boxes.php49 $message = sprintf( __('Page scheduled for: <b>%1$s</b>. <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 break;51 case 8:52 $message = sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );53 break;54 }55 }56 57 $notice = false;58 if ( 0 == $post_ID) {59 $form_action = 'post';60 $nonce_action = 'add-page';61 $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()62 $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";63 } else {64 $post_ID = (int) $post_ID;65 $form_action = 'editpost';66 $nonce_action = 'update-page_' . $post_ID;67 $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";68 $autosave = wp_get_post_autosave( $post_ID );69 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) )70 $notice = sprintf( __( 'There is an autosave of this page that is more recent than the version below. <a href="%s">View the autosave</a>.' ), get_edit_post_link( $autosave->ID ) );71 }72 73 $temp_ID = (int) $temp_ID;74 $user_ID = (int) $user_ID;75 76 require_once('includes/meta-boxes.php');77 78 $post_type = 'page';79 80 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'page', 'side', 'core');81 82 // all tag-style page taxonomies83 foreach ( get_object_taxonomies('page') as $tax_name ) {84 if ( !is_taxonomy_hierarchical($tax_name) ) {85 $taxonomy = get_taxonomy($tax_name);86 $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name;87 88 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', $post_type, 'side', 'core');89 }90 }91 92 if ( post_type_supports($post_type, 'page-attributes') )93 add_meta_box('pageparentdiv', __('Attributes'), 'page_attributes_meta_box', $post_type, 'side', 'core');94 if ( post_type_supports($post_type, 'custom-fields') )95 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', $post_type, 'normal', 'core');96 if ( post_type_supports($post_type, 'comments') )97 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', $post_type, 'normal', 'core');98 add_meta_box('slugdiv', __('Page Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');99 if ( current_theme_supports( 'post-thumbnails', 'page' ) && post_type_supports($post_type, 'post-thumbnails') )100 add_meta_box('postimagediv', __('Page Image'), 'post_thumbnail_meta_box', $post_type, 'side', 'low');101 102 $authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM103 if ( $post->post_author && !in_array($post->post_author, $authors) )104 $authors[] = $post->post_author;105 if ( $authors && count( $authors ) > 1 )106 add_meta_box('pageauthordiv', __('Page Author'), 'post_author_meta_box', $post_type, 'normal', 'core');107 108 if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) )109 add_meta_box('revisionsdiv', __('Page Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core');110 111 do_action('do_meta_boxes', $post_type, 'normal', $post);112 do_action('do_meta_boxes', $post_type, 'advanced', $post);113 do_action('do_meta_boxes', $post_type, 'side', $post);114 115 require_once('admin-header.php');116 ?>117 118 <div class="wrap">119 <?php screen_icon(); ?>120 <h2><?php echo esc_html( $title ); ?></h2>121 122 <form name="post" action="page.php" method="post" id="post">123 <?php if ( $notice ) : ?>124 <div id="notice" class="error"><p><?php echo $notice ?></p></div>125 <?php endif; ?>126 <?php if ( $message ) : ?>127 <div id="message" class="updated"><p><?php echo $message; ?></p></div>128 <?php endif; ?>129 130 <?php wp_nonce_field($nonce_action); ?>131 132 <input type="hidden" id="user-id" name="user_ID" value="<?php echo $user_ID ?>" />133 <input type="hidden" id="hiddenaction" name="action" value='<?php echo esc_attr($form_action) ?>' />134 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" />135 <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />136 <?php echo $form_extra ?>137 <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post->post_type) ?>" />138 <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($post->post_status) ?>" />139 <input name="referredby" type="hidden" id="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" />140 <?php if ( 'draft' != $post->post_status ) wp_original_referer_field(true, 'previous'); ?>141 142 <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">143 144 <div id="side-info-column" class="inner-sidebar">145 <?php146 do_action('submitpage_box');147 $side_meta_boxes = do_meta_boxes($post_type, 'side', $post); ?>148 </div>149 150 <div id="post-body">151 <div id="post-body-content">152 <div id="titlediv">153 <div id="titlewrap">154 <label class="screen-reader-text" for="title"><?php _e('Title') ?></label>155 <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off" />156 </div>157 <div class="inside">158 <?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?>159 <div id="edit-slug-box">160 <?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :161 echo $sample_permalink_html;162 endif; ?>163 </div>164 </div>165 </div>166 167 <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">168 169 <?php the_editor($post->post_content); ?>170 <table id="post-status-info" cellspacing="0"><tbody><tr>171 <td id="wp-word-count"></td>172 <td class="autosave-info">173 <span id="autosave"> </span>174 175 <?php176 if ($post_ID) {177 if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {178 $last_user = get_userdata($last_id);179 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));180 } else {181 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));182 }183 }184 ?>185 </td>186 </tr></tbody></table>187 188 <?php189 wp_nonce_field( 'autosave', 'autosavenonce', false );190 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );191 wp_nonce_field( 'getpermalink', 'getpermalinknonce', false );192 wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );193 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>194 </div>195 196 <?php197 do_meta_boxes($post_type, 'normal', $post);198 do_action('edit_page_form');199 do_meta_boxes($post_type, 'advanced', $post);200 ?>201 202 </div>203 </div>204 </div>205 206 </form>207 </div>208 209 <script type="text/javascript">210 try{document.post.title.focus();}catch(e){}211 </script> -
wp-admin/edit-form-advanced.php
16 16 * @var int 17 17 */ 18 18 $post_ID = isset($post_ID) ? (int) $post_ID : 0; 19 19 $temp_ID = isset($temp_ID) ? (int) $temp_ID : 0; 20 $user_ID = isset($user_ID) ? (int) $user_ID : 0; 20 21 $action = isset($action) ? $action : ''; 21 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 isset($_GET['revision']) ? sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 31 sprintf( __('Post published. <a href="%s">View post</a>'), get_permalink($post_ID) ), 32 __('Post saved.'), 33 sprintf( __('Post submitted. <a target="_blank" href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ), 34 // translators: Publish box date format, see http://php.net/date - Same as in meta-boxes.php 35 sprintf( __('Post scheduled for: <b>%1$s</b>. <a target="_blank" href="%2$s">Preview post</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), get_permalink($post_ID) ), 36 sprintf( __('Post draft updated. <a target="_blank" href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) 37 ); 38 $messages['page'] = array( 39 '', 40 sprintf( __('Page updated. <a href="%s">View page</a>'), get_permalink($post_ID) ), 41 __('Custom field updated.'), 42 __('Custom field deleted.'), 43 sprintf( __('Page published. <a href="%s">View page</a>'), get_permalink($post_ID) ), 44 isset($_GET['revision']) ? sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 45 sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ), 46 // translators: Publish box date format, see http://php.net/date - Same as in meta-boxes.php 47 sprintf( __('Page scheduled for: <b>%1$s</b>. <a target="_blank" href="%2$s">Preview page</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), get_permalink($post_ID) ), 48 sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) 49 ); 50 22 51 $message = false; 23 52 if ( isset($_GET['message']) ) { 24 53 $_GET['message'] = absint( $_GET['message'] ); 25 26 switch ( $_GET['message'] ) { 27 case 1: 28 $message = sprintf( __('Post updated. <a href="%s">View post</a>'), get_permalink($post_ID) ); 29 break; 30 case 2: 31 $message = __('Custom field updated.'); 32 break; 33 case 3: 34 $message = __('Custom field deleted.'); 35 break; 36 case 4: 37 $message = __('Post updated.'); 38 break; 39 case 5: 40 if ( isset($_GET['revision']) ) 41 $message = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ); 42 break; 43 case 6: 44 $message = sprintf( __('Post published. <a href="%s">View post</a>'), get_permalink($post_ID) ); 45 break; 46 case 7: 47 $message = __('Post saved.'); 48 break; 49 case 8: 50 $message = sprintf( __('Post submitted. <a target="_blank" href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ); 51 break; 52 case 9: 53 // translators: Publish box date formt, see http://php.net/date - Same as in meta-boxes.php 54 $message = sprintf( __('Post scheduled for: <b>%1$s</b>. <a target="_blank" href="%2$s">Preview post</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), get_permalink($post_ID) ); 55 break; 56 case 10: 57 $message = sprintf( __('Post draft updated. <a target="_blank" href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ); 58 break; 59 } 54 if ( isset($messages[$post_type][$_GET['message']]) ) 55 $message = $messages[$post_type][$_GET['message']]; 56 elseif ( !isset($messages[$post_type]) && isset($messages['post'][$_GET['message']]) ) 57 $message = $messages['post'][$_GET['message']]; 60 58 } 61 59 62 60 $notice = false; 63 61 if ( 0 == $post_ID ) { 64 62 $form_action = 'post'; 63 $nonce_action = 'add-' . $post_type; 65 64 $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() 66 65 $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='" . esc_attr($temp_ID) . "' />"; 67 66 $autosave = false; 68 67 } else { 69 68 $form_action = 'editpost'; 69 $nonce_action = 'update-' . $post_type . '_' . $post_ID; 70 70 $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />"; 71 71 $autosave = wp_get_post_autosave( $post_ID ); 72 72 … … 82 82 } 83 83 } 84 84 85 $post_type_object = get_post_type_object($post_type); 86 $post_type_cap = $post_type_object->capability_type; 87 $form_post = 'post.php'; 88 if ( 'page' == $post_type ) 89 $form_post = 'page.php'; 90 85 91 // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). 86 92 require_once('includes/meta-boxes.php'); 87 93 88 94 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $post_type, 'side', 'core'); 89 95 90 // all tag-style posttaxonomies96 // all tag-style taxonomies 91 97 foreach ( get_object_taxonomies($post_type) as $tax_name ) { 92 98 if ( !is_taxonomy_hierarchical($tax_name) ) { 93 99 $taxonomy = get_taxonomy($tax_name); … … 99 105 100 106 if ( is_object_in_taxonomy($post_type, 'category') ) 101 107 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', $post_type, 'side', 'core'); 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 102 112 if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports($post_type, 'post-thumbnails') ) 103 113 add_meta_box('postimagediv', __('Post Thumbnail'), 'post_thumbnail_meta_box', $post_type, 'side', 'low'); 114 104 115 if ( post_type_supports($post_type, 'excerpts') ) 105 116 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core'); 117 106 118 if ( post_type_supports($post_type, 'trackbacks') ) 107 119 add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', $post_type, 'normal', 'core'); 120 108 121 if ( post_type_supports($post_type, 'custom-fields') ) 109 122 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', $post_type, 'normal', 'core'); 123 110 124 do_action('dbx_post_advanced'); 111 125 if ( post_type_supports($post_type, 'comments') ) 112 126 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', $post_type, 'normal', 'core'); … … 115 129 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core'); 116 130 117 131 if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) ) 118 add_meta_box('slugdiv', __(' PostSlug'), 'post_slug_meta_box', $post_type, 'normal', 'core');132 add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core'); 119 133 120 134 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM 121 135 if ( $post->post_author && !in_array($post->post_author, $authors) ) 122 136 $authors[] = $post->post_author; 123 137 if ( $authors && count( $authors ) > 1 ) 124 add_meta_box('authordiv', __(' PostAuthor'), 'post_author_meta_box', $post_type, 'normal', 'core');138 add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core'); 125 139 126 140 if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) 127 add_meta_box('revisionsdiv', __(' PostRevisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core');141 add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core'); 128 142 129 143 do_action('do_meta_boxes', $post_type, 'normal', $post); 130 144 do_action('do_meta_boxes', $post_type, 'advanced', $post); 131 145 do_action('do_meta_boxes', $post_type, 'side', $post); 132 146 133 147 require_once('admin-header.php'); 134 135 148 ?> 136 149 137 150 <div class="wrap"> … … 143 156 <?php if ( $message ) : ?> 144 157 <div id="message" class="updated"><p><?php echo $message; ?></p></div> 145 158 <?php endif; ?> 146 <form name="post" action="post.php" method="post" id="post"> 147 <?php 148 149 if ( 0 == $post_ID) 150 wp_nonce_field('add-post'); 151 else 152 wp_nonce_field('update-post_' . $post_ID); 153 154 ?> 155 159 <form name="post" action="<?php echo $form_post; ?>" method="post" id="post"> 160 <?php wp_nonce_field($nonce_action); ?> 156 161 <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" /> 157 162 <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action) ?>" /> 158 163 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" /> … … 169 174 <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>"> 170 175 <div id="side-info-column" class="inner-sidebar"> 171 176 172 <?php do_action('submitpost_box'); ?> 173 174 <?php $side_meta_boxes = do_meta_boxes($post_type, 'side', $post); ?> 177 <?php 178 ('page' == $post_type) ? do_action('submitpage_box') : do_action('submitpost_box'); 179 $side_meta_boxes = do_meta_boxes($post_type, 'side', $post); 180 ?> 175 181 </div> 176 182 177 183 <div id="post-body"> … … 184 190 <div class="inside"> 185 191 <?php 186 192 $sample_permalink_html = get_sample_permalink_html($post->ID); 187 if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_ posts' ) ) ) { ?>193 if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_' . $post_type_cap . 's' ) ) ) { ?> 188 194 <div id="edit-slug-box"> 189 195 <?php 190 196 if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) : … … 230 236 231 237 do_meta_boxes($post_type, 'normal', $post); 232 238 233 do_action('edit_form_advanced');239 ( 'page' == $post_type ) ? do_action('edit_page_form') : do_action('edit_form_advanced'); 234 240 235 241 do_meta_boxes($post_type, 'advanced', $post); 236 242 -
wp-admin/page-new.php
8 8 9 9 /** WordPress Administration Bootstrap */ 10 10 require_once('admin.php'); 11 12 $post_type = 'page'; 13 11 14 $title = __('Add New Page'); 12 15 $parent_file = 'edit-pages.php'; 13 16 $editing = true; … … 23 26 $action = 'post'; 24 27 $post = get_default_page_to_edit(); 25 28 26 include('edit- page-form.php');29 include('edit-form-advanced.php'); 27 30 } 28 31 29 32 include('admin-footer.php'); -
wp-admin/page.php
122 122 wp_enqueue_script('autosave'); 123 123 } 124 124 125 include('edit-page-form.php'); 125 $post_type = $post->post_type; 126 include('edit-form-advanced.php'); 126 127 break; 127 128 128 129 case 'editattachment':