Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#14808 new enhancement

Add Editor Documentation Functions URL for theme-defined functions

Reported by: GamajoTech Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch
Focuses: Cc:


Currently, functions that are called within template files shown on the editor are included in the list of functions that you can try and lookup documentation for.

(The $ignore_functions array only seems to be for functions defined, not called, in a file.)

As the http://api.wordpress.org/core/handbook/1.0/?function=... seems to be hard-coded in, it's not possible for themes to overwrite it for functions they've defined.

Is it possible to allow themes to define where the documentation lookup should be for their own functions?

Attachments (1)

14808.diff (1.2 KB) - added by GaryJ 3 years ago.
First draft.

Download all attachments as: .zip

Change History (5)

comment:1 nacin3 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

GaryJ3 years ago

First draft.

comment:2 GaryJ3 years ago

  • Cc gary@… added

First attempt at adding a filter here.

  • esc_url() may or may not be the right escape here.
  • The filter name may need to be a less general name if the plugin editor can't be filtered with the same signature.
  • The current theme and file path are passed as arguments, so the URL can be changed conditionally.
  • It may be that passing the full path as the $file is not helpful, and can perhaps be trimmed down to be a relative path from the theme folder.

Themes could now filter the URL as per normal:

add_filter( 'documentation_url', 'child_documentation_url', 10, 3 );
 * Filter the function documentation URL in theme editor.
 * @param string $url
 * @param string $theme Name of the theme
 * @param string $file full path of the file being edited
 * @return string
function child_documentation_url( $url, $theme, $file ) {

	if ( 'My Awesome Theme' != $theme )
		return $url;

	return 'http://my.example.com/?theme= ' . $theme . '&function=';


It would then be up to the script at my.example.com to check the function name against a list of known functions for that theme (or at least ones they want to provide documentation for - could even provide more detailed documentation for WP functions) and redirect to their own documentation, or redirect back to api.wordpress.org/code/handbook/1.0/?function= accordingly.

comment:3 defries3 years ago

  • Cc remkus@… added

comment:4 SergeyBiryukov3 years ago

  • Keywords has-patch added; needs-patch removed
Note: See TracTickets for help on using tickets.