bookmark_borderDefining Minimum Add-On Requirements

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 are as simple as overriding the minimum_requirements function in the GFAddOn class.

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.

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.

array(
    'wordpress' => array(
        'version' => '4.6.2'
    )
)

WordPress Plugins

array(
    'plugins' => array(
        'rest-api/plugin.php',
    ),
)

Plugin Name

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.

array(
    'php' => array(
        // PHP-related requirements go here.
    )
)

PHP Version

array(
    'php' => array(
        'version' => '5.6',
    )
)

Extensions

array(
    'php' => array(
        'extensions' => array(
            'curl',
        ),
    ),
)

Extension Version

array(
    'php' => array(
        'extensions' => array(
            'curl' => array(
                'version' => '1.0',
            ),
        ),
    ),
)

Functions

array(
    'php' => array(
        'functions' => array(
            'openssl_random_pseudo_bytes',
        ),
    ),
)

Gravity Forms Requirements

Gravity Forms Add-Ons

array(
    'add-ons' => array(
        'gravityformsmailchimp',
    ),
)

Add-On Name

array(
    'add-ons' => array(
        'gravityformsstripe' => array(
            'name' => 'Gravity Forms Stripe Add-On',
        ),
    ),
)

Add-On Version

array(
    'add-ons' => array(
        'gravityformspaypal' => array(
            'version' => '5.0',
        ),
    ),
)

Custom Requirements

array(
    array( $this, 'custom_requirement_callback' ),
)