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

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

286 lines 10.3 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 /* Testimonials
8 /*-----------------------------------------------------------------------------------*/
9
10 class WPBakeryShortCode_borderless_wpbakery_testimonial_section extends WPBakeryShortCode {
11 protected function content( $atts, $content = null ) {
12 $atts = shortcode_atts( array(
13 'title' => '',
14 'occupation' => '',
15 'photo' => '',
16 'content' => $content,
17 'testimonial_color' => '',
18 'testimonial_name_color' => '',
19 'testimonial_occupation_color' => '',
20 // Static
21 'el_id' => '',
22 'el_class' => '',
23 'css' => '',
24 'css_animation' => ''
25 ), $atts );
26
27 $output = '';
28
29 // Assets.
30 wp_enqueue_style(
31 'borderless-wpbakery-style',
32 BORDERLESS__STYLES . 'wpbakery.min.css',
33 false,
34 BORDERLESS__VERSION
35 );
36 wp_enqueue_style(
37 'borderless-flickity-style',
38 BORDERLESS__LIB . 'flickity/flickity.css',
39 false,
40 BORDERLESS__VERSION
41 );
42 wp_enqueue_script(
43 'borderless-wpbakery-script',
44 BORDERLESS__SCRIPTS . 'borderless-wpbakery.min.js',
45 array( 'jquery' ),
46 BORDERLESS__VERSION,
47 true
48 );
49 wp_enqueue_script(
50 'borderless-flickity-script',
51 BORDERLESS__LIB . 'flickity/flickity.js',
52 array( 'jquery' ),
53 '2.2.2',
54 true
55 );
56
57 // Retrieve data from the database.
58 $options = get_option( 'borderless' );
59
60 // Set default values
61 $borderless_primary_color = isset( $options['primary_color'] ) ? $options['primary_color'] : '#3379fc'; // Primary Color
62 $borderless_secondary_color = isset( $options['secondary_color'] ) ? $options['secondary_color'] : '#3379fc'; // Secondary Color
63 $borderless_text_color = isset( $options['text_color'] ) ? $options['text_color'] : ''; // Text Color
64 $borderless_accent_color = isset( $options['accent_color'] ) ? $options['accent_color'] : '#3379fc'; // Accent Color
65
66 // Picture
67 if ( $atts['photo'] ) {
68 $img = wp_get_attachment_image_src( $atts['photo'], 'thumbnail' );
69 $imgSrc = isset( $img[0] ) ? esc_url( $img[0] ) : '';
70 } else {
71 $imgSrc = '';
72 }
73
74 // Default Extra Class, CSS and CSS animation
75 $css = isset( $atts['css'] ) ? $atts['css'] : '';
76 $el_id = isset( $atts['el_id'] ) ? $atts['el_id'] : '';
77 $el_id = ! empty( $el_id ) ? 'id="' . esc_attr( $el_id ) . '"' : '';
78 $el_class = isset( $atts['el_class'] ) ? $atts['el_class'] : '';
79
80 if ( '' !== $atts['css_animation'] ) {
81 wp_enqueue_script( 'waypoints' );
82 $css_animation_style = ' wpb_animate_when_almost_visible wpb_' . esc_attr( $atts['css_animation'] );
83 }
84
85 $class_to_filter = vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $atts['css_animation'] );
86 $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );
87
88 // Custom Colors
89 $testimonial_color_style = '';
90 if ( ! empty( $atts['testimonial_color'] ) ) {
91 $testimonial_color_style = 'style="color:' . esc_attr( $atts['testimonial_color'] ) . ';"';
92 }
93
94 $testimonial_name_color_style = '';
95 if ( ! empty( $atts['testimonial_name_color'] ) ) {
96 $testimonial_name_color_style = 'style="color:' . esc_attr( $atts['testimonial_name_color'] ) . ';"';
97 }
98
99 $testimonial_occupation_color_style = '';
100 if ( ! empty( $atts['testimonial_occupation_color'] ) ) {
101 $testimonial_occupation_color_style = 'style="color:' . esc_attr( $atts['testimonial_occupation_color'] ) . ';"';
102 }
103
104 // Output
105 $output .= '<div ' . $el_id . ' class="borderless-wpbakery-testimonial-section carousel-cell ' . esc_attr( $css_class ) . '">';
106 $output .= '<p ' . $testimonial_color_style . ' class="testimonial-quote">' . wp_kses_post( $content ) . '</p>';
107 $output .= '<div class="testimonial-photo-title-occupation">';
108 if ( ! empty( $imgSrc ) ) {
109 $output .= '<div class="testimonial-photo"><img src="' . esc_url( $imgSrc ) . '" /></div>';
110 }
111 $output .= '<div class="testimonial-title-occupation">';
112 if ( ! empty( $atts['title'] ) ) {
113 $output .= '<span ' . $testimonial_name_color_style . ' class="testimonial-title">' . esc_html( $atts['title'] ) . '</span>';
114 }
115 if ( ! empty( $atts['occupation'] ) ) {
116 $output .= '<span ' . $testimonial_occupation_color_style . ' class="testimonial-occupation">' . esc_html( $atts['occupation'] ) . '</span>';
117 }
118 $output .= '</div></div></div>';
119
120 return $output;
121 }
122 }
123
124 class WPBakeryShortCode_borderless_wpbakery_testimonial extends WPBakeryShortCodesContainer {
125 protected function content( $atts, $content = null ) {
126 $atts = shortcode_atts( array(
127 // Static
128 'el_id' => '',
129 'el_class' => '',
130 'css' => '',
131 'css_animation' => ''
132 ), $atts );
133
134 $output = '';
135
136 // Default Extra Class, CSS and CSS animation
137 $css = isset( $atts['css'] ) ? $atts['css'] : '';
138 $el_id = isset( $atts['el_id'] ) ? $atts['el_id'] : '';
139 $el_id = ! empty( $el_id ) ? 'id="' . esc_attr( $el_id ) . '"' : '';
140 $el_class = isset( $atts['el_class'] ) ? $atts['el_class'] : '';
141
142 if ( '' !== $atts['css_animation'] ) {
143 wp_enqueue_script( 'waypoints' );
144 $css_animation_style = ' wpb_animate_when_almost_visible wpb_' . esc_attr( $atts['css_animation'] );
145 }
146
147 $class_to_filter = vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $atts['css_animation'] );
148 $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );
149
150 // Output
151 $output .= '<div ' . $el_id . ' class="borderless-wpbakery-testimonial ' . esc_attr( $css_class ) . '">
152 <div class="testimonials">
153 <div class="testimonials-container">
154 <div class="testimonial">
155 <div class="main-carousel">' . wpb_js_remove_wpautop( do_shortcode( $content ) ) . '</div>
156 </div>
157 </div>
158 </div>
159 </div>';
160
161 return $output;
162 }
163 }
164
165
166 vc_map( array(
167 'name' => __( 'Testimonial', 'borderless' ),
168 'base' => 'borderless_wpbakery_testimonial',
169 'icon' => plugins_url('../images/testimonial.png', __FILE__),
170 "as_parent" => array('only' => 'borderless_wpbakery_testimonial_section'),
171 "content_element" => true,
172 "show_settings_on_create" => false,
173 "is_container" => true,
174 'category' => __( 'Borderless', 'borderless' ),
175 'description' => __( 'Display testimonials', 'borderless' ),
176 'admin_enqueue_js' => array(BORDERLESS__LIB . 'flickity/flickity.js'),
177 'params' => array(
178
179 vc_map_add_css_animation(),
180
181 array(
182 'type' => 'el_id',
183 'heading' => __( 'Element ID', 'borderless' ),
184 'param_name' => 'el_id',
185 '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>' ),
186 ),
187
188 array(
189 'type' => 'textfield',
190 'heading' => __( 'Extra class name', 'borderless' ),
191 'param_name' => 'el_class',
192 'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'borderless' ),
193 ),
194
195 array(
196 'type' => 'css_editor',
197 'heading' => __( 'CSS box', 'borderless' ),
198 'param_name' => 'css',
199 'group' => __( 'Design Options', 'borderless' ),
200 ),
201 ),
202 "js_view" => 'VcColumnView'
203 ) );
204
205 vc_map( array(
206 "name" => __("Testimonial Section", 'borderless'),
207 'description' => __( 'Testimonial content panels item.', 'borderless' ),
208 "base" => "borderless_wpbakery_testimonial_section",
209 'icon' => plugins_url('../images/testimonial-section.png', __FILE__),
210 "content_element" => true,
211 "as_child" => array('only' => 'borderless_wpbakery_testimonial_container'),
212 'category' => __( 'Borderless', 'borderless' ),
213 "params" => array(
214 array(
215 'type' => 'textfield',
216 'heading' => __( 'Name', 'borderless' ),
217 'param_name' => 'title',
218 ),
219 array(
220 'type' => 'textfield',
221 'heading' => __( 'Occupation', 'borderless' ),
222 'param_name' => 'occupation',
223 ),
224 array(
225 'type' => 'attach_image',
226 'heading' => __( 'Photo', 'borderless' ),
227 'param_name' => 'photo',
228 'value' => '',
229 'description' => __( 'Select image from media library.', 'borderless' ),
230 ),
231 array(
232 'type' => 'textarea_html',
233 'holder' => 'div',
234 'heading' => __( 'Content', 'borderless' ),
235 'param_name' => 'content',
236 'value' => __( '<p>I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.</p>', 'borderless' ),
237 ),
238
239 array(
240 'type' => 'colorpicker',
241 'heading' => __( 'Testimonial Color', 'borderless' ),
242 'param_name' => 'testimonial_color',
243 'description' => __( 'Select testimonial content color.', 'borderless' ),
244 'group' => 'Color',
245 ),
246
247 array(
248 'type' => 'colorpicker',
249 'heading' => __( 'Testimonial Name Color', 'borderless' ),
250 'param_name' => 'testimonial_name_color',
251 'description' => __( 'Select testimonial name color.', 'borderless' ),
252 'group' => 'Color',
253 ),
254
255 array(
256 'type' => 'colorpicker',
257 'heading' => __( 'Testimonial Occupation Color', 'borderless' ),
258 'param_name' => 'testimonial_occupation_color',
259 'description' => __( 'Select testimonial occupation color.', 'borderless' ),
260 'group' => 'Color',
261 ),
262
263 vc_map_add_css_animation(),
264
265 array(
266 'type' => 'el_id',
267 'heading' => __( 'Element ID', 'borderless' ),
268 'param_name' => 'el_id',
269 '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>' ),
270 ),
271
272 array(
273 'type' => 'textfield',
274 'heading' => __( 'Extra class name', 'borderless' ),
275 'param_name' => 'el_class',
276 'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'borderless' ),
277 ),
278
279 array(
280 'type' => 'css_editor',
281 'heading' => __( 'CSS box', 'borderless' ),
282 'param_name' => 'css',
283 'group' => __( 'Design Options', 'borderless' ),
284 ),
285 )
286 ) );