WC_GZD_Compatibility

The.

Defined (1)

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

/includes/abstracts/abstract-wc-gzd-compatibility.php  
  1. abstract class WC_GZD_Compatibility { 
  2.  
  3. private $plugin_name; 
  4. private $plugin_file; 
  5. private $version_data = array(); 
  6.  
  7. public function __construct( $plugin_name, $plugin_file, $version_data = array() ) { 
  8.  
  9. $version_data = wp_parse_args( $version_data, array( 
  10. 'version' => '1.0.0',  
  11. 'requires_at_least' => '',  
  12. 'tested_up_to' => '',  
  13. ) ); 
  14.  
  15. if ( empty( $version_data[ 'requires_at_least' ] ) && empty( $version_data[ 'tested_up_to' ] ) ) { 
  16. $version_data[ 'requires_at_least' ] = $version_data[ 'version' ]; 
  17. $version_data[ 'tested_up_to' ] = $version_data[ 'version' ]; 
  18. } else if ( empty( $version_data[ 'tested_up_to' ] ) ) { 
  19. $version_data[ 'tested_up_to' ] = $version_data[ 'requires_at_least' ]; 
  20. if ( WC_GZD_Dependencies::instance()->compare_versions( $version_data[ 'version' ], $version_data[ 'requires_at_least' ], '>' ) ) 
  21. $version_data[ 'tested_up_to' ] = $version_data[ 'version' ]; 
  22. } else if ( empty( $version_data[ 'requires_at_least' ] ) ) { 
  23. $version_data[ 'requires_at_least' ] = $version_data[ 'tested_up_to' ]; 
  24. if ( WC_GZD_Dependencies::instance()->compare_versions( $version_data[ 'version' ], $version_data[ 'requires_at_least' ], '<' ) ) 
  25. $version_data[ 'requires_at_least' ] = $version_data[ 'version' ]; 
  26.  
  27. $this->version_data = $version_data; 
  28.  
  29. $this->plugin_name = $plugin_name; 
  30. $this->plugin_file = $plugin_file; 
  31.  
  32. if ( ! $this->is_applicable() ) 
  33. return; 
  34.  
  35. $this->load(); 
  36.  
  37. public function is_applicable() { 
  38. return $this->is_activated() && $this->is_supported(); 
  39.  
  40. public function is_activated() { 
  41. return WC_GZD_Dependencies::instance()->is_plugin_activated( $this->plugin_file ); 
  42.  
  43. public function is_supported() { 
  44. return  
  45. WC_GZD_Dependencies::instance()->compare_versions( $this->version_data[ 'version' ], $this->version_data[ 'requires_at_least' ], '>=' ) &&  
  46. WC_GZD_Dependencies::instance()->compare_versions( $this->version_data[ 'version' ], $this->version_data[ 'tested_up_to' ], '<=' ); 
  47.  
  48. public function get_name() { 
  49. return $this->plugin_name; 
  50.  
  51. public function get_version_data() { 
  52. return $this->version_data; 
  53.  
  54. abstract function load(); 
  55.