Falcon_Connector_WordPress::get_thread_subscribers PHP Метод

get_thread_subscribers() защищенный Метод

Gets subscribers to the thread (i.e. parent comment authors who are subscribed) as well as subscribers to all threads (i.e. comment authors who are subscribed to all comments on the post)
protected get_thread_subscribers ( stdClass $comment ) : array
$comment stdClass Comment being checked
Результат array
    protected function get_thread_subscribers($comment)
    {
        $sibling_comments = get_comments(array('post_id' => $comment->comment_post_ID, 'comment__not_in' => $comment->comment_ID, 'type' => 'comment'));
        if (empty($sibling_comments)) {
            return array();
        }
        $users = array();
        $indexed = array();
        foreach ($sibling_comments as $sibling) {
            // Re-index by ID for later usage
            $indexed[$sibling->comment_ID] = $sibling;
            // Grab just comments with author IDs
            if (empty($sibling->user_id)) {
                continue;
            }
            // Skip duplicate parsing
            if (isset($users[$sibling->user_id])) {
                continue;
            }
            $pref = get_user_meta($sibling->user_id, $this->key_for_setting('notifications.comment'), true);
            $users[$sibling->user_id] = $pref === 'participant';
        }
        // Now, find users in the thread
        $sibling = $comment;
        while (!empty($sibling->comment_parent)) {
            $parent_id = $sibling->comment_parent;
            if (!isset($indexed[$parent_id])) {
                break;
            }
            $sibling = $indexed[$parent_id];
            if (!isset($sibling->user_id)) {
                continue;
            }
            $pref = get_user_meta($sibling->user_id, $this->key_for_setting('notifications.comment'), true);
            if ($pref) {
                $users[$sibling->user_id] = true;
            }
        }
        $subscribers = array();
        foreach ($users as $user => $subscribed) {
            if (!$subscribed) {
                continue;
            }
            $subscribers[] = get_userdata($user);
        }
        return $subscribers;
    }