@@ 1384-1418 (lines=35) @@ | ||
1381 | * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. |
|
1382 | * @return bool True on success, false on failure. |
|
1383 | */ |
|
1384 | function wp_untrash_comment($comment_id) { |
|
1385 | $comment = get_comment( $comment_id ); |
|
1386 | if ( ! $comment ) { |
|
1387 | return false; |
|
1388 | } |
|
1389 | ||
1390 | /** |
|
1391 | * Fires immediately before a comment is restored from the Trash. |
|
1392 | * |
|
1393 | * @since 2.9.0 |
|
1394 | * |
|
1395 | * @param int $comment_id The comment ID. |
|
1396 | */ |
|
1397 | do_action( 'untrash_comment', $comment->comment_ID ); |
|
1398 | ||
1399 | $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ); |
|
1400 | if ( empty($status) ) |
|
1401 | $status = '0'; |
|
1402 | ||
1403 | if ( wp_set_comment_status( $comment, $status ) ) { |
|
1404 | delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); |
|
1405 | delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); |
|
1406 | /** |
|
1407 | * Fires immediately after a comment is restored from the Trash. |
|
1408 | * |
|
1409 | * @since 2.9.0 |
|
1410 | * |
|
1411 | * @param int $comment_id The comment ID. |
|
1412 | */ |
|
1413 | do_action( 'untrashed_comment', $comment->comment_ID ); |
|
1414 | return true; |
|
1415 | } |
|
1416 | ||
1417 | return false; |
|
1418 | } |
|
1419 | ||
1420 | /** |
|
1421 | * Marks a comment as Spam |
|
@@ 1470-1504 (lines=35) @@ | ||
1467 | * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. |
|
1468 | * @return bool True on success, false on failure. |
|
1469 | */ |
|
1470 | function wp_unspam_comment( $comment_id ) { |
|
1471 | $comment = get_comment( $comment_id ); |
|
1472 | if ( ! $comment ) { |
|
1473 | return false; |
|
1474 | } |
|
1475 | ||
1476 | /** |
|
1477 | * Fires immediately before a comment is unmarked as Spam. |
|
1478 | * |
|
1479 | * @since 2.9.0 |
|
1480 | * |
|
1481 | * @param int $comment_id The comment ID. |
|
1482 | */ |
|
1483 | do_action( 'unspam_comment', $comment->comment_ID ); |
|
1484 | ||
1485 | $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ); |
|
1486 | if ( empty($status) ) |
|
1487 | $status = '0'; |
|
1488 | ||
1489 | if ( wp_set_comment_status( $comment, $status ) ) { |
|
1490 | delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); |
|
1491 | delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); |
|
1492 | /** |
|
1493 | * Fires immediately after a comment is unmarked as Spam. |
|
1494 | * |
|
1495 | * @since 2.9.0 |
|
1496 | * |
|
1497 | * @param int $comment_id The comment ID. |
|
1498 | */ |
|
1499 | do_action( 'unspammed_comment', $comment->comment_ID ); |
|
1500 | return true; |
|
1501 | } |
|
1502 | ||
1503 | return false; |
|
1504 | } |
|
1505 | ||
1506 | /** |
|
1507 | * The status of a comment by ID. |