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 / counter.php

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

268 lines 9.4 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 /* Counter
8 /*-----------------------------------------------------------------------------------*/
9
10 class WPBakeryShortCode_borderless_wpbakery_counter extends WPBakeryShortCode {
11 protected function content( $atts, $content = null ) {
12 extract( shortcode_atts( array(
13 'title' => '',
14 'value' => '999',
15 'value_speed' => '2000',
16 'value_interval' => '1',
17 'checkicon' => '',
18 'icon' => '',
19 'title_tag' => 'h3',
20 'title_size' => '1.3rem',
21 'title_line_height' => '1em',
22 'title_color' => '',
23 'counter_size' => '4rem',
24 'counter_line_height' => '1em',
25 'counter_color' => '#818b92',
26 'icon_size' => '4rem',
27 'icon_line_height' => '2em',
28 'icon_color' => '',
29 //Static
30 'el_id' => '',
31 'el_class' => '',
32 'css' => '',
33 'css_animation' => ''
34 ), $atts ) );
35 $output = '';
36
37 // Assets.
38 wp_enqueue_style(
39 'borderless-wpbakery-style',
40 BORDERLESS__STYLES . 'wpbakery.min.css',
41 false,
42 BORDERLESS__VERSION
43 );
44 wp_enqueue_script(
45 'borderless-appear-script',
46 BORDERLESS__LIB . 'appear.js', array('jquery'),
47 '1.0.0',
48 true
49 );
50 wp_enqueue_script(
51 'borderless-countto-script',
52 BORDERLESS__LIB . 'countto.js', array('jquery'),
53 '1.2.0',
54 true
55 );
56 wp_enqueue_script(
57 'borderless-wpbakery-script',
58 BORDERLESS__SCRIPTS . 'borderless-wpbakery.min.js', array('jquery'),
59 BORDERLESS__VERSION,
60 true
61 );
62
63 // Retrieve data from the database.
64 $options = get_option( 'borderless' );
65
66 // Set default values
67 $borderless_primary_color = isset( $options['primary_color'] ) ? esc_attr( $options['primary_color'] ) : '#3379fc'; //Primary Color
68 $borderless_secondary_color = isset( $options['secondary_color'] ) ? esc_attr( $options['secondary_color'] ) : '#3379fc'; //Secondary Color
69 $borderless_text_color = isset( $options['text_color'] ) ? esc_attr( $options['text_color'] ) : ''; //Text Color
70 $borderless_accent_color = isset( $options['accent_color'] ) ? esc_attr( $options['accent_color'] ) : '#3379fc'; //Accent Color
71
72 // Default Extra Class, CSS and CSS animation
73 $css = isset( $atts['css'] ) ? esc_attr( $atts['css'] ) : '';
74 $el_id = isset( $atts['el_id'] ) ? 'id="' . esc_attr( $atts['el_id'] ) . '"' : '';
75 $el_class = isset( $atts['el_class'] ) ? esc_attr( $atts['el_class'] ) : '';
76 if ( '' !== $css_animation ) {
77 wp_enqueue_script( 'waypoints' );
78 $css_animation_style = ' wpb_animate_when_almost_visible wpb_' . esc_attr( $css_animation );
79 }
80 $class_to_filter = vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation );
81 $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );
82
83 // Set custom values
84 $title_color = esc_attr( $title_color ?: $borderless_primary_color ); //Title Color
85 $icon_color = esc_attr( $icon_color ?: $borderless_primary_color ); //Icon Color
86
87 // Output
88 $output .= '<div '.$el_id.' class="borderless-wpbakery-counter text-center '.esc_attr( $css_class ).'">';
89 if ( $checkicon == 'icon' ) {
90 $output .= '<div class="borderless-wpbakery-counter-icon"><i style="font-size:'.esc_attr( $icon_size ).'; line-height:'.esc_attr( $icon_line_height ).'; color:'.esc_attr( $icon_color ).';" class="'.esc_attr( $icon ).'"></i></div>';
91 }
92 $output .= '<div class="borderless-wpbakery-counter-paramns" style="font-size:'.esc_attr( $counter_size ).'; line-height:'.esc_attr( $counter_line_height ).'; color:'.esc_attr( $counter_color ).';" value="'.esc_attr( $value ).'" value-speed="'.esc_attr( $value_speed ).'" value-interval="'.esc_attr( $value_interval ).'"></div>';
93 if ( $title != '' ) {
94 $output .= '<'.esc_attr( $title_tag ).' style="font-size:'.esc_attr( $title_size ).'; line-height:'.esc_attr( $title_line_height ).'; color:'.$title_color.';" class="borderless-wpbakery-counter-title">'.esc_html( $title ).'</'.esc_attr( $title_tag ).'>';
95 }
96 $output .= '</div>';
97
98 return $output;
99 }
100 }
101
102 return array(
103 'name' => __( 'Counter', 'borderless' ),
104 'base' => 'borderless_wpbakery_counter',
105 'icon' => plugins_url('../images/counter.png', __FILE__),
106 'show_settings_on_create' => true,
107 'category' => __( 'Borderless', 'borderless' ),
108 'description' => __( 'Your milestones and achievements', 'borderless' ),
109 'params' => array(
110 array(
111 'type' => 'textfield',
112 'heading' => __( 'Title', 'borderless' ),
113 'param_name' => 'title',
114 'description' => __( 'Enter the title here.', 'borderless' ),
115 ),
116 array(
117 'type' => 'textfield',
118 'heading' => __( 'Counter Value', 'borderless' ),
119 'param_name' => 'value',
120 'description' => __( 'Enter number for counter without any special character.', 'borderless' ),
121 ),
122 array(
123 'type' => 'textfield',
124 'heading' => __( 'Counter Value Speed', 'borderless' ),
125 'param_name' => 'value_speed',
126 'description' => __( 'Enter number for counter without any special character.', 'borderless' ),
127 ),
128 array(
129 'type' => 'textfield',
130 'heading' => __( 'Counter Value Interval', 'borderless' ),
131 'param_name' => 'value_interval',
132 'description' => __( 'Enter number for counter without any special character.', 'borderless' ),
133 ),
134 array(
135 'type' => 'dropdown',
136 'heading' => __( 'Icon library', 'borderless' ),
137 'param_name' => 'checkicon',
138 'value' => array(
139 __( 'No', 'borderless' ) => '',
140 __( 'Yes', 'borderless' ) => 'icon',
141 ),
142 'description' => __( 'Enable Icon Library.', 'borderless' ),
143 ),
144 array(
145 'type' => 'iconmanager',
146 'heading' => __( 'Icon', 'borderless' ),
147 'param_name' => 'icon',
148 'description' => __( 'Select icon from library.', 'borderless' ),
149 'dependency' => array(
150 'element' => 'checkicon',
151 'value' => array( 'icon' ),
152 ),
153 ),
154 array(
155 'type' => 'dropdown',
156 'heading' => __( 'Title Tag', 'borderless' ),
157 'param_name' => 'title_tag',
158 'group' => 'Typography',
159 'value' => array(
160 __( 'H1', 'borderless' ) => 'h1',
161 __( 'H2', 'borderless' ) => 'h2',
162 __( 'H3', 'borderless' ) => 'h3',
163 __( 'H4', 'borderless' ) => 'h4',
164 __( 'H5', 'borderless' ) => 'h5',
165 __( 'H6', 'borderless' ) => 'h6',
166 __( 'p', 'borderless' ) => 'p',
167 __( 'div', 'borderless' ) => 'div',
168 ),
169 'description' => __( 'Select title tag.', 'borderless' ),
170 ),
171 array(
172 'type' => 'textfield',
173 'heading' => __( 'Title Font Size', 'borderless' ),
174 'param_name' => 'title_size',
175 'description' => __( 'Enter font size.', 'borderless' ),
176 'group' => 'Typography',
177 ),
178 array(
179 'type' => 'textfield',
180 'heading' => __( 'Title Line Height', 'borderless' ),
181 'param_name' => 'title_line_height',
182 'description' => __( 'Enter line height.', 'borderless' ),
183 'group' => 'Typography',
184 ),
185 array(
186 'type' => 'colorpicker',
187 'heading' => __( 'Title Color', 'borderless' ),
188 'param_name' => 'title_color',
189 'description' => __( 'Select custom color for the title.', 'borderless' ),
190 'group' => 'Typography',
191 ),
192 array(
193 'type' => 'textfield',
194 'heading' => __( 'Counter Size', 'borderless' ),
195 'param_name' => 'counter_size',
196 'description' => __( 'Enter font size.', 'borderless' ),
197 'group' => 'Typography',
198 ),
199 array(
200 'type' => 'textfield',
201 'heading' => __( 'Counter Line Height', 'borderless' ),
202 'param_name' => 'counter_line_height',
203 'description' => __( 'Enter line height.', 'borderless' ),
204 'group' => 'Typography',
205 ),
206 array(
207 'type' => 'colorpicker',
208 'heading' => __( 'Counter Color', 'borderless' ),
209 'param_name' => 'counter_color',
210 'description' => __( 'Select custom color for the number.', 'borderless' ),
211 'group' => 'Typography',
212 ),
213 array(
214 'type' => 'textfield',
215 'heading' => __( 'Icon Size', 'borderless' ),
216 'param_name' => 'icon_size',
217 'description' => __( 'Enter font size.', 'borderless' ),
218 'group' => 'Typography',
219 'dependency' => array(
220 'element' => 'checkicon',
221 'value' => array( 'icon' ),
222 ),
223 ),
224 array(
225 'type' => 'textfield',
226 'heading' => __( 'Icon Line Height', 'borderless' ),
227 'param_name' => 'icon_line_height',
228 'description' => __( 'Enter line height.', 'borderless' ),
229 'group' => 'Typography',
230 'dependency' => array(
231 'element' => 'checkicon',
232 'value' => array( 'icon' ),
233 ),
234 ),
235 array(
236 'type' => 'colorpicker',
237 'heading' => __( 'Icon Color', 'borderless' ),
238 'param_name' => 'icon_color',
239 'description' => __( 'Select custom color for the icon.', 'borderless' ),
240 'group' => 'Typography',
241 'dependency' => array(
242 'element' => 'checkicon',
243 'value' => array( 'icon' ),
244 ),
245 ),
246 // Animation
247 vc_map_add_css_animation(),
248 array(
249 'type' => 'el_id',
250 'heading' => __( 'Element ID', 'borderless' ),
251 'param_name' => 'el_id',
252 '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>' ),
253 ),
254 array(
255 'type' => 'textfield',
256 'heading' => __( 'Extra class name', 'borderless' ),
257 'param_name' => 'el_class',
258 'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'borderless' ),
259 ),
260 array(
261 'type' => 'css_editor',
262 'heading' => __( 'CSS box', 'borderless' ),
263 'param_name' => 'css',
264 'group' => __( 'Design Options', 'borderless' ),
265 ),
266 ),
267 );
268