Make WordPress Core

Ticket #19373: patch-boolean.diff

File patch-boolean.diff, 1.6 KB (added by alexkingorg, 13 years ago)

boolean option for sanitization

  • wp-includes/post.php

     
    24122412 * @param bool $wp_error Optional. Allow return of WP_Error on failure.
    24132413 * @return int|WP_Error The value 0 or WP_Error on failure. The post ID on success.
    24142414 */
    2415 function wp_insert_post($postarr, $wp_error = false) {
     2415function wp_insert_post($postarr, $wp_error = false, $sanitize = true) {
    24162416        global $wpdb, $wp_rewrite, $user_ID;
    24172417
    24182418        $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID,
     
    24252425
    24262426        unset( $postarr[ 'filter' ] );
    24272427
    2428         $postarr = sanitize_post($postarr, 'db');
     2428        if ( $sanitize ) {
     2429                $postarr = sanitize_post($postarr, 'db');
     2430        }
    24292431
    24302432        // export array as variables
    24312433        extract($postarr, EXTR_SKIP);
     
    24792481        }
    24802482
    24812483        // Don't allow contributors to set the post slug for pending review posts
    2482         if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) )
     2484        if ( 'pending' == $post_status && $sanitize && !current_user_can( 'publish_posts' ) )
    24832485                $post_name = '';
    24842486
    24852487        // Create a valid post name.  Drafts and pending posts are allowed to have an empty
     
    26152617                        $taxonomy_obj = get_taxonomy($taxonomy);
    26162618                        if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical.
    26172619                                $tags = array_filter($tags);
    2618                         if ( current_user_can($taxonomy_obj->cap->assign_terms) )
     2620                        if ( !$sanitize || current_user_can($taxonomy_obj->cap->assign_terms) )
    26192621                                wp_set_post_terms( $post_ID, $tags, $taxonomy );
    26202622                }
    26212623        }