Inpsyde\MultilingualPress\Module\Trasher\Trasher::trash_related_posts PHP Method

    public function trash_related_posts($post_id)
    {
        if (!$this->setting_repository->get($post_id)) {
            return 0;
        }
        $current_site_id = get_current_blog_id();
        $related_posts = $this->content_relations->get_relations($current_site_id, $post_id, 'post');
        unset($related_posts[$current_site_id]);
        if (!$related_posts) {
            return 0;
        }
        $trashed_post = 0;
        // Temporarily remove the function to avoid recursion.
        $action = current_action();
        remove_action($action, [$this, __FUNCTION__]);
        array_walk($related_posts, function ($post_id, $site_id) use(&$trashed_post) {
            switch_to_blog($site_id);
            $trashed_post += (bool) wp_trash_post($post_id);
            restore_current_blog();
        });
        // Add the function back again.
        add_action($action, [$this, __FUNCTION__]);
        return $trashed_post;
    }