pmpro_update_plugins_filter

Infuse plugin update details when WordPress runs its update checker.

Description

(object) pmpro_update_plugins_filter( (object) $value ); 

Returns (object)

$value Amended WordPress update object on success, default if object is empty.

Parameters (1)

0. $value (object)
The WordPress update object.

Usage

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

Defined (1)

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

/includes/addons.php  
  1. function pmpro_update_plugins_filter( $value ) { 
  2.  
  3. // If no update object exists, return early. 
  4. if ( empty( $value ) ) { 
  5. return $value; 
  6.  
  7. // getaddoninformation 
  8. $addons = pmpro_getAddons(); 
  9.  
  10. // no addons? 
  11. if(empty($addons)) 
  12. return $value; 
  13.  
  14. //check addons 
  15. foreach($addons as $addon) 
  16. //skip wordpress.org plugins 
  17. if(empty($addon['License']) || $addon['License'] == 'wordpress') 
  18. continue; 
  19.  
  20. //get data for plugin 
  21. $plugin_file = $addon['Slug'] . '/' . $addon['Slug'] . '.php'; 
  22. $plugin_file_abs = WP_PLUGIN_DIR . "/" . $plugin_file;  
  23.  
  24. //couldn't find plugin, skip 
  25. if(!file_exists($plugin_file_abs)) 
  26. continue; 
  27. else 
  28. $plugin_data = get_plugin_data( $plugin_file_abs, false, true); 
  29.  
  30. //compare versions 
  31. if(!empty($addon['License']) && version_compare($plugin_data['Version'], $addon['Version'], '<')) 
  32. $value->response[$plugin_file] = pmpro_getPluginAPIObjectFromAddon($addon); 
  33. $value->response[$plugin_file]->new_version = $addon['Version'];  
  34.  
  35. // Return the update object. 
  36. return $value;