resources
2 years 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
notice-banner.php
60 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template for displaying the notice 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, $attributes, $data, $notice_type, $banner_title, $message, $animate, $inline ) = yith_plugin_fw_extract( $component, 'id', 'class', 'attributes', 'data', 'notice_type', 'title', 'message', 'animate', 'inline' ); |
| 12 | |
| 13 | $allowed_types = array( 'info', 'warning', 'error' ); |
| 14 | |
| 15 | $notice_type = in_array( $notice_type ?? '', $allowed_types, true ) ? $notice_type : 'info'; |
| 16 | $banner_title = $banner_title ?? ''; |
| 17 | $message = $message ?? ''; |
| 18 | $inline = $inline ?? true; |
| 19 | $animate = $animate ?? true; |
| 20 | $class = $class ?? ''; |
| 21 | |
| 22 | $icons = array( |
| 23 | 'info' => '<svg data-slot="icon" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path clip-rule="evenodd" fill-rule="evenodd" d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm8.706-1.442c1.146-.573 2.437.463 2.126 1.706l-.709 2.836.042-.02a.75.75 0 0 1 .67 1.34l-.04.022c-1.147.573-2.438-.463-2.127-1.706l.71-2.836-.042.02a.75.75 0 1 1-.671-1.34l.041-.022ZM12 9a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Z"></path></svg>', |
| 24 | 'warning' => '<svg fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path clip-rule="evenodd" fill-rule="evenodd" d="M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z"></path></svg>', |
| 25 | 'error' => '<svg fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path clip-rule="evenodd" fill-rule="evenodd" d="M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z"></path></svg>', |
| 26 | ); |
| 27 | |
| 28 | $icon = $icons[ $notice_type ] ?? ''; |
| 29 | |
| 30 | $allowed_icon_tags = array_merge( wp_kses_allowed_html( 'post' ), yith_plugin_fw_kses_allowed_svg_tags() ); |
| 31 | |
| 32 | $classes = array( |
| 33 | 'yith-plugin-fw__notice-banner', |
| 34 | "yith-plugin-fw__notice-banner--{$notice_type}", |
| 35 | $inline ? 'yith-plugin-fw--inline' : '', |
| 36 | $animate ? 'yith-plugin-fw-animate__appear-from-top' : '', |
| 37 | $class, |
| 38 | ); |
| 39 | |
| 40 | $class = implode( ' ', array_filter( $classes ) ); |
| 41 | ?> |
| 42 | <div |
| 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 | <div class="yith-plugin-fw__notice-banner__icon"> |
| 49 | <?php echo wp_kses( $icon, $allowed_icon_tags ); ?> |
| 50 | </div> |
| 51 | <div class="yith-plugin-fw__notice-banner__content"> |
| 52 | <div class="yith-plugin-fw__notice-banner__title"> |
| 53 | <?php echo wp_kses_post( $banner_title ); ?> |
| 54 | </div> |
| 55 | <div class="yith-plugin-fw__notice-banner__message"> |
| 56 | <?php echo wp_kses_post( $message ); ?> |
| 57 | </div> |
| 58 | </div> |
| 59 | </div> |
| 60 |