resources
1 year ago
action-button.php
3 years ago
list-items.php
3 years ago
list-table-blank-state.php
4 years ago
notice-banner.php
1 year ago
notice.php
3 years ago
tag.php
3 years ago
action-button.php
65 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template for displaying the action-button component |
| 4 | * |
| 5 | * @var array $component The component. |
| 6 | * @package YITH\PluginFramework\Templates\Components |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
| 10 | |
| 11 | list ( $component_id, $class, $the_title, $attributes, $data, $button_action, $icon, $icon_class, $url, $action_button_menu, $confirm_data ) = yith_plugin_fw_extract( $component, 'id', 'class', 'title', 'attributes', 'data', 'action', 'icon', 'icon_class', 'url', 'menu', 'confirm_data' ); |
| 12 | |
| 13 | $button_action = isset( $button_action ) ? $button_action : ''; |
| 14 | $icon = isset( $icon ) ? $icon : $button_action; |
| 15 | $icon_class = isset( $icon_class ) ? $icon_class : "yith-icon yith-icon-{$icon}"; |
| 16 | $url = isset( $url ) ? $url : '#'; |
| 17 | $class = isset( $class ) ? $class : ''; |
| 18 | $the_title = isset( $the_title ) ? $the_title : ''; |
| 19 | $action_button_menu = isset( $action_button_menu ) ? $action_button_menu : array(); |
| 20 | $confirm_data = isset( $confirm_data ) ? $confirm_data : array(); |
| 21 | |
| 22 | $classes = array( 'yith-plugin-fw__action-button', "yith-plugin-fw__action-button--{$button_action}-action", $class ); |
| 23 | |
| 24 | if ( ! ! $action_button_menu ) { |
| 25 | $classes[] = 'yith-plugin-fw__action-button--has-menu'; |
| 26 | } |
| 27 | |
| 28 | $link_classes = array( 'yith-plugin-fw__action-button__link' ); |
| 29 | $link_data = array(); |
| 30 | if ( isset( $confirm_data['title'], $confirm_data['message'] ) && '#' !== $url ) { |
| 31 | $link_classes[] = 'yith-plugin-fw__require-confirmation-link'; |
| 32 | $link_data = $confirm_data; |
| 33 | } |
| 34 | |
| 35 | if ( $the_title ) { |
| 36 | $link_classes[] = 'yith-plugin-fw__tips'; |
| 37 | } |
| 38 | |
| 39 | $class = implode( ' ', $classes ); |
| 40 | $link_class = implode( ' ', array_filter( $link_classes ) ); |
| 41 | ?> |
| 42 | <span |
| 43 | id="<?php echo esc_attr( $component_id ); ?>" |
| 44 | class="<?php echo esc_attr( $class ); ?>" |
| 45 | <?php echo yith_plugin_fw_html_attributes_to_string( $attributes ); ?> |
| 46 | <?php echo yith_plugin_fw_html_data_to_string( $data ); ?> |
| 47 | > |
| 48 | <a class="<?php echo esc_attr( $link_class ); ?>" |
| 49 | aria-label="<?php echo esc_attr( $the_title ); ?>" |
| 50 | href="<?php echo esc_url( $url ); ?>" |
| 51 | <?php if ( $the_title ) : ?> |
| 52 | data-tip="<?php echo esc_attr( $the_title ); ?>" |
| 53 | <?php endif; ?> |
| 54 | |
| 55 | <?php yith_plugin_fw_html_data_to_string( $link_data, true ); ?> |
| 56 | > |
| 57 | <?php if ( $icon ) : ?> |
| 58 | <i class="yith-plugin-fw__action-button__icon <?php echo esc_attr( $icon_class ); ?>"></i> |
| 59 | <?php endif; ?> |
| 60 | </a> |
| 61 | <?php if ( $action_button_menu ) : ?> |
| 62 | <?php yith_plugin_fw_include_fw_template( '/components/resources/action-button-menu.php', compact( 'action_button_menu' ) ); ?> |
| 63 | <?php endif; ?> |
| 64 | </span> |
| 65 |