Make WordPress Core

Opened 18 months ago

Closed 18 months ago

Last modified 18 months ago

#62888 closed defect (bug) (duplicate)

Plugin dependencies and "pro" version

Reported by: hupe13 Owned by:
Priority: normal Milestone:
Component: HTTP API Version: 6.7.1
Severity: normal Keywords:
Cc: Focuses: administration, performance

Description

This post shows how to use wp_plugin_dependencies_slug. Now every plugin listing (/wp-admin/plugins.php) makes a request to https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request%5Bslug%5D=my-plugin-pro&request%5Bfields%5D%5Bshort_description%5D=1&request%5Bfields%5D%5Bicons%5D=1&request%5Blocale%5D=de_DE&request%5Bwp_version%5D=6.7"
This request fails with 404 because the "my-plugin-pro" is not hosted by WordPress and is not necessary.

Change History (6)

#1 @siliconforks
18 months ago

This sounds like #61525.

#2 @dd32
18 months ago

  • Milestone Awaiting Review
  • Resolutionduplicate
  • Status newclosed

Duplicate of #61525.

#3 @dd32
18 months ago

Just noting that per #61525, having my-plugin-pro as the dependency is probably incorrect, and it should have a URI or other namespaced value instead of just a slug (Which refers to a w.org plugin)

#4 @hupe13
18 months ago

Thank you very much, it works now like the example. But this should documented somewhere.

* Requires Plugins:  slug1, slug2, ||slug2-pro
Last edited 18 months ago by hupe13 (previous) (diff)

#5 @afragen
18 months ago

This should work.

add_filter(
	'wp_plugin_dependencies_slug',
	function ($slug) {
		$slug = 'my-plugin' === $slug ? 'my-plugin-pro' : $slug;

		return $slug;
	},
	10,
	1
);

Version 1, edited 18 months ago by afragen (previous) (next) (diff)

#6 @hupe13
18 months ago

The code post ist correct. I learned that you have to define a filter for plugins_api to prevent the not necessary HTTP-API-Requests.

Note: See TracTickets for help on using tickets.