WordPress.org

Make WordPress Core

Ticket #21767: 21767.18.diff

File 21767.18.diff, 6.4 KB (added by ryan, 6 years ago)

slashed arg for wp_insert_post, wp_insert_attachment

  • wp-includes/post.php

     
    23972397        wp_add_post_meta($post_id,'_wp_trash_meta_time', time());
    23982398
    23992399        $post['post_status'] = 'trash';
     2400        $post['slashed'] = false;
     2401
    24002402        wp_insert_post($post);
    24012403
    24022404        wp_trash_post_comments($post_id);
     
    24322434        delete_post_meta($post_id, '_wp_trash_meta_status');
    24332435        delete_post_meta($post_id, '_wp_trash_meta_time');
    24342436
     2437        $post['slashed'] = false;
     2438
    24352439        wp_insert_post($post);
    24362440
    24372441        wp_untrash_post_comments($post_id);
     
    26702674 *     'guid'          - Global Unique ID for referencing the attachment.
    26712675 *     'post_content_filtered' - Post content filtered.
    26722676 *     'post_excerpt'  - Post excerpt.
     2677 *     'slashed'       - Whether the passed data is slashed or not. The default is true.
    26732678 *
    26742679 * @since 1.0.0
    26752680 * @uses $wpdb
     
    26912696                'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
    26922697                'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '',
    26932698                'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0,
    2694                 'post_content' => '', 'post_title' => '');
     2699                'post_content' => '', 'post_title' => '', 'slashed' => true );
    26952700
    26962701        $postarr = wp_parse_args($postarr, $defaults);
    26972702
    26982703        unset( $postarr[ 'filter' ] );
    26992704
     2705        if ( $postarr['slashed'] )
     2706                wp_unslash( $postarr );
     2707
    27002708        $postarr = sanitize_post($postarr, 'db');
    27012709
    27022710        // export array as variables
     
    29812989                $postarr['post_date_gmt'] = '';
    29822990        }
    29832991
     2992        $postarr['slashed'] = false;
     2993
    29842994        if ($postarr['post_type'] == 'attachment')
    29852995                return wp_insert_attachment($postarr);
    29862996
     
    39013911 *     'guid'          - Global Unique ID for referencing the attachment.
    39023912 *     'post_content_filtered' - Attachment post content filtered.
    39033913 *     'post_excerpt'  - Attachment excerpt.
     3914 *     'slashed'       - Whether the passed data is slashed or not. The default is true.
    39043915 *
    39053916 * @since 2.0.0
    39063917 * @uses $wpdb
     
    39193930        $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_ID,
    39203931                'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
    39213932                'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '',
    3922                 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'context' => '');
     3933                'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'context' => '',
     3934                'slashed' => true );
    39233935
    39243936        $object = wp_parse_args($object, $defaults);
     3937
     3938        if ( $postarr['slashed'] )
     3939                wp_unslash( $postarr );
     3940
    39253941        if ( !empty($parent) )
    39263942                $object['post_parent'] = $parent;
    39273943
  • wp-includes/revision.php

     
    241241                return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) );
    242242
    243243        $post = _wp_post_revision_fields( $post, $autosave );
     244        $post['slashed'] = false;
    244245
    245246        $revision_id = wp_insert_post( $post );
    246247        if ( is_wp_error($revision_id) )
  • wp-includes/class-wp-xmlrpc-server.php

     
    12021202                $this->attach_uploads( $post_ID, $post_data['post_content'] );
    12031203
    12041204                $post_data = apply_filters( 'xmlrpc_wp_insert_post_data', $post_data, $content_struct );
     1205                $post_data['slashed'] = false;
    12051206
    12061207                $post_ID = $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true );
    12071208                if ( is_wp_error( $post_ID ) )
     
    37703771                $post_date_gmt = current_time('mysql', 1);
    37713772
    37723773                $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status');
     3774                $post_data['slashed'] = false;
    37733775
    37743776                $post_ID = wp_insert_post($post_data);
    37753777                if ( is_wp_error( $post_ID ) )
     
    41694171                if ( isset( $content_struct['wp_post_format'] ) )
    41704172                        set_post_format( $post_ID, $content_struct['wp_post_format'] );
    41714173
     4174                $postdata['slashed'] = false;
     4175
    41724176                $post_ID = wp_insert_post( $postdata, true );
    41734177                if ( is_wp_error( $post_ID ) )
    41744178                        return new IXR_Error(500, $post_ID->get_error_message());
  • wp-includes/nav-menu.php

     
    357357        if ( ! $update ) {
    358358                $post['ID'] = 0;
    359359                $post['post_status'] = 'publish' == $args['menu-item-status'] ? 'publish' : 'draft';
     360                $post_data['slashed'] = false;
    360361                $menu_item_db_id = wp_insert_post( $post );
    361362                if ( ! $menu_item_db_id || is_wp_error( $menu_item_db_id ) )
    362363                        return $menu_item_db_id;
  • wp-mail.php

     
    202202        $post_category = array(get_option('default_email_category'));
    203203
    204204        $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status');
     205        $post_data['slashed'] = false;
    205206
    206207        $post_ID = wp_insert_post($post_data);
    207208        if ( is_wp_error( $post_ID ) )
  • wp-admin/includes/post.php

     
    440440                $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ));
    441441
    442442        if ( $create_in_db ) {
    443                 $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
     443                $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft', 'slashed' => false ) );
    444444                $post = get_post( $post_id );
    445445                if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) )
    446446                        set_post_format( $post, get_option( 'default_post_format' ) );
     
    566566        }
    567567
    568568        // Create the post.
    569         $post_ID = wp_insert_post( wp_unslash( $_POST ) );
     569        $post = wp_unslash( $_POST );
     570        $post['slashed'] = false;
     571        $post_ID = wp_insert_post( $post );
    570572        if ( is_wp_error( $post_ID ) )
    571573                return $post_ID;
    572574