Ticket #1820: save_pages_as_draft.2.diff

File save_pages_as_draft.2.diff, 12.0 kB (added by davidhouse, 3 years ago)
  • wp-includes/functions-post.php

    old new  
    1818                $post = & get_post($ID); 
    1919                $previous_status = $post->post_status; 
    2020        } 
    21  
     21         
    2222        // Get the basics. 
    2323        $post_content    = apply_filters('content_save_pre',   $post_content); 
    2424        $post_excerpt    = apply_filters('excerpt_save_pre',   $post_excerpt); 
     
    4848        // Create a valid post name.  Drafts are allowed to have an empty 
    4949        // post name. 
    5050        if ( empty($post_name) ) { 
    51                 if ( 'draft' != $post_status
     51                if ( 'draft' != $post_status && 'static-draft' != $post_status
    5252                        $post_name = sanitize_title($post_title); 
    5353        } else { 
    5454                $post_name = sanitize_title($post_name); 
     
    130130                        $post_ID = $wpdb->insert_id;                     
    131131        } 
    132132 
    133         if ( empty($post_name) && 'draft' != $post_status ) { 
     133        if ( empty($post_name) && 'draft' != $post_status && 'static-draft' != $post_status ) { 
    134134                $post_name = sanitize_title($post_title, $post_ID); 
    135135                $wpdb->query( "UPDATE $wpdb->posts SET post_name = '$post_name' WHERE ID = '$post_ID'" ); 
    136136        } 
    137137 
    138138        wp_set_post_cats('', $post_ID, $post_category); 
    139139 
    140         if ( 'static' == $post_status
     140        if ( 'static' == $post_status || 'static-draft' == $post_status
    141141                clean_page_cache($post_ID); 
    142142        else 
    143143                clean_post_cache($post_ID); 
     
    457457 
    458458        do_action('delete_post', $postid); 
    459459 
    460         if ( 'static' == $post->post_status
     460        if ( 'static' == $post->post_status || 'static-draft' == $post->post_status
    461461                $wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_status = 'static'"); 
    462462 
    463463        $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid"); 
  • wp-includes/classes.php

    old new  
    553553                        $where .= ' AND (post_status = "publish"'; 
    554554 
    555555                        if (isset($user_ID) && ('' != intval($user_ID))) 
    556                                 $where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')"; 
     556                                $where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static' AND post_status != 'static-draft')"; 
    557557                        else 
    558558                                $where .= ')';                           
    559559                } 
     
    610610                                        // User must be logged in to view unpublished posts. 
    611611                                        $this->posts = array(); 
    612612                                } else { 
    613                                         if ('draft' == $status) { 
     613                                        if ('draft' == $status || 'static-draft' == $status) { 
    614614                                                // User must have edit permissions on the draft to preview. 
    615615                                                if (! user_can_edit_post($user_ID, $this->posts[0]->ID)) { 
    616616                                                        $this->posts = array(); 
  • wp-includes/template-functions-links.php

    old new  
    4949 
    5050        $permalink = get_settings('permalink_structure'); 
    5151 
    52         if ( '' != $permalink && 'draft' != $post->post_status ) { 
     52        if ( '' != $permalink && 'draft' != $post->post_status && 'static-draft' != $post->post_status ) { 
    5353                $unixtime = strtotime($post->post_date); 
    5454 
    5555                $category = ''; 
  • wp-admin/post.php

    old new  
    4949                $location = 'post.php?posted=true'; 
    5050        } 
    5151 
    52         if ( 'static' == $_POST['post_status']
     52        if ( 'static' == $_POST['post_status'] || 'static-draft' == $_POST['post_status']
    5353                $location = "page-new.php?saved=true"; 
    5454 
    5555        if ( '' != $_POST['advanced'] || isset($_POST['save']) ) 
     
    7171 
    7272        $post = get_post_to_edit($post_ID); 
    7373         
    74         if ($post->post_status == 'static'
     74        if ($post->post_status == 'static' || $post->post_status == 'static-draft'
    7575                include('edit-page-form.php'); 
    7676        else 
    7777                include('edit-form-advanced.php'); 
     
    100100        } else { 
    101101                $location = 'post.php'; 
    102102        } 
     103//      die($location); 
    103104        header ('Location: ' . $location); // Send user on their way while we keep working 
    104105 
    105106        exit(); 
    106107        break; 
    107  
     108         
    108109case 'delete': 
    109110        check_admin_referer(); 
    110111 
  • wp-admin/admin-functions.php

    old new  
    3434                $_POST['post_status'] = 'publish'; 
    3535        if ('' != $_POST['advanced']) 
    3636                $_POST['post_status'] = 'draft'; 
    37         if ('' != $_POST['savepage']) 
     37        if ('' != $_POST['publishpage']) 
    3838                $_POST['post_status'] = 'static'; 
     39        if ('' != $_POST['savepageasdraft']) 
     40                $_POST['post_status'] = 'static-draft'; 
    3941 
    4042        if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts')) 
    4143                $_POST['post_status'] = 'draft'; 
     
    111113                $_POST['post_status'] = 'publish'; 
    112114        if ('' != $_POST['advanced']) 
    113115                $_POST['post_status'] = 'draft'; 
    114         if ('' != $_POST['savepage']) 
     116        if ('' != $_POST['publishpage']) 
    115117                $_POST['post_status'] = 'static'; 
     118        if ('' != $_POST['savepageasdraft']) 
     119                $_POST['post_status'] = 'static-draft'; 
    116120 
    117121        if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts')) 
    118122                $_POST['post_status'] = 'draft'; 
     
    204208        $post->post_title = format_to_edit($post->post_title); 
    205209        $post->post_title = apply_filters('title_edit_pre', $post->post_title); 
    206210 
    207         if ($post->post_status == 'static'
     211        if ($post->post_status == 'static' || $post->post_status == 'static-draft'
    208212                $post->page_template = get_post_meta($id, '_wp_page_template', true); 
    209213 
    210214        return $post; 
  • wp-admin/edit-page-form.php

    old new  
    3030<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" /> 
    3131<input type="hidden" name="action" value='<?php echo $form_action ?>' /> 
    3232<?php echo $form_extra ?> 
    33 <input type="hidden" name="post_status" value="static" /> 
     33<input type="hidden" name="post_status" value="<?php echo $post->post_status; ?>" /> 
    3434 
    3535<script type="text/javascript"> 
    3636<!-- 
     
    139139 
    140140<p class="submit"> 
    141141<?php if ( $post_ID ) : ?> 
    142 <input name="save" type="submit" id="save" tabindex="5" value=" <?php _e('Save and Continue Editing'); ?> "/>  
    143 <input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php $post_ID ? _e('Edit Page') : _e('Create New Page') ?> &raquo;" />  
     142        <input name="save" type="submit" id="save" tabindex="5" value=" <?php _e('Save and Continue Editing'); ?> "/>  
     143        <input name="submit" type="submit" id="submit" tabindex="6" value="<?php _e('Save Page') ?>" />  
     144        <?php if ( $post->post_status == 'static-draft' ) : ?> 
     145                <input name="publishpage" type="submit" id="publishpage" tabindex="5" value=" <?php _e('Publish Page'); ?> "/> 
     146        <?php endif; ?> 
    144147<?php else : ?> 
    145 <input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php _e('Create New Page') ?> &raquo;" />  
     148        <input name="submit" type="submit" id="submit" tabindex="7" value="<?php _e('Save Page'); ?>" /> 
     149        <input name="save" type="submit" id="save" tabindex="7" value="<?php _e('Save and Continue Editing'); ?>" /> 
     150        <input name="publishpage" type="submit" id="savepage" tabindex="6" value="<?php _e('Create New Page') ?>" />  
    146151<?php endif; ?> 
    147152<input name="referredby" type="hidden" id="referredby" value="<?php echo $sendto; ?>" /> 
    148153</p> 
  • wp-admin/admin-db.php

    old new  
    2525        return apply_filters('get_others_drafts', $other_drafts); 
    2626} 
    2727 
     28function get_users_page_drafts( $user_id ) { 
     29        global $wpdb; 
     30        $user_id = (int) $user_id; 
     31        $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'static-draft' AND post_author = $user_id ORDER BY ID DESC"; 
     32        $query = apply_filters('get_users_page_drafts', $query); 
     33        return $wpdb->get_results( $query ); 
     34} 
     35 
     36function get_others_page_drafts( $user_id ) { 
     37        global $wpdb; 
     38        $user = get_userdata( $user_id ); 
     39        $level_key = $wpdb->prefix . 'user_level'; 
     40 
     41        $editable = get_editable_user_ids( $user_id ); 
     42         
     43        if( !$editable ) { 
     44                $other_drafts = ''; 
     45        } else { 
     46                $editable = join(',', $editable); 
     47                $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'static-draft' AND post_author IN ($editable) AND post_author != '$user_id' "); 
     48        } 
     49 
     50        return apply_filters('get_others_drafts', $other_drafts); 
     51} 
     52 
    2853function get_editable_authors( $user_id ) { 
    2954        global $wpdb; 
    3055 
  • wp-admin/execute-pings.php

    old new  
    2727                } 
    2828        } 
    2929        // Do Trackbacks 
    30         if($trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' AND post_status != 'draft'")) { 
     30        if($trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' AND post_status != 'draft' AND post_status != 'static-draft'")) { 
    3131                foreach($trackbacks as $trackback) { 
    3232                        //echo "trackback : $trackback->ID<br/>"; 
    3333                        do_trackbacks($trackback->ID); 
  • wp-admin/page-new.php

    old new  
    1616        get_currentuserinfo(); 
    1717         
    1818        $post = get_default_post_to_edit(); 
    19         $post->post_status = 'static'; 
     19        $post->post_status = 'static-draft'; 
    2020 
    2121        include('edit-page-form.php'); 
    2222} 
  • wp-admin/edit-pages.php

    old new  
    55require_once('admin-header.php'); 
    66?> 
    77 
     8<?php 
     9$drafts = get_users_page_drafts($user_ID); 
     10$other_drafts = get_others_page_drafts($user_ID); 
     11if ($drafts || $other_drafts) { 
     12?>  
    813<div class="wrap"> 
     14<?php if ($drafts) { ?> 
     15    <p><strong><?php _e('Your Draft Pages:') ?></strong>  
     16    <?php 
     17        $i = 0; 
     18        foreach ($drafts as $draft) { 
     19                if (0 != $i) 
     20                        echo ', '; 
     21                $draft->post_title = stripslashes($draft->post_title); 
     22                if ($draft->post_title == '') 
     23                        $draft->post_title = sprintf(__('Post #%s'), $draft->ID); 
     24                echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>"; 
     25                ++$i; 
     26                } 
     27        ?>  
     28    .</p>  
     29<?php } ?> 
     30 
     31<?php if ($other_drafts) { ?>  
     32    <p><strong><?php _e('Other&#8217;s Draft Pages:') ?></strong>  
     33    <?php 
     34        $i = 0; 
     35        foreach ($other_drafts as $draft) { 
     36                if (0 != $i) 
     37                        echo ', '; 
     38                $draft->post_title = stripslashes($draft->post_title); 
     39                if ($draft->post_title == '') 
     40                        $draft->post_title = sprintf(__('Post #%s'), $draft->ID); 
     41                echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>"; 
     42                ++$i; 
     43                } 
     44        ?>  
     45    .</p>  
     46 
     47<?php } ?> 
     48 
     49</div> 
     50<?php } ?> 
     51 
     52<div class="wrap"> 
    953<h2><?php _e('Page Management'); ?></h2> 
    1054<p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page'); ?> &raquo;</a></p> 
    1155 
  • wp-admin/upgrade-schema.php

    old new  
    106106  post_title text NOT NULL, 
    107107  post_category int(4) NOT NULL default '0', 
    108108  post_excerpt text NOT NULL, 
    109   post_status enum('publish','draft','private','static','object') NOT NULL default 'publish', 
     109  post_status enum('publish','draft','private','static','object', 'static-draft') NOT NULL default 'publish', 
    110110  comment_status enum('open','closed','registered_only') NOT NULL default 'open', 
    111111  ping_status enum('open','closed') NOT NULL default 'open', 
    112112  post_password varchar(20) NOT NULL default '',