Ticket #12706: Custom_Stati_Support.patch
File Custom_Stati_Support.patch, 82.7 KB (added by , 14 years ago) |
---|
-
wp-admin/admin-ajax.php
683 683 684 684 $status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) ); 685 685 686 if ( empty($status) ) 686 $post_status_obj = get_post_status_object($status); 687 688 if ( empty($post_status_obj) ) 687 689 die('1'); 688 elseif ( in_array($status, array('draft', 'pending', 'trash') ))690 elseif ( ! $post_status_obj->public && ! $post_status_obj->private ) 689 691 die( __('Error: you are replying to a comment on a draft post.') ); 690 692 691 693 $user = wp_get_current_user(); … … 1181 1183 if ( isset($data['post_parent']) ) 1182 1184 $data['parent_id'] = $data['post_parent']; 1183 1185 1186 $post_type_object = get_post_type_object( $post['post_type'] ); 1187 1184 1188 // status 1185 if ( isset($data['keep_private']) && 'private' == $data['keep_private'] ) 1186 $data['post_status'] = 'private'; 1187 else 1189 foreach( get_post_stati( array( 'internal' => false, 'object_type' => $post['post_type'] ), 'object' ) as $_status => $_status_obj ) { 1190 if ( ( 'publish' == $_status ) || ( ! $_status_obj->private && ! $_status_obj->public ) ) // private and custom public stati only here 1191 continue; 1192 1193 if ( isset($data["keep_{$_status}"]) ) { 1194 $set_status_cap = "set_{$_status}_posts"; 1195 $check_cap = ( ! empty( $post_type_object->cap->$set_status_cap ) ) ? $post_type_object->cap->$set_status_cap : $post_type_object->cap->publish_posts; 1196 1197 if ( current_user_can( $check_cap ) ) { 1198 $data['post_status'] = $_status; 1199 $keeping_private = true; 1200 break; 1201 } 1202 } 1203 } 1204 1205 if ( empty($keeping_private) ) // private or custom public status selected and granted 1188 1206 $data['post_status'] = $data['_status']; 1189 1207 1190 1208 if ( empty($data['comment_status']) ) … … 1258 1276 if ( count($search_terms) > 1 && $search_terms[0] != $s ) 1259 1277 $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')"; 1260 1278 1261 $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND post_status IN ('draft', 'publish') AND ($search) ORDER BY post_date_gmt DESC LIMIT 50" ); 1279 $public_stati = apply_filters( 'find_posts_stati', get_post_stati( array( 'public' => true ) ) ); 1280 $public_csv = implode( "', '", $public_stati ); 1262 1281 1282 $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND post_status IN ('draft', '$public_csv') AND ($search) ORDER BY post_date_gmt DESC LIMIT 50" ); 1283 1263 1284 if ( ! $posts ) { 1264 1285 $posttype = get_post_type_object($what); 1265 1286 exit($posttype->labels->not_found); 1266 1287 } 1267 1288 1289 $stat = array(); 1290 1268 1291 $html = '<table class="widefat" cellspacing="0"><thead><tr><th class="found-radio"><br /></th><th>'.__('Title').'</th><th>'.__('Date').'</th><th>'.__('Status').'</th></tr></thead><tbody>'; 1269 1292 foreach ( $posts as $post ) { 1293 1294 if ( ! isset( $stat[$post->post_status] ) ) { 1295 $_status_obj = get_post_status_object( $post->post_status ); 1296 1297 if ( ! $_status_obj ) 1298 $_status_obj = get_post_status_object( 'draft' ); 1299 elseif ( ( $_status_obj->public || $_status_obj->private ) && ( 'publish' != $post->post_status ) ) 1300 $_status_obj = get_post_status_object( 'publish' ); 1270 1301 1271 switch ( $post->post_status ) { 1272 case 'publish' : 1273 case 'private' : 1274 $stat = __('Published'); 1275 break; 1276 case 'future' : 1277 $stat = __('Scheduled'); 1278 break; 1279 case 'pending' : 1280 $stat = __('Pending Review'); 1281 break; 1282 case 'draft' : 1283 $stat = __('Draft'); 1284 break; 1302 $stat[$post->post_status] = $_status_obj->labels->caption; 1285 1303 } 1286 1304 1287 1305 if ( '0000-00-00 00:00:00' == $post->post_date ) { … … 1292 1310 } 1293 1311 1294 1312 $html .= '<tr class="found-posts"><td class="found-radio"><input type="radio" id="found-'.$post->ID.'" name="found_post_id" value="' . esc_attr($post->ID) . '"></td>'; 1295 $html .= '<td><label for="found-'.$post->ID.'">'.esc_html( $post->post_title ).'</label></td><td>'.esc_html( $time ).'</td><td>'.esc_html( $stat ).'</td></tr>'."\n\n";1313 $html .= '<td><label for="found-'.$post->ID.'">'.esc_html( $post->post_title ).'</label></td><td>'.esc_html( $time ).'</td><td>'.esc_html( $stat[$post->post_status] ).'</td></tr>'."\n\n"; 1296 1314 } 1297 1315 $html .= '</tbody></table>'; 1298 1316 -
wp-admin/edit-form-advanced.php
49 49 // translators: Publish box date format, see http://php.net/date 50 50 date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), 51 51 10 => sprintf( __('Post draft updated. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 52 11 => sprintf( __('Post moderated. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 52 53 ); 53 54 $messages['page'] = array( 54 55 0 => '', // Unused. Messages start at index 1. … … 62 63 8 => sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 63 64 9 => 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 ) ), esc_url( get_permalink($post_ID) ) ), 64 65 10 => sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 66 11 => sprintf( __('Page moderated. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 65 67 ); 66 68 67 69 $messages = apply_filters( 'post_updated_messages', $messages ); … … 142 144 if ( post_type_supports($post_type, 'comments') ) 143 145 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', $post_type, 'normal', 'core'); 144 146 145 if ( ('publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') ) 147 if ( ! $post_status_object = get_post_status_object( $post->post_status ) ) 148 $post_status_object = get_post_status_object( 'draft' ); 149 150 if ( ( $post_status_object->public || $post_status_object->private ) && post_type_supports($post_type, 'comments') ) 146 151 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core'); 147 152 148 if ( ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) )153 if ( ! ( $post_status_object->moderation && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) 149 154 add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core'); 150 155 151 156 if ( post_type_supports($post_type, 'author') ) { … … 247 252 if ( !empty($shortlink) ) 248 253 $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>'; 249 254 250 if ( ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>255 if ( ! ( $post_status_object->moderation && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?> 251 256 <div id="edit-slug-box"> 252 257 <?php 253 258 if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status ) … … 314 319 try{document.post.title.focus();}catch(e){} 315 320 </script> 316 321 <?php endif; ?> 322 323 324 <?php 325 add_action( 'admin_print_footer_scripts', create_function('', "_edit_form_advanced_scripts('$post_type');") ); 326 327 function _edit_form_advanced_scripts( $post_type ) { 328 ?> 329 330 <script type="text/javascript"> 331 //<![CDATA[ 332 jQuery(document).ready( function($) { 333 function updateStatusCaptions() { 334 postStatus = $('#post_status'); 335 336 $('#post-status-display').html($('option:selected', postStatus).text()); 337 338 switch( $('option:selected', postStatus).val() ) { 339 340 <?php foreach( get_post_stati( array( 'public' => true, 'private' => true ), 'object', 'or' ) as $_status => $_status_obj ): ?> 341 case '<?php echo $_status ?>': 342 $('#save-post').hide(); 343 break; 344 <?php endforeach; ?> 345 346 <?php foreach( get_post_stati( array( 'moderation' => true, 'internal' => false, 'object_type' => $post_type ), 'object' ) as $_status => $_status_obj ): ?> 347 case '<?php echo $_status ?>': 348 $('#save-post').show().val( '<?php echo $_status_obj->labels->save_as ?>' ); 349 break; 350 <?php endforeach; ?> 351 352 default : 353 <?php $draft_status_obj = get_post_status_object( 'draft' ); ?> 354 $('#save-post').show().val( '<?php echo $draft_status_obj->labels->save_as ?>' ); 355 } 356 } 357 358 $('input:radio', '#post-visibility-select').change(function() { 359 switch ( $('input:radio:checked', '#post-visibility-select').val() ) { 360 case 'public': 361 $('#sticky-span').show(); 362 break; 363 364 <?php foreach( get_post_stati( array( 'public' => true, 'object_type' => $post_type ) ) as $_status ) : ?> 365 case '<?php echo $_status ?>': 366 $('#sticky-span').show(); 367 break; 368 <?php endforeach; ?> 369 370 default : 371 $('#sticky').attr('checked', false); 372 $('#sticky-span').hide(); 373 } 374 }); 375 376 function updateVisibilityCaptions() { 377 var postStatus = $('#post_status'), optPublish = $('option[value=publish]', postStatus); 378 379 switch( $('input:radio:checked', '#post-visibility-select').val() ) { 380 381 <?php foreach( get_post_stati( array( 'internal' => false, 'object_type' => $post_type ), 'object' ) as $_status => $_status_obj ) : 382 if ( ( 'publish' == $_status ) || ( ! $_status_obj->private && ! $_status_obj->public ) ) 383 continue; 384 ?> 385 case '<?php echo $_status ?>': 386 $('#publish').val( postL10n.update ); 387 388 if ( optPublish.length == 0 ) { 389 postStatus.append('<option value="publish">' + '<?php echo $_status_obj->labels->caption ?>' + '</option>'); 390 } else { 391 optPublish.html( '<?php echo $_status_obj->labels->caption ?>' ); 392 } 393 394 $('option[value=publish]', postStatus).attr('selected', true); 395 $('.edit-post-status', '#misc-publishing-actions').hide(); 396 397 break; 398 <?php endforeach; ?> 399 400 default: 401 if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { 402 if ( optPublish.length ) { 403 optPublish.remove(); 404 postStatus.val($('#hidden_post_status').val()); 405 } 406 } else { 407 optPublish.html( postL10n.published ); 408 } 409 if ( postStatus.is(':hidden') ) 410 $('.edit-post-status', '#misc-publishing-actions').show(); 411 } 412 413 return true; 414 } 415 416 $('.save-post-status', '#post-status-select').click(function() { 417 updateStatusCaptions(); 418 return false; 419 }); 420 421 $('.cancel-post-visibility', '#post-visibility-select').click(function () { 422 updateVisibilityCaptions(); 423 return false; 424 }); 425 426 $('.save-post-visibility', '#post-visibility-select').click(function () { // crazyhorse - multiple ok cancels 427 updateVisibilityCaptions(); 428 updateStatusCaptions(); 429 return false; 430 }); 431 }); 432 //]]> 433 </script> 434 435 <?php 436 } // end function edit_form_advanced_scripts 437 ?> 438 No newline at end of file -
wp-admin/includes/default-list-tables.php
137 137 } 138 138 139 139 $total_posts = array_sum( (array) $num_posts ); 140 140 141 141 // Subtract post types that are not included in the admin all list. 142 foreach ( get_post_stati( array('show_in_admin_all_list' => false ) ) as $state )142 foreach ( get_post_stati( array('show_in_admin_all_list' => false, 'object_type' => $post_type) ) as $state ) 143 143 $total_posts -= $num_posts->$state; 144 144 145 145 $class = empty($class) && empty($_REQUEST['post_status']) ? ' class="current"' : ''; 146 146 $status_links['all'] = "<li><a href='edit.php?post_type=$post_type{$allposts}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>'; 147 147 148 foreach ( get_post_stati(array('show_in_admin_status_list' => true ), 'objects') as $status ) {148 foreach ( get_post_stati(array('show_in_admin_status_list' => true, 'object_type' => $post_type), 'objects') as $status ) { 149 149 $class = ''; 150 150 151 151 $status_name = $status->name; … … 255 255 if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'post_tag' ) ) 256 256 $posts_columns['tags'] = __( 'Tags' ); 257 257 $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; 258 if ( !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) && ( empty( $post_type ) || post_type_supports( $post_type, 'comments' ) ) ) 258 259 $post_status_obj = get_post_status_object( $post_status ); 260 261 if ( ! in_array( $post_status, array( 'pending', 'draft', 'future' ) ) && empty( $GLOBALS['wp_post_statuses'][$post_status]->moderation ) && ( empty( $post_type ) || post_type_supports( $post_type, 'comments' ) ) ) 259 262 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>'; 260 263 $posts_columns['date'] = __( 'Date' ); 261 264 … … 523 526 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) 524 527 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>"; 525 528 } 526 if ( in_array( $post->post_status, array( 'pending', 'draft' ) ) ) {529 if ( in_array( $post->post_status, array( 'pending', 'draft' ) ) || ! empty( $GLOBALS['wp_post_statuses'][$post->post_status]->moderation ) ) { 527 530 if ( $can_edit_post ) 528 531 $actions['view'] = '<a href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>'; 529 532 } elseif ( 'trash' != $post->post_status ) { … … 559 562 else 560 563 echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>'; 561 564 echo '<br />'; 562 if ( 'publish' == $post->post_status ) { 565 566 $published_stati = get_post_stati( array( 'public' => true, 'private' => true ), 'names', 'or' ); 567 if ( in_array( $post->post_status, $published_stati ) ) { 563 568 _e( 'Published' ); 564 569 } elseif ( 'future' == $post->post_status ) { 565 570 if ( $time_diff > 0 ) … … 761 766 <span class="title"><?php _e( 'Password' ); ?></span> 762 767 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> 763 768 </label> 769 770 <?php 771 foreach ( get_post_stati( array( 'internal' => false, 'object_type' => $screen->post_type ), 'object' ) as $_status => $_status_obj ) : 772 if ( ( 'publish' == $_status ) || ( ! $_status_obj->private && ! $_status_obj->public ) ) // private and custom public stati only here 773 continue; 764 774 775 $set_status_cap = "set_{$_status}_posts"; 776 $check_cap = ( ! empty( $post_type_object->cap->$set_status_cap ) ) ? $post_type_object->cap->$set_status_cap : $post_type_object->cap->publish_posts; 777 778 if ( current_user_can( $check_cap ) ) { 779 if ( empty( $did_or ) ) : 780 $did_or = true; 781 ?> 765 782 <em style="margin:5px 10px 0 0" class="alignleft"> 766 783 <?php 767 784 /* translators: Between password field and private checkbox on post quick edit interface */ 768 785 echo __( '–OR–' ); 769 786 ?> 770 787 </em> 771 <label class="alignleft inline-edit-private"> 772 <input type="checkbox" name="keep_private" value="private" /> 773 <span class="checkbox-title"><?php echo __( 'Private' ); ?></span> 774 </label> 788 <?php endif; ?> 789 790 <label class="alignleft keep-private inline-edit-<?php echo $_status ?>"> 791 <input type="checkbox" name="keep_<?php echo $_status ?>" value="<?php echo $_status ?>" /> 792 <span class="checkbox-title"><?php echo $_status_obj->labels->name ?> </span> 793 </label> 794 <?php 795 } // endif user can set status 796 endforeach; ?> 797 775 798 </div> 776 799 777 800 <?php endif; ?> … … 908 931 <?php if ( $bulk ) : ?> 909 932 <option value="-1"><?php _e( '— No Change —' ); ?></option> 910 933 <?php endif; // $bulk ?> 911 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review"?>934 <?php if ( $can_publish ) : // Contributors only get draft and moderation stati ?> 912 935 <option value="publish"><?php _e( 'Published' ); ?></option> 913 936 <option value="future"><?php _e( 'Scheduled' ); ?></option> 914 <?php if ( $bulk ) : ?> 915 <option value="private"><?php _e( 'Private' ) ?></option> 916 <?php endif; // $bulk ?> 917 <?php endif; ?> 918 <option value="pending"><?php _e( 'Pending Review' ); ?></option> 937 <?php if ( $bulk ) : 938 foreach( get_post_stati( array( 'private' => true, 'object_type' => $screen->post_type ), 'object' ) as $_status => $_status_obj ) { 939 ?> 940 <option value="<?php echo $_status ?>"><?php echo $_status_obj->labels->name ?></option> 941 <?php 942 } // endforeach stati 943 endif; // $bulk ?> 944 <?php endif; ?> 945 <?php foreach( get_post_stati( array( 'moderation' => true, 'internal' => false, 'object_type' => $screen->post_type ), 'object' ) as $_status => $_status_obj ) : 946 $cap_name = "set_{$_status}_posts"; 947 if ( empty( $post_type_object->cap->$cap_name ) || current_user_can( $post_type_object->cap->$cap_name ) ) { 948 ?> 949 <option value="<?php echo $_status ?>"><?php echo $_status_obj->labels->caption ?></option> 950 <?php 951 } // endif 952 endforeach; ?> 919 953 <option value="draft"><?php _e( 'Draft' ); ?></option> 920 954 </select> 921 955 </label> -
wp-admin/includes/meta-boxes.php
11 11 */ 12 12 function post_submit_meta_box($post) { 13 13 global $action; 14 15 $post_type = $post->post_type; 16 $post_type_obj = get_post_type_object($post_type); 17 $can_publish = current_user_can($post_type_obj->cap->publish_posts); 18 $post_status = $post->post_status; 19 20 if ( ! $post_status_obj = get_post_status_object($post_status) ) 21 $post_status_obj = get_post_status_object( 'draft' ); 22 23 $moderation_stati = get_post_stati( array( 'moderation' => true, 'internal' => false, 'object_type' => $post_type ), 'object' ); 14 24 15 $post_type = $post->post_type; 16 $post_type_object = get_post_type_object($post_type); 17 $can_publish = current_user_can($post_type_object->cap->publish_posts); 25 foreach( array_keys($moderation_stati) as $_status ) { 26 $set_cap = "set_{$_status}_posts"; 27 if ( ( $_status != $post_status ) && ( ! empty( $post_type_obj->cap->$set_cap ) && ! current_user_can( $post_type_obj->cap->$set_cap ) ) ) 28 unset( $moderation_stati[$_status] ); 29 } 18 30 ?> 19 31 <div class="submitbox" id="submitpost"> 20 32 … … 27 39 28 40 <div id="minor-publishing-actions"> 29 41 <div id="save-action"> 30 <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> 31 <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 <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?> 33 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" tabindex="4" class="button button-highlighted" /> 42 <?php //if ( 'publish' != $post_status && 'future' != $post_status && 'pending' != $post_status ) { 43 if ( ! $post_status_obj->public && ! $post_status_obj->private && ! $post_status_obj->moderation && ( 'future' != $post_status ) ) { // TODO: confirm we don't need a hidden save button when current status is private 44 $draft_status_obj = get_post_status_object( 'draft' ); 45 ?> 46 <input type="submit" name="save" id="save-post" value="<?php echo $draft_status_obj->labels->save_as ?>" tabindex="4" class="button button-highlighted" /> 47 <?php 48 } elseif ( $post_status_obj->moderation && $can_publish ) { 49 ?> 50 <input type="submit" name="save" id="save-post" value="<?php echo $post_status_obj->labels->save_as ?>" tabindex="4" class="button button-highlighted" /> 34 51 <?php } ?> 35 52 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="draft-ajax-loading" alt="" /> 36 53 </div> 37 54 38 55 <div id="preview-action"> 39 56 <?php 40 if ( 'publish' == $post->post_status) {57 if ( $post_status_obj->public ) { 41 58 $preview_link = esc_url(get_permalink($post->ID)); 42 59 $preview_button = __('Preview Changes'); 43 60 } else { … … 57 74 <div class="misc-pub-section<?php if ( !$can_publish ) { echo ' misc-pub-section-last'; } ?>"><label for="post_status"><?php _e('Status:') ?></label> 58 75 <span id="post-status-display"> 59 76 <?php 60 switch ( $post->post_status ) { 61 case 'private': 62 _e('Privately Published'); 63 break; 64 case 'publish': 65 _e('Published'); 66 break; 67 case 'future': 68 _e('Scheduled'); 69 break; 70 case 'pending': 71 _e('Pending Review'); 72 break; 73 case 'draft': 74 case 'auto-draft': 75 _e('Draft'); 76 break; 77 case 'auto-draft': 78 _e('Unsaved'); 79 break; 80 } 77 echo $post_status_obj->labels->caption; 81 78 ?> 82 79 </span> 83 <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>84 <a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a> 80 <?php 81 $select_moderation = ( count($moderation_stati) > 1 || ( $post_status != key($moderation_stati) ) ); // multiple moderation stati are selectable or a single non-current moderation stati is selectable 85 82 83 if ( $post_status_obj->public || $post_status_obj->private || $can_publish || $select_moderation ) { ?> 84 <a href="#post_status" <?php if ( $post_status_obj->private || ( $post_status_obj->public && 'publish' != $post_status ) ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a> 85 86 86 <div id="post-status-select" class="hide-if-js"> 87 <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); ?>" />87 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post_status ) ? 'draft' : $post_status); ?>" /> 88 88 <select name='post_status' id='post_status' tabindex='4'> 89 <?php if ( 'publish' == $post->post_status ) : ?> 90 <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option> 91 <?php elseif ( 'private' == $post->post_status ) : ?> 92 <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option> 93 <?php elseif ( 'future' == $post->post_status ) : ?> 94 <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option> 89 90 <?php if ( $post_status_obj->public || $post_status_obj->private || ( 'future' == $post_status ) ) : ?> 91 <option<?php selected( $post_status, $post_status ); ?> value='publish'><?php echo $post_status_obj->labels->caption ?></option> 95 92 <?php endif; ?> 96 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> 97 <?php if ( 'auto-draft' == $post->post_status ) : ?> 98 <option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option> 99 <?php else : ?> 100 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option> 101 <?php endif; ?> 93 94 <?php 95 foreach( $moderation_stati as $_status => $_status_obj ) : ?> 96 <option<?php selected( $post_status, $_status ); ?> value='<?php echo $_status ?>'><?php echo $_status_obj->labels->caption ?></option> 97 <?php endforeach ?> 98 99 <?php 100 $draft_status_obj = get_post_status_object( 'draft' ); 101 $compare_status = ( 'auto-draft' == $post_status ) ? 'auto-draft' : 'draft'; 102 ?> 103 <option<?php selected( $post_status, $compare_status ); ?> value='draft'><?php echo $draft_status_obj->label ?></option> 104 102 105 </select> 103 106 <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a> 104 107 <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a> … … 110 113 <div class="misc-pub-section " id="visibility"> 111 114 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php 112 115 113 if ( 'private' == $post->post_status ) { 116 if ( 'future' == $post_status ) { // indicate eventual visibility of scheduled post 117 if ( ! $vis_status = get_post_meta( $post->ID, '_scheduled_status', true ) ) 118 $vis_status = 'publish'; 119 120 $vis_status_obj = get_post_status_object( $vis_status ); 121 } else { 122 $vis_status = $post_status; 123 $vis_status_obj = $post_status_obj; 124 } 125 126 if ( 'publish' == $vis_status ) { 114 127 $post->post_password = ''; 115 $visibility = 'private'; 116 $visibility_trans = __('Private'); 128 $visibility = 'public'; 129 130 if ( post_type_supports( $post->post_type, 'sticky' ) && is_sticky( $post->ID ) ) { 131 $visibility_trans = __('Public, Sticky'); 132 } else { 133 $visibility_trans = __('Public'); 134 } 135 } elseif ( $vis_status_obj->public ) { 136 $post->post_password = ''; 137 $visibility = $vis_status; 138 139 if ( post_type_supports( $post->post_type, 'sticky' ) && is_sticky( $post->ID ) ) { 140 $visibility_trans = sprintf( __('%s, Sticky'), $vis_status_obj->label ); 141 } else { 142 $visibility_trans = $vis_status_obj->labels->visibility; 143 } 144 } elseif ( $vis_status_obj->private ) { 145 $post->post_password = ''; 146 $visibility_trans = $vis_status_obj->labels->visibility; 117 147 } elseif ( !empty( $post->post_password ) ) { 118 148 $visibility = 'password'; 119 149 $visibility_trans = __('Password protected'); 120 } elseif ( post_type_supports( $post->post_type, 'sticky' ) && is_sticky( $post->ID ) ) {121 $visibility = 'public';122 $visibility_trans = __('Public, Sticky');123 150 } else { 124 151 $visibility = 'public'; 125 152 $visibility_trans = __('Public'); … … 136 163 <?php endif; ?> 137 164 <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" /> 138 165 166 <input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br /> 139 167 140 <input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br /> 141 <?php if ( post_type_supports( $post->post_type, 'sticky' ) ): ?> 168 <?php 169 foreach( get_post_stati( array( 'public' => true, 'object_type' => $post_type ), 'object' ) as $_status => $_status_obj ) : 170 if ( 'publish' == $_status ) 171 continue; 172 173 $post_cap = "set_{$_status}_posts"; 174 if ( empty( $post_type_obj->cap->$post_cap ) || current_user_can( $post_type_obj->cap->$post_cap ) ) { 175 ?> 176 <input type="radio" name="visibility" id="visibility-radio-<?php echo $_status ?>" value="<?php echo $_status ?>" <?php checked( $visibility, $_status ); ?> /> <label for="visibility-radio-<?php echo $_status ?>" class="selectit"><?php echo $_status_obj->labels->visibility ?></label><br /> 177 <?php 178 } // end if this user can set status 179 endforeach ?> 180 181 <?php if ( post_type_supports( $post->post_type, 'sticky' ) ) : ?> 142 182 <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID)); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick this to the front page') ?></label><br /></span> 143 183 <?php endif; ?> 184 144 185 <input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br /> 145 186 <span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" /><br /></span> 146 <input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />147 187 188 <?php 189 foreach( get_post_stati( array( 'private' => true, 'object_type' => $post_type ), 'object' ) as $_status => $_status_obj ) : 190 $post_cap = "set_{$_status}_posts"; 191 if ( empty( $post_type_obj->cap->$post_cap ) || current_user_can( $post_type_obj->cap->$post_cap ) ) { 192 ?> 193 <input type="radio" name="visibility" id="visibility-radio-<?php echo $_status ?>" value="<?php echo $_status ?>" <?php checked( $visibility, $_status ); ?> /> <label for="visibility-radio-<?php echo $_status ?>" class="selectit"><?php echo $_status_obj->label ?></label><br /> 194 <?php 195 } // end if this user can set status 196 endforeach ?> 148 197 <p> 149 198 <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a> 150 199 <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a> … … 158 207 <?php 159 208 // translators: Publish box date formt, see http://php.net/date 160 209 $datef = __( 'M j, Y @ G:i' ); 210 211 $published_stati = get_post_stati( array( 'public' => true, 'private' => true ), 'names', 'or' ); 212 161 213 if ( 0 != $post->ID ) { 162 if ( 'future' == $post ->post_status ) { // scheduled for publishing at a future date214 if ( 'future' == $post_status ) { // scheduled for publishing at a future date 163 215 $stamp = __('Scheduled for: <b>%1$s</b>'); 164 } else if ( 'publish' == $post->post_status || 'private' == $post->post_status) { // already published216 } else if ( in_array( $post_status, $published_stati ) ) { // already published 165 217 $stamp = __('Published on: <b>%1$s</b>'); 166 218 } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified 167 219 $stamp = __('Publish <b>immediately</b>'); … … 207 259 <div id="publishing-action"> 208 260 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="ajax-loading" alt="" /> 209 261 <?php 210 if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID) {262 if ( ( ! $post_status_obj->public && ! $post_status_obj->private && ( 'future' != $post_status ) ) ) { 211 263 if ( $can_publish ) : 212 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> 213 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" /> 214 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Schedule') ?>" /> 215 <?php else : ?> 216 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" /> 217 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Publish') ?>" /> 264 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : 265 $future_status_obj = get_post_status_object( 'future' ); 266 ?> 267 <input name="original_publish" type="hidden" id="original_publish" value="<?php echo $future_status_obj->labels->publish ?>" /> 268 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php echo $future_status_obj->labels->publish ?>" /> 269 <?php else : 270 $publish_status_obj = get_post_status_object( 'publish' ); 271 ?> 272 <input name="original_publish" type="hidden" id="original_publish" value="<?php echo $publish_status_obj->labels->publish ?>" /> 273 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php echo $publish_status_obj->labels->publish ?>" /> 218 274 <?php endif; 219 275 else : ?> 220 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" /> 221 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Submit for Review') ?>" /> 276 <?php 277 $moderation_button_status = apply_filters( 'post_moderation_status', 'pending', $post->ID ); 278 279 $status_obj = get_post_status_object( $moderation_button_status ); 280 $cap_name = "set_{$moderation_button_status}_posts"; 281 282 if ( ! $status_obj || ( ! empty($post_type_obj->cap->$cap_name) && ! current_user_can($post_type_obj->cap->$cap_name) ) ) 283 $status_obj = get_post_status_object( 'pending' ); 284 ?> 285 <input name="original_publish" type="hidden" id="original_publish" value="<?php echo $status_obj->labels->publish ?>" /> 286 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php echo $status_obj->labels->publish ?>" /> 222 287 <?php 223 288 endif; 224 289 } else { ?> -
wp-admin/includes/nav-menu.php
1013 1013 */ 1014 1014 function _wp_nav_menu_meta_box_object( $object = null ) { 1015 1015 if ( isset( $object->name ) ) { 1016 $public_stati = apply_filters( 'nav_menu_metabox_stati', get_post_stati( array( 'public' => true, 'object_type' => $object->name ) ), $object ); 1017 $public_csv = implode( ',', $public_stati ); 1016 1018 1017 1019 if ( 'page' == $object->name ) { 1018 1020 $object->_default_query = array( 1019 1021 'orderby' => 'menu_order title', 1020 'post_status' => 'publish',1022 'post_status' => $public_csv, 1021 1023 ); 1022 1024 1023 // posts should show only publi sheditems1025 // posts should show only public items 1024 1026 } elseif ( 'post' == $object->name ) { 1025 1027 $object->_default_query = array( 1026 'post_status' => 'publish',1028 'post_status' => $public_csv, 1027 1029 ); 1028 1030 1029 1031 // cats should be in reverse chronological order … … 1033 1035 'order' => 'DESC', 1034 1036 ); 1035 1037 1036 // custom post types should show only publi sheditems1038 // custom post types should show only public items 1037 1039 } else { 1038 1040 $object->_default_query = array( 1039 'post_status' => 'publish',1041 'post_status' => $public_csv, 1040 1042 ); 1041 1043 } 1042 1044 } -
wp-admin/includes/post.php
64 64 // What to do based on which button they pressed 65 65 if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) 66 66 $post_data['post_status'] = 'draft'; 67 if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) 67 if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) // TODO: is this set anywhere? 68 68 $post_data['post_status'] = 'private'; 69 69 if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) 70 70 $post_data['post_status'] = 'publish'; … … 81 81 82 82 // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published. 83 83 // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. 84 if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->cap->publish_posts )) ) 85 if ( $previous_status != 'publish' || !current_user_can( 'edit_post', $post_id ) ) 86 $ post_data['post_status'] = 'pending';84 if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->cap->publish_posts )) ) { 85 if ( $previous_status != 'publish' || !current_user_can( 'edit_post', $post_id ) ) { 86 $moderation_status = apply_filters( 'post_moderation_status', 'pending', $post->ID ); 87 87 88 $_status_obj = get_post_status_object( $moderation_status ); 89 $cap_name = "set_{$moderation_status}_posts"; 90 91 if ( empty($_status_obj) || ! $_status_obj->moderation || ( ! empty($ptype->cap->$cap_name) && ! current_user_can($ptype->cap->$cap_name) ) ) 92 $moderation_status = 'pending'; 93 94 $post_data['post_status'] = $moderation_status; 95 } 96 } 97 88 98 if ( ! isset($post_data['post_status']) ) 89 99 $post_data['post_status'] = $previous_status; 90 100 … … 169 179 case 'password' : 170 180 unset( $post_data['sticky'] ); 171 181 break; 172 case 'private' : 173 $post_data['post_status'] = 'private'; 174 $post_data['post_password'] = ''; 175 unset( $post_data['sticky'] ); 176 break; 182 default: 183 $status_obj = get_post_status_object( $post_data['visibility'] ); 184 185 if ( ! empty( $status_obj->private ) || ! empty( $status_obj->public ) ) { 186 $post_data['post_status'] = $status_obj->name; 187 $post_data['post_password'] = ''; 188 } 189 190 if ( ! empty( $status_obj->private ) ) { 191 unset( $post_data['sticky'] ); 192 } 177 193 } 178 194 } 179 195 … … 476 492 case 'password' : 477 493 unset( $_POST['sticky'] ); 478 494 break; 479 case 'private' : 480 $_POST['post_status'] = 'private'; 481 $_POST['post_password'] = ''; 482 unset( $_POST['sticky'] ); 483 break; 495 default: 496 $status_obj = get_post_status_object( $_POST['visibility'] ); 497 if ( ! empty( $status_obj->private ) ) { 498 $_POST['post_status'] = $status_obj->name; 499 $_POST['post_password'] = ''; 500 unset( $_POST['sticky'] ); 501 } 484 502 } 485 503 } 486 504 … … 827 845 828 846 if ( isset($q['orderby']) ) 829 847 $orderby = $q['orderby']; 830 elseif ( isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')) )848 elseif ( isset($q['post_status']) && ( in_array($q['post_status'], array('pending', 'draft')) || ! empty( $GLOBALS['wp_post_statuses'][$q['post_status']]->moderation ) ) ) 831 849 $orderby = 'modified'; 832 850 833 851 if ( isset($q['order']) ) … … 977 995 $original_date = $post->post_date; 978 996 $original_name = $post->post_name; 979 997 998 $post_status_obj = get_post_status_object( $post->post_status ); 999 980 1000 // Hack: get_permalink would return ugly permalink for 981 1001 // drafts, so we will fake, that our post is published 982 if ( in_array($post->post_status, array('draft', 'pending')) ) {1002 if ( in_array($post->post_status, array('draft', 'pending')) || ! empty($post_status_obj->moderation) ) { 983 1003 $post->post_status = 'publish'; 984 1004 $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID); 985 1005 } … … 1036 1056 1037 1057 list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); 1038 1058 1039 if ( 'publish' == $post->post_status ) { 1059 $public_stati = get_post_stati( array( 'public' => true ) ); 1060 if ( in_array( $post->post_status, $public_stati ) ) { 1040 1061 $ptype = get_post_type_object($post->post_type); 1041 1062 $view_post = $ptype->labels->view_item; 1042 1063 $title = __('Click to edit this part of the permalink'); -
wp-admin/includes/template.php
277 277 <div class="post_author">' . $post->post_author . '</div> 278 278 <div class="comment_status">' . $post->comment_status . '</div> 279 279 <div class="ping_status">' . $post->ping_status . '</div> 280 <div class="_status">' . $post->post_status . '</div> 280 <div class="_status">' . $post->post_status . '</div>'; 281 282 if ( 'future' == $post->post_status ) { 283 if ( ! $scheduled_status = get_post_meta( $post->ID, '_scheduled_status', true ) ) 284 $scheduled_status = 'publish'; 285 echo ' 286 <div class="scheduled_status">' . $scheduled_status . '</div>'; 287 } 288 289 echo ' 281 290 <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div> 282 291 <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div> 283 292 <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div> … … 579 588 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { 580 589 global $wp_locale, $post, $comment; 581 590 582 if ( $for_post ) 583 $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); 584 591 if ( $for_post ) { 592 $post_status_obj = get_post_status_object($post->post_status); 593 $edit = ( ( 'draft' != $post->post_status ) && empty($post_status_obj->moderation) ) || ( $post->post_date_gmt && '0000-00-00 00:00:00' != $post->post_date_gmt ); 594 } 595 585 596 $tab_index_attribute = ''; 586 597 if ( (int) $tab_index > 0 ) 587 598 $tab_index_attribute = " tabindex=\"$tab_index\""; … … 1596 1607 else 1597 1608 $post_status = ''; 1598 1609 1610 $post_status_obj = get_post_status_object($post->post_status); 1611 1599 1612 if ( !empty($post->post_password) ) 1600 1613 $post_states[] = __('Password protected'); 1601 if ( 'private' == $post->post_status && 'private' != $post_status ) 1602 $post_states[] = __('Private'); 1603 if ( 'draft' == $post->post_status && 'draft' != $post_status ) 1604 $post_states[] = __('Draft'); 1605 if ( 'pending' == $post->post_status && 'pending' != $post_status ) 1606 /* translators: post state */ 1607 $post_states[] = _x('Pending', 'post state'); 1614 1615 if ( $post_status_obj && ( 'publish' != $post->post_status ) ) { 1616 if ( $post->post_status != $post_status ) { 1617 $post_states[] = $post_status_obj->label; 1618 1619 if ( 'future' == $post->post_status ) { 1620 if ( $scheduled_status = get_post_meta( $post->ID, '_scheduled_status', true ) ) { 1621 if ( 'publish' != $scheduled_status ) { 1622 if ( $_scheduled_status_obj = get_post_status_object( $scheduled_status ) ) 1623 $post_states[] = $_scheduled_status_obj->label; 1624 } 1625 } 1626 } 1627 } 1628 } 1629 1608 1630 if ( is_sticky($post->ID) ) 1609 1631 $post_states[] = __('Sticky'); 1610 1632 -
wp-admin/js/inline-edit-post.dev.js
78 78 if ( $('form#posts-filter tr.inline-editor').length > 0 ) 79 79 t.revert(); 80 80 }); 81 82 $('.keep-private, .keep-private input').click(function() { 83 if ( $(this).attr('checked') ) { 84 $('.keep-private input').filter("[name!='" + $(this).attr('name') + "']").removeAttr('checked'); 85 } 86 }); 81 87 }, 82 88 83 89 toggle : function(el){ … … 128 134 if ( typeof(id) == 'object' ) 129 135 id = t.getId(id); 130 136 131 fields = ['post_title', 'post_name', 'post_author', '_status', ' jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password'];137 fields = ['post_title', 'post_name', 'post_author', '_status', 'scheduled_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password']; 132 138 if ( t.type == 'page' ) 133 139 fields.push('post_parent', 'menu_order', 'page_template'); 134 140 … … 178 184 } 179 185 }); 180 186 181 182 187 // handle the post status 183 188 status = $('._status', rowData).text(); 184 if ( 'future' != status ) 189 190 if ( 'future' == status ) { 191 status = $('.scheduled_status', rowData).text(); 192 } else { 185 193 $('select[name="_status"] option[value="future"]', editRow).remove(); 194 } 186 195 187 if ( 'private' == status) {188 $('input[name="keep_ private"]', editRow).attr("checked", "checked");196 if ( $('[name=keep_' + status + ']').length > 0) { 197 $('input[name="keep_' + status + '"]', editRow).attr("checked", "checked"); 189 198 $('input.inline-edit-password-input').val('').attr('disabled', 'disabled'); 190 199 } 191 200 -
wp-admin/js/post.dev.js
346 346 347 347 function updateVisibility() { 348 348 var pvSelect = $('#post-visibility-select'); 349 if ( $('input:radio:checked', pvSelect).val() != 'public' ) {350 $('#sticky').attr('checked', false);351 $('#sticky-span').hide();352 } else {353 $('#sticky-span').show();354 }355 349 if ( $('input:radio:checked', pvSelect).val() != 'password' ) { 356 350 $('#password-span').hide(); 357 351 } else { … … 360 354 } 361 355 362 356 function updateText() { 363 var attemptedDate, originalDate, currentDate, publishOn, page = 'page' == pagenow || 'page-new' == pagenow,357 var attemptedDate, originalDate, currentDate, publishOn, 364 358 postStatus = $('#post_status'), optPublish = $('option[value=publish]', postStatus), aa = $('#aa').val(), 365 359 mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(); 366 360 … … 383 377 $('#publish').val( postL10n.publish ); 384 378 } else { 385 379 publishOn = postL10n.publishOnPast; 386 if ( page ) 387 $('#publish').val( postL10n.updatePage ); 388 else 389 $('#publish').val( postL10n.updatePost ); 380 $('#publish').val( postL10n.update ); 390 381 } 382 391 383 if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack 392 384 $('#timestamp').html(stamp); 393 385 } else { … … 402 394 } 403 395 404 396 if ( $('input:radio:checked', '#post-visibility-select').val() == 'private' ) { 405 if ( page ) 406 $('#publish').val( postL10n.updatePage ); 407 else 408 $('#publish').val( postL10n.updatePost ); 409 if ( optPublish.length == 0 ) { 410 postStatus.append('<option value="publish">' + postL10n.privatelyPublished + '</option>'); 411 } else { 412 optPublish.html( postL10n.privatelyPublished ); 397 if ( attemptedDate <= currentDate ) { 398 $('#publish').val( postL10n.update ); 413 399 } 400 414 401 $('option[value=publish]', postStatus).attr('selected', true); 415 402 $('.edit-post-status', '#misc-publishing-actions').hide(); 416 403 } else { … … 425 412 if ( postStatus.is(':hidden') ) 426 413 $('.edit-post-status', '#misc-publishing-actions').show(); 427 414 } 428 $('#post-status-display').html($('option:selected', postStatus).text()); 429 if ( $('option:selected', postStatus).val() == 'private' || $('option:selected', postStatus).val() == 'publish' ) { 430 $('#save-post').hide(); 431 } else { 432 $('#save-post').show(); 433 if ( $('option:selected', postStatus).val() == 'pending' ) { 434 $('#save-post').show().val( postL10n.savePending ); 435 } else { 436 $('#save-post').show().val( postL10n.saveDraft ); 437 } 438 } 415 439 416 return true; 440 417 } 441 418 … … 447 424 } 448 425 return false; 449 426 }); 450 427 451 428 $('.cancel-post-visibility', '#post-visibility-select').click(function () { 452 429 $('#post-visibility-select').slideUp("normal"); 453 430 $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true); … … 455 432 $('#sticky').attr('checked', $('#hidden-post-sticky').attr('checked')); 456 433 $('#post-visibility-display').html(visibility); 457 434 $('.edit-visibility', '#visibility').show(); 458 updateText();459 435 return false; 460 436 }); 461 437 462 438 $('.save-post-visibility', '#post-visibility-select').click(function () { // crazyhorse - multiple ok cancels 463 439 var pvSelect = $('#post-visibility-select'); 464 440 465 441 pvSelect.slideUp("normal"); 466 442 $('.edit-visibility', '#visibility').show(); 467 updateText();468 443 469 if ( $('input:radio:checked', pvSelect).val() != 'public' ) {470 $('#sticky').attr('checked', false);471 } // WEAPON LOCKED472 473 444 if ( true == $('#sticky').attr('checked') ) { 474 445 sticky = 'Sticky'; 475 446 } else { 476 447 sticky = ''; 477 448 } 478 449 479 450 $('#post-visibility-display').html( postL10n[$('input:radio:checked', pvSelect).val() + sticky] ); 480 451 return false; 481 452 }); 482 453 483 454 $('input:radio', '#post-visibility-select').change(function() { 484 455 updateVisibility(); 485 456 }); -
wp-admin/post.php
68 68 $message = 9; 69 69 break; 70 70 default: 71 $message = 6; 71 $status_obj = get_post_status_object( $status ); 72 if ( ! empty($status_obj->moderation) ) 73 $message = 11; 74 else 75 $message = 6; 72 76 } 73 77 } else { 74 78 $message = 'draft' == $status ? 10 : 1; -
wp-comments-post.php
37 37 } elseif ( 'trash' == $status ) { 38 38 do_action('comment_on_trash', $comment_post_ID); 39 39 exit; 40 } elseif ( !$status_obj->public && !$status_obj->private) {40 } elseif ( empty($status_obj->public) && empty($status_obj->private) ) { 41 41 do_action('comment_on_draft', $comment_post_ID); 42 42 exit; 43 43 } elseif ( post_password_required($comment_post_ID) ) { -
wp-includes/default-widgets.php
542 542 else if ( $number > 15 ) 543 543 $number = 15; 544 544 545 $r = new WP_Query(array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true)); 545 $public_stati = apply_filters( 'recent_posts_stati', get_post_stati( array( 'public' => true ) ) ); 546 $status_arg = implode( ',', $public_stati ); 547 548 $r = new WP_Query(array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => $status_arg, 'ignore_sticky_posts' => true)); 546 549 if ($r->have_posts()) : 547 550 ?> 548 551 <?php echo $before_widget; ?> -
wp-includes/functions.php
3047 3047 $filtered = array(); 3048 3048 3049 3049 foreach ( $list as $key => $obj ) { 3050 $matched = count( array_intersect_assoc( (array) $obj, $args ) ); 3051 if ( ('and' == $operator && $matched == $count) || ('or' == $operator && $matched <= $count) ) { 3050 $matched = array_intersect_assoc( (array) $obj, $args ); 3051 3052 foreach( array_keys( $matched ) as $_key ) { 3053 if ( is_array( $args[$_key] ) ) { 3054 if ( ! array_intersect( $args[$_key], $matched[$_key] ) ) 3055 unset( $matched[$_key] ); 3056 } 3057 } 3058 3059 $num_matched = count( $matched ); 3060 3061 if ( ( 'and' == $operator && $num_matched == $count ) || ( 'or' == $operator && $num_matched ) ) { 3052 3062 $filtered[$key] = $obj; 3053 3063 } 3054 3064 } -
wp-includes/general-template.php
882 882 } 883 883 884 884 //filters 885 $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r ); 885 $public_stati = apply_filters( 'getarchives_stati', get_post_stati( array( 'public' => true ) ) ); 886 $public_csv = implode( "', '", $public_stati ); 887 888 $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status IN ('" . $public_csv . "')", $r ); 886 889 $join = apply_filters('getarchives_join', "", $r); 887 890 888 891 $output = ''; -
wp-includes/link-template.php
114 114 115 115 $permalink = apply_filters('pre_post_link', $permalink, $post, $leavename); 116 116 117 if ( '' != $permalink && ! in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) {117 if ( '' != $permalink && ! in_array( $post->post_status, array('draft', 'auto-draft', 'pending') ) && empty( $GLOBALS['wp_post_statuses'][$post->post_status]->moderation ) ) { 118 118 $unixtime = strtotime($post->post_date); 119 119 120 120 $category = ''; … … 185 185 186 186 $slug = $post->post_name; 187 187 188 $draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ));188 $draft_or_pending = in_array( $post->post_status, array('draft', 'auto-draft', 'pending') ) || ! empty( $GLOBALS['wp_post_statuses'][$post->post_status]->moderation ); 189 189 190 190 $post_type = get_post_type_object($post->post_type); 191 191 … … 273 273 274 274 $link = $wp_rewrite->get_page_permastruct(); 275 275 276 if ( '' != $link && ( ( isset($post->post_status) && 'draft' != $post->post_status && 'pending' != $post->post_status) || $sample ) ) {276 if ( '' != $link && ( ( isset($post->post_status) && ! in_array( $post->post_status, array('draft', 'auto-draft', 'pending') ) && empty( $GLOBALS['wp_post_statuses'][$post->post_status]->moderation ) ) || $sample ) ) { 277 277 if ( ! $leavename ) 278 278 $link = str_replace('%pagename%', get_page_uri($id), $link); 279 279 $link = home_url($link); -
wp-includes/nav-menu.php
466 466 if ( empty( $items ) ) 467 467 return $items; 468 468 469 $public_stati = apply_filters( 'nav_menu_stati', get_post_stati( array( 'public' => true ) ), $menu ); 470 $public_csv = implode( ',', $public_stati ); 471 469 472 $defaults = array( 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 470 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true,473 'post_status' => $public_csv, 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true, 471 474 'update_post_term_cache' => false ); 472 475 $args = wp_parse_args( $args, $defaults ); 473 476 if ( count( $items ) > 1 ) -
wp-includes/post-template.php
108 108 $id = isset($post->ID) ? $post->ID : (int) $id; 109 109 110 110 if ( !is_admin() ) { 111 if ( ! empty($post->post_password) ) {112 $protected_title_format = apply_filters( 'protected_title_format', __('Protected: %s'));111 if ( ! empty($post->post_password) ) { 112 $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) ); 113 113 $title = sprintf($protected_title_format, $title); 114 } else if ( isset($post->post_status) && 'private' == $post->post_status ) { 115 $private_title_format = apply_filters('private_title_format', __('Private: %s')); 116 $title = sprintf($private_title_format, $title); 114 } elseif ( isset($post->post_status) ) { 115 $post_status_obj = get_post_status_object( $post->post_status ); 116 if ( $post_status_obj && $post_status_obj->private ) { 117 if ( 'private' == $post->post_status ) { 118 $format_string = __( 'Private: %s' ); // preserve existing translation string 119 $private_title_format = apply_filters( 'private_title_format', $format_string ); 120 $title = sprintf($private_title_format, $title); 121 } else { 122 $format_string = _x( '%1$s: %2$s', 'post status: title' ); 123 $private_title_format = apply_filters( 'post_title_format', $format_string, $_status ); 124 $title = sprintf($private_title_format, $post_status_obj->labels->name, $title); 125 } 126 } 117 127 } 118 128 } 119 129 return apply_filters( 'the_title', $title, $id ); … … 631 641 if ( 1 == $i ) { 632 642 $url = get_permalink(); 633 643 } else { 634 if ( '' == get_option('permalink_structure') || in_array( $post->post_status, array('draft', 'pending')))644 if ( '' == get_option('permalink_structure') || in_array( $post->post_status, array('draft', 'auto-draft', 'pending') ) || ! empty( $GLOBALS['wp_post_statuses'][$post->post_status]->moderation ) ) 635 645 $url = add_query_arg( 'page', $i, get_permalink() ); 636 646 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID ) 637 647 $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged'); -
wp-includes/post.php
81 81 ) ); 82 82 83 83 register_post_status( 'publish', array( 84 'label' => _x( 'Published', 'post' ), 84 'labels' => array( 85 'name' => _x( 'Published', 'post' ), 86 'publish' => esc_attr__('Publish'), 87 'count' => _n_noop( 'Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>' ), 88 ), 85 89 'public' => true, 86 90 '_builtin' => true, /* internal use only. */ 87 'label_count' => _n_noop( 'Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>' ),88 91 ) ); 89 92 90 93 register_post_status( 'future', array( 91 'label' => _x( 'Scheduled', 'post' ), 94 'labels' => array( 95 'name' => _x( 'Scheduled', 'post' ), 96 'publish' => esc_attr__('Schedule'), 97 'count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>' ), 98 ), 92 99 'protected' => true, 93 100 '_builtin' => true, /* internal use only. */ 94 'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>' ),95 101 ) ); 96 102 97 103 register_post_status( 'draft', array( 98 'label' => _x( 'Draft', 'post' ), 104 'labels' => array( 105 'name' => _x( 'Draft', 'post' ), 106 'save_as' => esc_attr__('Save Draft'), 107 'count' => _n_noop( 'Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>' ), 108 ), 99 109 'protected' => true, 100 110 '_builtin' => true, /* internal use only. */ 101 'label_count' => _n_noop( 'Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>' ),102 111 ) ); 103 112 104 113 register_post_status( 'pending', array( 105 'label' => _x( 'Pending', 'post' ), 114 'labels' => array( 115 'name' => _x( 'Pending', 'post' ), 116 'caption' => __( 'Pending Review' ), 117 'publish' => esc_attr__('Submit for Review'), 118 'count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ), 119 ), 106 120 'protected' => true, 107 121 '_builtin' => true, /* internal use only. */ 108 ' label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ),122 'moderation' => true, 109 123 ) ); 110 124 111 125 register_post_status( 'private', array( 112 'label' => _x( 'Private', 'post' ), 126 'labels' => array( 127 'name' => _x( 'Private', 'post' ), 128 'caption' => __( 'Privately Published' ), 129 'count' => _n_noop( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>' ), 130 ), 113 131 'private' => true, 114 132 '_builtin' => true, /* internal use only. */ 115 'label_count' => _n_noop( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>' ),116 133 ) ); 117 134 118 135 register_post_status( 'trash', array( 119 'label' => _x( 'Trash', 'post' ), 136 'labels' => array( 137 'name' => _x( 'Trash', 'post' ), 138 'count' => _n_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>' ), 139 ), 120 140 'internal' => true, 121 141 '_builtin' => true, /* internal use only. */ 122 'label_count' => _n_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>' ),123 142 'show_in_admin_status_list' => true, 124 143 ) ); 125 144 126 145 register_post_status( 'auto-draft', array( 127 'label' => 'auto-draft', 146 'labels' => array( 147 'name' => 'auto-draft', 148 'caption' => __( 'Draft' ), 149 ), 128 150 'internal' => true, 129 151 '_builtin' => true, /* internal use only. */ 130 152 ) ); 131 153 132 154 register_post_status( 'inherit', array( 133 'label' => 'inherit', 155 'labels' => array( 156 'name' => 'inherit', 157 ), 134 158 'internal' => true, 135 159 '_builtin' => true, /* internal use only. */ 136 160 'exclude_from_search' => false, … … 594 618 } 595 619 596 620 /** 621 * Add an already registered post status to an object type. 622 * 623 * @package WordPress 624 * @subpackage Taxonomy 625 * @since 3.1.0 626 * @uses $wp_post_statuses Modifies post_type object 627 * 628 * @param string $post_status Name of post_status object 629 * @param array|string $object_type Name of the object type 630 * @return bool True if successful, false if not 631 */ 632 function register_status_for_object_type( $post_status, $object_type) { 633 global $wp_post_statuses; 634 635 if ( ! isset( $wp_post_statuses[$post_status] ) ) 636 return false; 637 638 if ( ! get_post_type_object($object_type) ) 639 return false; 640 641 $wp_post_statuses[$post_status]->object_type[] = $object_type; 642 643 return true; 644 } 645 646 /** 597 647 * Register a post type. Do not use before init. 598 648 * 599 649 * A simple function for creating or modifying a post status based on the … … 622 672 $wp_post_statuses = array(); 623 673 624 674 // Args prefixed with an underscore are reserved for internal use. 625 $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); 675 $defaults = array( 'object_type' => null, 'labels' => array(), '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, 'moderation' => 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); 676 626 677 $args = wp_parse_args($args, $defaults); 627 678 $args = (object) $args; 628 679 629 680 $post_status = sanitize_key($post_status); 630 681 $args->name = $post_status; 631 682 683 if ( null == $args->object_type ) { 684 $args->object_type = get_post_types( array( 'public' => true, 'show_ui' => true ) ); 685 } else { 686 $args->object_type = (array) $args->object_type; 687 } 688 632 689 if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private ) 633 690 $args->internal = true; 634 691 … … 638 695 if ( null === $args->private ) 639 696 $args->private = false; 640 697 698 if ( null === $args->moderation ) 699 $args->moderation = false; 700 641 701 if ( null === $args->protected ) 642 702 $args->protected = false; 643 703 … … 659 719 if ( null === $args->single_view_cap ) 660 720 $args->single_view_cap = $args->public ? '' : 'edit'; 661 721 662 if ( false === $args->label ) 663 $args->label = $post_status; 722 $args->labels = (object) $args->labels; 664 723 665 if ( false === $args->label_count ) 666 $args->label_count = array( $args->label, $args->label ); 724 if ( empty( $args->labels->name ) ) 725 $args->labels->name = ( ! empty( $args->label ) ) ? $args->label : $post_status; 726 727 if ( empty( $args->label ) ) 728 $args->label = $args->labels->name; 729 730 if ( empty( $args->labels->caption ) ) 731 $args->labels->caption = $args->label; 667 732 733 if ( empty( $args->labels->count ) ) 734 $args->labels->count = ( ! empty( $args->label_count ) ) ? $args->label_count : array( $args->label, $args->label ); 735 736 if ( empty( $args->label_count ) ) // TODO: need to support this for external API? 737 $args->label_count = $args->labels->count; 738 739 if ( empty( $args->labels->publish ) ) 740 $args->labels->publish = esc_attr( sprintf( __( 'Set %s' ), $args->label ) ); 741 742 if ( empty( $args->labels->save_as ) ) 743 $args->labels->save_as = esc_attr( sprintf( __( 'Save as %s' ), $args->label ) ); 744 745 if ( empty( $args->labels->visibility ) ) { 746 if ( 'publish' == $post_status ) 747 $args->labels->visibility =__( 'Public' ); 748 elseif ( $args->public ) 749 $args->labels->visibility = esc_attr( sprintf( __( 'Public (%s)' ), $args->label ) ); 750 elseif ( $args->private ) 751 $args->labels->visibility = $args->label; 752 } 753 668 754 $wp_post_statuses[$post_status] = $args; 669 755 670 756 return $args; … … 713 799 714 800 $field = ('names' == $output) ? 'name' : false; 715 801 802 if ( ! empty( $args['object_type'] ) ) 803 $args['object_type'] = (array) $args['object_type']; 804 716 805 return wp_filter_object_list($wp_post_statuses, $args, $operator, $field); 717 806 } 718 807 … … 868 957 'labels' => array(), 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, 869 958 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'capabilities' => array(), 'hierarchical' => false, 870 959 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 871 'taxonomies' => array(), 's how_ui' => null, 'menu_position' => null, 'menu_icon' => null,960 'taxonomies' => array(), 'statuses' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 872 961 'permalink_epmask' => EP_PERMALINK, 'can_export' => true, 'show_in_nav_menus' => null 873 962 ); 874 963 $args = wp_parse_args($args, $defaults); … … 958 1047 foreach ( $args->taxonomies as $taxonomy ) { 959 1048 register_taxonomy_for_object_type( $taxonomy, $post_type ); 960 1049 } 1050 1051 foreach ( $args->statuses as $post_status ) { 1052 register_status_for_object_type( $post_status, $post_type ); 1053 } 961 1054 962 1055 return $args; 963 1056 } … … 1624 1717 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; 1625 1718 if ( 'readable' == $perm && is_user_logged_in() ) { 1626 1719 $post_type_object = get_post_type_object($type); 1627 if ( !current_user_can( $post_type_object->cap->read_private_posts ) ) { 1628 $cache_key .= '_' . $perm . '_' . $user->ID; 1629 $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))"; 1720 foreach( get_post_stati( array( 'private' => true, 'object_type' => $type ) ) as $_status ) { 1721 $cap_name = "read_{$_status}_posts"; 1722 if ( ! empty($post_type_object->cap->$cap_name) && ! current_user_can( $post_type_object->cap->$cap_name ) ) { 1723 $suffix = ( 'private' == $_status ) ? '' : $_status; 1724 $cache_key .= '_' . $perm . $suffix . '_' . $user->ID; 1725 $query .= " AND (post_status != '$_status' OR ( post_author = '$user->ID' AND post_status = '$_status' ))"; 1726 } 1630 1727 } 1631 1728 } 1632 1729 $query .= ' GROUP BY post_status'; 1633 1730 1634 1731 $count = wp_cache_get($cache_key, 'counts'); 1635 1732 if ( false !== $count ) 1636 1733 return $count; … … 1638 1735 $count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); 1639 1736 1640 1737 $stats = array(); 1641 foreach ( get_post_stati( ) as $state )1738 foreach ( get_post_stati( array( 'object_type' => $type ) ) as $state ) 1642 1739 $stats[$state] = 0; 1643 1740 1644 1741 foreach ( (array) $count as $row ) … … 2123 2220 $limit = "LIMIT $num"; 2124 2221 } 2125 2222 2126 $sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status IN ( 'draft', 'publish', 'future', 'pending', 'private' ) ORDER BY post_date DESC $limit"; 2223 $status_names = get_post_stati( array( 'public' => true, 'object_type' => 'post' ) ); 2224 2225 $sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status IN ( '" . implode( "', '", $status_names ) . "' ) ORDER BY post_date DESC $limit"; 2127 2226 $result = $wpdb->get_results($sql, ARRAY_A); 2128 2227 2129 2228 return $result ? $result : array(); … … 2271 2370 $post_before = get_post($post_ID); 2272 2371 } 2273 2372 2274 // Don't allow contributors to set to set the post slug for pending review posts 2275 if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) ) 2373 // Don't allow contributors to set the post slug for pending review posts 2374 $post_status_obj = get_post_status_object( $post_status ); 2375 $draft_or_pending = in_array( $post_status, array('draft', 'auto-draft') ) || ! empty($post_status_obj->moderation); 2376 2377 if ( ! empty( $post_status_obj->moderation ) && ! current_user_can( 'publish_posts' ) ) 2276 2378 $post_name = ''; 2277 2379 2278 2380 // Create a valid post name. Drafts and pending posts are allowed to have an empty 2279 2381 // post name. 2280 2382 if ( empty($post_name) ) { 2281 if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ))2383 if ( ! $draft_or_pending ) 2282 2384 $post_name = sanitize_title($post_title); 2283 2385 else 2284 2386 $post_name = ''; … … 2291 2393 $post_date = current_time('mysql'); 2292 2394 2293 2395 if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) { 2294 if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ))2396 if ( ! $draft_or_pending ) 2295 2397 $post_date_gmt = get_gmt_from_date($post_date); 2296 2398 else 2297 2399 $post_date_gmt = '0000-00-00 00:00:00'; … … 2305 2407 $post_modified_gmt = $post_date_gmt; 2306 2408 } 2307 2409 2308 if ( 'publish' == $post_status ) { 2410 $set_status = $post_status; 2411 2412 if ( $post_status_obj->public || $post_status_obj->private ) { 2309 2413 $now = gmdate('Y-m-d H:i:59'); 2310 2414 if ( mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false) ) 2311 2415 $post_status = 'future'; … … 2315 2419 $post_status = 'publish'; 2316 2420 } 2317 2421 2422 if ( ( 'future' == $post_status ) && ( 'publish' != $set_status ) ) { 2423 update_post_meta( $post_ID, '_scheduled_status', $set_status ); 2424 } else 2425 delete_post_meta( $post_ID, '_scheduled_status' ); 2426 2318 2427 if ( empty($comment_status) ) { 2319 2428 if ( $update ) 2320 2429 $comment_status = 'closed'; … … 2345 2454 else 2346 2455 $menu_order = 0; 2347 2456 2348 if ( ! isset($post_password) || 'private' == $post_status)2457 if ( ! isset($post_password) || $post_status_obj->private ) 2349 2458 $post_password = ''; 2350 2459 2351 2460 $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent); … … 2386 2495 $where = array( 'ID' => $post_ID ); 2387 2496 } 2388 2497 2389 if ( empty($data['post_name']) && !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) { 2498 $post_status_obj = get_post_status_object( $data['post_status'] ); 2499 $draft_or_pending = in_array( $data['post_status'], array('draft', 'auto-draft') ) || ! empty($post_status_obj->moderation); 2500 2501 if ( empty($data['post_name']) && ! $draft_or_pending ) { 2390 2502 $data['post_name'] = sanitize_title($data['post_title'], $post_ID); 2391 2503 $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where ); 2392 2504 } … … 2479 2591 $post_cats = $post['post_category']; 2480 2592 2481 2593 // Drafts shouldn't be assigned a date unless explicitly done so by the user 2482 if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) && 2483 ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) 2484 $clear_date = true; 2485 else 2594 if ( isset( $post['post_status'] ) && empty($postarr['edit_date']) && ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) { 2595 $post_status_obj = get_post_status_object( $post['post_status'] ); 2596 2597 $clear_date = in_array( $post['post_status'], array('draft', 'auto-draft') ) || ! empty($post_status_obj->moderation); 2598 } else 2486 2599 $clear_date = false; 2487 2600 2488 2601 // Merge old and new fields with new fields overwriting old ones. … … 2520 2633 if ( 'publish' == $post->post_status ) 2521 2634 return; 2522 2635 2523 $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post_id ) ); 2636 if ( 'future' == $post->post_status ) { 2637 if ( ! $post_status = get_post_meta( $post_id, '_scheduled_status', true ) ) 2638 $post_status = 'publish'; 2639 } else 2640 $post_status = 'publish'; 2524 2641 2642 $wpdb->update( $wpdb->posts, array( 'post_status' => $post_status ), array( 'ID' => $post_id ) ); 2643 2525 2644 $old_status = $post->post_status; 2526 2645 $post->post_status = 'publish'; 2527 2646 wp_transition_post_status('publish', $old_status, $post); … … 2583 2702 * @return string unique slug for the post, based on $post_name (with a -1, -2, etc. suffix) 2584 2703 */ 2585 2704 function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) { 2586 if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) 2705 $post_status_obj = get_post_status_object( $post_status ); 2706 2707 if ( in_array( $post['post_status'], array('draft', 'auto-draft') ) || ! empty($post_status_obj->moderation) ) 2587 2708 return $slug; 2588 2709 2589 2710 global $wpdb, $wp_rewrite; … … 3127 3248 return false; 3128 3249 3129 3250 // Make sure we have a valid post status 3130 if ( ! in_array($post_status, get_post_stati()) )3251 if ( ! in_array( $post_status, get_post_stati( array( 'object_type' => $post_type ) ) ) ) 3131 3252 return false; 3132 3253 3133 3254 $cache = array(); -
wp-includes/query.php
2033 2033 $post_type_object = get_post_type_object ( 'post' ); 2034 2034 } 2035 2035 2036 $_post_type = ( $post_type ) ? $post_type : 'post'; // corresponds to hardcoded default for POST_TYPE clause 2037 $type_arg = ( 'any' == $_post_type ) ? array() : array( 'object_type' => $_post_type ); 2038 2036 2039 if ( !empty($post_type_object) ) { 2037 2040 $post_type_cap = $post_type_object->capability_type; 2038 2041 $edit_cap = $post_type_object->cap->edit_post; 2039 2042 $read_cap = $post_type_object->cap->read_post; 2040 2043 $edit_others_cap = $post_type_object->cap->edit_others_posts; 2041 $read_private_cap = $post_type_object->cap->read_private_posts;2042 2044 } else { 2043 2045 $edit_cap = 'edit_' . $post_type_cap; 2044 2046 $read_cap = 'read_' . $post_type_cap; 2045 2047 $edit_others_cap = 'edit_others_' . $post_type_cap . 's'; 2046 $read_private_cap = 'read_private_' . $post_type_cap . 's';2047 2048 } 2048 2049 2049 2050 if ( isset($q['post_status']) && '' != $q['post_status'] ) { … … 2051 2052 $q_status = explode(',', $q['post_status']); 2052 2053 $r_status = array(); 2053 2054 $p_status = array(); 2055 $p_status_owner = array(); 2054 2056 $e_status = array(); 2055 2057 if ( $q['post_status'] == 'any' ) { 2056 2058 foreach ( get_post_stati( array('exclude_from_search' => true) ) as $status ) 2057 2059 $e_status[] = "$wpdb->posts.post_status <> '$status'"; 2058 2060 } else { 2059 foreach ( get_post_stati() as $status ) { 2061 $_args = array_merge( array(), $type_arg ); 2062 foreach ( get_post_stati( $_args, 'object' ) as $status => $status_obj ) { 2060 2063 if ( in_array( $status, $q_status ) ) { 2061 if ( 'private' == $status ) 2062 $p_status[] = "$wpdb->posts.post_status = '$status'"; 2063 else 2064 if ( $status_obj->private ) { 2065 if ( ! empty($post_type_object) ) { 2066 $check_cap = "read_{$status}_posts"; 2067 $read_private_cap = ( ! empty( $post_type_object->cap->$check_cap ) ) ? $post_type_object->cap->$check_cap : $post_type_object->cap->read_private_posts; 2068 } else 2069 $read_private_cap = 'read_private_' . $post_type_cap . 's'; 2070 2071 if ( ! empty($q['perm'] ) && 'readable' == $q['perm'] && ! current_user_can( $read_private_cap ) ) 2072 $p_status_owner[] = "$wpdb->posts.post_status = '$status'"; 2073 else 2074 $p_status[] = "$wpdb->posts.post_status = '$status'"; 2075 } else 2064 2076 $r_status[] = "$wpdb->posts.post_status = '$status'"; 2065 2077 } 2066 2078 } 2067 2079 } 2068 2080 2069 2081 if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) { 2070 $r_status = array_merge($r_status, $p_status );2082 $r_status = array_merge($r_status, $p_status, $p_status_owner); 2071 2083 unset($p_status); 2084 unset($p_status_owner); 2072 2085 } 2073 2086 2074 2087 if ( !empty($e_status) ) { … … 2080 2093 else 2081 2094 $statuswheres[] = "(" . join( ' OR ', $r_status ) . ")"; 2082 2095 } 2083 if ( !empty($p_status) ) { 2084 if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can($read_private_cap) ) 2085 $statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $p_status ) . "))"; 2086 else 2087 $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")"; 2096 if ( ! empty( $p_status_owner ) ) { 2097 $statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $p_status_owner ) . "))"; 2088 2098 } 2099 if ( ! empty( $p_status ) ) { 2100 $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")"; 2101 } 2089 2102 if ( $post_status_join ) { 2090 2103 $join .= " LEFT JOIN $wpdb->posts AS p2 ON ($wpdb->posts.post_parent = p2.ID) "; 2091 2104 foreach ( $statuswheres as $index => $statuswhere ) 2092 2105 $statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts, 'p2', $statuswhere) . "))"; 2093 2106 } 2094 2107 foreach ( $statuswheres as $statuswhere ) 2095 $where .= " AND $statuswhere"; 2108 $where .= " AND $statuswhere"; 2109 2096 2110 } elseif ( !$this->is_singular ) { 2097 2111 $where .= " AND ($wpdb->posts.post_status = 'publish'"; 2098 2112 2099 2113 // Add public states. 2100 $public_states = get_post_stati( array('public' => true) ); 2114 $_args = array_merge( array( 'public' => true ), $type_arg ); 2115 $public_states = apply_filters_ref_array( 'posts_public_stati', array( get_post_stati( $_args ), &$this ) ); 2101 2116 foreach ( (array) $public_states as $state ) { 2102 2117 if ( 'publish' == $state ) // Publish is hard-coded above. 2103 2118 continue; … … 2106 2121 2107 2122 if ( is_admin() ) { 2108 2123 // Add protected states that should show in the admin all list. 2109 $admin_all_states = get_post_stati( array('protected' => true, 'show_in_admin_all_list' => true) ); 2124 $_args = array_merge( array( 'protected' => true, 'show_in_admin_all_list' => true ), $type_arg ); 2125 $admin_all_states = get_post_stati( $_args ); 2110 2126 foreach ( (array) $admin_all_states as $state ) 2111 2127 $where .= " OR $wpdb->posts.post_status = '$state'"; 2112 2128 } 2113 2129 2114 2130 if ( is_user_logged_in() ) { 2115 2131 // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states. 2116 $private_states = get_post_stati( array('private' => true) ); 2117 foreach ( (array) $private_states as $state ) 2132 $_args = array_merge( array( 'private' => true ), $type_arg ); 2133 $private_states = apply_filters_ref_array( 'posts_private_stati', array( get_post_stati( $_args ), &$this ) ); 2134 foreach ( (array) $private_states as $state ) { 2135 if ( ! empty($post_type_object) ) { 2136 $check_cap = "read_{$status}_posts"; 2137 $read_private_cap = ( ! empty( $post_type_object->cap->$check_cap ) ) ? $post_type_object->cap->$check_cap : $post_type_object->cap->read_private_posts; 2138 } else 2139 $read_private_cap = 'read_private_' . $post_type_cap . 's'; 2140 2118 2141 $where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_ID AND $wpdb->posts.post_status = '$state'"; 2142 } 2119 2143 } 2120 2144 2121 2145 $where .= ')'; … … 2158 2182 $cwhere = "WHERE comment_approved = '1' $where"; 2159 2183 $cgroupby = "$wpdb->comments.comment_id"; 2160 2184 } else { // Other non singular e.g. front 2185 $public_stati = apply_filters( 'comment_feed_stati', get_post_stati( array( 'public' => true ) ) ); 2186 $public_csv = implode( "', '", $public_stati ); 2187 2161 2188 $cjoin = "JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )"; 2162 $cwhere = "WHERE post_status = 'publish'AND comment_approved = '1'";2189 $cwhere = "WHERE post_status IN ( '$public_csv' ) AND comment_approved = '1'"; 2163 2190 $cgroupby = ''; 2164 2191 } 2165 2192 … … 2337 2364 $stickies_where = "AND $wpdb->posts.post_type IN ('" . $post_types . "')"; 2338 2365 } 2339 2366 2367 $public_stati = apply_filters_ref_array( 'posts_sticky_stati', array( get_post_stati( array( 'public' => true ) ), &$this ) ); 2340 2368 $stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in) $stickies_where" ); 2341 2369 foreach ( $stickies as $sticky_post ) { 2342 2370 // Ignore sticky posts the current user cannot read or are not published. 2343 if ( 'publish' != $sticky_post->post_status)2371 if ( ! in_array( $sticky_post->post_status, $public_stati ) ) 2344 2372 continue; 2373 2345 2374 array_splice($this->posts, $sticky_offset, 0, array($sticky_post)); 2346 2375 $sticky_offset++; 2347 2376 } -
wp-includes/script-loader.php
290 290 291 291 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20100526' ); 292 292 $scripts->add_data( 'post', 'group', 1 ); 293 $ scripts->localize( 'post', 'postL10n',array(293 $arr = array( 294 294 'tagsUsed' => __('Tags used on this post:'), 295 295 'add' => esc_attr(__('Add')), 296 296 'addTag' => esc_attr(__('Add new tag')), … … 305 305 'endcomm' => __('No more comments found.'), 306 306 'publish' => __('Publish'), 307 307 'schedule' => __('Schedule'), 308 'update' => __('Update'), 308 309 'updatePost' => __('Update Post'), 309 310 'updatePage' => __('Update Page'), 310 311 'savePending' => __('Save as Pending'), … … 316 317 'privatelyPublished' => __('Privately Published'), 317 318 'published' => __('Published'), 318 319 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};' 319 ) ); 320 ); 321 322 $custom = array(); 323 foreach( get_post_stati( array( 'public' => true, 'private' => true ), 'object', 'or' ) as $_status => $_status_obj ) { 324 if ( 'publish' == $_status ) 325 continue; 320 326 327 $custom[ $_status ] = $_status_obj->labels->visibility; 328 329 if ( $_status_obj->public ) 330 $custom[ $_status . 'Sticky' ] = sprintf( __('%s, Sticky'), $_status_obj->label ); 331 } 332 333 $arr = array_merge( $custom, $arr ); // note: 'publish' has existing value of 'Publish', cannot be used to reference status name 334 335 $scripts->localize( 'post', 'postL10n', $arr ); 336 321 337 $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), '20090526' ); 322 338 $scripts->add_data( 'link', 'group', 1 ); 323 339 -
wp-includes/taxonomy.php
109 109 110 110 $field = ('names' == $output) ? 'name' : false; 111 111 112 if ( isset( $args['object_type'] ) ) 113 $args['object_type'] = (array) $args['object_type']; 114 112 115 return wp_filter_object_list($wp_taxonomies, $args, $operator, $field); 113 116 } 114 117 … … 2516 2519 // Get the object and term ids and stick them in a lookup table 2517 2520 $tax_obj = get_taxonomy($taxonomy); 2518 2521 $object_types = esc_sql($tax_obj->object_type); 2519 $results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (" . implode(',', array_keys($term_ids)) . ") AND post_type IN ('" . implode("', '", $object_types) . "') AND post_status = 'publish'"); 2522 2523 $public_stati = apply_filters( 'term_count_stati', get_post_stati( array( 'public' => true, 'object_type' => $tax_obj->object_type ) ) ); 2524 $public_csv = implode( "', '", $public_stati ); 2525 2526 $results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (" . implode(',', array_keys($term_ids)) . ") AND post_type IN ('" . implode("', '", $object_types) . "') AND post_status IN ('$public_csv')"); 2520 2527 foreach ( $results as $row ) { 2521 2528 $id = $term_ids[$row->term_taxonomy_id]; 2522 2529 $term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1; … … 2565 2572 $object_types = is_array($taxonomy->object_type) ? $taxonomy->object_type : array($taxonomy->object_type); 2566 2573 $object_types = esc_sql($object_types); 2567 2574 2575 $public_stati = apply_filters( 'term_count_stati', get_post_stati( array( 'public' => true, 'object_type' => $taxonomy->object_type ) ) ); 2576 $public_csv = implode( "', '", $public_stati ); 2577 2568 2578 foreach ( (array) $terms as $term ) { 2569 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish'AND post_type IN ('" . implode("', '", $object_types) . "') AND term_taxonomy_id = %d", $term ) );2579 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status IN ('$public_csv') AND post_type IN ('" . implode("', '", $object_types) . "') AND term_taxonomy_id = %d", $term ) ); 2570 2580 do_action( 'edit_term_taxonomy', $term, $taxonomy ); 2571 2581 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 2572 2582 do_action( 'edited_term_taxonomy', $term, $taxonomy );