admin/classes/admin-options/fields/sortable-repeater-icons
class-merchant-field-sortable-repeater-icons.php
3.7 KB
1 month ago
template.php
2.6 KB
1 month ago
template.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.3.1, at admin/classes/admin-options/fields/sortable-repeater-icons/template.php
| 1 | <?php |
| 2 | /** |
| 3 | * Template for sortable-repeater-icons field. |
| 4 | * |
| 5 | * Extends sortable-repeater with a per-row icon picker dropdown. |
| 6 | * Items are stored as JSON array of { text, icon } objects. |
| 7 | * |
| 8 | * @var array<string, mixed> $settings Field configuration. |
| 9 | * @var mixed $value Current saved value. |
| 10 | * @var string $module_id Module ID. |
| 11 | * @var Merchant_Field_Sortable_Repeater_Icons $field Field instance. |
| 12 | * |
| 13 | * @package Merchant |
| 14 | * @since 2.3.0 |
| 15 | */ |
| 16 | |
| 17 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | exit; |
| 19 | } |
| 20 | |
| 21 | // Resolve icons: use field config override or field class defaults. |
| 22 | $allowed_icons = $field->get_allowed_icons(); |
| 23 | $icon_library = array(); |
| 24 | foreach ( $allowed_icons as $icon_key ) { |
| 25 | $icon_library[ $icon_key ] = Merchant_SVG_Icons::get_svg_icon( $icon_key ); |
| 26 | } |
| 27 | |
| 28 | $sorting_disabled = isset( $settings['sorting'] ) && false === $settings['sorting']; |
| 29 | $button_label = $settings['button_label'] ?? esc_html__( 'Add new item', 'merchant' ); |
| 30 | ?> |
| 31 | <div class="merchant-sortable-repeater-icons-control<?php echo $sorting_disabled ? ' disable-sorting' : ''; ?>" |
| 32 | data-icons="<?php echo esc_attr( (string) wp_json_encode( $icon_library ) ); ?>"> |
| 33 | |
| 34 | <div class="merchant-sortable-repeater-icons sortable regular-field"> |
| 35 | <div class="repeater"> |
| 36 | <button type="button" class="merchant-icon-picker-toggle" data-icon="" title="<?php esc_attr_e( 'Select icon', 'merchant' ); ?>"> |
| 37 | <span class="dashicons dashicons-plus-alt2"></span> |
| 38 | </button> |
| 39 | <div class="merchant-icon-picker-dropdown" style="display:none;"> |
| 40 | <button type="button" class="merchant-icon-option" data-icon="" title="<?php esc_attr_e( 'Use campaign icon', 'merchant' ); ?>"> |
| 41 | <span class="dashicons dashicons-no-alt"></span> |
| 42 | </button> |
| 43 | <?php foreach ( $icon_library as $key => $svg ) : ?> |
| 44 | <button type="button" class="merchant-icon-option" data-icon="<?php echo esc_attr( $key ); ?>" title="<?php echo esc_attr( $key ); ?>"> |
| 45 | <?php echo wp_kses( $svg, merchant_kses_allowed_tags( array(), false ) ); ?> |
| 46 | </button> |
| 47 | <?php endforeach; ?> |
| 48 | </div> |
| 49 | <input type="text" value="" class="repeater-input" /><span class="dashicons dashicons-menu"></span><a class="customize-control-sortable-repeater-delete" |
| 50 | href="#"><span class="dashicons dashicons-no-alt"></span></a> |
| 51 | </div> |
| 52 | </div> |
| 53 | |
| 54 | <button class="button customize-control-sortable-repeater-icons-add" type="button"><?php echo esc_html( $button_label ); ?></button> |
| 55 | <input class="merchant-sortable-repeater-input" type="hidden" name="merchant[<?php echo esc_attr( $settings['id'] ); ?>]" value="<?php echo esc_attr( (string) wp_json_encode( $value ) ); ?>" /> |
| 56 | </div> |
| 57 | <?php |
| 58 |