Ticket #8592: 8592-parent-status-check.diff
File 8592-parent-status-check.diff, 6.3 KB (added by , 10 years ago) |
---|
-
wp-admin/includes/meta-boxes.php
14 14 15 15 $post_type = $post->post_type; 16 16 $post_type_object = get_post_type_object($post_type); 17 $can_publish = current_user_can($post_type_object->cap->publish_posts); 17 $can_publish = current_user_can($post_type_object->cap->publish_posts); 18 $unpublished_parent = false; 19 if ( isset( $post->post_parent ) && $post->post_parent ) { 20 $parent_status = get_post_status( $post->post_parent ); 21 if ( 'publish' !== $parent_status ) { 22 $unpublished_parent = true; 23 $post->post_status = $parent_status; 24 } 25 } 18 26 ?> 19 27 <div class="submitbox" id="submitpost"> 20 28 … … 23 31 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?> 24 32 <div style="display:none;"> 25 33 <?php submit_button( __( 'Save' ), 'button', 'save' ); ?> 34 <input type="hidden" name="unpublished_parent" id="unpublished_parent" value="<?php if ( $unpublished_parent ) echo 35 1; else echo 0; ?>" /> 26 36 </div> 27 37 28 38 <div id="minor-publishing-actions"> … … 124 134 } 125 135 126 136 echo esc_html( $visibility_trans ); ?></span> 127 <?php if ( $can_publish ) { ?> 137 <?php if ( $unpublished_parent ) { ?> 138 <p><?php printf('To publish this page, you must first <a href="%s">publish its parent page</a>.', get_edit_post_link( $post->post_parent ) ); ?></p> 139 <?php } elseif ( $can_publish ) { ?> 128 140 <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a> 129 141 130 142 <div id="post-visibility-select" class="hide-if-js"> … … 220 232 <div id="publishing-action"> 221 233 <span class="spinner"></span> 222 234 <?php 223 if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { 235 if ( !$unpublished_parent && !in_array( $post->post_status, array('publish', 'future', 236 'private') ) || 0 == $post->ID ) { 224 237 if ( $can_publish ) : 225 238 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> 226 239 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" /> -
wp-includes/post-template.php
784 784 ); 785 785 786 786 $r = wp_parse_args( $args, $defaults ); 787 $r = apply_filters( 'wp_dropdown_pages_args', $r ); 788 // revert to default (public) post_status on the Reading Settings page 789 $screen = get_current_screen(); 790 if ( 'options-reading' == $screen->base ) 791 unset( $r['post_status'] ); 787 792 extract( $r, EXTR_SKIP ); 788 793 789 794 $pages = get_pages($r); … … 829 834 ); 830 835 831 836 $r = wp_parse_args( $args, $defaults ); 837 $r = apply_filters( 'wp_list_pages_args', $r ); 832 838 extract( $r, EXTR_SKIP ); 833 839 834 840 $output = ''; -
wp-includes/post.php
2675 2675 if ( empty($post_type) ) 2676 2676 $post_type = 'post'; 2677 2677 2678 if ( empty($post_status) ) 2679 $post_status = 'draft'; 2678 if ( isset($post_parent) ) 2679 $post_parent = (int) $post_parent; 2680 else 2681 $post_parent = 0; 2682 2683 // Check the post_parent to see if it will cause a hierarchy loop 2684 $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr ); 2685 2686 // Check to see if the post parent is unpublished. If so, set this post status to match. 2687 if ( isset( $post_parent ) && $post_parent ) { 2688 $post_parent_object = get_post( $post_parent ); 2689 if ( 'publish' !== $post_parent_object->post_status ) { 2690 $post_status = $post_parent_object->post_status; 2691 } 2692 } 2693 if ( empty($post_status) ) 2694 $post_status = 'draft'; 2680 2695 2681 2696 if ( !empty($post_category) ) 2682 2697 $post_category = array_filter($post_category); // Filter out empty terms … … 2770 2785 2771 2786 if ( ! isset($pinged) ) 2772 2787 $pinged = ''; 2773 2774 if ( isset($post_parent) )2775 $post_parent = (int) $post_parent;2776 else2777 $post_parent = 0;2778 2779 // Check the post_parent to see if it will cause a hierarchy loop2780 $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr );2781 2788 2782 2789 if ( isset($menu_order) ) 2783 2790 $menu_order = (int) $menu_order; -
wp-admin/js/post.js
515 515 if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) { 516 516 publishOn = postL10n.publishOnFuture; 517 517 $('#publish').val( postL10n.schedule ); 518 } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) {518 } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' && $('#unpublished_parent').val() != 1 ) { 519 519 publishOn = postL10n.publishOn; 520 520 $('#publish').val( postL10n.publish ); 521 521 } else { -
wp-includes/js/autosave.js
176 176 177 177 if ( res.responses[0].data ) // update autosave message 178 178 jQuery('.autosave-message').text( res.responses[0].data ); 179 180 if ( res.responses[0].supplemental.parent_status ) // update hidden unpublished_parent field 181 jQuery('#unpublished_parent').val( res.responses[0].supplemental.parent_status ); 179 182 } 180 183 } 181 184 -
wp-admin/includes/ajax-actions.php
1081 1081 $id = $post->ID; 1082 1082 } 1083 1083 1084 $parent_status = get_post_status( $post->post_parent ); 1085 if ( $parent_status !== 'publish' ) 1086 $supplemental['replace-unpublished_parent'] = 1; 1087 1084 1088 if ( ! is_wp_error($id) ) { 1085 1089 /* translators: draft saved date format, see http://php.net/date */ 1086 1090 $draft_saved_date_format = __('g:i:s a');