PluginProbe
Borderless – Addons and Templates for Elementor / 1.4.9
Borderless – Addons and Templates for Elementor v1.4.9
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 All 78 releases
borderless / modules / wpbakery / elements / icon.php

icon.php in Borderless – Addons and Templates for Elementor 1.4.9, at modules/wpbakery/elements/icon.php

222 lines 7.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( '-1' );
4 }
5
6 /*-----------------------------------------------------------------------------------*/
7 /* Icon
8 /*-----------------------------------------------------------------------------------*/
9
10 class WPBakeryShortCode_borderless_wpbakery_icon extends WPBakeryShortCode {
11 protected function content( $atts, $content = null ) {
12 extract( shortcode_atts( array(
13 'icon' => '',
14 'icon_color' => '',
15 'custom_icon_color' => '',
16 'shape' => '',
17 'color_shape' => '',
18 'icon_size' => '32px',
19 'spacing' => '',
20 'icon_alignment' => 'left',
21 'link' => '',
22 //Static
23 'el_id' => '',
24 'el_class' => '',
25 'css' => '',
26 'css_animation' => ''
27 ), $atts ) );
28 $output = '';
29
30 // Assets.
31 wp_enqueue_style(
32 'borderless-wpbakery-style',
33 BORDERLESS__STYLES . 'wpbakery.min.css',
34 false,
35 BORDERLESS__VERSION
36 );
37
38
39 // Retrieve data from the database.
40 $options = get_option( 'borderless' );
41
42
43 // Set default values
44 $borderless_primary_color = isset( $options['primary_color'] ) ? $options['primary_color'] : '#3379fc'; //Primary Color
45 $borderless_secondary_color = isset( $options['secondary_color'] ) ? $options['secondary_color'] : '#3379fc'; //Secondary Color
46 $borderless_text_color = isset( $options['text_color'] ) ? $options['text_color'] : ''; //Text Color
47 $borderless_accent_color = isset( $options['accent_color'] ) ? $options['accent_color'] : '#3379fc'; //Accent Color
48
49
50 // Default Extra Class, CSS and CSS animation
51 $css = isset( $atts['css'] ) ? $atts['css'] : '';
52 $el_id = isset( $atts['el_id'] ) ? 'id="' . esc_attr( $el_id ) . '"' : '';
53 $el_class = isset( $atts['el_class'] ) ? $atts['el_class'] : '';
54 if ( '' !== $css_animation ) {
55 wp_enqueue_script( 'waypoints' );
56 $css_animation_style = ' wpb_animate_when_almost_visible wpb_' . $css_animation;
57 }
58 $class_to_filter = vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation );
59 $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );
60
61
62 // Set custom values
63 $link = vc_build_link( $link );
64 $color = ($icon_color == 'custom') ? 'color:'.$custom_icon_color.';' : 'color:'.$borderless_primary_color.';'; //Icon Color
65 $font_size_reference = $icon_size;
66 $icon_size = $icon_size ? 'font-size:'.$icon_size.';' : ' font-size:4rem;'; //Font Size
67 $icon_alignment = $icon_alignment ? 'text-align:'.$icon_alignment.';' : ''; //Icon Alignment
68
69 if($shape != '') {
70
71 if($shape == 'rounded' || $shape == 'square' || $shape == 'round') {
72 $color_shape = $color_shape ? 'background-color:'.$color_shape.';' : 'background-color:'.$borderless_primary_color.';'; //Background Color
73 } else {
74 $color_shape = $color_shape ? 'border-color:'.$color_shape.';' : 'border-color:'.$borderless_primary_color.';'; //Border Color
75 }
76
77 } else {
78 $color_shape = $default_color_shape = '';
79 }
80
81 if($spacing != '') {
82 $spacing = 'height:'.$spacing.'; width:'.$spacing.';';
83 } else {
84 $spacing = 'height:calc('.$font_size_reference.' + 2em); width:calc('.$font_size_reference.' + 2em);';
85 }
86
87
88 // Output
89 $output .= '<div '.$el_id.' class="borderless-wpbakery-icon background-shape '.$css_class.'" style="'.$icon_alignment.'">';
90 if($link['url'] != ''){$output .= '<a href="'.esc_attr( $link['url'] ).'">';}
91 $output .= '<div style="'.$color_shape.''.$spacing.'" class="single-icon '.$shape.'">';
92 $output .= '<i class="'.$icon.'" style="'.$color.$icon_size.'" aria-hidden="true"></i>';
93 $output .= '</div>';
94 if($link['url'] != ''){$output .= '</a>';}
95 $output .= '</div>';
96
97 return $output;
98 }
99 }
100
101 return array(
102 'name' => __( 'Icon', 'borderless' ),
103 'base' => 'borderless_wpbakery_icon',
104 'icon' => plugins_url('../images/icon.png', __FILE__),
105 'show_settings_on_create' => true,
106 'category' => __( 'Borderless', 'borderless' ),
107 'description' => __( 'Choose an icon from libraries', 'borderless' ),
108 'params' => array(
109 array(
110 'type' => 'iconmanager',
111 'heading' => __( 'Icon', 'borderless' ),
112 'param_name' => 'icon',
113 'description' => __( 'Select icon from library.', 'borderless' ),
114 ),
115 array(
116 'type' => 'dropdown',
117 'heading' => __( 'Icon color', 'borderless' ),
118 'param_name' => 'icon_color',
119 'value' => array(
120 __( 'Preset Color', 'borderless' ) => '',
121 __( 'Custom Color', 'borderless' ) => 'custom',
122 ),
123 'description' => __( 'Select icon color.', 'borderless' ),
124 ),
125 array(
126 'type' => 'colorpicker',
127 'heading' => __( 'Custom Icon Color', 'borderless' ),
128 'param_name' => 'custom_icon_color',
129 'description' => __( 'Select custom icon color.', 'borderless' ),
130 'dependency' => array(
131 'element' => 'icon_color',
132 'value' => array( 'custom' ),
133 ),
134 ),
135 array(
136 'type' => 'dropdown',
137 'heading' => __( 'Shape', 'borderless' ),
138 'description' => __( 'Select icon shape.', 'borderless' ),
139 'param_name' => 'shape',
140 'value' => array(
141 __( 'None', 'borderless' ) => '',
142 __( 'Rounded', 'borderless' ) => 'rounded',
143 __( 'Square', 'borderless' ) => 'square',
144 __( 'Round', 'borderless' ) => 'round',
145 __( 'Outline Rounded', 'borderless' ) => 'outline-rounded',
146 __( 'Outline Square', 'borderless' ) => 'outline-square',
147 __( 'Outline Round', 'borderless' ) => 'outline-round',
148 ),
149 ),
150 array(
151 'type' => 'colorpicker',
152 'heading' => __( 'Color Shape', 'borderless' ),
153 'param_name' => 'color_shape',
154 'description' => __( 'Select custom shape background color.', 'borderless' ),
155 'dependency' => array(
156 'element' => 'shape',
157 'value' => array( 'rounded','square','round','outline-rounded','outline-square','outline-round', ),
158 ),
159 ),
160 array(
161 'type' => 'textfield',
162 'heading' => __( 'Size', 'borderless' ),
163 'param_name' => 'icon_size',
164 'description' => __( 'Icon size. Default value is 32px.', 'borderless' ),
165 'value' => '32px',
166 ),
167 array(
168 'type' => 'textfield',
169 'heading' => __( 'Spacing', 'borderless' ),
170 'param_name' => 'spacing',
171 'description' => __( 'Select icon spacing.', 'borderless' ),
172 ),
173 array(
174 'type' => 'textfield',
175 'heading' => __( 'Gap', 'borderless' ),
176 'param_name' => 'gap',
177 'description' => __( 'Select icon gap.', 'borderless' ),
178 ),
179 array(
180 'type' => 'dropdown',
181 'heading' => __( 'Alignment', 'borderless' ),
182 'param_name' => 'icon_alignment',
183 'value' => array(
184 __( 'Left', 'borderless' ) => 'left',
185 __( 'Right', 'borderless' ) => 'right',
186 __( 'Center', 'borderless' ) => 'center',
187 ),
188 'description' => __( 'Select icon alignment.', 'borderless' ),
189 ),
190 array(
191 'type' => 'vc_link',
192 'heading' => __( 'URL (Link)', 'borderless' ),
193 'param_name' => 'link',
194 'description' => __( 'Add link to icon.', 'borderless' ),
195 ),
196
197 // Animation
198 vc_map_add_css_animation(),
199
200 array(
201 'type' => 'el_id',
202 'heading' => __( 'Element ID', 'borderless' ),
203 'param_name' => 'el_id',
204 'description' => sprintf( __( 'Enter element ID (Note: make sure it is unique and valid according to %sw3c specification%s).', 'borderless' ), '<a href="https://www.w3schools.com/tags/att_global_id.asp" target="_blank">', '</a>' ),
205 ),
206
207 array(
208 'type' => 'textfield',
209 'heading' => __( 'Extra class name', 'borderless' ),
210 'param_name' => 'el_class',
211 'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'borderless' ),
212 ),
213
214 array(
215 'type' => 'css_editor',
216 'heading' => __( 'CSS box', 'borderless' ),
217 'param_name' => 'css',
218 'group' => __( 'Design Options', 'borderless' ),
219 ),
220 ),
221 );
222