Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/08/2017 04:06:24 AM (9 years ago)
Author:
johnjamesjacoby
Message:

General: Audit wp_insert_post() usages.

Return a WP_Error object in some instances, and explicitly do not in others.

Where possible, use the error message in the user feedback response.

Fixes #2817.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/replies/functions.php

    r6477 r6499  
    4343
    4444    // Insert reply
    45     $reply_id = wp_insert_post( $reply_data );
     45    $reply_id = wp_insert_post( $reply_data, false );
    4646
    4747    // Bail if no reply was added
     
    404404
    405405    // Insert reply
    406     $reply_id = wp_insert_post( $reply_data );
     406    $reply_id = wp_insert_post( $reply_data, true );
    407407
    408408    /** No Errors *************************************************************/
     
    492492    /** Errors ****************************************************************/
    493493
     494    // WP_Error
     495    } elseif ( is_wp_error( $reply_id ) ) {
     496        bbp_add_error( 'bbp_reply_error', sprintf( __( '<strong>ERROR</strong>: The following problem(s) occurred: %s', 'bbpress' ), $reply_id->get_error_message() ) );
     497
     498    // Generic error
    494499    } else {
    495         $append_error = ( is_wp_error( $reply_id ) && $reply_id->get_error_message() ) ? $reply_id->get_error_message() . ' ' : '';
    496         bbp_add_error( 'bbp_reply_error', __( '<strong>ERROR</strong>: The following problem(s) have been found with your reply:' . $append_error . 'Please try again.', 'bbpress' ) );
     500        bbp_add_error( 'bbp_reply_error', __( '<strong>ERROR</strong>: The reply was not created.', 'bbpress' ) );
    497501    }
    498502}
Note: See TracChangeset for help on using the changeset viewer.