WordPress.org

Make WordPress Core

Ticket #21767: 21767.20.diff

File 21767.20.diff, 2.5 KB (added by ryan, 5 years ago)

slashed arg for wp_insert_post, wp_update_post, wp_insert_attachment

  • wp-includes/post.php

     
    26182618 *     'guid'          - Global Unique ID for referencing the attachment.
    26192619 *     'post_content_filtered' - Post content filtered.
    26202620 *     'post_excerpt'  - Post excerpt.
     2621 *     'slashed'       - Whether the passed data is slashed or not. The default is true.
    26212622 *
    26222623 * @since 1.0.0
    26232624 * @uses $wpdb
     
    26392640                'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
    26402641                'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '',
    26412642                'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0,
    2642                 'post_content' => '', 'post_title' => '');
     2643                'post_content' => '', 'post_title' => '', 'slashed' => true );
    26432644
    26442645        $postarr = wp_parse_args($postarr, $defaults);
    26452646
    26462647        unset( $postarr[ 'filter' ] );
    26472648
     2649        if ( ! $postarr['slashed'] )
     2650                $postarr = wp_slash( $postarr );
     2651
    26482652        $postarr = sanitize_post($postarr, 'db');
    26492653
    26502654        // export array as variables
     
    29052909                // non-escaped post was passed
    29062910                $postarr = get_object_vars($postarr);
    29072911                $postarr = wp_slash($postarr);
     2912                $postarr['slashed'] = true;
     2913        } else {
     2914                if ( ! isset( $postarr['slashed'] ) )
     2915                        $postarr['slashed'] = true;
     2916
     2917                if ( ! $postarr['slashed'] )
     2918                        $postarr = wp_slash( $postarr );
    29082919        }
    29092920
    29102921        // First, get all of the original fields
     
    38583869 *     'guid'          - Global Unique ID for referencing the attachment.
    38593870 *     'post_content_filtered' - Attachment post content filtered.
    38603871 *     'post_excerpt'  - Attachment excerpt.
     3872 *     'slashed'       - Whether the passed data is slashed or not. The default is true.
    38613873 *
    38623874 * @since 2.0.0
    38633875 * @uses $wpdb
     
    38763888        $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_ID,
    38773889                'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
    38783890                'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '',
    3879                 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'context' => '');
     3891                'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'context' => '',
     3892                'slashed' => true );
    38803893
    38813894        $object = wp_parse_args($object, $defaults);
    38823895        if ( !empty($parent) )
     
    38843897
    38853898        unset( $object[ 'filter' ] );
    38863899
     3900        if ( ! $object['slashed'] )
     3901                $object = wp_slash( $object );
     3902
    38873903        $object = sanitize_post($object, 'db');
    38883904
    38893905        // export array as variables