WordPress.org

Making WordPress.org

#1730 closed defect (fixed)

Fix auto-linking of inline @see tags for dynamic hooks.

Reported by: coffee2code Owned by: coffee2code
Milestone: Priority: normal
Component: Developer Hub Keywords:
Cc:

Description

As spotted by @DrewAPicture, dynamic hooks referenced via inline@see tags are not linked properly.

For example: https://developer.wordpress.org/reference/functions/get_page_template/ contains a generated URL for the $type_template dynamic hook of:

https://developer.wordpress.org/reference/functions/‘$type_template’

The URL should be:

https://developer.wordpress.org/reference/hooks/type_template/

The issue stems from the presence of the $ in dynamic hooks, which causes the current link_internal_element() regex for hooks to fail, leading to the fallback conditional block (which is meant to handle functions) to be executed. This is the reason the bad URL is pointing to /functions/ and not /hooks/.

And, obviously, the proper link should also be sanitized to remove the $, ‘, and ’.

Change History (1)

#1 @coffee2code
19 months ago

  • Owner set to coffee2code
  • Resolution set to fixed
  • Status changed from new to closed

In 3233:

developer.wordpress.org: Fix auto-linking of inline @see tags for dynamic hooks.

  • Fix regex for hooks in link_internal_element () to allow $.
  • Remove $ and encoded quotes from hook slug in URL.
  • Don't capture encoded quotes in match for slug, saving the need to remove them.

Fixes #1730.

Note: See TracTickets for help on using tickets.