Defining Minimum Add-On Requirements

Defining Minimum Add-On Requirements

WordPress RequirementsWordPress VersionWordPress PluginsPlugin NamePHP RequirementsPHP VersionExtensionsExtension VersionFunctionsGravity Forms RequirementsGravity Forms Add-OnsAdd-On NameAdd-On VersionCustom 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 is as simple as overriding the minimum_requirements function in the GFAddOn class.
1234567891011class 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.
12345array(    '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.
12345array(    'wordpress' => array(        'version' => '4.6.2'    ))
WordPress Plugins
12345array(    'plugins' => array(        'rest-api/plugin.php',    ),)
Plugin Name
12345array(    '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.
12345array(    'php' => array(        // PHP-related requirements go here.    ))
PHP Version
12345array(    'php' => array(        'version' => '5.6',    ))
Extensions
1234567array(    'php' => array(        'extensions' => array(            'curl',        ),    ),)
Extension Version
123456789array(    'php' => array(        'extensions' => array(            'curl' => array(                'version' => '1.0',            ),        ),    ),)
Functions
1234567array(    'php' => array(        'functions' => array(            'openssl_random_pseudo_bytes',        ),    ),)
Gravity Forms Requirements
Gravity Forms Add-Ons
12345array(    'add-ons' => array(        'gravityformsmailchimp',    ),)
Add-On Name
1234567array(    'add-ons' => array(        'gravityformsstripe' => array(            'name' => 'Gravity Forms Stripe Add-On',        ),    ),)
Add-On Version
1234567array(    'add-ons' => array(        'gravityformspaypal' => array(            'version' => '5.0',        ),    ),)
Custom Requirements
123array(    array( $this, 'custom_requirement_callback' ),)

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注