Ticket #12706: 12706-1.diff
File 12706-1.diff, 81.0 KB (added by , 12 years ago) |
---|
-
wp-admin/edit-form-advanced.php
diff --git wp-admin/edit-form-advanced.php wp-admin/edit-form-advanced.php index c22c68a..47a652d 100644
$messages['post'] = array( 45 45 // translators: Publish box date format, see http://php.net/date 46 46 date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), 47 47 10 => sprintf( __('Post draft updated. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 48 11 => sprintf( __('Post moderated. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 48 49 ); 49 50 $messages['page'] = array( 50 51 0 => '', // Unused. Messages start at index 1. … … $messages['page'] = array( 58 59 8 => sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 59 60 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) ) ), 60 61 10 => sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 62 11 => sprintf( __('Page moderated. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 61 63 ); 62 64 63 65 $messages = apply_filters( 'post_updated_messages', $messages ); … … do_action('dbx_post_advanced'); 140 142 if ( post_type_supports($post_type, 'comments') ) 141 143 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', null, 'normal', 'core'); 142 144 143 if ( ('publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') ) 145 if ( ! $post_status_object = get_post_status_object( $post->post_status ) ) 146 $post_status_object = get_post_status_object( 'draft' ); 147 148 if ( ( $post_status_object->public || $post_status_object->private ) && post_type_supports($post_type, 'comments') ) 144 149 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core'); 145 150 146 if ( ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) )151 if ( ! ( $post_status_object->moderation && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) 147 152 add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core'); 148 153 149 154 if ( post_type_supports($post_type, 'author') ) { … … $shortlink = wp_get_shortlink($post->ID, 'post'); 292 297 if ( !empty($shortlink) ) 293 298 $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>'; 294 299 295 if ( $post_type_object->public && ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>300 if ( $post_type_object->public && ! ( $post_status_object->moderation && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?> 296 301 <div id="edit-slug-box"> 297 302 <?php 298 303 if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status ) … … if ( post_type_supports( $post_type, 'comments' ) ) 383 388 try{document.post.title.focus();}catch(e){} 384 389 </script> 385 390 <?php endif; ?> 391 392 393 <?php 394 add_action( 'admin_print_footer_scripts', create_function('', "_edit_form_advanced_scripts('$post_type');") ); 395 396 function _edit_form_advanced_scripts( $post_type ) { 397 ?> 398 399 <script type="text/javascript"> 400 //<![CDATA[ 401 jQuery(document).ready( function($) { 402 function updateStatusCaptions() { 403 postStatus = $('#post_status'); 404 405 $('#post-status-display').html($('option:selected', postStatus).text()); 406 407 switch( $('option:selected', postStatus).val() ) { 408 409 <?php foreach( get_post_stati( array( 'public' => true, 'private' => true ), 'object', 'or' ) as $_status => $_status_obj ): ?> 410 case '<?php echo $_status ?>': 411 $('#save-post').hide(); 412 break; 413 <?php endforeach; ?> 414 415 <?php foreach( get_post_stati( array( 'moderation' => true, 'internal' => false, 'object_type' => $post_type ), 'object' ) as $_status => $_status_obj ): ?> 416 case '<?php echo $_status ?>': 417 $('#save-post').show().val( '<?php echo $_status_obj->labels->save_as ?>' ); 418 break; 419 <?php endforeach; ?> 420 421 default : 422 <?php $draft_status_obj = get_post_status_object( 'draft' ); ?> 423 $('#save-post').show().val( '<?php echo $draft_status_obj->labels->save_as ?>' ); 424 } 425 } 426 427 $('input:radio', '#post-visibility-select').change(function() { 428 switch ( $('input:radio:checked', '#post-visibility-select').val() ) { 429 case 'public': 430 $('#sticky-span').show(); 431 break; 432 433 <?php foreach( get_post_stati( array( 'public' => true, 'object_type' => $post_type ) ) as $_status ) : ?> 434 case '<?php echo $_status ?>': 435 $('#sticky-span').show(); 436 break; 437 <?php endforeach; ?> 438 439 default : 440 $('#sticky').attr('checked', false); 441 $('#sticky-span').hide(); 442 } 443 }); 444 445 function updateVisibilityCaptions() { 446 var postStatus = $('#post_status'), optPublish = $('option[value=publish]', postStatus); 447 448 switch( $('input:radio:checked', '#post-visibility-select').val() ) { 449 450 <?php foreach( get_post_stati( array( 'internal' => false, 'object_type' => $post_type ), 'object' ) as $_status => $_status_obj ) : 451 if ( ( 'publish' == $_status ) || ( ! $_status_obj->private && ! $_status_obj->public ) ) 452 continue; 453 ?> 454 case '<?php echo $_status ?>': 455 $('#publish').val( postL10n.update ); 456 457 if ( optPublish.length == 0 ) { 458 postStatus.append('<option value="publish">' + '<?php echo $_status_obj->labels->caption ?>' + '</option>'); 459 } else { 460 optPublish.html( '<?php echo $_status_obj->labels->caption ?>' ); 461 } 462 463 $('option[value=publish]', postStatus).attr('selected', true); 464 $('.edit-post-status', '#misc-publishing-actions').hide(); 465 466 break; 467 <?php endforeach; ?> 468 469 default: 470 if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { 471 if ( optPublish.length ) { 472 optPublish.remove(); 473 postStatus.val($('#hidden_post_status').val()); 474 } 475 } else { 476 optPublish.html( postL10n.published ); 477 } 478 if ( postStatus.is(':hidden') ) 479 $('.edit-post-status', '#misc-publishing-actions').show(); 480 } 481 482 return true; 483 } 484 485 $('.save-post-status', '#post-status-select').click(function() { 486 updateStatusCaptions(); 487 return false; 488 }); 489 490 $('.cancel-post-visibility', '#post-visibility-select').click(function () { 491 updateVisibilityCaptions(); 492 return false; 493 }); 494 495 $('.save-post-visibility', '#post-visibility-select').click(function () { // crazyhorse - multiple ok cancels 496 updateVisibilityCaptions(); 497 updateStatusCaptions(); 498 return false; 499 }); 500 }); 501 //]]> 502 </script> 503 504 <?php 505 } // end function edit_form_advanced_scripts 506 ?> 507 No newline at end of file -
wp-admin/includes/ajax-actions.php
diff --git wp-admin/includes/ajax-actions.php wp-admin/includes/ajax-actions.php index 5ced901..4fc7541 100644
function wp_ajax_replyto_comment( $action ) { 730 730 wp_die( -1 ); 731 731 732 732 $status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) ); 733 $post_status_obj = get_post_status_object($status); 733 734 734 if ( empty($ status) )735 if ( empty($post_status_obj) ) 735 736 wp_die( 1 ); 736 elseif ( in_array($status, array('draft', 'pending', 'trash') ))737 elseif ( ! $post_status_obj->public && ! $post_status_obj->private ) 737 738 wp_die( __('ERROR: you are replying to a comment on a draft post.') ); 738 739 739 740 $user = wp_get_current_user(); … … function wp_ajax_inline_save() { 1351 1352 if ( isset($data['post_parent']) ) 1352 1353 $data['parent_id'] = $data['post_parent']; 1353 1354 1355 $post_type_object = get_post_type_object( $post['post_type'] ); 1356 1354 1357 // status 1355 if ( isset($data['keep_private']) && 'private' == $data['keep_private'] ) 1356 $data['post_status'] = 'private'; 1357 else 1358 foreach( get_post_stati( array( 'internal' => false, 'object_type' => $post['post_type'] ), 'object' ) as $_status => $_status_obj ) { 1359 if ( ( 'publish' == $_status ) || ( ! $_status_obj->private && ! $_status_obj->public ) ) // private and custom public stati only here 1360 continue; 1361 1362 if ( isset($data["keep_{$_status}"]) ) { 1363 $set_status_cap = "set_{$_status}_posts"; 1364 $check_cap = ( ! empty( $post_type_object->cap->$set_status_cap ) ) ? $post_type_object->cap->$set_status_cap : $post_type_object->cap->publish_posts; 1365 1366 if ( current_user_can( $check_cap ) ) { 1367 $data['post_status'] = $_status; 1368 $keeping_private = true; 1369 break; 1370 } 1371 } 1372 } 1373 1374 if ( empty($keeping_private) ) // private or custom public status selected and granted 1358 1375 $data['post_status'] = $data['_status']; 1359 1376 1360 1377 if ( empty($data['comment_status']) ) … … function wp_ajax_find_posts() { 1442 1459 if ( count($search_terms) > 1 && $search_terms[0] != $s ) 1443 1460 $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')"; 1444 1461 1445 $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" ); 1462 $public_stati = apply_filters( 'find_posts_stati', get_post_stati( array( 'public' => true ) ) ); 1463 $public_csv = implode( "', '", $public_stati ); 1464 1465 $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" ); 1446 1466 1447 1467 if ( ! $posts ) { 1448 1468 $posttype = get_post_type_object($what); 1449 1469 wp_die( $posttype->labels->not_found ); 1450 1470 } 1471 1472 $stat = array(); 1451 1473 1452 1474 $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>'; 1453 1475 foreach ( $posts as $post ) { 1454 1476 1455 switch ( $post->post_status ) { 1456 case 'publish' : 1457 case 'private' : 1458 $stat = __('Published'); 1459 break; 1460 case 'future' : 1461 $stat = __('Scheduled'); 1462 break; 1463 case 'pending' : 1464 $stat = __('Pending Review'); 1465 break; 1466 case 'draft' : 1467 $stat = __('Draft'); 1468 break; 1477 if ( ! isset( $stat[$post->post_status] ) ) { 1478 $_status_obj = get_post_status_object( $post->post_status ); 1479 1480 if ( ! $_status_obj ) 1481 $_status_obj = get_post_status_object( 'draft' ); 1482 elseif ( ( $_status_obj->public || $_status_obj->private ) && ( 'publish' != $post->post_status ) ) 1483 $_status_obj = get_post_status_object( 'publish' ); 1484 1485 $stat[$post->post_status] = $_status_obj->labels->caption; 1469 1486 } 1470 1487 1471 1488 if ( '0000-00-00 00:00:00' == $post->post_date ) { … … function wp_ajax_find_posts() { 1476 1493 } 1477 1494 1478 1495 $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>'; 1479 $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";1496 $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"; 1480 1497 } 1481 1498 $html .= '</tbody></table>'; 1482 1499 -
wp-admin/includes/meta-boxes.php
diff --git wp-admin/includes/meta-boxes.php wp-admin/includes/meta-boxes.php index 7dc4552..c8ec50d 100644
10 10 * @param object $post 11 11 */ 12 12 function post_submit_meta_box($post) { 13 global $action; 14 13 global $action; 14 15 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); 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' ); 24 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 … … function post_submit_meta_box($post) { 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 43 //if ( 'publish' != $post_status && 'future' != $post_status && 'pending' != $post_status ) { 44 if ( ! $post_status_obj->public && ! $post_status_obj->private && ! $post_status_obj->moderation && ( 'future' != $post_status ) ) { 45 // TODO: confirm we don't need a hidden save button when current status is private 46 $draft_status_obj = get_post_status_object( 'draft' ); 47 ?> 48 <input type="submit" name="save" id="save-post" value="<?php echo $draft_status_obj->labels->save_as ?>" tabindex="4" class="button button-highlighted" /> 49 <?php 50 } elseif ( $post_status_obj->moderation && $can_publish ) { 51 ?> 52 <input type="submit" name="save" id="save-post" value="<?php echo $post_status_obj->labels->save_as ?>" tabindex="4" class="button button-highlighted" /> 34 53 <?php } ?> 35 54 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="draft-ajax-loading" alt="" /> 36 55 </div> 37 <?php if ( $post_type_obj ect->public ) : ?>56 <?php if ( $post_type_obj->public ) : ?> 38 57 <div id="preview-action"> 39 58 <?php 40 if ( 'publish' == $post->post_status) {59 if ( $post_status_obj->public ) { 41 60 $preview_link = esc_url( get_permalink( $post->ID ) ); 42 61 $preview_button = __( 'Preview Changes' ); 43 62 } else { … … if ( 'publish' == $post->post_status ) { 59 78 60 79 <div class="misc-pub-section"><label for="post_status"><?php _e('Status:') ?></label> 61 80 <span id="post-status-display"> 62 <?php 63 switch ( $post->post_status ) { 64 case 'private': 65 _e('Privately Published'); 66 break; 67 case 'publish': 68 _e('Published'); 69 break; 70 case 'future': 71 _e('Scheduled'); 72 break; 73 case 'pending': 74 _e('Pending Review'); 75 break; 76 case 'draft': 77 case 'auto-draft': 78 _e('Draft'); 79 break; 80 } 81 ?> 81 <?php echo $post_status_obj->labels->caption; ?> 82 82 </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> 83 <?php 84 $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 86 if ( $post_status_obj->public || $post_status_obj->private || $can_publish || $select_moderation ) { ?> 87 <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 88 86 89 <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); ?>" />90 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post_status ) ? 'draft' : $post_status); ?>" /> 88 91 <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> 95 <?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> 92 93 <?php if ( $post_status_obj->public || $post_status_obj->private || ( 'future' == $post_status ) ) : ?> 94 <option<?php selected( $post_status, $post_status ); ?> value='publish'><?php echo $post_status_obj->labels->caption ?></option> 101 95 <?php endif; ?> 96 97 <?php 98 foreach( $moderation_stati as $_status => $_status_obj ) : ?> 99 <option<?php selected( $post_status, $_status ); ?> value='<?php echo $_status ?>'><?php echo $_status_obj->labels->caption ?></option> 100 <?php endforeach ?> 101 102 <?php 103 $draft_status_obj = get_post_status_object( 'draft' ); 104 $compare_status = ( 'auto-draft' == $post_status ) ? 'auto-draft' : 'draft'; 105 ?> 106 <option<?php selected( $post_status, $compare_status ); ?> value='draft'><?php echo $draft_status_obj->label ?></option> 107 102 108 </select> 103 109 <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a> 104 110 <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a> … … switch ( $post->post_status ) { 110 116 <div class="misc-pub-section" id="visibility"> 111 117 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php 112 118 113 if ( 'private' == $post->post_status ) { 119 if ( 'future' == $post_status ) { // indicate eventual visibility of scheduled post 120 if ( ! $vis_status = get_post_meta( $post->ID, '_scheduled_status', true ) ) 121 $vis_status = 'publish'; 122 123 $vis_status_obj = get_post_status_object( $vis_status ); 124 } else { 125 $vis_status = $post_status; 126 $vis_status_obj = $post_status_obj; 127 } 128 129 if ( 'publish' == $vis_status ) { 130 $post->post_password = ''; 131 $visibility = 'public'; 132 133 if ( post_type_supports( $post->post_type, 'sticky' ) && is_sticky( $post->ID ) ) { 134 $visibility_trans = __('Public, Sticky'); 135 } else { 136 $visibility_trans = __('Public'); 137 } 138 } elseif ( $vis_status_obj->public ) { 139 $post->post_password = ''; 140 $visibility = $vis_status; 141 142 if ( post_type_supports( $post->post_type, 'sticky' ) && is_sticky( $post->ID ) ) { 143 $visibility_trans = sprintf( __('%s, Sticky'), $vis_status_obj->label ); 144 } else { 145 $visibility_trans = $vis_status_obj->labels->visibility; 146 } 147 } elseif ( $vis_status_obj->private ) { 114 148 $post->post_password = ''; 115 $visibility = 'private'; 116 $visibility_trans = __('Private'); 149 $visibility_trans = $vis_status_obj->labels->visibility; 117 150 } elseif ( !empty( $post->post_password ) ) { 118 151 $visibility = 'password'; 119 152 $visibility_trans = __('Password protected'); … … echo esc_html( $visibility_trans ); ?></span> 135 168 <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> /> 136 169 <?php endif; ?> 137 170 <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" /> 171 138 172 <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 /> 173 174 <?php 175 foreach( get_post_stati( array( 'public' => true, 'object_type' => $post_type ), 'object' ) as $_status => $_status_obj ) : 176 if ( 'publish' == $_status ) 177 continue; 178 179 $post_cap = "set_{$_status}_posts"; 180 if ( empty( $post_type_obj->cap->$post_cap ) || current_user_can( $post_type_obj->cap->$post_cap ) ) { 181 ?> 182 <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 /> 183 <?php 184 } // end if this user can set status 185 endforeach ?> 186 139 187 <?php if ( $post_type == 'post' && current_user_can( 'edit_others_posts' ) ) : ?> 140 188 <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 post to the front page' ); ?></label><br /></span> 141 189 <?php endif; ?> 190 142 191 <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 /> 143 192 <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> 144 <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 />145 193 194 <?php 195 foreach( get_post_stati( array( 'private' => true, 'object_type' => $post_type ), 'object' ) as $_status => $_status_obj ) : 196 $post_cap = "set_{$_status}_posts"; 197 if ( empty( $post_type_obj->cap->$post_cap ) || current_user_can( $post_type_obj->cap->$post_cap ) ) { 198 ?> 199 <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 /> 200 <?php 201 } // end if this user can set status 202 endforeach ?> 146 203 <p> 147 204 <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a> 148 205 <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a> … … echo esc_html( $visibility_trans ); ?></span> 155 212 <?php 156 213 // translators: Publish box date format, see http://php.net/date 157 214 $datef = __( 'M j, Y @ G:i' ); 215 216 $published_stati = get_post_stati( array( 'public' => true, 'private' => true ), 'names', 'or' ); 217 158 218 if ( 0 != $post->ID ) { 159 if ( 'future' == $post ->post_status ) { // scheduled for publishing at a future date219 if ( 'future' == $post_status ) { // scheduled for publishing at a future date 160 220 $stamp = __('Scheduled for: <b>%1$s</b>'); 161 } else if ( 'publish' == $post->post_status || 'private' == $post->post_status) { // already published221 } else if ( in_array( $post_status, $published_stati ) ) { // already published 162 222 $stamp = __('Published on: <b>%1$s</b>'); 163 223 } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified 164 224 $stamp = __('Publish <b>immediately</b>'); … … if ( current_user_can( "delete_post", $post->ID ) ) { 204 264 <div id="publishing-action"> 205 265 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="ajax-loading" alt="" /> 206 266 <?php 207 if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID) {267 if ( ( ! $post_status_obj->public && ! $post_status_obj->private && ( 'future' != $post_status ) ) ) { 208 268 if ( $can_publish ) : 209 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> 210 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" /> 211 <?php submit_button( __( 'Schedule' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?> 212 <?php else : ?> 213 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" /> 214 <?php submit_button( __( 'Publish' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?> 269 270 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : 271 $future_status_obj = get_post_status_object( 'future' ); 272 ?> 273 <input name="original_publish" type="hidden" id="original_publish" value="<?php echo $future_status_obj->labels->publish ?>" /> 274 <?php submit_button( $future_status_obj->labels->publish, 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?> 275 <?php else : 276 $publish_status_obj = get_post_status_object( 'publish' ); 277 ?> 278 <input name="original_publish" type="hidden" id="original_publish" value="<?php echo $publish_status_obj->labels->publish ?>" /> 279 <?php submit_button( $publish_status_obj->labels->publish, 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?> 215 280 <?php endif; 216 281 else : ?> 217 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" /> 218 <?php submit_button( __( 'Submit for Review' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?> 282 <?php 283 $moderation_button_status = apply_filters( 'post_moderation_status', 'pending', $post->ID ); 284 285 $status_obj = get_post_status_object( $moderation_button_status ); 286 $cap_name = "set_{$moderation_button_status}_posts"; 287 288 if ( ! $status_obj || ( ! empty($post_type_obj->cap->$cap_name) && ! current_user_can($post_type_obj->cap->$cap_name) ) ) 289 $status_obj = get_post_status_object( 'pending' ); 290 ?> 291 <input name="original_publish" type="hidden" id="original_publish" value="<?php echo $status_obj->labels->publish ?>" /> 292 <?php submit_button( $status_obj->labels->publish, 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?> 219 293 <?php 220 294 endif; 221 295 } else { ?> -
wp-admin/includes/nav-menu.php
diff --git wp-admin/includes/nav-menu.php wp-admin/includes/nav-menu.php index 5fc73fc..1780b07 100644
function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) { 1039 1039 */ 1040 1040 function _wp_nav_menu_meta_box_object( $object = null ) { 1041 1041 if ( isset( $object->name ) ) { 1042 $public_stati = apply_filters( 'nav_menu_metabox_stati', get_post_stati( array( 'public' => true, 'object_type' => $object->name ) ), $object ); 1043 $public_csv = implode( ',', $public_stati ); 1042 1044 1043 1045 if ( 'page' == $object->name ) { 1044 1046 $object->_default_query = array( 1045 1047 'orderby' => 'menu_order title', 1046 'post_status' => 'publish',1048 'post_status' => $public_csv, 1047 1049 ); 1048 1050 1049 // posts should show only publi sheditems1051 // posts should show only public items 1050 1052 } elseif ( 'post' == $object->name ) { 1051 1053 $object->_default_query = array( 1052 'post_status' => 'publish',1054 'post_status' => $public_csv, 1053 1055 ); 1054 1056 1055 1057 // cats should be in reverse chronological order … … function _wp_nav_menu_meta_box_object( $object = null ) { 1059 1061 'order' => 'DESC', 1060 1062 ); 1061 1063 1062 // custom post types should show only publi sheditems1064 // custom post types should show only public items 1063 1065 } else { 1064 1066 $object->_default_query = array( 1065 'post_status' => 'publish',1067 'post_status' => $public_csv, 1066 1068 ); 1067 1069 } 1068 1070 } -
wp-admin/includes/post.php
diff --git wp-admin/includes/post.php wp-admin/includes/post.php index 3bfea57..3762889 100644
function _wp_translate_postdata( $update = false, $post_data = null ) { 71 71 // What to do based on which button they pressed 72 72 if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) 73 73 $post_data['post_status'] = 'draft'; 74 if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) 74 if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) // TODO: is this set anywhere? 75 75 $post_data['post_status'] = 'private'; 76 76 if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) 77 77 $post_data['post_status'] = 'publish'; … … function _wp_translate_postdata( $update = false, $post_data = null ) { 88 88 89 89 // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published. 90 90 // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. 91 if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->cap->publish_posts )) ) 92 if ( $previous_status != 'publish' || !current_user_can( 'edit_post', $post_id ) ) 93 $post_data['post_status'] = 'pending'; 91 if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->cap->publish_posts )) ) { 92 if ( $previous_status != 'publish' || !current_user_can( 'edit_post', $post_id ) ) { 93 $moderation_status = apply_filters( 'post_moderation_status', 'pending', $post->ID ); 94 95 $_status_obj = get_post_status_object( $moderation_status ); 96 $cap_name = "set_{$moderation_status}_posts"; 97 98 if ( empty($_status_obj) || ! $_status_obj->moderation || ( ! empty($ptype->cap->$cap_name) && ! current_user_can($ptype->cap->$cap_name) ) ) 99 $moderation_status = 'pending'; 100 101 $post_data['post_status'] = $moderation_status; 102 } 103 } 94 104 95 105 if ( ! isset($post_data['post_status']) ) 96 106 $post_data['post_status'] = $previous_status; … … function edit_post( $post_data = null ) { 182 192 case 'password' : 183 193 unset( $post_data['sticky'] ); 184 194 break; 185 case 'private' : 186 $post_data['post_status'] = 'private'; 187 $post_data['post_password'] = ''; 188 unset( $post_data['sticky'] ); 189 break; 195 default: 196 $status_obj = get_post_status_object( $post_data['visibility'] ); 197 198 if ( ! empty( $status_obj->private ) || ! empty( $status_obj->public ) ) { 199 $post_data['post_status'] = $status_obj->name; 200 $post_data['post_password'] = ''; 201 } 202 203 if ( ! empty( $status_obj->private ) ) { 204 unset( $post_data['sticky'] ); 205 } 190 206 } 191 207 } 192 208 … … function wp_write_post() { 564 580 case 'password' : 565 581 unset( $_POST['sticky'] ); 566 582 break; 567 case 'private' : 568 $_POST['post_status'] = 'private'; 569 $_POST['post_password'] = ''; 570 unset( $_POST['sticky'] ); 571 break; 583 default: 584 $status_obj = get_post_status_object( $_POST['visibility'] ); 585 if ( ! empty( $status_obj->private ) ) { 586 $_POST['post_status'] = $status_obj->name; 587 $_POST['post_password'] = ''; 588 unset( $_POST['sticky'] ); 589 } 572 590 } 573 591 } 574 592 … … function wp_edit_posts_query( $q = false ) { 849 867 else 850 868 $post_type = 'post'; 851 869 852 $avail_post_stati = get_available_post_statuses( $post_type);870 $avail_post_stati = get_available_post_statuses( $post_type ); 853 871 854 872 if ( isset($q['post_status']) && in_array( $q['post_status'], $post_stati ) ) { 855 873 $post_status = $q['post_status']; … … function wp_edit_posts_query( $q = false ) { 858 876 859 877 if ( isset($q['orderby']) ) 860 878 $orderby = $q['orderby']; 861 elseif ( isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')) )879 elseif ( isset($q['post_status']) && ( in_array($q['post_status'], array('pending', 'draft')) || ! empty( $GLOBALS['wp_post_statuses'][$q['post_status']]->moderation ) ) ) 862 880 $orderby = 'modified'; 863 881 864 882 if ( isset($q['order']) ) … … function get_sample_permalink($id, $title = null, $name = null) { 1020 1038 $original_date = $post->post_date; 1021 1039 $original_name = $post->post_name; 1022 1040 1041 $post_status_obj = get_post_status_object( $post->post_status ); 1042 1023 1043 // Hack: get_permalink would return ugly permalink for 1024 1044 // drafts, so we will fake, that our post is published 1025 if ( in_array($post->post_status, array('draft', 'pending')) ) {1045 if ( in_array($post->post_status, array('draft', 'pending')) || ! empty($post_status_obj->moderation) ) { 1026 1046 $post->post_status = 'publish'; 1027 1047 $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID); 1028 1048 } … … function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { 1080 1100 1081 1101 list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); 1082 1102 1083 if ( 'publish' == $post->post_status ) { 1103 $public_stati = get_post_stati( array( 'public' => true ) ); 1104 if ( in_array( $post->post_status, $public_stati ) ) { 1084 1105 $ptype = get_post_type_object($post->post_type); 1085 1106 $view_post = $ptype->labels->view_item; 1086 1107 $title = __('Click to edit this part of the permalink'); -
wp-admin/includes/template.php
diff --git wp-admin/includes/template.php wp-admin/includes/template.php index 3834874..c7fc1bf 100644
function get_inline_data($post) { 256 256 <div class="post_author">' . $post->post_author . '</div> 257 257 <div class="comment_status">' . esc_html( $post->comment_status ) . '</div> 258 258 <div class="ping_status">' . esc_html( $post->ping_status ) . '</div> 259 <div class="_status">' . esc_html( $post->post_status ) . '</div> 259 <div class="_status">' . esc_html( $post->post_status ) . '</div>'; 260 261 if ( 'future' == $post->post_status ) { 262 if ( ! $scheduled_status = get_post_meta( $post->ID, '_scheduled_status', true ) ) 263 $scheduled_status = 'publish'; 264 echo ' 265 <div class="scheduled_status">' . esc_html( $scheduled_status ). '</div>'; 266 } 267 268 echo ' 260 269 <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div> 261 270 <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div> 262 271 <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div> … … function meta_form() { 577 586 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { 578 587 global $wp_locale, $post, $comment; 579 588 580 if ( $for_post ) 581 $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); 582 589 if ( $for_post ) { 590 $post_status_obj = get_post_status_object($post->post_status); 591 $edit = ( ( 'draft' != $post->post_status ) && empty($post_status_obj->moderation) ) || ( $post->post_date_gmt && '0000-00-00 00:00:00' != $post->post_date_gmt ); 592 } 593 583 594 $tab_index_attribute = ''; 584 595 if ( (int) $tab_index > 0 ) 585 596 $tab_index_attribute = " tabindex=\"$tab_index\""; … … function _post_states($post) { 1469 1480 else 1470 1481 $post_status = ''; 1471 1482 1483 $post_status_obj = get_post_status_object($post->post_status); 1484 1472 1485 if ( !empty($post->post_password) ) 1473 1486 $post_states['protected'] = __('Password protected'); 1474 if ( 'private' == $post->post_status && 'private' != $post_status ) 1475 $post_states['private'] = __('Private'); 1476 if ( 'draft' == $post->post_status && 'draft' != $post_status ) 1477 $post_states['draft'] = __('Draft'); 1478 if ( 'pending' == $post->post_status && 'pending' != $post_status ) 1479 /* translators: post state */ 1480 $post_states['pending'] = _x('Pending', 'post state'); 1481 if ( is_sticky($post->ID) ) 1482 $post_states['sticky'] = __('Sticky'); 1487 1488 if ( $post_status_obj && ( 'publish' != $post->post_status ) ) { 1489 if ( $post->post_status != $post_status ) { 1490 $post_states[] = $post_status_obj->label; 1491 1492 if ( 'future' == $post->post_status ) { 1493 if ( $scheduled_status = get_post_meta( $post->ID, '_scheduled_status', true ) ) { 1494 if ( 'publish' != $scheduled_status ) { 1495 if ( $_scheduled_status_obj = get_post_status_object( $scheduled_status ) ) 1496 $post_states[] = $_scheduled_status_obj->label; 1497 } 1498 } 1499 } 1500 } 1501 } 1483 1502 1484 1503 $post_states = apply_filters( 'display_post_states', $post_states ); 1485 1504 -
wp-admin/js/inline-edit-post.dev.js
diff --git wp-admin/js/inline-edit-post.dev.js wp-admin/js/inline-edit-post.dev.js index 4b0eb2e..69f8586 100644
inlineEditPost = { 78 78 t.revert(); 79 79 $('select[name^="action"]').val('-1'); 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){ … … inlineEditPost = { 129 135 if ( typeof(id) == 'object' ) 130 136 id = t.getId(id); 131 137 132 fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password', 'post_format', 'menu_order']; 138 fields = ['post_title', 'post_name', 'post_author', '_status', 'scheduled_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password', 'post_format', 'menu_order']; 139 133 140 if ( t.type == 'page' ) 134 141 fields.push('post_parent', 'page_template'); 135 142 … … inlineEditPost = { 198 205 199 206 // handle the post status 200 207 status = $('._status', rowData).text(); 201 if ( 'future' != status ) 208 209 if ( 'future' == status ) { 210 status = $('.scheduled_status', rowData).text(); 211 } else { 202 212 $('select[name="_status"] option[value="future"]', editRow).remove(); 213 } 203 214 204 if ( 'private' == status) {205 $('input[name="keep_ private"]', editRow).prop("checked", true);206 $('input.inline-edit-password-input').val('').prop('disabled', true);215 if ( $('[name=keep_' + status + ']').length > 0) { 216 $('input[name="keep_' + status + '"]', editRow).prop("checked", "checked"); 217 $('input.inline-edit-password-input').val('').prop('disabled', 'disabled'); 207 218 } 208 219 209 220 // remove the current page and children from the parent dropdown -
wp-admin/js/post.dev.js
diff --git wp-admin/js/post.dev.js wp-admin/js/post.dev.js index 42cd217..ba12f63 100644
jQuery(document).ready( function($) { 382 382 } 383 383 384 384 function updateText() { 385 var attemptedDate, originalDate, currentDate, publishOn, postStatus = $('#post_status'),386 optPublish = $('option[value="publish"]', postStatus), aa = $('#aa').val(),385 var attemptedDate, originalDate, currentDate, publishOn, 386 postStatus = $('#post_status'), optPublish = $('option[value=publish]', postStatus), aa = $('#aa').val(), 387 387 mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(); 388 388 389 389 attemptedDate = new Date( aa, mm - 1, jj, hh, mn ); … … jQuery(document).ready( function($) { 407 407 publishOn = postL10n.publishOnPast; 408 408 $('#publish').val( postL10n.update ); 409 409 } 410 410 411 if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack 411 412 $('#timestamp').html(stamp); 412 413 } else { … … jQuery(document).ready( function($) { 421 422 } 422 423 423 424 if ( $('input:radio:checked', '#post-visibility-select').val() == 'private' ) { 425 424 426 $('#publish').val( postL10n.update ); 425 427 if ( optPublish.length == 0 ) { 426 428 postStatus.append('<option value="publish">' + postL10n.privatelyPublished + '</option>'); 427 429 } else { 428 430 optPublish.html( postL10n.privatelyPublished ); 429 431 } 432 430 433 $('option[value="publish"]', postStatus).prop('selected', true); 434 431 435 $('.edit-post-status', '#misc-publishing-actions').hide(); 432 436 } else { 433 437 if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { … … jQuery(document).ready( function($) { 441 445 if ( postStatus.is(':hidden') ) 442 446 $('.edit-post-status', '#misc-publishing-actions').show(); 443 447 } 444 $('#post-status-display').html($('option:selected', postStatus).text()); 445 if ( $('option:selected', postStatus).val() == 'private' || $('option:selected', postStatus).val() == 'publish' ) { 446 $('#save-post').hide(); 447 } else { 448 $('#save-post').show(); 449 if ( $('option:selected', postStatus).val() == 'pending' ) { 450 $('#save-post').show().val( postL10n.savePending ); 451 } else { 452 $('#save-post').show().val( postL10n.saveDraft ); 453 } 454 } 448 455 449 return true; 456 450 } 457 451 … … jQuery(document).ready( function($) { 463 457 } 464 458 return false; 465 459 }); 466 460 467 461 $('.cancel-post-visibility', '#post-visibility-select').click(function () { 468 462 $('#post-visibility-select').slideUp('fast'); 469 463 $('#visibility-radio-' + $('#hidden-post-visibility').val()).prop('checked', true); … … jQuery(document).ready( function($) { 471 465 $('#sticky').prop('checked', $('#hidden-post-sticky').prop('checked')); 472 466 $('#post-visibility-display').html(visibility); 473 467 $('.edit-visibility', '#visibility').show(); 474 updateText();475 468 return false; 476 469 }); 477 470 478 471 $('.save-post-visibility', '#post-visibility-select').click(function () { // crazyhorse - multiple ok cancels 479 472 var pvSelect = $('#post-visibility-select'); 480 473 481 474 pvSelect.slideUp('fast'); 482 475 $('.edit-visibility', '#visibility').show(); 483 updateText(); 476 484 477 485 478 if ( $('input:radio:checked', pvSelect).val() != 'public' ) { 486 479 $('#sticky').prop('checked', false); … … jQuery(document).ready( function($) { 491 484 } else { 492 485 sticky = ''; 493 486 } 494 487 495 488 $('#post-visibility-display').html( postL10n[$('input:radio:checked', pvSelect).val() + sticky] ); 496 489 return false; 497 490 }); 498 491 499 492 $('input:radio', '#post-visibility-select').change(function() { 500 493 updateVisibility(); 501 494 }); -
wp-admin/post.php
diff --git wp-admin/post.php wp-admin/post.php index 035a185..85f6924 100644
function redirect_post($post_id = '') { 51 51 $message = 9; 52 52 break; 53 53 default: 54 $message = 6; 54 $status_obj = get_post_status_object( $status ); 55 if ( ! empty($status_obj->moderation) ) 56 $message = 11; 57 else 58 $message = 6; 55 59 } 56 60 } else { 57 61 $message = 'draft' == $status ? 10 : 1; -
wp-comments-post.php
diff --git wp-comments-post.php wp-comments-post.php index 194e00f..a71686b 100644
if ( !comments_open($comment_post_ID) ) { 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
diff --git wp-includes/default-widgets.php wp-includes/default-widgets.php index e4856da..85e4b2a 100644
class WP_Widget_Recent_Posts extends WP_Widget { 562 562 if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) 563 563 $number = 10; 564 564 565 $public_stati = apply_filters( 'recent_posts_stati', get_post_stati( array( 'public' => true ) ) ); 566 $status_arg = implode( ',', $public_stati ); 567 565 568 $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); 566 569 if ($r->have_posts()) : 567 570 ?> -
wp-includes/general-template.php
diff --git wp-includes/general-template.php wp-includes/general-template.php index 1972696..297ec99 100644
function wp_get_archives($args = '') { 915 915 } 916 916 917 917 //filters 918 $where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r ); 919 $join = apply_filters( 'getarchives_join', '', $r ); 918 $public_stati = apply_filters( 'getarchives_stati', get_post_stati( array( 'public' => true ) ) ); 919 $public_csv = implode( "', '", $public_stati ); 920 921 $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status IN ('" . $public_csv . "')", $r ); 922 $join = apply_filters('getarchives_join', "", $r); 920 923 921 924 $output = ''; 922 925 -
wp-includes/link-template.php
diff --git wp-includes/link-template.php wp-includes/link-template.php index ae8a9f1..17c59dd 100644
function get_permalink($id = 0, $leavename = false) { 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 = ''; … … function get_post_permalink( $id = 0, $leavename = false, $sample = false ) { 185 185 186 186 $slug = $post->post_name; 187 187 188 $draft_or_pending = isset($post->post_status) && in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) ;188 $draft_or_pending = isset($post->post_status) && in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ! empty( $GLOBALS['wp_post_statuses'][$post->post_status]->moderation ); 189 189 190 190 $post_type = get_post_type_object($post->post_type); 191 191 … … function _get_page_link( $id = false, $leavename = false, $sample = false ) { 275 275 276 276 $link = $wp_rewrite->get_page_permastruct(); 277 277 278 if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample )) {278 if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) && empty( $GLOBALS['wp_post_statuses'][$post->post_status]->moderation ) ) || $sample ) { 279 279 if ( ! $leavename ) { 280 280 $link = str_replace('%pagename%', get_page_uri($id), $link); 281 281 } -
wp-includes/load.php
diff --git wp-includes/load.php wp-includes/load.php index 94e6339..9d51e86 100644
function wp_get_active_and_valid_plugins() { 491 491 492 492 $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; 493 493 494 foreach ( $active_plugins as $plugin ) { 494 foreach ( $active_plugins as $plugin ) { 495 495 if ( ! validate_file( $plugin ) // $plugin must validate as file 496 496 && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' 497 497 && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist … … function wp_get_active_and_valid_plugins() { 499 499 && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) ) 500 500 ) 501 501 $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; 502 } 502 } 503 503 return $plugins; 504 504 } 505 505 -
wp-includes/nav-menu.php
diff --git wp-includes/nav-menu.php wp-includes/nav-menu.php index 361a8de..2cddd01 100644
function wp_get_nav_menu_items( $menu, $args = array() ) { 482 482 if ( empty( $items ) ) 483 483 return $items; 484 484 485 $public_stati = apply_filters( 'nav_menu_stati', get_post_stati( array( 'public' => true ) ), $menu ); 486 $public_csv = implode( ',', $public_stati ); 487 485 488 $defaults = array( 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 486 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true,489 'post_status' => $public_csv, 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true, 487 490 'update_post_term_cache' => false ); 488 491 $args = wp_parse_args( $args, $defaults ); 489 492 if ( count( $items ) > 1 ) -
wp-includes/post-template.php
diff --git wp-includes/post-template.php wp-includes/post-template.php index 5a414ea..716790f 100644
function get_the_title( $id = 0 ) { 107 107 $id = isset($post->ID) ? $post->ID : (int) $id; 108 108 109 109 if ( !is_admin() ) { 110 if ( ! empty($post->post_password) ) {111 $protected_title_format = apply_filters( 'protected_title_format', __('Protected: %s'));110 if ( ! empty($post->post_password) ) { 111 $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) ); 112 112 $title = sprintf($protected_title_format, $title); 113 } else if ( isset($post->post_status) && 'private' == $post->post_status ) { 114 $private_title_format = apply_filters('private_title_format', __('Private: %s')); 115 $title = sprintf($private_title_format, $title); 113 } elseif ( isset($post->post_status) ) { 114 $post_status_obj = get_post_status_object( $post->post_status ); 115 if ( $post_status_obj && $post_status_obj->private ) { 116 if ( 'private' == $post->post_status ) { 117 $format_string = __( 'Private: %s' ); // preserve existing translation string 118 $private_title_format = apply_filters( 'private_title_format', $format_string ); 119 $title = sprintf( $private_title_format, $title ); 120 } else { 121 $format_string = _x( '%1$s: %2$s', 'post status: title' ); 122 $private_title_format = apply_filters( 'post_title_format', $format_string, $_status ); 123 $title = sprintf( $private_title_format, $post_status_obj->labels->name, $title ); 124 } 125 } 116 126 } 117 127 } 118 128 return apply_filters( 'the_title', $title, $id ); … … function _wp_link_page( $i ) { 697 707 if ( 1 == $i ) { 698 708 $url = get_permalink(); 699 709 } else { 700 if ( '' == get_option('permalink_structure') || in_array( $post->post_status, array('draft', 'pending')))710 if ( '' == get_option('permalink_structure') || in_array( $post->post_status, array('draft', 'auto-draft', 'pending') ) || ! empty( $GLOBALS['wp_post_statuses'][$post->post_status]->moderation ) ) 701 711 $url = add_query_arg( 'page', $i, get_permalink() ); 702 712 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID ) 703 713 $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged'); -
wp-includes/post.php
diff --git wp-includes/post.php wp-includes/post.php index dee484e..392cbec 100644
function create_initial_post_types() { 101 101 ) ); 102 102 103 103 register_post_status( 'publish', array( 104 'label' => _x( 'Published', 'post' ), 104 'labels' => array( 105 'name' => _x( 'Published', 'post' ), 106 'publish' => esc_attr__('Publish'), 107 'count' => _n_noop( 'Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>' ), 108 ), 105 109 'public' => true, 106 110 '_builtin' => true, /* internal use only. */ 107 'label_count' => _n_noop( 'Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>' ),108 111 ) ); 109 112 110 113 register_post_status( 'future', array( 111 'label' => _x( 'Scheduled', 'post' ), 114 'labels' => array( 115 'name' => _x( 'Scheduled', 'post' ), 116 'publish' => esc_attr__('Schedule'), 117 'count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>' ), 118 ), 112 119 'protected' => true, 113 120 '_builtin' => true, /* internal use only. */ 114 'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>' ),115 121 ) ); 116 122 117 123 register_post_status( 'draft', array( 118 'label' => _x( 'Draft', 'post' ), 124 'labels' => array( 125 'name' => _x( 'Draft', 'post' ), 126 'save_as' => esc_attr__('Save Draft'), 127 'count' => _n_noop( 'Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>' ), 128 ), 119 129 'protected' => true, 120 130 '_builtin' => true, /* internal use only. */ 121 'label_count' => _n_noop( 'Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>' ),122 131 ) ); 123 132 124 133 register_post_status( 'pending', array( 125 'label' => _x( 'Pending', 'post' ), 134 'labels' => array( 135 'name' => _x( 'Pending', 'post' ), 136 'caption' => __( 'Pending Review' ), 137 'publish' => esc_attr__('Submit for Review'), 138 'count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ), 139 ), 126 140 'protected' => true, 127 141 '_builtin' => true, /* internal use only. */ 128 ' label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ),142 'moderation' => true, 129 143 ) ); 130 144 131 145 register_post_status( 'private', array( 132 'label' => _x( 'Private', 'post' ), 146 'labels' => array( 147 'name' => _x( 'Private', 'post' ), 148 'caption' => __( 'Privately Published' ), 149 'count' => _n_noop( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>' ), 150 ), 133 151 'private' => true, 134 152 '_builtin' => true, /* internal use only. */ 135 'label_count' => _n_noop( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>' ),136 153 ) ); 137 154 138 155 register_post_status( 'trash', array( 139 'label' => _x( 'Trash', 'post' ), 156 'labels' => array( 157 'name' => _x( 'Trash', 'post' ), 158 'count' => _n_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>' ), 159 ), 140 160 'internal' => true, 141 161 '_builtin' => true, /* internal use only. */ 142 'label_count' => _n_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>' ),143 162 'show_in_admin_status_list' => true, 144 163 ) ); 145 164 146 165 register_post_status( 'auto-draft', array( 147 'label' => 'auto-draft', 166 'labels' => array( 167 'name' => 'auto-draft', 168 'caption' => __( 'Draft' ), 169 ), 148 170 'internal' => true, 149 171 '_builtin' => true, /* internal use only. */ 172 'a' => false, 173 'show_in_admin_status_list' => false, 150 174 ) ); 151 175 152 176 register_post_status( 'inherit', array( 153 'label' => 'inherit', 177 'labels' => array( 178 'name' => 'inherit', 179 ), 154 180 'internal' => true, 155 181 '_builtin' => true, /* internal use only. */ 156 182 'exclude_from_search' => false, … … function register_post_status($post_status, $args = array()) { 671 697 $wp_post_statuses = array(); 672 698 673 699 // Args prefixed with an underscore are reserved for internal use. 674 $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); 700 $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, 'publicly_queryable' => null, 'show_in_admin_status_list' => null, 'show_in_admin_all_list' => null, 'single_view_cap' => null); 701 675 702 $args = wp_parse_args($args, $defaults); 676 703 $args = (object) $args; 677 704 678 705 $post_status = sanitize_key($post_status); 679 706 $args->name = $post_status; 680 707 708 if ( null == $args->object_type ) { 709 $args->object_type = array_values( get_post_types( array( 'public' => true, 'show_ui' => true ) ) ); 710 } else { 711 $args->object_type = (array) $args->object_type; 712 } 713 681 714 if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private ) 682 715 $args->internal = true; 683 716 … … function register_post_status($post_status, $args = array()) { 687 720 if ( null === $args->private ) 688 721 $args->private = false; 689 722 723 if ( null === $args->moderation ) 724 $args->moderation = false; 725 690 726 if ( null === $args->protected ) 691 727 $args->protected = false; 692 728 … … function register_post_status($post_status, $args = array()) { 708 744 if ( null === $args->single_view_cap ) 709 745 $args->single_view_cap = $args->public ? '' : 'edit'; 710 746 711 if ( false === $args->label ) 712 $args->label = $post_status; 747 $args->labels = (object) $args->labels; 748 749 if ( empty( $args->labels->name ) ) 750 $args->labels->name = ( ! empty( $args->label ) ) ? $args->label : $post_status; 751 752 if ( empty( $args->label ) ) 753 $args->label = $args->labels->name; 754 755 if ( empty( $args->labels->caption ) ) 756 $args->labels->caption = $args->label; 757 758 if ( empty( $args->labels->count ) ) 759 $args->labels->count = ( ! empty( $args->label_count ) ) ? $args->label_count : array( $args->label, $args->label ); 713 760 714 if ( false === $args->label_count ) 715 $args->label_count = array( $args->label, $args->label ); 761 if ( empty( $args->label_count ) ) // TODO: need to support this for external API? 762 $args->label_count = $args->labels->count; 763 764 if ( empty( $args->labels->publish ) ) 765 $args->labels->publish = esc_attr( sprintf( __( 'Set %s' ), $args->label ) ); 766 767 if ( empty( $args->labels->save_as ) ) 768 $args->labels->save_as = esc_attr( sprintf( __( 'Save as %s' ), $args->label ) ); 769 770 if ( empty( $args->labels->visibility ) ) { 771 if ( 'publish' == $post_status ) 772 $args->labels->visibility =__( 'Public' ); 773 elseif ( $args->public ) 774 $args->labels->visibility = esc_attr( sprintf( __( 'Public (%s)' ), $args->label ) ); 775 elseif ( $args->private ) 776 $args->labels->visibility = $args->label; 777 } 716 778 717 779 $wp_post_statuses[$post_status] = $args; 718 780 719 781 return $args; 720 782 } 721 783 784 /** 785 * Add an already registered post status to an object type. 786 * 787 * @package WordPress 788 * @subpackage Taxonomy 789 * @since 3.1.0 790 * @uses $wp_post_statuses Modifies post_type object 791 * 792 * @param string $post_status Name of post_status object 793 * @param array|string $object_type Name of the object type 794 * @return bool True if successful, false if not 795 */ 796 function register_status_for_object_type( $post_status, $object_type) { 797 global $wp_post_statuses; 798 799 if ( ! isset( $wp_post_statuses[$post_status] ) ) 800 return false; 801 802 if ( ! get_post_type_object($object_type) ) 803 return false; 804 805 $wp_post_statuses[$post_status]->object_type[] = $object_type; 806 807 return true; 808 } 809 722 810 /** 723 811 * Retrieve a post status object by name 724 812 * … … function get_post_status_object( $post_status ) { 759 847 */ 760 848 function get_post_stati( $args = array(), $output = 'names', $operator = 'and' ) { 761 849 global $wp_post_statuses; 850 851 $post_statuses = $wp_post_statuses; 762 852 763 853 $field = ('names' == $output) ? 'name' : false; 854 855 //wp_filter_object_list doesn't like nested arrays, 856 //so grab a subset of post stati that match the query, and THEN run through wp_list_filter 857 if ( ! empty( $args['object_type'] ) ) { 858 $post_statuses = get_object_stati( $args['object_type'], 'objects' ); 859 unset( $args['object_type'] ); 860 } 764 861 765 return wp_filter_object_list($wp_post_statuses, $args, $operator, $field); 862 return wp_filter_object_list( $post_statuses, $args, $operator, $field ); 863 } 864 865 /** 866 * Return all of the post_statuses that are of $object_type. 867 * * 868 * <code><?php $taxonomies = get_object_stati('post'); ?></code> Should 869 * result in <code>Array('publish', 'future', 'pending', etc. )</code> 870 * 871 * @package WordPress 872 * @subpackage Taxonomy 873 * @since 3.5 874 * 875 * @uses $wp_post_statuses 876 * 877 * @param array|string|object $object Name of the type of post_status object, or an object (row from posts) 878 * @param string $output The type of output to return, either status 'names' or 'objects'. 'names' is the default. 879 * @return array The names of all statuses of $object_type. 880 */ 881 882 function get_object_stati($object, $output = 'names') { 883 global $wp_post_statuses; 884 885 if ( is_object($object) ) 886 $object = $object->post_type; 887 888 $object = (array) $object; 889 890 $stati = array(); 891 foreach ( (array) $wp_post_statuses as $status_name => $status_obj ) { 892 if ( array_intersect($object, (array) $status_obj->object_type) ) { 893 if ( 'names' == $output ) 894 $stati[] = $status_name; 895 else 896 $stati[ $status_name ] = $status_obj; 897 } 898 } 899 900 return $stati; 766 901 } 767 902 768 903 /** … … function register_post_type( $post_type, $args = array() ) { 966 1101 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'hierarchical' => false, 967 1102 'public' => false, 'rewrite' => true, 'has_archive' => false, 'query_var' => true, 968 1103 'supports' => array(), 'register_meta_box_cb' => null, 969 'taxonomies' => array(), 's how_ui' => null, 'menu_position' => null, 'menu_icon' => null,1104 'taxonomies' => array(), 'statuses' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 970 1105 'can_export' => true, 971 1106 'show_in_nav_menus' => null, 'show_in_menu' => null, 'show_in_admin_bar' => null, 972 1107 'delete_with_user' => null, … … function register_post_type( $post_type, $args = array() ) { 1088 1223 foreach ( $args->taxonomies as $taxonomy ) { 1089 1224 register_taxonomy_for_object_type( $taxonomy, $post_type ); 1090 1225 } 1226 1227 foreach ( $args->statuses as $post_status ) { 1228 register_status_for_object_type( $post_status, $post_type ); 1229 } 1091 1230 1092 1231 do_action( 'registered_post_type', $post_type, $args ); 1093 1232 … … function wp_count_posts( $type = 'post', $perm = '' ) { 1862 2001 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; 1863 2002 if ( 'readable' == $perm && is_user_logged_in() ) { 1864 2003 $post_type_object = get_post_type_object($type); 1865 if ( !current_user_can( $post_type_object->cap->read_private_posts ) ) { 1866 $cache_key .= '_' . $perm . '_' . $user->ID; 1867 $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))"; 2004 foreach( get_post_stati( array( 'private' => true, 'object_type' => $type ) ) as $_status ) { 2005 $cap_name = "read_{$_status}_posts"; 2006 if ( ! empty($post_type_object->cap->$cap_name) && ! current_user_can( $post_type_object->cap->$cap_name ) ) { 2007 $suffix = ( 'private' == $_status ) ? '' : $_status; 2008 $cache_key .= '_' . $perm . $suffix . '_' . $user->ID; 2009 $query .= " AND (post_status != '$_status' OR ( post_author = '$user->ID' AND post_status = '$_status' ))"; 2010 } 1868 2011 } 1869 2012 } 1870 2013 $query .= ' GROUP BY post_status'; 1871 2014 1872 2015 $count = wp_cache_get($cache_key, 'counts'); 1873 2016 if ( false !== $count ) 1874 2017 return $count; … … function wp_count_posts( $type = 'post', $perm = '' ) { 1876 2019 $count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); 1877 2020 1878 2021 $stats = array(); 1879 foreach ( get_post_stati( ) as $state )2022 foreach ( get_post_stati( array( 'object_type' => $type ) ) as $state ) 1880 2023 $stats[$state] = 0; 1881 2024 1882 2025 foreach ( (array) $count as $row ) … … function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) { 2351 2494 $args = array( 'numberposts' => absint( $args ) ); 2352 2495 } 2353 2496 2497 $status_names = get_post_stati( array( 'public' => true, 'object_type' => 'post' ) ); 2498 $status_names_csv = "'" . implode( "', '", $status_names ) . "'"; 2499 2354 2500 // Set default arguments 2355 2501 $defaults = array( 2356 2502 'numberposts' => 10, 'offset' => 0, 2357 2503 'category' => 0, 'orderby' => 'post_date', 2358 2504 'order' => 'DESC', 'include' => '', 2359 2505 'exclude' => '', 'meta_key' => '', 2360 'meta_value' =>'', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending, private',2506 'meta_value' =>'', 'post_type' => 'post', 'post_status' => $status_names_csv, 2361 2507 'suppress_filters' => true 2362 2508 ); 2363 2509 … … function wp_insert_post($postarr, $wp_error = false) { 2524 2670 } 2525 2671 2526 2672 // Don't allow contributors to set the post slug for pending review posts 2527 if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) ) 2673 $post_status_obj = get_post_status_object( $post_status ); 2674 $draft_or_pending = in_array( $post_status, array( 'draft', 'auto-draft' ) ) || ! empty( $post_status_obj->moderation ); 2675 2676 if ( ! empty( $post_status_obj->moderation ) && ! current_user_can( 'publish_posts' ) ) 2528 2677 $post_name = ''; 2529 2678 2530 2679 // Create a valid post name. Drafts and pending posts are allowed to have an empty 2531 2680 // post name. 2532 2681 if ( empty($post_name) ) { 2533 if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ))2682 if ( ! $draft_or_pending ) 2534 2683 $post_name = sanitize_title($post_title); 2535 2684 else 2536 2685 $post_name = ''; … … function wp_insert_post($postarr, $wp_error = false) { 2548 2697 $post_date = current_time('mysql'); 2549 2698 2550 2699 if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) { 2551 if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ))2700 if ( ! $draft_or_pending ) 2552 2701 $post_date_gmt = get_gmt_from_date($post_date); 2553 2702 else 2554 2703 $post_date_gmt = '0000-00-00 00:00:00'; … … function wp_insert_post($postarr, $wp_error = false) { 2562 2711 $post_modified_gmt = $post_date_gmt; 2563 2712 } 2564 2713 2565 if ( 'publish' == $post_status ) { 2714 $set_status = $post_status; 2715 2716 if ( $post_status_obj->public || $post_status_obj->private ) { 2566 2717 $now = gmdate('Y-m-d H:i:59'); 2567 2718 if ( mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false) ) 2568 2719 $post_status = 'future'; … … function wp_insert_post($postarr, $wp_error = false) { 2572 2723 $post_status = 'publish'; 2573 2724 } 2574 2725 2726 if ( ( 'future' == $post_status ) && ( 'publish' != $set_status ) ) { 2727 update_post_meta( $post_ID, '_scheduled_status', $set_status ); 2728 } else 2729 delete_post_meta( $post_ID, '_scheduled_status' ); 2730 2575 2731 if ( empty($comment_status) ) { 2576 2732 if ( $update ) 2577 2733 $comment_status = 'closed'; … … function wp_insert_post($postarr, $wp_error = false) { 2602 2758 else 2603 2759 $menu_order = 0; 2604 2760 2605 if ( ! isset($post_password) || 'private' == $post_status)2761 if ( ! isset($post_password) || $post_status_obj->private ) 2606 2762 $post_password = ''; 2607 2763 2608 2764 $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent); … … function wp_insert_post($postarr, $wp_error = false) { 2643 2799 $where = array( 'ID' => $post_ID ); 2644 2800 } 2645 2801 2646 if ( empty($data['post_name']) && !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) { 2802 $post_status_obj = get_post_status_object( $data['post_status'] ); 2803 $draft_or_pending = in_array( $data['post_status'], array('draft', 'auto-draft') ) || ! empty($post_status_obj->moderation); 2804 2805 if ( empty($data['post_name']) && ! $draft_or_pending ) { 2647 2806 $data['post_name'] = sanitize_title($data['post_title'], $post_ID); 2648 2807 $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where ); 2649 2808 } … … function wp_update_post($postarr = array()) { 2733 2892 $post_cats = $post['post_category']; 2734 2893 2735 2894 // Drafts shouldn't be assigned a date unless explicitly done so by the user 2736 if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) && 2737 ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) 2738 $clear_date = true; 2739 else 2895 if ( isset( $post['post_status'] ) && empty($postarr['edit_date']) && ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) { 2896 $post_status_obj = get_post_status_object( $post['post_status'] ); 2897 2898 $clear_date = in_array( $post['post_status'], array('draft', 'auto-draft') ) || ! empty($post_status_obj->moderation); 2899 } else 2740 2900 $clear_date = false; 2741 2901 2742 2902 // Merge old and new fields with new fields overwriting old ones. … … function wp_publish_post($post_id) { 2774 2934 if ( 'publish' == $post->post_status ) 2775 2935 return; 2776 2936 2777 $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post_id ) ); 2937 if ( 'future' == $post->post_status ) { 2938 if ( ! $post_status = get_post_meta( $post_id, '_scheduled_status', true ) ) 2939 $post_status = 'publish'; 2940 } else 2941 $post_status = 'publish'; 2942 2943 $wpdb->update( $wpdb->posts, array( 'post_status' => $post_status ), array( 'ID' => $post_id ) ); 2778 2944 2779 2945 $old_status = $post->post_status; 2780 2946 $post->post_status = 'publish'; … … function check_and_publish_future_post($post_id) { 2832 2998 * @return string unique slug for the post, based on $post_name (with a -1, -2, etc. suffix) 2833 2999 */ 2834 3000 function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) { 2835 if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) 3001 $post_status_obj = get_post_status_object( $post_status ); 3002 3003 if ( in_array( $post_status, array('draft', 'auto-draft') ) || ! empty($post_status_obj->moderation) ) 2836 3004 return $slug; 2837 3005 2838 3006 global $wpdb, $wp_rewrite; … … function get_page_uri($page) { 3370 3538 * @param mixed $args Optional. Array or string of options that overrides defaults. 3371 3539 * @return array List of pages matching defaults or $args 3372 3540 */ 3373 function &get_pages($args = '') { 3541 function &get_pages($args = '') { 3374 3542 global $wpdb; 3375 3543 3376 3544 $defaults = array( … … function &get_pages($args = '') { 3387 3555 extract( $r, EXTR_SKIP ); 3388 3556 $number = (int) $number; 3389 3557 $offset = (int) $offset; 3390 3558 $false = false; 3559 3391 3560 // Make sure the post type is hierarchical 3392 3561 $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) ); 3393 3562 if ( !in_array( $post_type, $hierarchical_post_types ) ) 3394 return false;3563 return $false; 3395 3564 3396 3565 // Make sure we have a valid post status 3397 3566 if ( !is_array( $post_status ) ) 3398 3567 $post_status = explode( ',', $post_status ); 3399 if ( array_diff( $post_status, get_post_stati() ) ) 3400 return false; 3568 3569 if ( array_diff( $post_status, get_post_stati( array( 'object_type' => $post_type ) ) ) ) 3570 return $false; 3401 3571 3402 3572 $cache = array(); 3403 3573 $key = md5( serialize( compact(array_keys($defaults)) ) ); -
wp-includes/query.php
diff --git wp-includes/query.php wp-includes/query.php index 5f6ccdd..35d3785 100644
class WP_Query { 2403 2403 $post_type_object = get_post_type_object ( 'post' ); 2404 2404 } 2405 2405 2406 $_post_type = ( $post_type ) ? $post_type : 'post'; // corresponds to hardcoded default for POST_TYPE clause 2407 $type_arg = ( 'any' == $_post_type ) ? array() : array( 'object_type' => $_post_type ); 2408 2406 2409 if ( ! empty( $post_type_object ) ) { 2410 $post_type_cap = $post_type_object->capability_type; 2407 2411 $edit_cap = $post_type_object->cap->edit_post; 2408 2412 $read_cap = $post_type_object->cap->read_post; 2409 2413 $edit_others_cap = $post_type_object->cap->edit_others_posts; 2410 $read_private_cap = $post_type_object->cap->read_private_posts;2411 2414 } else { 2412 2415 $edit_cap = 'edit_' . $post_type_cap; 2413 2416 $read_cap = 'read_' . $post_type_cap; 2414 2417 $edit_others_cap = 'edit_others_' . $post_type_cap . 's'; 2415 $read_private_cap = 'read_private_' . $post_type_cap . 's';2416 2418 } 2417 2419 2418 2420 if ( ! empty( $q['post_status'] ) ) { … … class WP_Query { 2422 2424 $q_status = explode(',', $q_status); 2423 2425 $r_status = array(); 2424 2426 $p_status = array(); 2427 $p_status_owner = array(); 2425 2428 $e_status = array(); 2426 2429 if ( in_array('any', $q_status) ) { 2427 2430 foreach ( get_post_stati( array('exclude_from_search' => true) ) as $status ) 2428 2431 $e_status[] = "$wpdb->posts.post_status <> '$status'"; 2429 2432 } else { 2430 foreach ( get_post_stati() as $status ) { 2433 $_args = array_merge( array(), $type_arg ); 2434 foreach ( get_post_stati( $_args, 'object' ) as $status => $status_obj ) { 2431 2435 if ( in_array( $status, $q_status ) ) { 2432 if ( 'private' == $status ) 2433 $p_status[] = "$wpdb->posts.post_status = '$status'"; 2434 else 2436 if ( $status_obj->private ) { 2437 if ( ! empty($post_type_object) ) { 2438 $check_cap = "read_{$status}_posts"; 2439 $read_private_cap = ( ! empty( $post_type_object->cap->$check_cap ) ) ? $post_type_object->cap->$check_cap : $post_type_object->cap->read_private_posts; 2440 } else 2441 $read_private_cap = 'read_private_' . $post_type_cap . 's'; 2442 2443 if ( ! empty($q['perm'] ) && 'readable' == $q['perm'] && ! current_user_can( $read_private_cap ) ) 2444 $p_status_owner[] = "$wpdb->posts.post_status = '$status'"; 2445 else 2446 $p_status[] = "$wpdb->posts.post_status = '$status'"; 2447 } else 2435 2448 $r_status[] = "$wpdb->posts.post_status = '$status'"; 2436 2449 } 2437 2450 } 2438 2451 } 2439 2452 2440 2453 if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) { 2441 $r_status = array_merge($r_status, $p_status );2454 $r_status = array_merge($r_status, $p_status, $p_status_owner); 2442 2455 unset($p_status); 2456 unset($p_status_owner); 2443 2457 } 2444 2458 2445 2459 if ( !empty($e_status) ) { … … class WP_Query { 2451 2465 else 2452 2466 $statuswheres[] = "(" . join( ' OR ', $r_status ) . ")"; 2453 2467 } 2454 if ( !empty($p_status) ) { 2468 2469 if ( ! empty( $p_status ) ) { 2455 2470 if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can($read_private_cap) ) 2456 2471 $statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $p_status ) . "))"; 2457 2472 else 2458 2473 $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")"; 2459 2474 } 2475 if ( ! empty( $p_status ) ) { 2476 $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")"; 2477 } 2460 2478 if ( $post_status_join ) { 2461 2479 $join .= " LEFT JOIN $wpdb->posts AS p2 ON ($wpdb->posts.post_parent = p2.ID) "; 2462 2480 foreach ( $statuswheres as $index => $statuswhere ) 2463 2481 $statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts, 'p2', $statuswhere) . "))"; 2464 2482 } 2465 2483 foreach ( $statuswheres as $statuswhere ) 2466 $where .= " AND $statuswhere"; 2484 $where .= " AND $statuswhere"; 2485 2467 2486 } elseif ( !$this->is_singular ) { 2468 2487 $where .= " AND ($wpdb->posts.post_status = 'publish'"; 2469 2488 2470 2489 // Add public states. 2471 $public_states = get_post_stati( array('public' => true) ); 2490 $_args = array_merge( array( 'public' => true ), $type_arg ); 2491 $public_states = apply_filters_ref_array( 'posts_public_stati', array( get_post_stati( $_args ), &$this ) ); 2472 2492 foreach ( (array) $public_states as $state ) { 2473 2493 if ( 'publish' == $state ) // Publish is hard-coded above. 2474 2494 continue; … … class WP_Query { 2477 2497 2478 2498 if ( $this->is_admin ) { 2479 2499 // Add protected states that should show in the admin all list. 2480 $admin_all_states = get_post_stati( array('protected' => true, 'show_in_admin_all_list' => true) ); 2500 $_args = array_merge( array( 'show_in_admin_all_list' => true ), $type_arg ); 2501 $admin_all_states = get_post_stati( $_args ); 2481 2502 foreach ( (array) $admin_all_states as $state ) 2482 2503 $where .= " OR $wpdb->posts.post_status = '$state'"; 2483 2504 } 2484 2505 2485 2506 if ( is_user_logged_in() ) { 2486 2507 // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states. 2487 $private_states = get_post_stati( array('private' => true) ); 2488 foreach ( (array) $private_states as $state ) 2508 $_args = array_merge( array( 'private' => true ), $type_arg ); 2509 $private_states = apply_filters_ref_array( 'posts_private_stati', array( get_post_stati( $_args ), &$this ) ); 2510 foreach ( (array) $private_states as $state ) { 2511 if ( ! empty($post_type_object) ) { 2512 $check_cap = "read_{$state}_posts"; 2513 $read_private_cap = ( ! empty( $post_type_object->cap->$check_cap ) ) ? $post_type_object->cap->$check_cap : $post_type_object->cap->read_private_posts; 2514 } else 2515 $read_private_cap = 'read_private_' . $post_type_cap . 's'; 2516 2489 2517 $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'"; 2518 } 2490 2519 } 2491 2520 2492 2521 $where .= ')'; … … class WP_Query { 2527 2556 $cwhere = "WHERE comment_approved = '1' $where"; 2528 2557 $cgroupby = "$wpdb->comments.comment_id"; 2529 2558 } else { // Other non singular e.g. front 2559 $public_stati = apply_filters( 'comment_feed_stati', get_post_stati( array( 'public' => true ) ) ); 2560 $public_csv = implode( "', '", $public_stati ); 2561 2530 2562 $cjoin = "JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )"; 2531 $cwhere = "WHERE post_status = 'publish'AND comment_approved = '1'";2563 $cwhere = "WHERE post_status IN ( '$public_csv' ) AND comment_approved = '1'"; 2532 2564 $cgroupby = ''; 2533 2565 } 2534 2566 … … class WP_Query { 2742 2774 $stickies_where = "AND $wpdb->posts.post_type IN ('" . $post_types . "')"; 2743 2775 } 2744 2776 2777 $public_stati = apply_filters_ref_array( 'posts_sticky_stati', array( get_post_stati( array( 'public' => true ) ), &$this ) ); 2745 2778 $stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in) $stickies_where" ); 2746 2779 foreach ( $stickies as $sticky_post ) { 2747 2780 // Ignore sticky posts the current user cannot read or are not published. 2748 if ( 'publish' != $sticky_post->post_status)2781 if ( ! in_array( $sticky_post->post_status, $public_stati ) ) 2749 2782 continue; 2783 2750 2784 array_splice($this->posts, $sticky_offset, 0, array($sticky_post)); 2751 2785 $sticky_offset++; 2752 2786 } -
wp-includes/script-loader.php
diff --git wp-includes/script-loader.php wp-includes/script-loader.php index dab5868..c54ccd9 100644
function wp_default_scripts( &$scripts ) { 339 339 $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 ); 340 340 341 341 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), false, 1 ); 342 $ scripts->localize( 'post', 'postL10n',array(342 $arr = array( 343 343 'ok' => __('OK'), 344 344 'cancel' => __('Cancel'), 345 345 'publishOn' => __('Publish on:'), … … function wp_default_scripts( &$scripts ) { 359 359 'privatelyPublished' => __('Privately Published'), 360 360 'published' => __('Published'), 361 361 'comma' => _x( ',', 'tag delimiter' ), 362 ) ); 362 ); 363 364 if ( function_exists( 'get_post_stati' ) ) { 365 $custom = array(); 366 foreach( get_post_stati( array( 'public' => true, 'private' => true ), 'object', 'or' ) as $_status => $_status_obj ) { 367 if ( 'publish' == $_status ) 368 continue; 369 370 $custom[ $_status ] = $_status_obj->labels->visibility; 371 372 if ( $_status_obj->public ) 373 $custom[ $_status . 'Sticky' ] = sprintf( __('%s, Sticky'), $_status_obj->label ); 374 } 375 376 $arr = array_merge( $custom, $arr ); // note: 'publish' has existing value of 'Publish', cannot be used to reference status name 377 } 378 379 $scripts->localize( 'post', 'postL10n', $arr ); 363 380 364 381 $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), false, 1 ); 382 $scripts->add_data( 'link', 'group', 1 ); 365 383 366 384 $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array('jquery') ); 367 385 $scripts->add_data( 'comment', 'group', 1 ); -
wp-includes/taxonomy.php
diff --git wp-includes/taxonomy.php wp-includes/taxonomy.php index 8ea976f..25bd211 100644
function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) 132 132 133 133 $field = ('names' == $output) ? 'name' : false; 134 134 135 if ( isset( $args['object_type'] ) ) 136 $args['object_type'] = (array) $args['object_type']; 137 135 138 return wp_filter_object_list($wp_taxonomies, $args, $operator, $field); 136 139 } 137 140 … … function _pad_term_counts(&$terms, $taxonomy) { 2840 2843 // Get the object and term ids and stick them in a lookup table 2841 2844 $tax_obj = get_taxonomy($taxonomy); 2842 2845 $object_types = esc_sql($tax_obj->object_type); 2843 $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'"); 2846 2847 $public_stati = apply_filters( 'term_count_stati', get_post_stati( array( 'public' => true, 'object_type' => $tax_obj->object_type ) ) ); 2848 $public_csv = implode( "', '", $public_stati ); 2849 2850 $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')"); 2844 2851 foreach ( $results as $row ) { 2845 2852 $id = $term_ids[$row->term_taxonomy_id]; 2846 2853 $term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1; … … function _update_post_term_count( $terms, $taxonomy ) { 2901 2908 if ( $object_types ) 2902 2909 $object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) ); 2903 2910 2911 $public_stati = apply_filters( 'term_count_stati', get_post_stati( array( 'public' => true, 'object_type' => $taxonomy->object_type ) ) ); 2912 $public_csv = implode( "', '", $public_stati ); 2913 2904 2914 foreach ( (array) $terms as $term ) { 2915 2905 2916 $count = 0; 2906 2917 2907 2918 // Attachments can be 'inherit' status, we need to base count off the parent's status if so 2908 2919 if ( $check_attachments ) 2909 $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish') ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) );2920 $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status IN ('$public_csv') OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) IN ('$public_csv') ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) ); 2910 2921 2911 2922 if ( $object_types ) 2912 $count += (int) $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 ) );2923 $count += (int) $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 ) ); 2913 2924 2914 2925 do_action( 'edit_term_taxonomy', $term, $taxonomy ); 2915 2926 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );