Ticket #19373: 19373.diff
File 19373.diff, 1.8 KB (added by , 12 years ago) |
---|
-
wp-includes/post.php
2680 2680 * 2681 2681 * @param array $postarr Elements that make up post to insert. 2682 2682 * @param bool $wp_error Optional. Allow return of WP_Error on failure. 2683 * @param bool $sanitize Optional. Run "current user" sanitization routines on $postarr. 2683 2684 * @return int|WP_Error The value 0 or WP_Error on failure. The post ID on success. 2684 2685 */ 2685 function wp_insert_post( $postarr, $wp_error = false) {2686 function wp_insert_post( $postarr, $wp_error = false, $sanitize = true ) { 2686 2687 global $wpdb, $user_ID; 2687 2688 2688 2689 $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID, … … 2695 2696 2696 2697 unset( $postarr[ 'filter' ] ); 2697 2698 2698 $postarr = sanitize_post($postarr, 'db'); 2699 if ( ! $sanitize ) 2700 kses_remove_filters(); 2701 $postarr = sanitize_post( $postarr, 'db' ); 2702 if ( ! $sanitize ) 2703 kses_init(); 2699 2704 2700 2705 // export array as variables 2701 2706 extract($postarr, EXTR_SKIP); … … 2753 2758 $post_author = $user_ID; 2754 2759 2755 2760 // Don't allow contributors to set the post slug for pending review posts 2756 if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) )2761 if ( 'pending' == $post_status && $sanitize && !current_user_can( 'publish_posts' ) ) 2757 2762 $post_name = ''; 2758 2763 2759 2764 // Create a valid post name. Drafts and pending posts are allowed to have an empty … … 2901 2906 $taxonomy_obj = get_taxonomy($taxonomy); 2902 2907 if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical. 2903 2908 $tags = array_filter($tags); 2904 if ( current_user_can($taxonomy_obj->cap->assign_terms) )2909 if ( ! $sanitize || current_user_can( $taxonomy_obj->cap->assign_terms ) ) 2905 2910 wp_set_post_terms( $post_ID, $tags, $taxonomy ); 2906 2911 } 2907 2912 }