PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.68
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.68
1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 All 174 releases
userswp / vendor / ayecode / wp-ayecode-ui / includes / components / class-aui-component-alert.php

class-aui-component-alert.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.68, at vendor/ayecode/wp-ayecode-ui/includes/components/class-aui-component-alert.php

97 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 /**
8 * A component class for rendering a bootstrap alert.
9 *
10 * @since 1.0.0
11 */
12 class AUI_Component_Alert {
13
14 /**
15 * Build the component.
16 *
17 * @param array $args
18 *
19 * @return string The rendered component.
20 */
21 public static function get($args = array()){
22 global $aui_bs5;
23 $defaults = array(
24 'type' => 'info',
25 'class' => '',
26 'icon' => '',
27 'heading' => '',
28 'content' => '',
29 'footer' => '',
30 'dismissible'=> false,
31 'data' => '',
32 );
33
34 /**
35 * Parse incoming $args into an array and merge it with $defaults
36 */
37 $args = wp_parse_args( $args, $defaults );
38 $output = '';
39 if ( ! empty( $args['content'] ) ) {
40 $type = sanitize_html_class( $args['type'] );
41 if($type=='error'){$type='danger';}
42 $icon = !empty($args['icon']) ? "<i class='".esc_attr($args['icon'])."'></i>" : '';
43
44 // set default icon
45 if(!$icon && $args['icon']!==false && $type){
46 if($type=='danger'){$icon = '<i class="fas fa-exclamation-circle"></i>';}
47 elseif($type=='warning'){$icon = '<i class="fas fa-exclamation-triangle"></i>';}
48 elseif($type=='success'){$icon = '<i class="fas fa-check-circle"></i>';}
49 elseif($type=='info'){$icon = '<i class="fas fa-info-circle"></i>';}
50 }
51
52 $data = '';
53 $class = !empty($args['class']) ? esc_attr($args['class']) : '';
54 if($args['dismissible']){$class .= " alert-dismissible fade show";}
55
56 // open
57 $output .= '<div class="alert alert-' . $type . ' '.$class.'" role="alert" '.$data.'>';
58
59 // heading
60 if ( ! empty( $args['heading'] ) ) {
61 $output .= '<h4 class="alert-heading">' . $args['heading'] . '</h4>';
62 }
63
64 // icon
65 if ( ! empty( $icon) ) {
66 $output .= $icon." ";
67 }
68
69 // content
70 $output .= $args['content'];
71
72 // dismissible
73 if($args['dismissible']){
74
75 if ( $aui_bs5 ) {
76 $output .= '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>';
77 }else{
78 $output .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close">';
79 $output .= '<span aria-hidden="true">&times;</span>';
80 $output .= '</button>';
81 }
82 }
83
84 // footer
85 if ( ! empty( $args['footer'] ) ) {
86 $output .= '<hr>';
87 $output .= '<p class="mb-0">' . $args['footer'] . '</p>';
88 }
89
90 // close
91 $output .= '</div>';
92 }
93
94 return $output;
95 }
96
97 }