PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/woocommerce-products-filter/views/html_types/checkbox.php

https://bitbucket.org/hcdesenvolvimentos/adegamalbec_loja
PHP | 198 lines | 168 code | 20 blank | 10 comment | 40 complexity | f0873cd6482ded49740c59a496af5710 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, MIT, LGPL-2.1
  1. <?php if (!defined('ABSPATH')) die('No direct access allowed'); ?>
  2. <?php
  3. global $WOOF;
  4. $_REQUEST['additional_taxes'] = $additional_taxes;
  5. $_REQUEST['hide_terms_count_txt'] = isset($this->settings['hide_terms_count_txt']) ? $this->settings['hide_terms_count_txt'] : 0;
  6. //***
  7. if (!function_exists('woof_draw_checkbox_childs'))
  8. {
  9. function woof_draw_checkbox_childs($taxonomy_info, $tax_slug, $term_id, $childs, $show_count, $show_count_dynamic, $hide_dynamic_empty_pos)
  10. {
  11. $do_not_show_childs = (int) apply_filters('woof_terms_where_hidden_childs', $term_id);
  12. if ($do_not_show_childs == 1)
  13. {
  14. return "";
  15. }
  16. //***
  17. $current_request = array();
  18. global $WOOF;
  19. $request = $WOOF->get_request_data();
  20. if ($WOOF->is_isset_in_request_data($tax_slug))
  21. {
  22. $current_request = $request[$tax_slug];
  23. $current_request = explode(',', urldecode($current_request));
  24. }
  25. //***
  26. static $hide_childs = -1;
  27. if ($hide_childs == -1)
  28. {
  29. $hide_childs = (int) get_option('woof_checkboxes_slide');
  30. }
  31. //excluding hidden terms
  32. $hidden_terms = array();
  33. if (!isset($_REQUEST['woof_shortcode_excluded_terms']))
  34. {
  35. if (isset($WOOF->settings['excluded_terms'][$tax_slug]))
  36. {
  37. $hidden_terms = explode(',', $WOOF->settings['excluded_terms'][$tax_slug]);
  38. }
  39. } else
  40. {
  41. $hidden_terms = explode(',', $_REQUEST['woof_shortcode_excluded_terms']);
  42. }
  43. $childs = apply_filters('woof_sort_terms_before_out', $childs, 'checkbox');
  44. ?>
  45. <?php if (!empty($childs) AND is_array($childs)): ?>
  46. <ul class="woof_childs_list woof_childs_list_<?php echo $term_id ?>" <?php if ($hide_childs == 1): ?>style="display: none;"<?php endif; ?>>
  47. <?php foreach ($childs as $term) : $inique_id = uniqid(); ?>
  48. <?php
  49. $count_string = "";
  50. $count = 0;
  51. if (!in_array($term['slug'], $current_request))
  52. {
  53. if ($show_count)
  54. {
  55. if ($show_count_dynamic)
  56. {
  57. $count = $WOOF->dynamic_count($term, 'multi', $_REQUEST['additional_taxes']);
  58. } else
  59. {
  60. $count = $term['count'];
  61. }
  62. $count_string = '<span class="woof_checkbox_count">(' . $count . ')</span>';
  63. }
  64. //+++
  65. if ($hide_dynamic_empty_pos AND $count == 0)
  66. {
  67. continue;
  68. }
  69. }
  70. if ($_REQUEST['hide_terms_count_txt'])
  71. {
  72. $count_string = "";
  73. }
  74. //excluding hidden terms
  75. if (in_array($term['term_id'], $hidden_terms))
  76. {
  77. continue;
  78. }
  79. ?>
  80. <li <?php if ($WOOF->settings['dispay_in_row'][$tax_slug] AND empty($term['childs'])): ?>style="display: inline-block !important;"<?php endif; ?>><input type="checkbox" <?php if (!$count AND ! in_array($term['slug'], $current_request) AND $show_count): ?>disabled=""<?php endif; ?> id="<?php echo 'woof_' . $term['term_id'] . '_' . $inique_id ?>" class="woof_checkbox_term woof_checkbox_term_<?php echo $term['term_id'] ?>" data-tax="<?php echo $tax_slug ?>" name="<?php echo $term['slug'] ?>" data-term-id="<?php echo $term['term_id'] ?>" value="<?php echo $term['term_id'] ?>" <?php echo checked(in_array($term['slug'], $current_request)) ?> /><label class="woof_checkbox_label <?php if (in_array($term['slug'], $current_request)): ?>woof_checkbox_label_selected<?php endif; ?>" for="<?php echo 'woof_' . $term['term_id'] . '_' . $inique_id ?>"><?php
  81. if (has_filter('woof_before_term_name'))
  82. echo apply_filters('woof_before_term_name', $term, $taxonomy_info);
  83. else
  84. echo $term['name'];
  85. ?><?php echo $count_string ?></label>
  86. <?php
  87. if (!empty($term['childs']))
  88. {
  89. woof_draw_checkbox_childs($taxonomy_info, $tax_slug, $term['term_id'], $term['childs'], $show_count, $show_count_dynamic, $hide_dynamic_empty_pos);
  90. }
  91. ?>
  92. <input type="hidden" value="<?php echo $term['name'] ?>" data-anchor="woof_n_<?php echo $tax_slug ?>_<?php echo $term['slug'] ?>" />
  93. </li>
  94. <?php endforeach; ?>
  95. </ul>
  96. <?php endif; ?>
  97. <?php
  98. }
  99. }
  100. ?>
  101. <ul class="woof_list woof_list_checkbox">
  102. <?php
  103. $woof_tax_values = array();
  104. $current_request = array();
  105. $request = $this->get_request_data();
  106. if ($this->is_isset_in_request_data($tax_slug))
  107. {
  108. $current_request = $request[$tax_slug];
  109. $current_request = explode(',', urldecode($current_request));
  110. }
  111. //excluding hidden terms
  112. $hidden_terms = array();
  113. if (!isset($_REQUEST['woof_shortcode_excluded_terms']))
  114. {
  115. if (isset($WOOF->settings['excluded_terms'][$tax_slug]))
  116. {
  117. $hidden_terms = explode(',', $WOOF->settings['excluded_terms'][$tax_slug]);
  118. }
  119. } else
  120. {
  121. $hidden_terms = explode(',', $_REQUEST['woof_shortcode_excluded_terms']);
  122. }
  123. $terms = apply_filters('woof_sort_terms_before_out', $terms, 'checkbox');
  124. ?>
  125. <?php if (!empty($terms) AND is_array($terms)): ?>
  126. <?php foreach ($terms as $term) : $inique_id = uniqid(); ?>
  127. <?php
  128. $count_string = "";
  129. $count = 0;
  130. if (!in_array($term['slug'], $current_request))
  131. {
  132. if ($show_count)
  133. {
  134. if ($show_count_dynamic)
  135. {
  136. $count = $this->dynamic_count($term, 'multi', $_REQUEST['additional_taxes']);
  137. } else
  138. {
  139. $count = $term['count'];
  140. }
  141. $count_string = '<span class="woof_checkbox_count">(' . $count . ')</span>';
  142. }
  143. //+++
  144. if ($hide_dynamic_empty_pos AND $count == 0)
  145. {
  146. continue;
  147. }
  148. }
  149. if ($_REQUEST['hide_terms_count_txt'])
  150. {
  151. $count_string = "";
  152. }
  153. //excluding hidden terms
  154. if (in_array($term['term_id'], $hidden_terms))
  155. {
  156. continue;
  157. }
  158. ?>
  159. <li <?php if ($this->settings['dispay_in_row'][$tax_slug] AND empty($term['childs'])): ?>style="display: inline-block !important;"<?php endif; ?>><input type="checkbox" <?php if (!$count AND ! in_array($term['slug'], $current_request) AND $show_count): ?>disabled=""<?php endif; ?> id="<?php echo 'woof_' . $term['term_id'] . '_' . $inique_id ?>" class="woof_checkbox_term woof_checkbox_term_<?php echo $term['term_id'] ?>" data-tax="<?php echo $tax_slug ?>" name="<?php echo $term['slug'] ?>" data-term-id="<?php echo $term['term_id'] ?>" value="<?php echo $term['term_id'] ?>" <?php echo checked(in_array($term['slug'], $current_request)) ?> /><label class="woof_checkbox_label <?php if (in_array($term['slug'], $current_request)): ?>woof_checkbox_label_selected<?php endif; ?>" for="<?php echo 'woof_' . $term['term_id'] . '_' . $inique_id ?>"><?php
  160. if (has_filter('woof_before_term_name'))
  161. echo apply_filters('woof_before_term_name', $term, $taxonomy_info);
  162. else
  163. echo $term['name'];
  164. ?><?php echo $count_string ?></label>
  165. <?php
  166. if (!empty($term['childs']))
  167. {
  168. woof_draw_checkbox_childs($taxonomy_info, $tax_slug, $term['term_id'], $term['childs'], $show_count, $show_count_dynamic, $hide_dynamic_empty_pos);
  169. }
  170. ?>
  171. <input type="hidden" value="<?php echo $term['name'] ?>" data-anchor="woof_n_<?php echo $tax_slug ?>_<?php echo $term['slug'] ?>" />
  172. </li>
  173. <?php endforeach; ?>
  174. <?php endif; ?>
  175. </ul>
  176. <?php
  177. //we need it only here, and keep it in $_REQUEST for using in function for child items
  178. unset($_REQUEST['additional_taxes']);