As of Gravity Forms 2.2, add-ons can now easily define requirements that are needed before the add-on can be used. Defining requirements is as simple as overriding the minimum_requirements function in the GFAddOn class.
1 2 3 4 5 6 7 8 9 10 11 | class Example_AddOn extends GFAddOn { public function minimum_requirements() { return array ( 'wordpress' => array ( 'version' => '4.6.2' , ) ); } } |
WordPress Requirements
Using the wordpress array key, requirements based on the WordPress installation can be defined.
1 2 3 4 5 | array ( 'wordpress' => array ( // WordPress-related requirements go here. ) ) |
WordPress Version
Within the wordpress requirement, the version key can be used to define a specific WordPress version to be used as a minimum requirement. Versions higher than this number will succeed, while lower versions will fail.
1 2 3 4 5 | array ( 'wordpress' => array ( 'version' => '4.6.2' ) ) |
WordPress Plugins
1 2 3 4 5 | array ( 'plugins' => array ( 'rest-api/plugin.php' , ), ) |
Plugin Name
1 2 3 4 5 | array ( 'plugins' => array ( 'jetpack/jetpack.php' => 'Jetpack by WordPress.com' , ), ) |
PHP Requirements
Requirements related to PHP versions, extensions, or even available functions can be defined by using the php array key.
1 2 3 4 5 | array ( 'php' => array ( // PHP-related requirements go here. ) ) |
PHP Version
1 2 3 4 5 | array ( 'php' => array ( 'version' => '5.6' , ) ) |
Extensions
1 2 3 4 5 6 7 | array ( 'php' => array ( 'extensions' => array ( 'curl' , ), ), ) |
Extension Version
1 2 3 4 5 6 7 8 9 | array ( 'php' => array ( 'extensions' => array ( 'curl' => array ( 'version' => '1.0' , ), ), ), ) |
Functions
1 2 3 4 5 6 7 | array ( 'php' => array ( 'functions' => array ( 'openssl_random_pseudo_bytes' , ), ), ) |
Gravity Forms Requirements
Gravity Forms Add-Ons
1 2 3 4 5 | array ( 'add-ons' => array ( 'gravityformsmailchimp' , ), ) |
Add-On Name
1 2 3 4 5 6 7 | array ( 'add-ons' => array ( 'gravityformsstripe' => array ( 'name' => 'Gravity Forms Stripe Add-On' , ), ), ) |
Add-On Version
1 2 3 4 5 6 7 | array ( 'add-ons' => array ( 'gravityformspaypal' => array ( 'version' => '5.0' , ), ), ) |
Custom Requirements
1 2 3 | array ( array ( $this , 'custom_requirement_callback' ), ) |