pmpro_getPluginAPIObjectFromAddon

Convert the format from the pmpro_getAddons function to that needed for plugins_api.

Description

pmpro_getPluginAPIObjectFromAddon( $addon ); 

Parameters (1)

0. $addon
The addon.

Usage

  1. if ( !function_exists( 'pmpro_getPluginAPIObjectFromAddon' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/addons.php'; 
  3.  
  4. // The addon. 
  5. $addon = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = pmpro_getPluginAPIObjectFromAddon($addon); 
  9.  

Defined (1)

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

/includes/addons.php  
  1. function pmpro_getPluginAPIObjectFromAddon($addon) 
  2. $api = new stdClass; 
  3.  
  4. if(empty($addon)) 
  5. return $api; 
  6.  
  7. $api->name = isset( $addon['Name'] ) ? $addon['Name'] : ''; 
  8. $api->slug = isset( $addon['Slug'] ) ? $addon['Slug'] : ''; 
  9. $api->plugin = isset( $addon['plugin'] ) ? $addon['plugin'] : ''; 
  10. $api->version = isset( $addon['Version'] ) ? $addon['Version'] : ''; 
  11. $api->author = isset( $addon['Author'] ) ? $addon['Author'] : ''; 
  12. $api->author_profile = isset( $addon['AuthorURI'] ) ? $addon['AuthorURI'] : ''; 
  13. $api->requires = isset( $addon['Requires'] ) ? $addon['Requires'] : ''; 
  14. $api->tested = isset( $addon['Tested'] ) ? $addon['Tested'] : ''; 
  15. $api->last_updated = isset( $addon['LastUpdated'] ) ? $addon['LastUpdated'] : ''; 
  16. $api->homepage = isset( $addon['URI'] ) ? $addon['URI'] : ''; 
  17. $api->sections['changelog'] = isset( $addon['Changelog'] ) ? $addon['Changelog'] : ''; 
  18. $api->download_link = isset( $addon['Download'] ) ? $addon['Download'] : ''; 
  19. $api->package = isset( $addon['Download'] ) ? $addon['Download'] : ''; 
  20.  
  21. //get license key if one is available 
  22. $key = get_option("pmpro_license_key", ""); 
  23. if(!empty($key) && !empty($api->download_link)) 
  24. $api->download_link = add_query_arg("key", $key, $api->download_link); 
  25. if(!empty($key) && !empty($api->package)) 
  26. $api->package = add_query_arg("key", $key, $api->package); 
  27. if(empty($api->upgrade_notice) && !pmpro_license_isValid()) 
  28. $api->upgrade_notice = __('Important: This plugin requires a valid PMPro Plus license key to update.', 'paid-memberships-pro'); 
  29.  
  30. return $api;