Making WordPress.org

Opened 3 years ago

Closed 8 months ago

#6039 closed enhancement (wontfix)

Functions broken links at plugin editor

Reported by: mehedi890's profile mehedi890 Owned by:
Milestone: Priority: low
Component: API Keywords:
Cc:

Attachments (2)

plugin-editor.png (35.7 KB) - added by mehedi890 3 years ago.
broken-link.png (15.3 KB) - added by mehedi890 3 years ago.

Download all attachments as: .zip

Change History (6)

@mehedi890
3 years ago

#1 follow-up: @SergeyBiryukov
3 years ago

  • Component changed from Plugin Directory to Developer Hub

Hi there, welcome to WordPress Meta Trac! Thanks for the report.

Just copying my response from #WP54891 for some more context.

It looks like most of these functions come from WooCommerce and not from WordPress core, so they don't exist in the function reference.

The Look Up button in the plugin/theme editor appears to send the function name to an endpoint like this:
https://api.wordpress.org/core/handbook/1.0/?function=woocommerce_template_loop_price
which then redirects to the resulting URL.

Apparently the endpoint needs some adjustment to avoid linking WooCommerce functions to the WordPress core function reference.

#2 in reply to: ↑ 1 @mehedi890
3 years ago

WP_Query class is also in there
WP_Query() https://developer.wordpress.org/reference/functions/WP_Query/

I think this also needs to be fixed.

#3 @SergeyBiryukov
3 years ago

Right, the correct URL for WP_Query would be this one:
https://developer.wordpress.org/reference/classes/wp_query/

#4 @coffee2code
8 months ago

  • Component changed from Developer Hub to API
  • Priority changed from normal to low
  • Resolution set to wontfix
  • Status changed from new to closed
  • Type changed from defect (bug) to enhancement

Thanks for the report!

The case of WP_Query or any other class being requested as a function (and more broadly, any parsed post type that isn't found is looked for as any other parsed post type) as of wporg-developer/fcfebee:

Redirects: Redirect 404 request to a single parsed post type to a match in another parsed post type.

As for the issue of links to non-WP functions pointing to nonexistent Code Reference pages... it's not easily mitigated and probably not worth the effort to implement and maintain (especially for something not widely used).

For this plugin editor functionality, Core uses wp_doc_link_parse() on every .php file to extract functions. That is only modified by the 'documentation_ignore_functions' hook, and thus is a straightforward list of all used functions. No checks occur to see if the function belongs to WP or not. All functions blindly link to the api.wordpress.org/core/handbook/1.0/ endpoint.

That endpoint does not do anything too intelligent either. If the function is a PHP function, it'll redirect to the php.net documentation for it. Otherwise, it assumes it is a WP function and redirects to the Developer Code Reference as if the function documentation existed. The endpoint has no knowledge of what is an actual WP function (and doesn't even load WP itself).

Getting a 404 is the expected outcome for a non-WP class or function such as WC(). The endpoint couldn't possibly know what all non-WP functions relate to and where they are documented (assuming they are). So as far as the endpoint is concerned, that's probably as good as this will be. Ideally WP wouldn't link non-WP functions/classes (which happens before the endpoint is involved). However, WP wouldn't know anything about that without calling out to a different (and smarter) endpoint (and awaiting its response) or already having that information baked into WP or extracted from the running WP instance.

Ultimately, I consider this is a wontfix, though I fully acknowledge the current situation isn't ideal.

Note: See TracTickets for help on using tickets.