Changeset 576275
- Timestamp:
- 07/23/2012 07:20:28 PM (14 years ago)
- Location:
- approval-workflow/trunk
- Files:
-
- 3 edited
-
approval-workflow.php (modified) (4 diffs)
-
class/workflow-list-table.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
approval-workflow/trunk/approval-workflow.php
r560668 r576275 5 5 Description: 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. 6 6 Author: ericjuden 7 Version: 1. 27 Version: 1.3 8 8 Author URI: http://ericjuden.com 9 9 Site Wide only: false … … 211 211 function post_submitbox_misc_actions(){ 212 212 global $post; 213 if($post->post_status != 'publish'){214 return;215 }216 213 217 214 // Only show if people don't have publish permissions … … 227 224 function save_post($post_id, $post){ 228 225 global $wpdb; 226 $is_new = false; 227 229 228 if($this->done){ 230 229 return $post_id; … … 245 244 $custom = get_post_custom($post_id); 246 245 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; 250 253 } 251 254 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 } 256 260 update_post_meta($post_id, '_in_progress', 1); 257 261 -
approval-workflow/trunk/class/workflow-list-table.php
r555220 r576275 141 141 switch_to_blog($blog); 142 142 143 $this-> items = $this->_get_workflow_items($blog, $date_format);143 $this->_get_workflow_items($blog, $date_format); 144 144 } 145 145 switch_to_blog($old_blog_id); 146 146 } else { 147 $this-> items = $this->_get_workflow_items(1, $date_format);147 $this->_get_workflow_items(1, $date_format); 148 148 } 149 149 … … 153 153 function _get_workflow_items($blog, $date_format){ 154 154 global $wpdb; 155 156 $_items = array(); 155 157 156 $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'"; 159 158 $results = $wpdb->get_results($query); 160 159 if(!empty($results)){ 161 160 $posts[$blog] = $results; 162 161 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); 164 164 $revision_compare_link = admin_url( 'revision.php?action=diff&post_type=' . $post->post_type . '&right=' . $post->ID . '&left=' . $last_revision->ID ); 165 165 166 $ _items[] = array(166 $this->items[] = array( 167 167 'ID' => $post->ID, 168 168 'title' => $post->post_title, … … 181 181 } 182 182 } 183 184 return $_items;185 183 } 186 184 -
approval-workflow/trunk/readme.txt
r560668 r576275 26 26 27 27 == Changelog == 28 = 1.3 = 29 * Fix for new items not showing up in workflow. 30 28 31 = 1.2 = 29 32 * 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.