Changeset 8973 for trunk/wp-admin/includes/post.php
- Timestamp:
- 09/25/2008 01:42:34 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/includes/post.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/post.php
r8912 r8973 176 176 177 177 return $post_ID; 178 } 179 180 function bulk_edit_posts( $post_data = null ) { 181 182 if ( empty($post_data) ) 183 $post_data = &$_POST; 184 185 if ( 'page' == $post_data['post_type'] ) { 186 if ( ! current_user_can( 'edit_pages' ) ) 187 wp_die( __('You are not allowed to edit pages.') ); 188 } else { 189 if ( ! current_user_can( 'edit_posts' ) ) 190 wp_die( __('You are not allowed to edit posts.') ); 191 } 192 193 $post_IDs = array_map( intval, (array) $post_data['post'] ); 194 195 if ( isset($post_data['post_category']) ) { 196 if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) 197 $new_cats = array_map( absint, $post_data['post_category'] ); 198 else 199 unset($post_data['post_category']); 200 } 201 202 if ( isset($post_data['tags_input']) ) { 203 if ( ! empty($post_data['tags_input']) ) { 204 $new_tags = preg_replace( '/\s*,\s*/', ',', rtrim($post_data['tags_input'], ' ,') ); 205 $new_tags = explode(',', $new_tags); 206 } else { 207 unset($post_data['tags_input']); 208 } 209 } 210 211 $reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private' ); 212 foreach ( $reset as $field ) { 213 if ( isset($post_data[$field]) && '' == $post_data[$field] ) 214 unset($post_data[$field]); 215 } 216 217 $updated = $skipped = array(); 218 foreach ( $post_IDs as $post_ID ) { 219 220 if ( wp_check_post_lock( $post_ID ) ) { 221 $skipped[] = $post_ID; 222 continue; 223 } 224 225 if ( isset($new_cats) ) { 226 $cats = (array) wp_get_post_categories($post_ID); 227 $post_data['post_category'] = array_unique( array_merge($cats, $new_cats) ); 228 } 229 230 if ( isset($new_tags) ) { 231 $tags = wp_get_post_tags($post_ID, array('fields' => 'names')); 232 $post_data['tags_input'] = array_unique( array_merge($tags, $new_tags) ); 233 } 234 235 $post_data['ID'] = $post_ID; 236 $updated[] = wp_update_post( $post_data ); 237 } 238 239 return array( 'upd' => $updated, 'skip' => $skipped ); 178 240 } 179 241
Note:
See TracChangeset
for help on using the changeset viewer.