Skip to main content

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

MethodDescription
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

NameTypeDefaultDescription
$license_keystringLicense key to be registered.
$is_md5booleanfalseSpecifies if $license_key provided is an MD5 or unhashed license key.

Returns

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

NameTypeDefaultDescription
$new_license_key_md5stringHash license key to be updated

Returns

Since:

  • 2.3
  • 2.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

NameTypeDefaultDescription
$keystringThe license key.

Returns

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

NameTypeDefaultDescription
$raw_responseWP_Error | WP_REST_ResponseThe API response.
$as_arrayboolfalseWhether to return the response as an array or object.

Returns

Since:

  • unknown
  • 2.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:

  • unknown
  • 2.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

NameTypeDefaultDescription
$resourcestringThe API route.
$bodyarrayThe request body.
$methodstring'POST'The method.
$optionsarray[]The options.

Returns

Since:

  • unknown
  • 2.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