Ticket #19373: patch.diff
File patch.diff, 1.8 KB (added by , 13 years ago) |
---|
-
wp-includes/post.php
2412 2412 * @param bool $wp_error Optional. Allow return of WP_Error on failure. 2413 2413 * @return int|WP_Error The value 0 or WP_Error on failure. The post ID on success. 2414 2414 */ 2415 function wp_insert_post($postarr, $wp_error = false ) {2415 function wp_insert_post($postarr, $wp_error = false, $user = null) { 2416 2416 global $wpdb, $wp_rewrite, $user_ID; 2417 2417 2418 if ( is_null( $user ) ) { 2419 $user = $user_ID; 2420 } 2421 2418 2422 $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID, 2419 2423 'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, 2420 2424 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', … … 2425 2429 2426 2430 unset( $postarr[ 'filter' ] ); 2427 2431 2428 $postarr = sanitize_post($postarr, 'db'); 2432 if ( $user ) { 2433 $postarr = sanitize_post($postarr, 'db'); 2434 } 2429 2435 2430 2436 // export array as variables 2431 2437 extract($postarr, EXTR_SKIP); … … 2479 2485 } 2480 2486 2481 2487 // Don't allow contributors to set the post slug for pending review posts 2482 if ( 'pending' == $post_status && !current_user_can('publish_posts' ) )2488 if ( 'pending' == $post_status && $user && !user_can( $user, 'publish_posts' ) ) 2483 2489 $post_name = ''; 2484 2490 2485 2491 // Create a valid post name. Drafts and pending posts are allowed to have an empty … … 2615 2621 $taxonomy_obj = get_taxonomy($taxonomy); 2616 2622 if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical. 2617 2623 $tags = array_filter($tags); 2618 if ( current_user_can($taxonomy_obj->cap->assign_terms) )2624 if ( !$user || user_can( $user, $taxonomy_obj->cap->assign_terms) ) 2619 2625 wp_set_post_terms( $post_ID, $tags, $taxonomy ); 2620 2626 } 2621 2627 }