Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 25th April 2024 21:35 Europe/London time based on the source file dated 8th March 2024 15:10 Europe/London time.