Make WordPress Core

Opened 22 months ago

Closed 22 months ago

Last modified 21 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
22 months ago

This sounds like #61525.

#2 @dd32
22 months ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed

Duplicate of #61525.

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

#5 @afragen
22 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 22 months ago by afragen (previous) (diff)

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