Skip to content

Setting up Requirements for the plugin

Sumit Pore edited this page Apr 29, 2019 · 2 revisions

Introduction

Every plugin has one or more of the following dependencies

  • PHP Version - Plugin needs a minimum php version to function properly.
  • WP Version - Plugin needs a minimum WP version to function properly.
  • Required Plugin(s) - Plugin is an extension to some other plugin.

These dependencies can be defined in requirements-config.php file inside your plugin folder.

Let's say your plugin needs php 7.1+, WordPress 5.0+ & WooCommerce 3.5+, then requirements-config.php file will look like this.

<?php
return [

	'min_php_version' => '7.1', // Minimum PHP Version.

	'min_wp_version' => '5.0',  // Minimum WordPress Version.

	'required_plugins' => [ // Plugins on which our plugin is dependent on.

		
		'WooCommerce' => [
			'plugin_slug' => 'woocommerce/woocommerce.php',
			'min_plugin_version' => '3.5',
		],

	],

];

You can pass as many plugins as you want in required_plugins section. All keys in requirement-config.php file are optional.

Pass key is_multisite_compatible with value true if your plugin supports WordPress MultiSite.

What will happen if I don't pass the minimum php version in requirement-config.php?

If you don't pass php version specifically in requirements-config.php, then the plugin will consider 5.6 to be the minimum php version installed.

What will happen if I don't pass the minimum WordPress/WP version in requirement-config.php?

If you don't pass WordPress version specifically in requirements-config.php, then the plugin will consider 4.8 to be the minimum wp version installed.

What happens when the plugin is installed on a site where dependencies are not met?

If a customer activates the plugin on a site and dependencies are not met, then the plugin will show the information about dependencies that are not met & will deactivate itself.

If dependencies were met during activation but somewhere down the road dependencies failed (e.g. customer installed an older version of one of the required_plugins), then in that case too, the plugin will deactivate itself & notify about dependencies are not met.