VTMIN_Checkbox_classes

The VarkTech Minimum Purchase for WooCommerce VTMIN Checkbox classes class.

Defined (1)

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

/admin/vtmin-checkbox-classes.php  
  1. class VTMIN_Checkbox_classes{ 
  2.  
  3. public function __construct() { 
  4. //look at usernoise admin/settings.php for constructor stuff 
  5.  
  6.  
  7. /** 
  8. function function vtmin_build_checkbox_contents migrated to rules-ui, to allow for easy alteration in freemium model. 
  9. */ 
  10.  
  11. /** 
  12. * For the checkbox tax_type, get all the selected values and return in checked_list 
  13. */ 
  14. public function vtmin_produce_tax_checked_list ($post_ID, $taxonomy) {  
  15. $checked_list = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids')); 
  16. return $checked_list; 
  17.  
  18.  
  19. /** 
  20. * For the checkbox tax_type, get all the selected values and return in checked_list 
  21. * ONLY works following updates  
  22. */ 
  23. public function vtmin_process_tax_checklist ($post_ID, $taxonomy) {  
  24. $checked_list = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids')); 
  25. return $checked_list; 
  26.  
  27.  
  28.  
  29. public function vtmin_is_product_in_tax_list ($prod_id, $tax_name, $checked_list) {  
  30. $tax_ids = wp_get_object_terms( $prod_id, $tax_name ); //get all terms within tax this id belongs to  
  31. $sizeof_tax_ids = sizeof($tax_ids); 
  32. for($i=0; $i < $sizeof_tax_ids; $i++) { 
  33. if (strpos($checked_list, $tax_ids[$i])) { //if cat_id is in previously checked_list 
  34. $selected = true; 
  35. $i = $sizeof_tax_ids; 
  36. }  
  37. if ($selected) { 
  38. return true; 
  39. } else { 
  40. return false; 
  41.  
  42.  
  43. /** 
  44. * checked_list (o) - selection list from previous iteration of rule selection  
  45. *  
  46. */ 
  47. public function vtmin_fill_roles_checklist ($tax_class, $checked_list = NULL) {  
  48. $roles = get_editable_roles(); 
  49. $roles['notLoggedIn'] = array( 'name' => 'Not logged in (just visiting)' ); 
  50.  
  51. foreach ($roles as $role => $info) { 
  52. $name_translated = translate_user_role( $info['name'] ); 
  53. $output = '<li id='.$role.'>' ; 
  54. $output .= '<label class="selectit">' ; 
  55. $output .= '<input id="'.$role.'_'.$tax_class.' " '; 
  56. $output .= 'type="checkbox" name="tax-input-' . $tax_class . '[]" '; 
  57. $output .= 'value="'.$role.'" '; 
  58. if ($checked_list) { 
  59. if (in_array($role, $checked_list)) { //if cat_id is in previously checked_list  
  60. $output .= 'checked="checked"'; 
  61. }  
  62. $output .= '>'; //end input statement 
  63. $output .= ' ' . $name_translated; 
  64. $output .= '</label>'; 
  65.  
  66. $output .= '</li>'; 
  67. echo $output ; 
  68. return;  
  69. }  
  70.  
  71. /** 
  72. * For the checkbox rolelist, get all the selected values and return in checked_list 
  73. */ 
  74. public function vtmin_process_roles_checklist () {  
  75. if(empty($_REQUEST['rolelist'])) { 
  76. return false; 
  77.  
  78. $checked_list; 
  79. $checkbox = $_REQUEST['rolelist']; //gets all of the selected 'rolelist[]' boxes 
  80. $sizeof_checkBox = sizeof($checkBox); 
  81. for($i=0; $i < $sizeof_checkBox; $i++) { 
  82. $checked_list .= $checkBox[$i].'>'; //returns 'value' from checkbox input statement 
  83. }  
  84. return $checked_list; 
  85.  
  86. /** 
  87. * For the checkbox list, get all the selected values and return in checked_list 
  88. */ 
  89. public function vtmin_checked_list_from_checkboxes ($checkbox) {  
  90. $checked_list; 
  91. $sizeof_checkBox = sizeof($checkBox); 
  92. for($i=0; $i < $sizeof_checkBox; $i++) { 
  93. $checked_list .= $checkBox[$i].'>'; //returns 'value' from checkbox input statement 
  94. }  
  95. return $checked_list; 
  96.  
  97. public function vtmin_is_user_in_role_list ($checked_list) {  
  98. if ( !is_user_logged_in() ) { 
  99. return false; 
  100. if (strpos($checked_list, vtmin_get_current_user_role() )) { //if role is in previously checked_list 
  101. return true; 
  102. } else {  
  103. return false; 
  104.  
  105.  
  106. public function vtmin_get_current_user_role() { 
  107. global $current_user;  
  108. $user_roles = $current_user->roles; 
  109. $user_role = array_shift($user_roles);  
  110. return $user_role; 
  111.  
  112. } //end class