CommentModel::$ancestor_id_meta_key, 'meta_value' => $comment_ID, ]); $child_comments = get_comments([ 'parent' => $comment_ID, ]); // set children's parent to 0 foreach ($child_comments as $child_comment) { // https://developer.wordpress.org/reference/functions/wp_insert_comment/ wp_update_comment([ 'comment_ID' => $child_comment->comment_ID, 'comment_parent' => 0, ], false); } // update ancestor for descendant foreach ($descendant_comments as $descendant_comment) { CommentModel::update_comment_ancestor_meta($descendant_comment->comment_ID); } } } public static function after_switch_theme_actions(string $old_name, WP_Theme $old_theme) { CommentController::init_comment_ancestor_meta(); } public static function filter_rest_allow_anonymous_comments($false, $request) { // return [ // 'code' => 123 // ]; throw new \Exception("opps"); // return true; } }