Plugin Directory

Changeset 576275


Ignore:
Timestamp:
07/23/2012 07:20:28 PM (14 years ago)
Author:
ericjuden
Message:

Fix for new items not showing up in workflow

Location:
approval-workflow/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • approval-workflow/trunk/approval-workflow.php

    r560668 r576275  
    55Description: Plugin that checks if user has permissions to publish pages/posts/custom post types. If they don't, it will send it to review by someone who can publish.
    66Author: ericjuden
    7 Version: 1.2
     7Version: 1.3
    88Author URI: http://ericjuden.com
    99Site Wide only: false
     
    211211    function post_submitbox_misc_actions(){
    212212        global $post;
    213         if($post->post_status != 'publish'){
    214             return;
    215         }
    216213
    217214        // Only show if people don't have publish permissions
     
    227224    function save_post($post_id, $post){
    228225        global $wpdb;
     226        $is_new = false;
     227       
    229228        if($this->done){
    230229            return $post_id;
     
    245244            $custom = get_post_custom($post_id);
    246245           
    247             $last_revision = array_pop(wp_get_post_revisions($post_id, array('posts_per_page' => 1)));         
    248             if(empty($last_revision) || empty($last_revision->post_content)){
    249                 return $post_id;
     246            // Get revisions from db
     247            $revisions = wp_get_post_revisions($post_id, array('posts_per_page' => 1));
     248            $last_revision = array_pop($revision);         
     249           
     250            // Is this a new post
     251            if(count($revisions) <= 1 || empty($last_revision) || empty($last_revision->post_content)){
     252                $is_new = true;
    250253            }           
    251254           
    252             // Set published content to previous version
    253             $last_revision = $last_revision->ID;
    254             wp_restore_post_revision($last_revision);
    255            
     255            if(!$is_new){
     256                // Set published content to previous version
     257                $last_revision = $last_revision->ID;
     258                wp_restore_post_revision($last_revision);
     259            }
    256260            update_post_meta($post_id, '_in_progress', 1);
    257261           
  • approval-workflow/trunk/class/workflow-list-table.php

    r555220 r576275  
    141141                switch_to_blog($blog);
    142142               
    143                 $this->items = $this->_get_workflow_items($blog, $date_format);
     143                $this->_get_workflow_items($blog, $date_format);
    144144            }
    145145            switch_to_blog($old_blog_id);
    146146        } else {
    147             $this->items = $this->_get_workflow_items(1, $date_format);
     147            $this->_get_workflow_items(1, $date_format);
    148148        }
    149149       
     
    153153    function _get_workflow_items($blog, $date_format){
    154154        global $wpdb;
    155          
    156         $_items = array();
     155       
    157156        $post_types = get_post_types(array(), 'objects');
    158         $query = "SELECT p.* FROM " . $wpdb->prefix . "posts p INNER JOIN " . $wpdb->prefix . "postmeta m ON m.post_id = p.ID WHERE m.meta_key = '_waiting_for_approval' AND m.meta_value = '1'";
     157        $query = "SELECT p.* FROM " . $wpdb->prefix . "posts p INNER JOIN " . $wpdb->prefix . "postmeta m ON m.post_id = p.ID WHERE m.meta_key = '_waiting_for_approval' AND m.meta_value = '1' AND p.post_status <> 'trash'";
    159158        $results = $wpdb->get_results($query);
    160159        if(!empty($results)){
    161160            $posts[$blog] = $results;
    162161            foreach($results as $post){
    163                 $last_revision = array_pop(wp_get_post_revisions($post->ID, array('posts_per_page' => 1)));
     162                $revisions = wp_get_post_revisions($post->ID, array('posts_per_page' => 1));
     163                $last_revision = array_pop($revisions);
    164164                $revision_compare_link = admin_url( 'revision.php?action=diff&post_type=' . $post->post_type . '&right=' . $post->ID . '&left=' . $last_revision->ID );
    165165                 
    166                 $_items[] = array(
     166                $this->items[] = array(
    167167                        'ID' => $post->ID,
    168168                        'title' => $post->post_title,
     
    181181            }
    182182        }
    183        
    184         return $_items;
    185183    }
    186184   
  • approval-workflow/trunk/readme.txt

    r560668 r576275  
    2626
    2727== Changelog ==
     28= 1.3 =
     29* Fix for new items not showing up in workflow.
     30
    2831= 1.2 =
    2932* Fix for not being able to access settings page after changing approval role in settings.
Note: See TracChangeset for help on using the changeset viewer.