wppaste
WordPress

get_comment_link( WP_Comment|int|null $comment = null, array $args = array() ): string

Since
1.5.0, 4.4.0
Source
wp-includes/comment-template.php:778
Retrieves the link to a given comment.

Compatibility

WordPress
since 4.4.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$commentWP_Comment|int|nulloptional
Comment to retrieve. Default current comment.Default: null
$argsarrayoptional
An array of optional arguments to override the defaults.Default: array()
  • $typestring

    Passed to get_page_of_comment().
  • $pageint

    Current page of comments, for calculating comment pagination.
  • $per_pageint

    Per-page value for comment pagination.
  • $max_depthint

    Passed to get_page_of_comment().
  • $cpageint|string

    Value to use for the comment's "comment-page" or "cpage" value. If provided, this value overrides any value calculated from $page and $per_page.

Return value

string
The permalink to the given comment.

Performance profile

How much work a call to get_comment_link() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reaches the database via get_post().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
43–108

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 123.

Plugin surface
1 hook

Third-party callbacks on 'get_comment_link' run inside this call, and their cost is not bounded by anything here.

Called by
21

21 places in core call this, so the cost is paid more often than your own code shows.

What it touches

  • optionoption read or writeget_option()called directly
  • hookthird-party callbacksapply_filters()called directly
  • querycontent queryget_post()one call below get_comment_link()
  • cacheobject cachewp_cache_get()one call below get_comment_link()
  • serializeserialisationmaybe_unserialize()one call below get_comment_link()

Further down the call graph this can also reach transient. That is the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 114 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost get_comment_link() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!$args && !->using_permalinks()43–45get_comment(), wp_parse_args(), get_permalink(), ->using_permalinks(), apply_filters()
!->using_permalinks()47–63get_comment(), wp_parse_args(), get_permalink(), get_option(), ->using_permalinks(), apply_filters()
!$args && ->using_permalinks()48–50get_comment(), wp_parse_args(), get_permalink(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && !->using_permalinks()51–53get_comment(), wp_parse_args(), get_permalink(), get_option(), ->using_permalinks(), ->using_permalinks(), apply_filters()
->using_permalinks()52–68get_comment(), wp_parse_args(), get_permalink(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option()56–58get_comment(), wp_parse_args(), get_permalink(), get_option(), ->using_permalinks(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$args && get_option() && !->using_permalinks()57–59get_comment(), wp_parse_args(), get_permalink(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), apply_filters()
get_option()57–59get_comment(), wp_parse_args(), get_permalink(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage !== "" && !get_option() && !->using_permalinks()58–67get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), ->using_permalinks(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && !$args && !->using_permalinks()62–71get_comment(), wp_parse_args(), get_permalink(), get_query_var(), get_option(), ->using_permalinks(), apply_filters()
$cpage !== "" && get_option() && !->using_permalinks()62–71get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), apply_filters()
$cpage !== "" && !->using_permalinks()62–72get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), ->using_permalinks(), apply_filters()
102 further outcomes, up to 108 instructions
$args && get_option()62–64get_comment(), wp_parse_args(), get_permalink(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && ->using_permalinks()62–64get_comment(), wp_parse_args(), get_permalink(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && empty($in_comment_loop) && !$args && !->using_permalinks()63–72get_comment(), wp_parse_args(), get_permalink(), get_page_of_comment(), get_option(), ->using_permalinks(), apply_filters()
$cpage !== "" && !get_option() && ->using_permalinks()63–72get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$args && get_option()65–67get_comment(), wp_parse_args(), get_permalink(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && $args && !get_option() && !->using_permalinks()66–75get_comment(), wp_parse_args(), get_permalink(), get_query_var(), get_option(), get_option(), ->using_permalinks(), apply_filters()
!get_option() && $cpage === "" && !empty($in_comment_loop) && !$args && !->using_permalinks()66–75get_comment(), wp_parse_args(), get_permalink(), get_option(), get_query_var(), get_option(), ->using_permalinks(), apply_filters()
$cpage !== "" && !->using_permalinks()66–75get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), apply_filters()
$cpage === "" && empty($in_comment_loop) && $args && !get_option() && !->using_permalinks()67–76get_comment(), wp_parse_args(), get_permalink(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && !$args && ->using_permalinks()67–76get_comment(), wp_parse_args(), get_permalink(), get_query_var(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
!get_option() && $cpage === "" && empty($in_comment_loop) && !$args && !->using_permalinks()67–76get_comment(), wp_parse_args(), get_permalink(), get_option(), get_page_of_comment(), get_option(), ->using_permalinks(), apply_filters()
$cpage !== "" && get_option()67–76get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage !== "" && ->using_permalinks()67–77get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage !== "" && $args && !->using_permalinks()67–76get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), get_option(), ->using_permalinks(), apply_filters()
$cpage === "" && empty($in_comment_loop) && !$args && ->using_permalinks()68–77get_comment(), wp_parse_args(), get_permalink(), get_page_of_comment(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage !== "" && $args && get_option() && !->using_permalinks()68–77get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), apply_filters()
$cpage !== "" && get_option()68–77get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && get_option() && !->using_permalinks()70–79get_comment(), wp_parse_args(), get_permalink(), get_query_var(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), apply_filters()
!get_option() && $cpage === "" && !empty($in_comment_loop) && $args && !->using_permalinks()70–79get_comment(), wp_parse_args(), get_permalink(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), apply_filters()
$args && get_option() && ->using_permalinks()70–72get_comment(), wp_parse_args(), get_permalink(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && empty($in_comment_loop) && get_option() && !->using_permalinks()71–80get_comment(), wp_parse_args(), get_permalink(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && $args && !get_option() && ->using_permalinks()71–80get_comment(), wp_parse_args(), get_permalink(), get_query_var(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
!get_option() && $cpage === "" && empty($in_comment_loop) && $args && !->using_permalinks()71–80get_comment(), wp_parse_args(), get_permalink(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), apply_filters()
!get_option() && $cpage === "" && !empty($in_comment_loop) && !$args && ->using_permalinks()71–80get_comment(), wp_parse_args(), get_permalink(), get_option(), get_query_var(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage === "" && !empty($in_comment_loop) && !$args && !->using_permalinks()71–80get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_query_var(), get_option(), ->using_permalinks(), apply_filters()
$cpage !== ""71–80get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage !== "" && !->using_permalinks()71–80get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), apply_filters()
$cpage === "" && empty($in_comment_loop) && $args && !get_option() && ->using_permalinks()72–81get_comment(), wp_parse_args(), get_permalink(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
!get_option() && $cpage === "" && empty($in_comment_loop) && !$args && ->using_permalinks()72–81get_comment(), wp_parse_args(), get_permalink(), get_option(), get_page_of_comment(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage === "" && empty($in_comment_loop) && !$args && !->using_permalinks()72–81get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_page_of_comment(), get_option(), ->using_permalinks(), apply_filters()
$cpage !== "" && $args && !->using_permalinks()72–81get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), apply_filters()
$cpage !== ""72–81get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage !== "" && $args && ->using_permalinks()72–81get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage !== "" && $args && get_option()73–82get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage !== "" && get_option() && ->using_permalinks()73–82get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && !->using_permalinks()74–83get_comment(), wp_parse_args(), get_permalink(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && get_option()75–84get_comment(), wp_parse_args(), get_permalink(), get_query_var(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && empty($in_comment_loop) && !->using_permalinks()75–84get_comment(), wp_parse_args(), get_permalink(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), apply_filters()
!get_option() && $cpage === "" && !empty($in_comment_loop) && $args && ->using_permalinks()75–84get_comment(), wp_parse_args(), get_permalink(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && $args && !->using_permalinks()75–84get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), apply_filters()
$cpage !== "" && $args && get_option()76–85get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage === "" && empty($in_comment_loop) && get_option()76–85get_comment(), wp_parse_args(), get_permalink(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && $args && get_option() && !->using_permalinks()76–85get_comment(), wp_parse_args(), get_permalink(), get_query_var(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && get_option()76–85get_comment(), wp_parse_args(), get_permalink(), get_query_var(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), apply_filters()
!get_option() && $cpage === "" && empty($in_comment_loop) && $args && ->using_permalinks()76–85get_comment(), wp_parse_args(), get_permalink(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && empty($in_comment_loop) && $args && !->using_permalinks()76–85get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), apply_filters()
get_option() && $cpage === "" && !empty($in_comment_loop) && !$args && ->using_permalinks()76–85get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_query_var(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage !== ""76–85get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && empty($in_comment_loop) && $args && get_option() && !->using_permalinks()77–86get_comment(), wp_parse_args(), get_permalink(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), apply_filters()
$cpage === "" && empty($in_comment_loop) && get_option()77–86get_comment(), wp_parse_args(), get_permalink(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), apply_filters()
get_option() && $cpage === "" && empty($in_comment_loop) && !$args && ->using_permalinks()77–86get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_page_of_comment(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage !== "" && $args77–86get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage !== "" && ->using_permalinks()77–86get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage !== "" && $args && !->using_permalinks()77–86get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), apply_filters()
get_option() && $cpage !== ""77–86get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage === "" && !empty($in_comment_loop)79–88get_comment(), wp_parse_args(), get_permalink(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage === "" && !empty($in_comment_loop) && !->using_permalinks()79–88get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), apply_filters()
$cpage !== "" && $args80–89get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage === "" && empty($in_comment_loop)80–89get_comment(), wp_parse_args(), get_permalink(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && $args && !->using_permalinks()80–89get_comment(), wp_parse_args(), get_permalink(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), apply_filters()
$cpage === "" && !empty($in_comment_loop)80–89get_comment(), wp_parse_args(), get_permalink(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), apply_filters()
get_option() && $cpage === "" && empty($in_comment_loop) && !->using_permalinks()80–89get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && $args && ->using_permalinks()80–89get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage !== "" && $args && get_option() && ->using_permalinks()81–90get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && $args && get_option()81–90get_comment(), wp_parse_args(), get_permalink(), get_query_var(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && get_option() && ->using_permalinks()81–90get_comment(), wp_parse_args(), get_permalink(), get_query_var(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && empty($in_comment_loop) && $args && !->using_permalinks()81–90get_comment(), wp_parse_args(), get_permalink(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), apply_filters()
$cpage === "" && empty($in_comment_loop)81–90get_comment(), wp_parse_args(), get_permalink(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage === "" && empty($in_comment_loop) && $args && ->using_permalinks()81–90get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && empty($in_comment_loop) && $args && get_option()82–91get_comment(), wp_parse_args(), get_permalink(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && empty($in_comment_loop) && get_option() && ->using_permalinks()82–91get_comment(), wp_parse_args(), get_permalink(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage !== "" && $args82–91get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage !== "" && ->using_permalinks()82–91get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && $args && get_option()84–93get_comment(), wp_parse_args(), get_permalink(), get_query_var(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), apply_filters()
get_option() && $cpage === "" && !empty($in_comment_loop)84–93get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && empty($in_comment_loop) && $args && get_option()85–94get_comment(), wp_parse_args(), get_permalink(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage !== "" && $args && ->using_permalinks()85–94get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && $args85–94get_comment(), wp_parse_args(), get_permalink(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && ->using_permalinks()85–94get_comment(), wp_parse_args(), get_permalink(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage !== "" && $args85–94get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), apply_filters()
get_option() && $cpage === "" && empty($in_comment_loop)85–94get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage === "" && !empty($in_comment_loop) && $args && !->using_permalinks()85–94get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), apply_filters()
get_option() && $cpage === "" && !empty($in_comment_loop)85–94get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage === "" && empty($in_comment_loop) && $args86–95get_comment(), wp_parse_args(), get_permalink(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && empty($in_comment_loop) && ->using_permalinks()86–95get_comment(), wp_parse_args(), get_permalink(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage === "" && empty($in_comment_loop) && $args && !->using_permalinks()86–95get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), apply_filters()
get_option() && $cpage === "" && empty($in_comment_loop)86–95get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && $args88–97get_comment(), wp_parse_args(), get_permalink(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && $args && get_option() && ->using_permalinks()89–98get_comment(), wp_parse_args(), get_permalink(), get_query_var(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && empty($in_comment_loop) && $args89–98get_comment(), wp_parse_args(), get_permalink(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage === "" && empty($in_comment_loop) && $args && get_option() && ->using_permalinks()90–99get_comment(), wp_parse_args(), get_permalink(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage !== "" && $args && ->using_permalinks()90–99get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage === "" && !empty($in_comment_loop) && $args90–99get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage === "" && !empty($in_comment_loop) && ->using_permalinks()90–99get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage === "" && empty($in_comment_loop) && $args91–100get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), add_query_arg(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage === "" && empty($in_comment_loop) && ->using_permalinks()91–100get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
$cpage === "" && !empty($in_comment_loop) && $args && ->using_permalinks()93–102get_comment(), wp_parse_args(), get_permalink(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage === "" && !empty($in_comment_loop) && $args93–102get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), apply_filters()
$cpage === "" && empty($in_comment_loop) && $args && ->using_permalinks()94–103get_comment(), wp_parse_args(), get_permalink(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage === "" && empty($in_comment_loop) && $args94–103get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), apply_filters()
get_option() && $cpage === "" && !empty($in_comment_loop) && $args && ->using_permalinks()98–107get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_query_var(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()
get_option() && $cpage === "" && empty($in_comment_loop) && $args && ->using_permalinks()99–108get_comment(), wp_parse_args(), get_permalink(), get_option(), get_option(), get_page_of_comment(), get_option(), get_option(), ->using_permalinks(), trailingslashit(), user_trailingslashit(), ->using_permalinks(), user_trailingslashit(), apply_filters()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 123 instructions, 43–108 executed per call, 15 branches. The work does not change between versions.

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 1

One hook fires while get_comment_link() runs, in this order:

  1. apply_filters( get_comment_link )filterline 866 (+88 into the body)

    Filters the returned single comment permalink.

Uses · 10

Used by · 21

Show all 21

Source code

function get_comment_link( $comment = null, $args = array() ) {	global $wp_rewrite, $in_comment_loop; 	$comment = get_comment( $comment ); 	// Back-compat.	if ( ! is_array( $args ) ) {		$args = array( 'page' => $args );	} 	$defaults = array(		'type'      => 'all',		'page'      => '',		'per_page'  => '',		'max_depth' => '',		'cpage'     => null,	); 	$args = wp_parse_args( $args, $defaults ); 	$comment_link = get_permalink( $comment->comment_post_ID ); 	// The 'cpage' param takes precedence.	if ( ! is_null( $args['cpage'] ) ) {		$cpage = $args['cpage']; 		// No 'cpage' is provided, so we calculate one.	} else {		if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) {			$args['per_page'] = get_option( 'comments_per_page' );		} 		if ( empty( $args['per_page'] ) ) {			$args['per_page'] = 0;			$args['page']     = 0;		} 		$cpage = $args['page']; 		if ( '' === $cpage ) {			if ( ! empty( $in_comment_loop ) ) {				$cpage = (int) get_query_var( 'cpage' );			} else {				// Requires a database hit, so we only do it when we can't figure out from context.				$cpage = get_page_of_comment( $comment->comment_ID, $args );			}		} 		/*		 * If the default page displays the oldest comments, the permalinks for comments on the default page		 * do not need a 'cpage' query var.		 */		if ( 'oldest' === get_option( 'default_comments_page' ) && 1 === $cpage ) {			$cpage = '';		}	} 	if ( $cpage && get_option( 'page_comments' ) ) {		if ( $wp_rewrite->using_permalinks() ) {			if ( $cpage ) {				$comment_link = trailingslashit( $comment_link ) . $wp_rewrite->comments_pagination_base . '-' . $cpage;			} 			$comment_link = user_trailingslashit( $comment_link, 'comment' );		} elseif ( $cpage ) {			$comment_link = add_query_arg( 'cpage', $cpage, $comment_link );		}	} 	if ( $wp_rewrite->using_permalinks() ) {		$comment_link = user_trailingslashit( $comment_link, 'comment' );	} 	$comment_link = $comment_link . '#comment-' . $comment->comment_ID; 	/**	 * Filters the returned single comment permalink.	 *	 * @since 2.8.0	 * @since 4.4.0 Added the `$cpage` parameter.

Changelog

Introduced in 1.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

4.4.0
Added the ability for $comment to also accept a WP_Comment object. Added $cpage argument.from the docblock
1.5.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/comment-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.