File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -1619,7 +1619,7 @@ function wp_trash_comment( $comment_id ) {
16191619
16201620 // For top level 'note' type comments, also trash any children as well.
16211621 if ( 'note ' === $ comment ->comment_type && 0 === (int ) $ comment ->comment_parent ) {
1622- wp_trash_comment_children ( $ comment ->comment_ID );
1622+ wp_trash_note_descendants ( $ comment ->comment_ID );
16231623 }
16241624
16251625 return true ;
@@ -1629,24 +1629,33 @@ function wp_trash_comment( $comment_id ) {
16291629}
16301630
16311631/**
1632- * Delete all of a note's children (replies).
1632+ * Trash all of a note's descendants (replies).
16331633 *
16341634 * @since 6.9.0
16351635 *
16361636 * @param int $comment_id The comment ID.
1637+ * @return bool Whether the descendants were successfully trashed.
16371638 */
1638- function wp_trash_comment_children ( $ comment_id ) {
1639- $ children = get_comments (
1639+ function wp_trash_note_descendants ( $ comment_id ) {
1640+ $ comment = get_comment ( $ comment_id );
1641+ if ( ! $ comment ) {
1642+ return false ;
1643+ }
1644+ $ children = $ comment ->get_children (
16401645 array (
1641- 'parent ' => $ comment_id ,
1646+ 'fields ' => ' ids ' ,
16421647 'status ' => 'all ' ,
16431648 'type ' => 'note ' ,
1644- 'fields ' => 'ids ' ,
16451649 )
16461650 );
1651+
1652+ $ success = true ;
16471653 foreach ( $ children as $ child_id ) {
1648- wp_trash_comment ( $ child_id );
1654+ if ( ! wp_trash_comment ( $ child_id ) ) {
1655+ $ success = false ;
1656+ }
16491657 }
1658+ return $ success ;
16501659}
16511660
16521661/**
You can’t perform that action at this time.
0 commit comments