Naguro_Module_Model

The WooCommerce Naguro Connect Naguro Module Model class.

Defined (1)

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

/includes/naguro/models/class-module-model.php  
  1. abstract class Naguro_Module_Model extends Naguro_Model implements Naguro_Module { 
  2. public $slug = ''; 
  3. public $name = ''; 
  4. public $active = false; 
  5. public $unlocked = false; 
  6. public $always_on = false; 
  7. public $description = ''; 
  8. public $purchase_url = ''; 
  9.  
  10. /** 
  11. * @return bool 
  12. */ 
  13. public function activate() { 
  14. if ( $this->active ) { 
  15. return true; 
  16.  
  17. $active_modules_array = get_option('naguro_active_modules', array() ); 
  18.  
  19. if ( ! in_array( $this->slug, $active_modules_array ) ) { 
  20. array_push( $active_modules_array, $this->slug ); 
  21. update_option( 'naguro_active_modules', $active_modules_array ); 
  22. return true; 
  23.  
  24. return false; 
  25.  
  26. /** 
  27. * @return bool 
  28. */ 
  29. public function deactivate() { 
  30. if ( ! $this->active ) { 
  31. return true; 
  32.  
  33. $active_modules_array = get_option('naguro_active_modules', array() ); 
  34.  
  35. $module_key = array_search( $this->slug, $active_modules_array ); 
  36.  
  37. if ( false === $module_key ) { 
  38. return true; 
  39.  
  40. unset( $active_modules_array[ $module_key ] ); 
  41.  
  42. update_option( 'naguro_active_modules', $active_modules_array ); 
  43. return true;