Yoast_Plugin_Update_Manager

The Google Analytics by Yoast Yoast Plugin Update Manager class.

Defined (1)

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

/vendor/yoast/license-manager/class-plugin-update-manager.php  
  1. class Yoast_Plugin_Update_Manager extends Yoast_Update_Manager { 
  2.  
  3. /** 
  4. * Constructor 
  5. * @param string $api_url 
  6. * @param string $item_name 
  7. * @param string $license_key 
  8. * @param string $slug The path to the main plugin file, relative to plugins dir 
  9. * @param string $version 
  10. * @param string $author (optional) 
  11. * @param string $text_domain  
  12. */ 
  13. public function __construct( Yoast_Product $product, $license_key ) { 
  14. parent::__construct( $product, $license_key ); 
  15.  
  16. // setup hooks 
  17. $this->setup_hooks(); 
  18.  
  19.  
  20. /** 
  21. * Setup hooks 
  22. */ 
  23. private function setup_hooks() { 
  24.  
  25. // check for updates 
  26. add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'set_updates_available_data' ) ); 
  27.  
  28. // get correct plugin information (when viewing details) 
  29. add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); 
  30.  
  31. /** 
  32. * Check for updates and if so, add to "updates available" data 
  33. * @param object $data 
  34. * @return object $data 
  35. */ 
  36. public function set_updates_available_data( $data ) { 
  37.  
  38. if ( empty( $data ) ) { 
  39. return $data; 
  40.  
  41. // send of API request to check for updates 
  42. $remote_data = $this->get_remote_data(); 
  43.  
  44. // did we get a response? 
  45. if( $remote_data === false ) { 
  46. return $data; 
  47.  
  48. // compare local version with remote version 
  49. if ( version_compare( $this->product->get_version(), $remote_data->new_version, '<' ) ) { 
  50.  
  51. // remote version is newer, add to data 
  52. $data->response[ $this->product->get_slug() ] = $remote_data; 
  53.  
  54.  
  55. return $data; 
  56.  
  57. /** 
  58. * Gets new plugin version details (view version x.x.x details) 
  59. * @uses api_request() 
  60. * @param object $data 
  61. * @param string $action 
  62. * @param object $args (optional) 
  63. * @return object $data 
  64. */ 
  65. public function plugins_api_filter( $data, $action = '', $args = null ) { 
  66.  
  67. // only do something if we're checking for our plugin 
  68. if ( $action !== 'plugin_information' || ! isset( $args->slug ) || $args->slug !== $this->product->get_slug() ) { 
  69. return $data; 
  70.  
  71. $api_response = $this->get_remote_data(); 
  72.  
  73. // did we get a response? 
  74. if ( $api_response === false ) { 
  75. return $data;  
  76.  
  77. // return api response 
  78. return $api_response; 
  79.