Make WordPress Core

Opened 4 months ago

Closed 4 months ago

Last modified 3 months ago

#62888 closed defect (bug) (duplicate)

Plugin dependencies and "pro" version

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

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
4 months ago

This sounds like #61525.

#2 @dd32
4 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #61525.

#3 @dd32
4 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
4 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 4 months ago by hupe13 (previous) (diff)

#5 @afragen
3 months ago

This should work for when there are both freemium and premium plugins.

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

		return $slug;
	},
	10,
	1
);

Last edited 3 months ago by afragen (previous) (diff)

#6 @hupe13
3 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.