Make WordPress Core

Ticket #43019: 43019.2.diff

File 43019.2.diff, 832 bytes (added by henry.wright, 7 years ago)
  • src/wp-includes/post.php

    diff --git src/wp-includes/post.php src/wp-includes/post.php
    index 1796dde..ee66869 100644
    function wp_insert_post( $postarr, $wp_error = false ) { 
    32143214
    32153215        $postarr = wp_parse_args( $postarr, $defaults );
    32163216
     3217        // The data is innocent until proven guilty.
     3218        $is_valid = true;
     3219
     3220        /**
     3221         * Hooks in before insert post is properly run.
     3222         *
     3223         * @since 4.9
     3224         *
     3225         * @param bool $is_valid An indicator of whether the post data is valid.
     3226         * @param array $postarr An array of raw post data.
     3227        */
     3228        $is_valid = apply_filters( 'pre_insert_post', $is_valid, $postarr );
     3229
     3230        if ( ! $is_valid ) {
     3231                return new WP_Error( 'invalid_data', __( "The data supplied isn't valid." ) );
     3232        }
     3233
    32173234        unset( $postarr['filter'] );
    32183235
    32193236        $postarr = sanitize_post( $postarr, 'db' );