challenge
1 year ago
css
1 week ago
img
1 year ago
js
1 month ago
menu
1 month ago
partials
2 weeks ago
rest-api
1 week ago
scss
1 year ago
settings
1 week ago
uninstall
1 year ago
wpchill
1 month ago
admin-notices.php
6 months ago
admin.php
1 month ago
class-strong-testimonials-addons.php
1 month ago
class-strong-testimonials-admin-category-list.php
1 year ago
class-strong-testimonials-admin-list.php
1 year ago
class-strong-testimonials-admin-scripts.php
1 month ago
class-strong-testimonials-admin.php
1 month ago
class-strong-testimonials-debug.php
6 months ago
class-strong-testimonials-exporter.php
1 year ago
class-strong-testimonials-help.php
1 year ago
class-strong-testimonials-helper.php
1 month ago
class-strong-testimonials-list-table.php
1 year ago
class-strong-testimonials-lite-vs-pro-page.php
1 month ago
class-strong-testimonials-post-editor.php
7 months ago
class-strong-testimonials-review.php
1 year ago
class-strong-testimonials-updater.php
1 month ago
class-strong-testimonials-upsell.php
1 week ago
class-strong-views-list-table.php
1 month ago
class-walker-strong-category-checklist.php
1 year ago
class-walker-strong-form-category-checklist.php
1 year ago
class-wpmtst-onboarding.php
1 year ago
compat.php
1 year ago
custom-fields-ajax.php
1 year ago
custom-fields.php
1 week ago
form-preview.php
1 year ago
view-list-order.php
1 year ago
views-ajax.php
1 month ago
views-validate.php
1 year ago
views.php
1 month ago
class-walker-strong-category-checklist.php
130 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Taxonomy API: Walker_Strong_Category_Checklist class |
| 4 | * |
| 5 | * @since 2.2.0 |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Custom walker class to output an unordered list of category checkbox input elements. |
| 10 | * |
| 11 | * @since 2.5.1 |
| 12 | * |
| 13 | * @see Walker |
| 14 | * @see wp_category_checklist() |
| 15 | * @see wp_terms_checklist() |
| 16 | */ |
| 17 | class Walker_Strong_Category_Checklist extends Walker { |
| 18 | public $tree_type = 'category'; |
| 19 | public $db_fields = array( |
| 20 | 'parent' => 'parent', |
| 21 | 'id' => 'term_id', |
| 22 | ); //TODO: decouple this |
| 23 | |
| 24 | /** |
| 25 | * Starts the list before the elements are added. |
| 26 | * |
| 27 | * @see Walker:start_lvl() |
| 28 | * |
| 29 | * @since 2.5.1 |
| 30 | * |
| 31 | * @param string $output Passed by reference. Used to append additional content. |
| 32 | * @param int $depth Depth of category. Used for tab indentation. |
| 33 | * @param array $args An array of arguments. @see wp_terms_checklist() |
| 34 | */ |
| 35 | public function start_lvl( &$output, $depth = 0, $args = array() ) { |
| 36 | $indent = str_repeat( "\t", $depth ); |
| 37 | $output .= "$indent<ul class='children'>\n"; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Ends the list of after the elements are added. |
| 42 | * |
| 43 | * @see Walker::end_lvl() |
| 44 | * |
| 45 | * @since 2.5.1 |
| 46 | * |
| 47 | * @param string $output Passed by reference. Used to append additional content. |
| 48 | * @param int $depth Depth of category. Used for tab indentation. |
| 49 | * @param array $args An array of arguments. @see wp_terms_checklist() |
| 50 | */ |
| 51 | public function end_lvl( &$output, $depth = 0, $args = array() ) { |
| 52 | $indent = str_repeat( "\t", $depth ); |
| 53 | $output .= "$indent</ul>\n"; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Start the element output. |
| 58 | * |
| 59 | * @see Walker::start_el() |
| 60 | * |
| 61 | * @since 2.5.1 |
| 62 | * |
| 63 | * @param string $output Passed by reference. Used to append additional content. |
| 64 | * @param object $category The current term object. |
| 65 | * @param int $depth Depth of the term in reference to parents. Default 0. |
| 66 | * @param array $args An array of arguments. @see wp_terms_checklist() |
| 67 | * @param int $id ID of the current term. |
| 68 | */ |
| 69 | public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
| 70 | if ( empty( $args['taxonomy'] ) ) { |
| 71 | $taxonomy = 'wpm-testimonial-category'; |
| 72 | } else { |
| 73 | $taxonomy = $args['taxonomy']; |
| 74 | } |
| 75 | |
| 76 | $name = 'view[data][category]'; |
| 77 | |
| 78 | $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats']; |
| 79 | $class = in_array( $category->term_id, $args['popular_cats'], true ) ? ' class="popular-category"' : ''; |
| 80 | |
| 81 | $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats']; |
| 82 | |
| 83 | $args['cat_counts'] = empty( $args['cat_counts'] ) ? array() : $args['cat_counts']; |
| 84 | |
| 85 | if ( ! empty( $args['list_only'] ) ) { |
| 86 | $aria_cheched = 'false'; |
| 87 | $inner_class = 'category'; |
| 88 | |
| 89 | if ( in_array( $category->term_id, $args['selected_cats'], true ) ) { |
| 90 | $inner_class .= ' selected'; |
| 91 | $aria_cheched = 'true'; |
| 92 | } |
| 93 | |
| 94 | /** This filter is documented in wp-includes/category-template.php */ |
| 95 | $output .= "\n" . '<li' . $class . '>' . |
| 96 | '<div class="' . $inner_class . '" data-term-id=' . $category->term_id . |
| 97 | ' tabindex="0" role="checkbox" aria-checked="' . $aria_cheched . '">' . |
| 98 | esc_html( apply_filters( 'the_category', $category->name ) ) . '</div>'; |
| 99 | } else { |
| 100 | /** This filter is documented in wp-includes/category-template.php */ |
| 101 | // newlines make for consistent spacing without extra CSS |
| 102 | $output .= "\n" . '<li id="li-category-' . $category->term_id . '"' . $class . '>' . "\n"; |
| 103 | $output .= '<input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]"' |
| 104 | . ' id="category-' . $category->term_id . '"' |
| 105 | . checked( in_array( $category->term_id, $args['selected_cats'], true ), true, false ) |
| 106 | . disabled( empty( $args['disabled'] ), false, false ) . ' />' . "\n"; |
| 107 | $output .= '<label class="selectit" for="category-' . $category->term_id . '">' . "\n"; |
| 108 | $output .= esc_html( apply_filters( 'the_category', $category->name ) ) |
| 109 | . ' <span class="cat-count">(' . $category->count . ')</span>'; |
| 110 | $output .= '</label>'; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Ends the element output, if needed. |
| 116 | * |
| 117 | * @see Walker::end_el() |
| 118 | * |
| 119 | * @since 2.5.1 |
| 120 | * |
| 121 | * @param string $output Passed by reference. Used to append additional content. |
| 122 | * @param object $category The current term object. |
| 123 | * @param int $depth Depth of the term in reference to parents. Default 0. |
| 124 | * @param array $args An array of arguments. @see wp_terms_checklist() |
| 125 | */ |
| 126 | public function end_el( &$output, $category, $depth = 0, $args = array() ) { |
| 127 | $output .= "</li>\n"; |
| 128 | } |
| 129 | } |
| 130 |