Ticket #19373: 19373.2.diff
File 19373.2.diff, 2.6 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 … … 2848 2853 2849 2854 $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent); 2850 2855 2851 // expected_slashed (everything!) 2856 // expected_slashed, everything, unless $sanitize = false 2857 if ( ! $sanitize ) 2858 $sanitize = wp_slash( $sanitize ); // That way the wp_insert_post_data filter receives consistent data. 2852 2859 $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) ); 2853 2860 $data = apply_filters('wp_insert_post_data', $data, $postarr); 2854 2861 $data = wp_unslash( $data ); … … 2901 2908 $taxonomy_obj = get_taxonomy($taxonomy); 2902 2909 if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical. 2903 2910 $tags = array_filter($tags); 2904 if ( current_user_can($taxonomy_obj->cap->assign_terms) )2911 if ( ! $sanitize || current_user_can( $taxonomy_obj->cap->assign_terms ) ) 2905 2912 wp_set_post_terms( $post_ID, $tags, $taxonomy ); 2906 2913 } 2907 2914 }