Collections functions
General functions
Render functions
Theme permission functions
Resource functions

find_root_comment()

Description

Find the root of a comment tree that the ref provided is a part of

Parameters

ColumnTypeDefaultDescription
$ref int ref of a comment

Return

int|null ref of the root comment or null if the comment tree has been completely removed / the comment being checked has already been deleted.

Location

include/comment_functions.php lines 161 to 176

Definition

 
function find_root_comment($ref)
    {
    
$comment ps_query('SELECT ref, ref_parent FROM comment WHERE ref = ?', ['i'$ref]);

    if(
is_array($comment) && !empty($comment))
        {
        
$comment $comment[0];

        if(!empty(
$comment['ref_parent']))
            {
            return 
find_root_comment($comment['ref_parent']);
            }
        return 
$comment['ref'];
        }
    return 
null;
    }

This article was last updated 26th June 2022 06:05 Europe/London time based on the source file dated 21st June 2022 10:00 Europe/London time.