PluginProbe
Borderless – Addons and Templates for Elementor / trunk
Borderless – Addons and Templates for Elementor vtrunk
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 trunk, at modules/wpbakery/elements/icon.php

214 lines 7.9 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 // Retrieve data from the database.
39 $options = get_option( 'borderless' );
40
41 // Set default values
42 $borderless_primary_color = isset( $options['primary_color'] ) ? esc_attr( $options['primary_color'] ) : '#3379fc'; //Primary Color
43 $borderless_secondary_color = isset( $options['secondary_color'] ) ? esc_attr( $options['secondary_color'] ) : '#3379fc'; //Secondary Color
44 $borderless_text_color = isset( $options['text_color'] ) ? esc_attr( $options['text_color'] ) : ''; //Text Color
45 $borderless_accent_color = isset( $options['accent_color'] ) ? esc_attr( $options['accent_color'] ) : '#3379fc'; //Accent Color
46
47 // Default Extra Class, CSS and CSS animation
48 $css = isset( $atts['css'] ) ? esc_attr( $atts['css'] ) : '';
49 $el_id = isset( $atts['el_id'] ) ? 'id="' . esc_attr( $atts['el_id'] ) . '"' : '';
50 $el_class = isset( $atts['el_class'] ) ? esc_attr( $atts['el_class'] ) : '';
51 if ( '' !== $css_animation ) {
52 wp_enqueue_script( 'waypoints' );
53 $css_animation_style = ' wpb_animate_when_almost_visible wpb_' . esc_attr( $css_animation );
54 }
55 $class_to_filter = vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation );
56 $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );
57
58 // Set custom values
59 $link = vc_build_link( $link );
60 $color = ($icon_color == 'custom') ? 'color:' . esc_attr( $custom_icon_color ) . ';' : 'color:' . esc_attr( $borderless_primary_color ) . ';'; //Icon Color
61 $font_size_reference = esc_attr( $icon_size );
62 $icon_size = $icon_size ? 'font-size:' . esc_attr( $icon_size ) . ';' : ' font-size:4rem;'; //Font Size
63 $icon_alignment = $icon_alignment ? 'text-align:' . esc_attr( $icon_alignment ) . ';' : ''; //Icon Alignment
64
65 if ( $shape != '' ) {
66 if ( $shape == 'rounded' || $shape == 'square' || $shape == 'round' ) {
67 $color_shape = $color_shape ? 'background-color:' . esc_attr( $color_shape ) . ';' : 'background-color:' . esc_attr( $borderless_primary_color ) . ';'; //Background Color
68 } else {
69 $color_shape = $color_shape ? 'border-color:' . esc_attr( $color_shape ) . ';' : 'border-color:' . esc_attr( $borderless_primary_color ) . ';'; //Border Color
70 }
71 } else {
72 $color_shape = $default_color_shape = '';
73 }
74
75 if ( $spacing != '' ) {
76 $spacing = 'height:' . esc_attr( $spacing ) . '; width:' . esc_attr( $spacing ) . ';';
77 } else {
78 $spacing = 'height:calc(' . esc_attr( $font_size_reference ) . ' + 2em); width:calc(' . esc_attr( $font_size_reference ) . ' + 2em);';
79 }
80
81 // Output
82 $output .= '<div ' . $el_id . ' class="borderless-wpbakery-icon background-shape ' . esc_attr( $css_class ) . '" style="' . esc_attr( $icon_alignment ) . '">';
83 if ( ! empty( $link['url'] ) ) {
84 $output .= '<a href="' . esc_url( $link['url'] ) . '">';
85 }
86 $output .= '<div style="' . esc_attr( $color_shape ) . '' . esc_attr( $spacing ) . '" class="single-icon ' . esc_attr( $shape ) . '">';
87 $output .= '<i class="' . esc_attr( $icon ) . '" style="' . esc_attr( $color ) . esc_attr( $icon_size ) . '" aria-hidden="true"></i>';
88 $output .= '</div>';
89 if ( ! empty( $link['url'] ) ) {
90 $output .= '</a>';
91 }
92 $output .= '</div>';
93
94 return $output;
95 }
96 }
97
98 return array(
99 'name' => __( 'Icon', 'borderless' ),
100 'base' => 'borderless_wpbakery_icon',
101 'icon' => plugins_url('../images/icon.png', __FILE__),
102 'show_settings_on_create' => true,
103 'category' => __( 'Borderless', 'borderless' ),
104 'description' => __( 'Choose an icon from libraries', 'borderless' ),
105 'params' => array(
106 array(
107 'type' => 'iconmanager',
108 'heading' => __( 'Icon', 'borderless' ),
109 'param_name' => 'icon',
110 'description' => __( 'Select icon from library.', 'borderless' ),
111 ),
112 array(
113 'type' => 'dropdown',
114 'heading' => __( 'Icon color', 'borderless' ),
115 'param_name' => 'icon_color',
116 'value' => array(
117 __( 'Preset Color', 'borderless' ) => '',
118 __( 'Custom Color', 'borderless' ) => 'custom',
119 ),
120 'description' => __( 'Select icon color.', 'borderless' ),
121 ),
122 array(
123 'type' => 'colorpicker',
124 'heading' => __( 'Custom Icon Color', 'borderless' ),
125 'param_name' => 'custom_icon_color',
126 'description' => __( 'Select custom icon color.', 'borderless' ),
127 'dependency' => array(
128 'element' => 'icon_color',
129 'value' => array( 'custom' ),
130 ),
131 ),
132 array(
133 'type' => 'dropdown',
134 'heading' => __( 'Shape', 'borderless' ),
135 'description' => __( 'Select icon shape.', 'borderless' ),
136 'param_name' => 'shape',
137 'value' => array(
138 __( 'None', 'borderless' ) => '',
139 __( 'Rounded', 'borderless' ) => 'rounded',
140 __( 'Square', 'borderless' ) => 'square',
141 __( 'Round', 'borderless' ) => 'round',
142 __( 'Outline Rounded', 'borderless' ) => 'outline-rounded',
143 __( 'Outline Square', 'borderless' ) => 'outline-square',
144 __( 'Outline Round', 'borderless' ) => 'outline-round',
145 ),
146 ),
147 array(
148 'type' => 'colorpicker',
149 'heading' => __( 'Color Shape', 'borderless' ),
150 'param_name' => 'color_shape',
151 'description' => __( 'Select custom shape background color.', 'borderless' ),
152 'dependency' => array(
153 'element' => 'shape',
154 'value' => array( 'rounded', 'square', 'round', 'outline-rounded', 'outline-square', 'outline-round' ),
155 ),
156 ),
157 array(
158 'type' => 'textfield',
159 'heading' => __( 'Size', 'borderless' ),
160 'param_name' => 'icon_size',
161 'description' => __( 'Icon size. Default value is 32px.', 'borderless' ),
162 'value' => '32px',
163 ),
164 array(
165 'type' => 'textfield',
166 'heading' => __( 'Spacing', 'borderless' ),
167 'param_name' => 'spacing',
168 'description' => __( 'Select icon spacing.', 'borderless' ),
169 ),
170 array(
171 'type' => 'textfield',
172 'heading' => __( 'Gap', 'borderless' ),
173 'param_name' => 'gap',
174 'description' => __( 'Select icon gap.', 'borderless' ),
175 ),
176 array(
177 'type' => 'dropdown',
178 'heading' => __( 'Alignment', 'borderless' ),
179 'param_name' => 'icon_alignment',
180 'value' => array(
181 __( 'Left', 'borderless' ) => 'left',
182 __( 'Right', 'borderless' ) => 'right',
183 __( 'Center', 'borderless' ) => 'center',
184 ),
185 'description' => __( 'Select icon alignment.', 'borderless' ),
186 ),
187 array(
188 'type' => 'vc_link',
189 'heading' => __( 'URL (Link)', 'borderless' ),
190 'param_name' => 'link',
191 'description' => __( 'Add link to icon.', 'borderless' ),
192 ),
193 vc_map_add_css_animation(),
194 array(
195 'type' => 'el_id',
196 'heading' => __( 'Element ID', 'borderless' ),
197 'param_name' => 'el_id',
198 '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>' ),
199 ),
200 array(
201 'type' => 'textfield',
202 'heading' => __( 'Extra class name', 'borderless' ),
203 'param_name' => 'el_class',
204 'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'borderless' ),
205 ),
206 array(
207 'type' => 'css_editor',
208 'heading' => __( 'CSS box', 'borderless' ),
209 'param_name' => 'css',
210 'group' => __( 'Design Options', 'borderless' ),
211 ),
212 ),
213 );
214