1265 | | extract(wp_unslash($commentdata), EXTR_SKIP); |
| 1267 | $commentdata = wp_unslash( $commentdata ); |
| 1268 | $defaults = array( |
| 1269 | 'comment_post_ID' => null, |
| 1270 | 'comment_author' => '', |
| 1271 | 'comment_author_email' => '', |
| 1272 | 'comment_author_url' => '', |
| 1273 | 'comment_author_IP' => '', |
| 1274 | 'comment_date' => current_time( 'mysql', false ), |
| 1275 | 'comment_date_gmt' => current_time( 'mysql', true ), |
| 1276 | 'comment_content' => '', |
| 1277 | 'comment_karma' => 0, |
| 1278 | 'comment_approved' => 1, |
| 1279 | 'comment_agent' => '', |
| 1280 | 'comment_type' => '', |
| 1281 | 'comment_parent' => 0, |
| 1282 | 'user_id' => 0, |
| 1283 | ); |
| 1284 | $commentdata = array_merge( $defaults, $commentdata ); |
| 1285 | $data = array_intersect_key( $commentdata, $defaults ); |
| 1286 | $data = apply_filters( 'wp_insert_comment_data', $data ); |
| 1287 | extract($data, EXTR_SKIP); |
1267 | | if ( ! isset($comment_author_IP) ) |
1268 | | $comment_author_IP = ''; |
1269 | | if ( ! isset($comment_date) ) |
1270 | | $comment_date = current_time('mysql'); |
1271 | | if ( ! isset($comment_date_gmt) ) |
1272 | | $comment_date_gmt = get_gmt_from_date($comment_date); |
1273 | | if ( ! isset($comment_parent) ) |
1274 | | $comment_parent = 0; |
1275 | | if ( ! isset($comment_approved) ) |
1276 | | $comment_approved = 1; |
1277 | | if ( ! isset($comment_karma) ) |
1278 | | $comment_karma = 0; |
1279 | | if ( ! isset($user_id) ) |
1280 | | $user_id = 0; |
1281 | | if ( ! isset($comment_type) ) |
1282 | | $comment_type = ''; |
| 1289 | if ( empty( $comment_post_ID ) || ! get_post( $comment_post_ID ) ) { |
| 1290 | return new WP_Error( 'invalid_comment_post_id', __( 'Missing or invalid comment_post_ID' ) ); |
| 1291 | } |