Ticket #12567: poststatus.diff
File poststatus.diff, 16.0 KB (added by , 15 years ago) |
---|
-
wp-includes/post.php
15 15 * Creates the initial post types when 'init' action is fired. 16 16 */ 17 17 function create_initial_post_types() { 18 18 19 register_post_type( 'post', array( 'label' => __('Posts'), 19 20 'singular_label' => __('Post'), 20 21 'public' => true, … … 73 74 'rewrite' => false, 74 75 'query_var' => false, 75 76 ) ); 76 77 77 78 register_post_status( 'publish', array( 'label' => _x('Published', 'post'), 78 79 'public' => true, 79 80 '_builtin' => true, /* internal use only. */ … … 89 90 register_post_status( 'draft', array( 'label' => _x('Draft', 'post'), 90 91 'protected' => true, 91 92 '_builtin' => true, /* internal use only. */ 92 'label_count' => _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>') 93 'label_count' => _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>'), 94 'show_in_select_ui' => true 93 95 ) ); 94 96 95 97 register_post_status( 'pending', array( 'label' => _x('Pending', 'post'), 96 98 'protected' => true, 97 99 '_builtin' => true, /* internal use only. */ 98 'label_count' => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>') 100 'label_count' => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>'), 101 'show_in_select_ui' => true, 102 'display_label' => 'Pending Review' 99 103 ) ); 100 104 101 105 register_post_status( 'private', array( 'label' => _x('Private', 'post'), … … 114 118 register_post_status( 'auto-draft', array( 'label' => 'auto-draft', 115 119 'internal' => true, 116 120 '_builtin' => true, /* internal use only. */ 121 'display_label' => 'Draft' 117 122 ) ); 118 123 119 124 register_post_status( 'inherit', array( 'label' => 'inherit', … … 521 526 return $status; 522 527 } 523 528 529 function post_type_can_have_status($post_type, $status){ 530 global $wp_post_statuses; 531 532 $post_type_object = get_post_type_object($post_type); 533 534 if( $status == 'draft') : 535 $return = true; 536 elseif( is_array($post_type_object->allowed_status) ) : 537 if( in_array($status, $post_type_object->allowed_status) ) 538 $return = true; 539 else 540 $return = false; 541 else : 542 $status_obj = $wp_post_statuses[$status]; 543 544 if( empty($status_obj) ) 545 $return = false; 546 elseif( is_array($status_obj->post_type) ){ 547 if( in_array($post_type, $status_obj->post_type) ) 548 $return = true; 549 else 550 $return = false; 551 }elseif( $status_obj->internal === true ) 552 $return = false; 553 else 554 $return = true; 555 556 endif; 557 558 return $return; 559 } 560 561 562 563 564 524 565 /** 525 566 * Register a post type. Do not use before init. 526 567 * … … 550 591 $wp_post_statuses = array(); 551 592 552 593 // Args prefixed with an underscore are reserved for internal use. 553 $defaults = array(' label' => false, 'label_count' => false, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => null, 'internal' => null, 'protected' => null, 'private' => null, 'show_in_admin_all' => null, 'publicly_queryable' => null, 'show_in_admin_status_list' => null, 'show_in_admin_all_list' => null, 'single_view_cap' => null);594 $defaults = array('post_type' => false, 'edit_cap' => null, 'show_in_select_ui' => false, 'display_label' => false, 'label' => false, 'label_count' => false, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => null, 'internal' => null, 'protected' => null, 'private' => null, 'show_in_admin_all' => null, 'publicly_queryable' => null, 'show_in_admin_status_list' => null, 'show_in_admin_all_list' => null, 'single_view_cap' => null); 554 595 $args = wp_parse_args($args, $defaults); 555 596 $args = (object) $args; 556 597 557 598 $post_status = sanitize_user($post_status, true); 558 599 $args->name = $post_status; 559 600 601 if ( null === $args->post_type ) 602 $args->post_type = false; 603 604 if ( null === $args->edit_cap ) 605 $args->edit_cap = null; 606 607 if ( null === $args->show_in_select_ui ) 608 $args->show_in_select_ui = false; 609 560 610 if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private ) 561 611 $args->internal = true; 562 612 … … 589 639 590 640 if ( false === $args->label ) 591 641 $args->label = $post_status; 642 643 if ( null === $args->display_label || $args->display_label == false ) 644 $args->display_label = $args->label; 592 645 593 646 if ( false === $args->label_count ) 594 647 $args->label_count = array( $args->label, $args->label ); … … 797 850 $wp_post_types = array(); 798 851 799 852 // Args prefixed with an underscore are reserved for internal use. 800 $defaults = array(' label' => false, 'singular_label' => false, 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 'permalink_epmask' => EP_PERMALINK );853 $defaults = array('allowed_status' => false, 'label' => false, 'singular_label' => false, 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 'permalink_epmask' => EP_PERMALINK ); 801 854 $args = wp_parse_args($args, $defaults); 802 855 $args = (object) $args; 803 856 804 857 $post_type = sanitize_user($post_type, true); 805 858 $args->name = $post_type; 859 860 if( null === $args->allowed_status || empty($args->allowed_status) ) 861 $args->status_restrict = false; 806 862 807 863 // If not set, default to the setting for public. 808 864 if ( null === $args->publicly_queryable ) -
wp-includes/script-loader.php
301 301 'updatePage' => __('Update Page'), 302 302 'savePending' => __('Save as Pending'), 303 303 'saveDraft' => __('Save Draft'), 304 'saveDefault' => __('Save'), 304 305 'private' => __('Private'), 305 306 'public' => __('Public'), 306 307 'publicSticky' => __('Public, Sticky'), -
wp-admin/includes/meta-boxes.php
10 10 * @param object $post 11 11 */ 12 12 function post_submit_meta_box($post) { 13 global $action ;13 global $action, $wp_post_statuses; 14 14 15 15 $post_type = $post->post_type; 16 16 $post_type_object = get_post_type_object($post_type); … … 27 27 28 28 <div id="minor-publishing-actions"> 29 29 <div id="save-action"> 30 <?php if( post_type_can_have_status($post_type, 'publish') ) : ?> 30 31 <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> 31 32 <input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" tabindex="4" class="button button-highlighted" /> 32 33 <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?> 33 34 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" tabindex="4" class="button button-highlighted" /> 34 35 <?php } ?> 36 <?php endif; ?> 35 37 </div> 36 38 37 39 <div id="preview-action"> … … 52 54 </div><?php // /minor-publishing-actions ?> 53 55 54 56 <div id="misc-publishing-actions"> 55 56 57 <div class="misc-pub-section<?php if ( !$can_publish ) { echo ' misc-pub-section-last'; } ?>"><label for="post_status"><?php _e('Status:') ?></label> 57 58 <span id="post-status-display"> 58 <?php 59 switch ( $post->post_status ) { 60 case 'private': 61 _e('Privately Published'); 62 break; 63 case 'publish': 64 _e('Published'); 65 break; 66 case 'future': 67 _e('Scheduled'); 68 break; 69 case 'pending': 70 _e('Pending Review'); 71 break; 72 case 'draft': 73 case 'auto-draft': 74 _e('Draft'); 75 break; 76 case 'auto-draft': 77 _e('Unsaved'); 78 break; 79 } 59 <?php 60 $status = get_post_status_object($post->post_status); 61 if($status->label == 'auto-draft' ) _e('Draft'); 62 else _e($status->label); 80 63 ?> 81 64 </span> 82 65 <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?> … … 84 67 85 68 <div id="post-status-select" class="hide-if-js"> 86 69 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post->post_status ) ? 'draft' : $post->post_status); ?>" /> 70 87 71 <select name='post_status' id='post_status' tabindex='4'> 88 <?php if ( 'publish' == $post->post_status ) : ?> 89 <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option> 90 <?php elseif ( 'private' == $post->post_status ) : ?> 91 <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option> 92 <?php elseif ( 'future' == $post->post_status ) : ?> 93 <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option> 94 <?php endif; ?> 95 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> 96 <?php if ( 'auto-draft' == $post->post_status ) : ?> 97 <option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option> 98 <?php else : ?> 99 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option> 100 <?php endif; ?> 72 73 <?php output_post_status_select( $post->post_type, $post->ID ); ?> 74 101 75 </select> 102 76 <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a> 103 77 <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a> … … 106 80 <?php } ?> 107 81 </div><?php // /misc-pub-section ?> 108 82 83 <?php if( post_type_can_have_status($post->post_type, 'private') ) : ?> 109 84 <div class="misc-pub-section " id="visibility"> 110 85 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php 111 86 … … 151 126 </div> 152 127 <?php } ?> 153 128 154 </div><?php // /misc-pub-section ?> 129 </div> 130 <?php endif; // /misc-pub-section for visbility ?> 155 131 156 132 157 <?php 133 <?php 134 158 135 // translators: Publish box date formt, see http://php.net/date 159 136 $datef = __( 'M j, Y @ G:i' ); 160 137 if ( 0 != $post->ID ) { … … 177 154 178 155 if ( $can_publish ) : // Contributors don't get to choose the date of publish ?> 179 156 <div class="misc-pub-section curtime misc-pub-section-last"> 157 <?php if(post_type_can_have_status($post_type, 'future') ) : ?> 180 158 <span id="timestamp"> 181 159 <?php printf($stamp, $date); ?></span> 182 160 <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a> 183 <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div>184 </div><?php // /misc-pub-section ?>185 161 <?php endif; ?> 186 162 163 <div id="timestampdiv" <?php if(!post_type_can_have_status($post_type, 'future')) echo 'style="display: none;"'; ?> class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div> 164 </div><?php // /misc-pub-section ?> 165 <?php endif; //end future post status ?> 166 187 167 <?php do_action('post_submitbox_misc_actions'); ?> 188 168 </div> 189 169 <div class="clear"></div> … … 206 186 <div id="publishing-action"> 207 187 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" id="ajax-loading" style="visibility:hidden;" alt="" /> 208 188 <?php 189 if( post_type_can_have_status($post_type, 'publish') === true ) : 209 190 if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { 210 191 if ( $can_publish ) : 211 192 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> … … 224 205 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" /> 225 206 <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Update') ?>" /> 226 207 <?php 227 } ?> 208 } 209 else: ?> 210 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Save') ?>" /> 211 <input name="save" type="submit" class="button-primary" id="save_post" tabindex="5" accesskey="p" value="<?php esc_attr_e('Save') ?>" /> 212 <?php endif; ?> 228 213 </div> 229 214 <div class="clear"></div> 230 215 </div> -
wp-admin/includes/template.php
8 8 * @subpackage Administration 9 9 */ 10 10 11 function output_post_status_select( $post_type, $id = null, $view_defaults = false ){ 12 global $wp_post_statuses; 13 14 $post = (!empty($id)) ? get_post( $id ) : null; 15 //$post_type = $post->post_type; 16 $post_type_object = get_post_type_object($post_type); 17 18 19 foreach( $wp_post_statuses as $status => $args ): 20 if($status == 'auto-draft') continue; 21 22 if(post_type_can_have_status($post_type, $status)){ 23 24 if( $view_defaults === true && in_array($status, array('publish', 'draft')) ) 25 $continue = true; 26 27 if( $status == $post->post_status || $args->show_in_select_ui === true || $continue === true ) { 28 29 $allowed_edit = true; 30 31 if( isset($args->edit_cap) && !current_user_can($args->edit_cap) ) 32 $allowed_edit = false; 33 if( $allowed_edit === true ) { ?> 34 35 <option<?php ( isset($post) ) ? selected( $post->post_status, $status ) : ''; ?> value='<?php echo ($status == 'auto-draft') ? 'draft' : $status; ?>'><?php _e($args->display_label); ?></option>; 36 <?php } 37 } 38 } 39 unset($continue); 40 endforeach; 41 } 42 11 43 /** 12 44 * {@internal Missing Short Description}} 13 45 * … … 847 879 * @param string $screen 848 880 */ 849 881 function inline_edit_row( $screen ) { 850 global $current_user, $mode ;882 global $current_user, $mode, $wp_post_statuses, $posts; 851 883 852 884 if ( is_string($screen) ) { 853 885 $screen = array('id' => 'edit-' . $screen, 'base' => 'edit', 'post_type' => $screen ); … … 1099 1131 <?php if ( $bulk ) : ?> 1100 1132 <option value="-1"><?php _e('— No Change —'); ?></option> 1101 1133 <?php endif; // $bulk ?> 1102 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?> 1103 <option value="publish"><?php _e( 'Published' ); ?></option> 1104 <option value="future"><?php _e( 'Scheduled' ); ?></option> 1105 <?php if ( $bulk ) : ?> 1106 <option value="private"><?php _e('Private') ?></option> 1107 <?php endif; // $bulk ?> 1108 <?php endif; ?> 1109 <option value="pending"><?php _e( 'Pending Review' ); ?></option> 1110 <option value="draft"><?php _e( 'Draft' ); ?></option> 1134 1135 <?php output_post_status_select( $screen->post_type, null, true); ?> 1136 1111 1137 </select> 1112 1138 </label> 1113 1139 … … 1164 1190 <br class="clear" /> 1165 1191 </p> 1166 1192 </td></tr> 1167 <?php 1193 <?php 1168 1194 $bulk++; 1169 1195 } ?> 1170 1196 </tbody></table></form> -
wp-admin/js/post.dev.js
432 432 $('#save-post').hide(); 433 433 } else { 434 434 $('#save-post').show(); 435 if ( $('option:selected', postStatus).val() == ' pending' ) {436 $('#save-post').show().val( postL10n.save Pending);435 if ( $('option:selected', postStatus).val() == 'draft' ) { 436 $('#save-post').show().val( postL10n.saveDraft ); 437 437 } else { 438 $('#save-post').show().val( postL10n.saveD raft );438 $('#save-post').show().val( postL10n.saveDefault ); 439 439 } 440 440 } 441 441 return true;