monsterinsights_get_addons

Retrieves addons from the stored transient or remote server.

Description

monsterinsights_get_addons(); 

Usage

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

Defined (1)

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

/includes/admin/pages/addons.php  
  1. function monsterinsights_get_addons() { 
  2.  
  3. // Get license key and type. 
  4.  
  5. // Get addons data from transient or perform API query if no transient. 
  6. if ( false === ( $addons = get_transient( '_monsterinsights_addons' ) ) ) { 
  7. $addons = monsterinsights_get_addons_data( $key ); 
  8.  
  9. // If no Addons exist, return false 
  10. if ( ! $addons ) { 
  11. return false; 
  12.  
  13. // Iterate through Addons, to build two arrays:  
  14. // - Addons the user is licensed to use,  
  15. // - Addons the user isn't licensed to use. 
  16. $results = array( 
  17. 'licensed' => array(),  
  18. 'unlicensed'=> array(),  
  19. ); 
  20. foreach ( (array) $addons as $i => $addon ) { 
  21.  
  22. // Determine whether the user is licensed to use this Addon or not. 
  23. if (  
  24. empty( $type ) || 
  25. ( in_array( 'Pro', $addon->categories ) && ( $type != 'pro' && $type != 'master' ) ) || 
  26. ( in_array( 'Plus', $addon->categories ) && $type != 'plus' && $type != 'pro' && $type != 'master' ) || 
  27. ( in_array( 'Basic', $addon->categories ) && ( $type != 'basic' && $type != 'plus' && $type != 'pro' && $type != 'master' ) ) 
  28. ) { 
  29. // Unlicensed 
  30. $results['unlicensed'][] = $addon; 
  31. continue; 
  32.  
  33. // Licensed 
  34. $results['licensed'][] = $addon; 
  35.  
  36.  
  37. // Return Addons, split by licensed and unlicensed. 
  38. return $results; 
  39.