list.php
4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
su_add_shortcode(
array(
'id' => 'list',
'callback' => 'su_shortcode_list',
'image' => su_get_plugin_url() . 'admin/images/shortcodes/list.svg',
'name' => __( 'List', 'shortcodes-ultimate' ),
'type' => 'wrap',
'group' => 'content',
'atts' => array(
'icon' => array(
'type' => 'icon',
'default' => '',
'name' => __( 'Icon', 'shortcodes-ultimate' ),
'desc' => __( 'You can upload custom icon for this list or pick a built-in icon', 'shortcodes-ultimate' ),
),
'icon_color' => array(
'type' => 'color',
'default' => '#333333',
'name' => __( 'Icon color', 'shortcodes-ultimate' ),
'desc' => __( 'This color will be applied to the selected icon. Does not works with uploaded icons', 'shortcodes-ultimate' ),
),
'indent' => array(
'type' => 'slider',
'default' => 0,
'step' => 1,
'min' => -100,
'max' => 100,
'name' => __( 'Indent', 'shortcodes-ultimate' ),
'desc' => __( 'Defines list indent size (in pixels). Negative numbers are also allowed', 'shortcodes-ultimate' ),
),
'class' => array(
'type' => 'extra_css_class',
'name' => __( 'Extra CSS class', 'shortcodes-ultimate' ),
'desc' => __( 'Additional CSS class name(s) separated by space(s)', 'shortcodes-ultimate' ),
'default' => '',
),
),
'content' => __( "<ul>\n<li>List item</li>\n<li>List item</li>\n<li>List item</li>\n</ul>", 'shortcodes-ultimate' ),
'desc' => __( 'Styled unordered list', 'shortcodes-ultimate' ),
'icon' => 'list-ol',
)
);
function su_shortcode_list( $atts = null, $content = null ) {
$atts = shortcode_atts(
array(
'icon' => 'icon: star',
'icon_color' => '#333',
'indent' => 0,
'style' => null,
'class' => '',
),
$atts,
'list'
);
// Backward compatibility // 4.2.3+
if ( null !== $atts['style'] ) {
switch ( $atts['style'] ) {
case 'star':
$atts['icon'] = 'icon: star';
$atts['icon_color'] = '#ffd647';
break;
case 'arrow':
$atts['icon'] = 'icon: arrow-right';
$atts['icon_color'] = '#00d1ce';
break;
case 'check':
$atts['icon'] = 'icon: check';
$atts['icon_color'] = '#17bf20';
break;
case 'cross':
$atts['icon'] = 'icon: remove';
$atts['icon_color'] = '#ff142b';
break;
case 'thumbs':
$atts['icon'] = 'icon: thumbs-o-up';
$atts['icon_color'] = '#8a8a8a';
break;
case 'link':
$atts['icon'] = 'icon: external-link';
$atts['icon_color'] = '#5c5c5c';
break;
case 'gear':
$atts['icon'] = 'icon: cog';
$atts['icon_color'] = '#ccc';
break;
case 'time':
$atts['icon'] = 'icon: time';
$atts['icon_color'] = '#a8a8a8';
break;
case 'note':
$atts['icon'] = 'icon: edit';
$atts['icon_color'] = '#f7d02c';
break;
case 'plus':
$atts['icon'] = 'icon: plus-sign';
$atts['icon_color'] = '#61dc3c';
break;
case 'guard':
$atts['icon'] = 'icon: shield';
$atts['icon_color'] = '#1bbe08';
break;
case 'event':
$atts['icon'] = 'icon: bullhorn';
$atts['icon_color'] = '#ff4c42';
break;
case 'idea':
$atts['icon'] = 'icon: sun';
$atts['icon_color'] = '#ffd880';
break;
case 'settings':
$atts['icon'] = 'icon: cogs';
$atts['icon_color'] = '#8a8a8a';
break;
case 'twitter':
$atts['icon'] = 'icon: twitter-sign';
$atts['icon_color'] = '#00ced6';
break;
}
}
if ( strpos( $atts['icon'], 'icon:' ) !== false ) {
$atts['icon'] = '<i class="sui sui-' . esc_attr( trim( str_replace( 'icon:', '', $atts['icon'] ) ) ) . '" style="color:' . esc_attr( $atts['icon_color'] ) . '"></i>';
su_query_asset( 'css', 'su-icons' );
} else {
$atts['icon'] = '<img src="' . esc_attr( $atts['icon'] ) . '" alt="" />';
}
su_query_asset( 'css', 'su-shortcodes' );
$indent_pos = is_rtl() ? 'right' : 'left';
return '<div class="su-list' . su_get_css_class( $atts ) . '" style="margin-' . $indent_pos . ':' . intval( $atts['indent'] ) . 'px">' . str_replace( '<li>', '<li>' . $atts['icon'] . ' ', su_do_nested_shortcodes( $content, 'list' ) ) . '</div>';
}