list.php
121 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Code-snippet for WordPress plugin list. |
| 4 | * Used in function lib3()->html->addon_list() |
| 5 | * |
| 6 | * @since 1.1.0 |
| 7 | * |
| 8 | * Variables: |
| 9 | * - $items |
| 10 | * - $lang |
| 11 | * - $filters |
| 12 | */ |
| 13 | |
| 14 | $item_fields = array( |
| 15 | 'class', |
| 16 | 'title', |
| 17 | 'description', |
| 18 | 'version', |
| 19 | 'author', |
| 20 | 'active', |
| 21 | 'action', // Array |
| 22 | 'details', // Array |
| 23 | 'icon', |
| 24 | 'footer', |
| 25 | ); |
| 26 | |
| 27 | $current = 'current'; |
| 28 | |
| 29 | ?> |
| 30 | <div class="wpmui-list-wrapper"> |
| 31 | |
| 32 | <?php if ( ! empty( $filters ) ) : ?> |
| 33 | <div class="wp-filter"><ul class="filter-links"><?php |
| 34 | foreach ( $filters as $key => $label ) { |
| 35 | printf( |
| 36 | '<li><a href="#" class="filter %3$s" data-filter="%1$s">%2$s</a></li>', |
| 37 | $key, |
| 38 | $label, |
| 39 | $current |
| 40 | ); |
| 41 | $current = ''; |
| 42 | } |
| 43 | ?></ul></div> |
| 44 | <?php endif; ?> |
| 45 | |
| 46 | <div class="wp-list-table widefat wpmui-list-table"> |
| 47 | <div class="the-list wpmui-list"> |
| 48 | <?php foreach ( $items as $item ) : |
| 49 | self::$core->array->equip( $item, $item_fields ); |
| 50 | if ( isset( $item->action ) && is_array( $item->action ) ) { |
| 51 | $item->details = self::$core->array->get( $item->details ); |
| 52 | } else { |
| 53 | $item->action = array(); |
| 54 | $item->details = array(); |
| 55 | } |
| 56 | |
| 57 | $item_class = $item->active ? 'active' : ''; |
| 58 | $item_class .= ' ' . $item->class; |
| 59 | ?> |
| 60 | <div class="list-card <?php echo esc_attr( $item_class ); ?>"> |
| 61 | <div class="list-card-top"> |
| 62 | <span class="badge-container"> |
| 63 | <span class="badge-active"> |
| 64 | <?php echo esc_html( $lang->active_badge ); ?> |
| 65 | </span> |
| 66 | </span> |
| 67 | <div class="item-icon"><?php echo $item->icon; ?></div> |
| 68 | <div class="name"> |
| 69 | <h4 class="<?php if ( $item->details ) : ?>toggle-details<?php endif; ?> is-no-detail"> |
| 70 | <?php echo esc_html( $item->title ); ?> |
| 71 | </h4> |
| 72 | <h4 class="is-detail"> |
| 73 | <?php echo esc_html( $item->title ); ?> |
| 74 | </h4> |
| 75 | </div> |
| 76 | <div class="desc"> |
| 77 | <?php echo $item->description; ?> |
| 78 | </div> |
| 79 | <div class="action-links"> |
| 80 | <span class="toggle-details toggle-link is-detail close-button"> |
| 81 | </span> |
| 82 | <?php |
| 83 | foreach ( $item->action as $action ) { |
| 84 | self::$core->html->element( $action ); |
| 85 | } |
| 86 | ?> |
| 87 | </div> |
| 88 | <div class="details"> |
| 89 | <?php |
| 90 | foreach ( $item->details as $detail ) { |
| 91 | if ( is_array( $detail ) ) { |
| 92 | if ( isset( $detail['ajax_data'] ) |
| 93 | && is_array( $detail['ajax_data'] ) |
| 94 | ) { |
| 95 | $detail['ajax_data']['_is_detail'] = true; |
| 96 | } |
| 97 | } |
| 98 | self::$core->html->element( $detail ); |
| 99 | } |
| 100 | ?> |
| 101 | </div> |
| 102 | <div class="fader"></div> |
| 103 | </div> |
| 104 | <div class="list-card-bottom"> |
| 105 | <span class="list-card-footer is-no-detail"> |
| 106 | <?php echo $item->footer; ?> |
| 107 | </span> |
| 108 | <?php if ( $item->details ) : ?> |
| 109 | <span class="toggle-details toggle-link is-no-detail"> |
| 110 | <?php echo esc_html( $lang->show_details ); ?> |
| 111 | </span> |
| 112 | <span class="toggle-details toggle-link is-detail"> |
| 113 | <?php echo esc_html( $lang->close_details ); ?> |
| 114 | </span> |
| 115 | <?php endif; ?> |
| 116 | </div> |
| 117 | </div> |
| 118 | <?php endforeach; ?> |
| 119 | </div> |
| 120 | </div> |
| 121 | </div> |