Naguro_Modules_List

The WooCommerce Naguro Connect Naguro Modules List class.

Defined (1)

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

/includes/wordpress/class-modules-list.php  
  1. class Naguro_Modules_List extends WP_List_Table { 
  2. public function get_columns() { 
  3. $columns = array( 
  4. 'name' => 'Name',  
  5. 'description' => 'Description',  
  6. 'actions' => 'Actions',  
  7. ); 
  8.  
  9. return $columns; 
  10.  
  11. public function prepare_items() { 
  12. $columns = $this->get_columns(); 
  13. $hidden = array(); 
  14. $sortable = array(); 
  15. $this->_column_headers = array( $columns, $hidden, $sortable ); 
  16.  
  17. public function column_default( $item, $column_name ) { 
  18. switch( $column_name ) { 
  19. case 'name': 
  20. return $item->name; 
  21. case 'description': 
  22. return $item->description; 
  23. case 'actions': 
  24. return $this->get_actions( $item ); 
  25. default: 
  26. return ''; 
  27.  
  28. /** 
  29. * @return string 
  30. */ 
  31. private function get_actions( $item ) { 
  32. if ( $item->always_on ) { 
  33. return ''; 
  34.  
  35. if ( ! $item->unlocked ) { 
  36. $text = 'Get this module'; 
  37.  
  38. if ( ! empty( $item->purchase_url ) ) { 
  39. return '<a href="'.esc_url( $item->purchase_url ) . '">'. $text .'</a>'; 
  40.  
  41. return $text; 
  42.  
  43. if ( ! $item->active ) { 
  44. $tab_link = '?page=woocommerce-naguro&tab=modules'; 
  45. $activate_link = $tab_link . '&naguro-action=activate-module&naguro-module=' . $item->slug; 
  46. return '<a href="'.$activate_link.'">Activate this module</a>'; 
  47. } else { 
  48. $tab_link = '?page=woocommerce-naguro&tab=modules'; 
  49. $deactivate_link = $tab_link . '&naguro-action=deactivate-module&naguro-module=' . $item->slug; 
  50. return '<a href="'.$deactivate_link.'">Deactivate this module</a>'; 
  51.  
  52. public function single_row( $item ) { 
  53. $active_class = ( $item->active ) ? 'active' : ''; 
  54.  
  55. echo '<tr class="'.$active_class.'">'; 
  56. echo $this->single_row_columns( $item ); 
  57. echo "</tr>\n";