Nenhuma Descrição

walkers.php 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. require_once( ABSPATH . 'wp-admin/includes/template.php' );
  3. class Br_Walker_Category_Checklist extends Walker_Category_Checklist {
  4. public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
  5. $taxonomy = empty( $args['taxonomy'] ) ? 'category' : $args['taxonomy'];
  6. $name = 'category' === $taxonomy ? 'post_category' : "br_brand_category[$taxonomy]";
  7. $args['popular_cats'] = ! empty( $args['popular_cats'] ) ? array_map( 'intval', $args['popular_cats'] ) : array();
  8. $class = in_array( $category->term_id, $args['popular_cats'], true ) ? ' class="popular-category"' : '';
  9. $args['selected_cats'] = ! empty( $args['selected_cats'] ) ? array_map( 'intval', $args['selected_cats'] ) : array();
  10. if ( ! empty( $args['list_only'] ) ) {
  11. $aria_checked = 'false';
  12. $inner_class = 'category';
  13. if ( in_array( $category->term_id, $args['selected_cats'], true ) ) {
  14. $inner_class .= ' selected';
  15. $aria_checked = 'true';
  16. }
  17. $output .= "\n" . '<li' . $class . '>' .
  18. '<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
  19. ' tabindex="0" role="checkbox" aria-checked="' . $aria_checked . '">' .
  20. /** This filter is documented in wp-includes/category-template.php */
  21. esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>';
  22. } else {
  23. $is_selected = in_array( $category->term_id, $args['selected_cats'], true );
  24. $is_disabled = ! empty( $args['disabled'] );
  25. $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
  26. '<label class="selectit"><input value="' . $category->name . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
  27. checked( $is_selected, true, false ) .
  28. disabled( $is_disabled, true, false ) . ' /> ' .
  29. /** This filter is documented in wp-includes/category-template.php */
  30. esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>';
  31. }
  32. }
  33. }
  34. class Br_Walker_Brand_Checklist extends Walker_Category_Checklist {
  35. public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
  36. $taxonomy = empty( $args['taxonomy'] ) ? 'category' : $args['taxonomy'];
  37. $name = 'category' === $taxonomy ? 'post_category' : BeRocket_product_brand::$taxonomy_name;
  38. $args['popular_cats'] = ! empty( $args['popular_cats'] ) ? array_map( 'intval', $args['popular_cats'] ) : array();
  39. $class = in_array( $category->term_id, $args['popular_cats'], true ) ? ' class="popular-category"' : '';
  40. $args['selected_cats'] = ! empty( $args['selected_cats'] ) ? array_map( 'intval', $args['selected_cats'] ) : array();
  41. if ( ! empty( $args['list_only'] ) ) {
  42. $aria_checked = 'false';
  43. $inner_class = 'category';
  44. if ( in_array( $category->term_id, $args['selected_cats'], true ) ) {
  45. $inner_class .= ' selected';
  46. $aria_checked = 'true';
  47. }
  48. $output .= "\n" . '<li' . $class . '>' .
  49. '<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
  50. ' tabindex="0" role="checkbox" aria-checked="' . $aria_checked . '">' .
  51. /** This filter is documented in wp-includes/category-template.php */
  52. esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>';
  53. } else {
  54. $is_selected = in_array( $category->term_id, $args['selected_cats'], true );
  55. $is_disabled = ! empty( $args['disabled'] );
  56. $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>
  57. <label class='selectit'><input value='{$category->term_id}' type='checkbox' name='{$name}[]'" .
  58. checked( $is_selected, true, false ) .
  59. disabled( $is_disabled, true, false ) . ' /> ' .
  60. /** This filter is documented in wp-includes/category-template.php */
  61. esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>';
  62. // $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
  63. // '<label class="selectit"><input value="' . $category->name . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
  64. // checked( $is_selected, true, false ) .
  65. // disabled( $is_disabled, true, false ) . ' /> ' .
  66. // /** This filter is documented in wp-includes/category-template.php */
  67. // esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>';
  68. }
  69. }
  70. }
  71. class Br_Walker_Brand_Selectlist extends Walker_Category_Checklist {
  72. public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
  73. $taxonomy = empty( $args['taxonomy'] ) ? 'category' : $args['taxonomy'];
  74. $name = 'category' === $taxonomy ? 'post_category' : BeRocket_product_brand::$taxonomy_name;
  75. $args['popular_cats'] = ! empty( $args['popular_cats'] ) ? array_map( 'intval', $args['popular_cats'] ) : array();
  76. $class = in_array( $category->term_id, $args['popular_cats'], true ) ? ' class="popular-category"' : '';
  77. $args['selected_cats'] = ! empty( $args['selected_cats'] ) ? array_map( 'intval', $args['selected_cats'] ) : array();
  78. if ( ! empty( $args['list_only'] ) ) {
  79. $aria_checked = 'false';
  80. $inner_class = 'category';
  81. if ( in_array( $category->term_id, $args['selected_cats'], true ) ) {
  82. $inner_class .= ' selected';
  83. $aria_checked = 'true';
  84. }
  85. $output .= "\n" . '<li' . $class . '>' .
  86. '<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
  87. ' tabindex="0" role="checkbox" aria-checked="' . $aria_checked . '">' .
  88. /** This filter is documented in wp-includes/category-template.php */
  89. esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>';
  90. } else {
  91. $is_selected = in_array( $category->term_id, $args['selected_cats'], true );
  92. $is_disabled = ! empty( $args['disabled'] );
  93. $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>
  94. <label class='selectit'><input value='{$category->term_id}' type='radio' name='{$name}[]'" .
  95. checked( $is_selected, true, false ) .
  96. disabled( $is_disabled, true, false ) . ' /> ' .
  97. /** This filter is documented in wp-includes/category-template.php */
  98. esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>';
  99. // $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
  100. // '<label class="selectit"><input value="' . $category->name . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
  101. // checked( $is_selected, true, false ) .
  102. // disabled( $is_disabled, true, false ) . ' /> ' .
  103. // /** This filter is documented in wp-includes/category-template.php */
  104. // esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>';
  105. }
  106. }
  107. }