Gravity_Api
Client-side API wrapper for interacting with the Gravity APIs.
Since: 1.9
Source: includes/class-gravity-api.php:21
Details
- Kind:
class - Namespace:
(global)
Methods
| Method | Description |
|---|---|
register_current_site() | Retrieves site key and site secret key from remote API and stores them as WP options. Returns false if license key is invalid; otherwise, returns true. |
update_current_site() | Updates license key for a site that has already been registered. |
check_license() | Check the given license key to get its information from the API. |
get_plugins_info() | Get GF core and add-on family information. |
update_site_data() | Update the usage data (call version.php in Gravity Manager). We will replace it once we have statistics API endpoints. |
get_key() | |
prepare_response_body() | Prepare response body. |
purge_site_credentials() | Purge the site credentials. |
request() | Making API requests. |
get_site_key() | |
get_site_secret() | |
get_gravity_api_url() | |
is_site_registered() | Check if the site has the gf_site_key and gf_site_secret options. |
is_legacy_registration() | Check if the site has the gf_site_key, gf_site_secret and also the gf_site_registered options. |
Method Reference
register_current_site()
public function register_current_site( $license_key, $is_md5=false )
Retrieves site key and site secret key from remote API and stores them as WP options. Returns false if license key is invalid; otherwise, returns true.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$license_key | string | License key to be registered. | |
$is_md5 | boolean | false | Specifies if $license_key provided is an MD5 or unhashed license key. |
Returns
bool| WP_Error
Since: 2.3
Source: includes/class-gravity-api.php:45
update_current_site()
public function update_current_site( $new_license_key_md5 )
Updates license key for a site that has already been registered.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$new_license_key_md5 | string | Hash license key to be updated |
Returns
Since:
2.32.5(Returns License Response on success.)
Source: includes/class-gravity-api.php:88
check_license()
public function check_license( $key )
Check the given license key to get its information from the API.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$key | string | The license key. |
Returns
array|false| WP_Error
Since: 2.5
Source: includes/class-gravity-api.php:165
get_plugins_info()
public function get_plugins_info()
Get GF core and add-on family information.
Returns
false|array
Since: 2.5
Source: includes/class-gravity-api.php:205
update_site_data()
public function update_site_data()
Update the usage data (call version.php in Gravity Manager). We will replace it once we have statistics API endpoints.
Since: 2.5
Source: includes/class-gravity-api.php:322
get_key()
public function get_key()
Returns
false|mixed|void
Source: includes/class-gravity-api.php:379
prepare_response_body()
public function prepare_response_body( $raw_response, $as_array=false )
Prepare response body.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$raw_response | WP_Error | WP_REST_Response | The API response. | |
$as_array | bool | false | Whether to return the response as an array or object. |
Returns
array|object| WP_Error
Since:
unknown2.5(Support a WP_Error being returned.)2.5(Allow results to be returned as array with second param.)
Source: includes/class-gravity-api.php:433
purge_site_credentials()
public function purge_site_credentials()
Purge the site credentials.
Since:
unknown2.5(Added the deletion of the gf_site_registered option.)
Source: includes/class-gravity-api.php:468
request()
public function request( $resource, $body, $method='POST', $options=[] )
Making API requests.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$resource | string | The API route. | |
$body | array | The request body. | |
$method | string | 'POST' | The method. |
$options | array | [] | The options. |
Returns
array| WP_Error
Since:
unknown2.5(Purge the registration data on site if certain errors matched.)
Source: includes/class-gravity-api.php:489
get_site_key()
public function get_site_key()
Returns
false|mixed|void
Source: includes/class-gravity-api.php:519
get_site_secret()
public function get_site_secret()
Returns
false|mixed|void
Source: includes/class-gravity-api.php:537
get_gravity_api_url()
public function get_gravity_api_url()
Returns
string
Source: includes/class-gravity-api.php:552
is_site_registered()
public function is_site_registered()
Check if the site has the gf_site_key and gf_site_secret options.
Returns
bool
Since: unknown
Source: includes/class-gravity-api.php:563
is_legacy_registration()
public function is_legacy_registration()
Check if the site has the gf_site_key, gf_site_secret and also the gf_site_registered options.
Returns
bool
Since: 2.5
Source: includes/class-gravity-api.php:574