Changeset 48208
- Timestamp:
- 06/28/2020 10:08:22 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r48207 r48208 657 657 * 658 658 * @since 2.0.0 659 * @since 4.7.0 The `$avoid_die` parameter was added, allowing the function to 660 * return a WP_Error object instead of dying. 659 * @since 4.7.0 The `$avoid_die` parameter was added, allowing the function 660 * to return a WP_Error object instead of dying. 661 * @since 5.5.0 The `$avoid_die` parameter was renamed to `$wp_error`. 661 662 * 662 663 * @global wpdb $wpdb WordPress database abstraction object. 663 664 * 664 665 * @param array $commentdata Contains information on the comment. 665 * @param bool $ avoid_dieWhen true, a disallowed comment will result in the function666 * @param bool $wp_error When true, a disallowed comment will result in the function 666 667 * returning a WP_Error object, rather than executing wp_die(). 667 668 * Default false. 668 669 * @return int|string|WP_Error Allowed comments return the approval status (0|1|'spam'|'trash'). 669 * If `$ avoid_die` is true, disallowed comments return a WP_Error.670 */ 671 function wp_allow_comment( $commentdata, $ avoid_die= false ) {670 * If `$wp_error` is true, disallowed comments return a WP_Error. 671 */ 672 function wp_allow_comment( $commentdata, $wp_error = false ) { 672 673 global $wpdb; 673 674 … … 724 725 $comment_duplicate_message = apply_filters( 'comment_duplicate_message', __( 'Duplicate comment detected; it looks as though you’ve already said that!' ) ); 725 726 726 if ( true === $avoid_die) {727 if ( $wp_error ) { 727 728 return new WP_Error( 'comment_duplicate', $comment_duplicate_message, 409 ); 728 729 } else { … … 742 743 * @since 2.3.0 743 744 * @since 4.7.0 The `$avoid_die` parameter was added. 745 * @since 5.5.0 The `$avoid_die` parameter was renamed to `$wp_error`. 744 746 * 745 747 * @param string $comment_author_IP Comment author's IP address. 746 748 * @param string $comment_author_email Comment author's email. 747 749 * @param string $comment_date_gmt GMT date the comment was posted. 748 * @param bool $ avoid_die Whether to prevent executing wp_die()749 * or die() if a comment flood is occurring.750 * @param bool $wp_error Whether to return a WP_Error object instead of executing 751 * wp_die() or die() if a comment flood is occurring. 750 752 */ 751 753 do_action( … … 754 756 $commentdata['comment_author_email'], 755 757 $commentdata['comment_date_gmt'], 756 $ avoid_die758 $wp_error 757 759 ); 758 760 … … 763 765 * 764 766 * @since 4.7.0 767 * @since 5.5.0 The `$avoid_die` parameter was renamed to `$wp_error`. 765 768 * 766 769 * @param bool $is_flood Is a comment flooding occurring? Default false. … … 768 771 * @param string $comment_author_email Comment author's email. 769 772 * @param string $comment_date_gmt GMT date the comment was posted. 770 * @param bool $ avoid_die Whether to prevent executing wp_die()771 * or die() if a comment flood is occurring.773 * @param bool $wp_error Whether to return a WP_Error object instead of executing 774 * wp_die() or die() if a comment flood is occurring. 772 775 */ 773 776 $is_flood = apply_filters( … … 777 780 $commentdata['comment_author_email'], 778 781 $commentdata['comment_date_gmt'], 779 $ avoid_die782 $wp_error 780 783 ); 781 784 … … 2140 2143 * @since 1.5.0 2141 2144 * @since 4.3.0 Introduced the `comment_agent` and `comment_author_IP` arguments. 2142 * @since 4.7.0 The `$avoid_die` parameter was added, allowing the function to 2143 * return a WP_Error object instead of dying. 2145 * @since 4.7.0 The `$avoid_die` parameter was added, allowing the function 2146 * to return a WP_Error object instead of dying. 2147 * @since 5.5.0 The `$avoid_die` parameter was renamed to `$wp_error`. 2144 2148 * @since 5.5.0 Introduced the `comment_type` argument. 2145 2149 * … … 2167 2171 * 'REMOTE_ADDR' in the `$_SERVER` superglobal sent in the original request. 2168 2172 * } 2169 * @param bool $ avoid_dieShould errors be returned as WP_Error objects instead of2170 * 2173 * @param bool $wp_error Should errors be returned as WP_Error objects instead of 2174 * executing wp_die()? Default false. 2171 2175 * @return int|false|WP_Error The ID of the comment on success, false or WP_Error on failure. 2172 2176 */ 2173 function wp_new_comment( $commentdata, $ avoid_die= false ) {2177 function wp_new_comment( $commentdata, $wp_error = false ) { 2174 2178 global $wpdb; 2175 2179 … … 2228 2232 $commentdata = wp_filter_comment( $commentdata ); 2229 2233 2230 $commentdata['comment_approved'] = wp_allow_comment( $commentdata, $ avoid_die);2234 $commentdata['comment_approved'] = wp_allow_comment( $commentdata, $wp_error ); 2231 2235 if ( is_wp_error( $commentdata['comment_approved'] ) ) { 2232 2236 return $commentdata['comment_approved']; … … 2245 2249 $commentdata = wp_filter_comment( $commentdata ); 2246 2250 2247 $commentdata['comment_approved'] = wp_allow_comment( $commentdata, $ avoid_die);2251 $commentdata['comment_approved'] = wp_allow_comment( $commentdata, $wp_error ); 2248 2252 if ( is_wp_error( $commentdata['comment_approved'] ) ) { 2249 2253 return $commentdata['comment_approved']; … … 2416 2420 * @since 2.0.0 2417 2421 * @since 4.9.0 Add updating comment meta during comment update. 2418 * @since 5.5.0 Allow returning a WP_Error object on failure.2422 * @since 5.5.0 The `$wp_error` parameter was added. 2419 2423 * 2420 2424 * @global wpdb $wpdb WordPress database abstraction object. … … 2489 2493 * 2490 2494 * @since 4.7.0 2491 * @since 5.5.0 Allow returning a WP_Error object on failure.2495 * @since 5.5.0 The `$wp_error` parameter was added. 2492 2496 * 2493 2497 * @param array $data The new, processed comment data.
Note: See TracChangeset
for help on using the changeset viewer.