monsterinsights_get_addons_data

Pings the remote server for addons data.

Description

(array) monsterinsights_get_addons_data( (string) $key ); 

Returns (array)

Array of addon data otherwise.

Parameters (1)

0. $key (string)
The user license key.

Usage

  1. if ( !function_exists( 'monsterinsights_get_addons_data' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/admin/pages/addons.php'; 
  3.  
  4. // The user license key. 
  5. $key = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = monsterinsights_get_addons_data($key); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/admin/pages/addons.php  
  1. function monsterinsights_get_addons_data( $key ) { 
  2. // Get the base class object. 
  3. $base = MonsterInsights(); 
  4.  
  5. // Get Addons 
  6. // If the key is valid, we'll get personalised upgrade URLs for each Addon (if necessary) and plugin update information. 
  7. if ( $key && $type !== 'basic' ) { 
  8. $addons = $base->license->perform_remote_request( 'get-addons-data-v600', array( 'tgm-updater-key' => $key ) );  
  9. } else { 
  10. $addons = $base->license->perform_remote_request( 'get-all-addons-data', array() );  
  11.  
  12. // If there was an API error, set transient for only 10 minutes. 
  13. if ( ! $addons ) { 
  14. set_transient( '_monsterinsights_addons', false, 10 * MINUTE_IN_SECONDS ); 
  15. return false; 
  16.  
  17. // If there was anerrorretrieving the addons, set the error. 
  18. if ( isset( $addons->error ) ) { 
  19. set_transient( '_monsterinsights_addons', false, 10 * MINUTE_IN_SECONDS ); 
  20. return false; 
  21.  
  22. // Otherwise, our request worked. Save the data and return it. 
  23. set_transient( '_monsterinsights_addons', $addons, 4 * HOUR_IN_SECONDS ); 
  24. return $addons; 
  25.