about-widget.php
6 years ago
accordion-widget.php
6 years ago
accordion.php
6 years ago
attachment-url.php
6 years ago
audio.php
6 years ago
before-after.php
6 years ago
button.php
6 years ago
code.php
6 years ago
contact-box.php
6 years ago
contact-form.php
6 years ago
custom-list.php
6 years ago
divider.php
6 years ago
dropcap.php
6 years ago
facebook.php
6 years ago
flickr.php
6 years ago
gallery.php
6 years ago
general-element-fields.php
6 years ago
gmap.php
6 years ago
highlight.php
6 years ago
image.php
6 years ago
instagram-feed.php
6 years ago
latest-items.php
8 years ago
latest-posts-slider.php
6 years ago
popular-posts-widget.php
6 years ago
quote.php
6 years ago
recent-posts-grid-carousel.php
6 years ago
recent-posts-land-style.php
6 years ago
recent-posts-masonry.php
6 years ago
recent-posts-tiles-carousel.php
6 years ago
recent-posts-tiles.php
6 years ago
recent-posts-timeline.php
6 years ago
recent-posts-widget.php
6 years ago
recent-products.php
6 years ago
related-posts.php
8 years ago
sample-element.php
6 years ago
search.php
6 years ago
socials-list.php
6 years ago
staff.php
6 years ago
tab-widget.php
6 years ago
tabs.php
6 years ago
testimonial.php
6 years ago
text.php
6 years ago
touch-slider.php
6 years ago
video.php
6 years ago
testimonial.php
285 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Testimonial Widget |
| 4 | * |
| 5 | * |
| 6 | * @package Auxin |
| 7 | * @license LICENSE.txt |
| 8 | * @author averta |
| 9 | * @link http://phlox.pro/ |
| 10 | * @copyright (c) 2010-2020 averta |
| 11 | */ |
| 12 | |
| 13 | function auxin_get_testimonial_master_array( $master_array ) { |
| 14 | |
| 15 | $master_array['aux_testimonial'] = array( |
| 16 | 'name' => __('Testimonial ', 'auxin-elements'), |
| 17 | 'auxin_output_callback' => 'auxin_widget_testimonial_callback', |
| 18 | 'base' => 'aux_testimonial', |
| 19 | 'description' => __('Testimonial Element', 'auxin-elements'), |
| 20 | 'class' => 'aux-widget-testimonial', |
| 21 | 'show_settings_on_create' => true, |
| 22 | 'weight' => 1, |
| 23 | 'is_widget' => true, |
| 24 | 'is_shortcode' => true, |
| 25 | 'is_so' => false, |
| 26 | 'is_vc' => true, |
| 27 | 'category' => THEME_NAME, |
| 28 | 'group' => '', |
| 29 | 'so_api' => false, |
| 30 | 'admin_enqueue_js' => '', |
| 31 | 'admin_enqueue_css' => '', |
| 32 | 'front_enqueue_js' => '', |
| 33 | 'front_enqueue_css' => '', |
| 34 | 'icon' => 'aux-element aux-pb-icons-testimonial', |
| 35 | 'custom_markup' => '', |
| 36 | 'js_view' => '', |
| 37 | 'html_template' => '', |
| 38 | 'deprecated' => '', |
| 39 | 'content_element' => '', |
| 40 | 'as_parent' => '', |
| 41 | 'as_child' => '', |
| 42 | 'params' => array( |
| 43 | array( |
| 44 | 'heading' => __( 'Testimonial Templates','auxin-elements' ), |
| 45 | 'description' => '', |
| 46 | 'param_name' => 'template', |
| 47 | 'type' => 'aux_visual_select', |
| 48 | 'def_value' => 'default', |
| 49 | 'holder' => '', |
| 50 | 'class' => 'template', |
| 51 | 'admin_label' => false, |
| 52 | 'dependency' => '', |
| 53 | 'weight' => '', |
| 54 | 'group' => '', |
| 55 | 'edit_field_class' => '', |
| 56 | 'choices' => array( |
| 57 | 'default' => array( |
| 58 | 'label' => __( 'Default Template', 'auxin-elements' ), |
| 59 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/testimonial-1.svg' |
| 60 | ), |
| 61 | 'def-img' => array( |
| 62 | 'label' => __( 'Default Template With Image', 'auxin-elements' ), |
| 63 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/testimonial-2.svg' |
| 64 | ), |
| 65 | 'bordered' => array( |
| 66 | 'label' => __( 'Bordered On Content', 'auxin-elements' ), |
| 67 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/testimonial-3.svg' |
| 68 | ), |
| 69 | 'quote' => array( |
| 70 | 'label' => __( 'Quotation Mark on Top of the Content', 'auxin-elements' ), |
| 71 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/testimonial-4.svg' |
| 72 | ), |
| 73 | 'info-top' => array( |
| 74 | 'label' => __( 'Show Info on Top of Content', 'auxin-elements' ), |
| 75 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/testimonial-5.svg' |
| 76 | ), |
| 77 | 'image-top' => array( |
| 78 | 'label' => __( 'Show Image on Top of the Content', 'auxin-elements' ), |
| 79 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/testimonial-6.svg' |
| 80 | ) |
| 81 | ) |
| 82 | ), |
| 83 | array( |
| 84 | 'heading' => __('Customer Name','auxin-elements'), |
| 85 | 'description' => __('Customer Name, leave it empty if you don`t need title.', 'auxin-elements'), |
| 86 | 'param_name' => 'title', |
| 87 | 'type' => 'textfield', |
| 88 | 'value' => '', |
| 89 | 'holder' => 'textfield', |
| 90 | 'class' => 'title', |
| 91 | 'admin_label' => true, |
| 92 | 'dependency' => '', |
| 93 | 'weight' => '', |
| 94 | 'group' => '' , |
| 95 | 'edit_field_class' => '' |
| 96 | ), |
| 97 | array( |
| 98 | 'heading' => __('Customer Link','auxin-elements'), |
| 99 | 'description' => __('Customer Link, leave it empty if you don`t need it', 'auxin-elements'), |
| 100 | 'param_name' => 'link', |
| 101 | 'type' => 'textfield', |
| 102 | 'value' => '', |
| 103 | 'holder' => 'textfield', |
| 104 | 'class' => 'title', |
| 105 | 'admin_label' => true, |
| 106 | 'dependency' => '', |
| 107 | 'weight' => '', |
| 108 | 'group' => '' , |
| 109 | 'edit_field_class' => '' |
| 110 | ), |
| 111 | array( |
| 112 | 'heading' => __('Customer Occupation','auxin-elements'), |
| 113 | 'description' => __('Customer Occupation, leave it empty if you don`t need it.', 'auxin-elements'), |
| 114 | 'param_name' => 'subtitle', |
| 115 | 'type' => 'textfield', |
| 116 | 'value' => '', |
| 117 | 'holder' => 'textfield', |
| 118 | 'class' => 'subtitle', |
| 119 | 'admin_label' => true, |
| 120 | 'dependency' => '', |
| 121 | 'weight' => '', |
| 122 | 'group' => '' , |
| 123 | 'edit_field_class' => '' |
| 124 | ), |
| 125 | array( |
| 126 | 'heading' => __('Customer Rating','auxin-elements'), |
| 127 | 'description' => __('Customer Rating, Set it to "None" if you don`t need it.', 'auxin-elements'), |
| 128 | 'param_name' => 'rating', |
| 129 | 'type' => 'dropdown', |
| 130 | 'def_value' => '', |
| 131 | 'value' => array( |
| 132 | 'none' => __( 'None' , 'auxin-elements' ), |
| 133 | '1' => '1', |
| 134 | '2' => '2', |
| 135 | '3' => '3', |
| 136 | '4' => '4', |
| 137 | '5' => '5', |
| 138 | ), |
| 139 | 'holder' => 'dropdown', |
| 140 | 'class' => 'rating', |
| 141 | 'admin_label' => true, |
| 142 | 'dependency' => '', |
| 143 | 'weight' => '', |
| 144 | 'group' => '' , |
| 145 | 'edit_field_class' => '' |
| 146 | ), |
| 147 | array( |
| 148 | 'heading' => __('Customer Image', 'auxin-elements'), |
| 149 | 'description' => '', |
| 150 | 'param_name' => 'customer_img', |
| 151 | 'type' => 'attach_image', |
| 152 | 'def_value' => '', |
| 153 | 'value' => '', |
| 154 | 'holder' => '', |
| 155 | 'class' => 'customer-img', |
| 156 | 'admin_label' => true, |
| 157 | 'dependency' => array( |
| 158 | 'element' => 'template', |
| 159 | 'value' => array('bordered', 'def-img', 'info-top', 'image-top') |
| 160 | ), |
| 161 | 'weight' => '', |
| 162 | 'group' => '', |
| 163 | 'edit_field_class' => '' |
| 164 | ), |
| 165 | array( |
| 166 | 'heading' => __('Content','auxin-elements'), |
| 167 | 'description' => __('Enter a text as a text content.','auxin-elements'), |
| 168 | 'param_name' => 'content', |
| 169 | 'type' => 'textarea_html', |
| 170 | 'value' => '', |
| 171 | 'def_value' => '', |
| 172 | 'holder' => 'div', |
| 173 | 'class' => 'content', |
| 174 | 'admin_label' => true, |
| 175 | 'dependency' => '', |
| 176 | 'weight' => '', |
| 177 | 'group' => '' , |
| 178 | 'edit_field_class' => '' |
| 179 | ), |
| 180 | ) |
| 181 | ); |
| 182 | |
| 183 | return $master_array; |
| 184 | } |
| 185 | |
| 186 | add_filter( 'auxin_master_array_shortcodes', 'auxin_get_testimonial_master_array', 10, 1 ); |
| 187 | |
| 188 | |
| 189 | /** |
| 190 | * Testimonial Widget Markup |
| 191 | * |
| 192 | * The front-end output of this element is returned by the following function |
| 193 | * |
| 194 | * @param array $atts The array containing the parsed values from shortcode, it should be same as defined params above. |
| 195 | * @param string $shortcode_content The shorcode content |
| 196 | * @return string The output of element markup |
| 197 | */ |
| 198 | function auxin_widget_testimonial_callback( $atts, $shortcode_content = null ){ |
| 199 | |
| 200 | // Defining default attributes |
| 201 | $default_atts = array( |
| 202 | |
| 203 | 'template' => 'default', |
| 204 | 'title' => '', |
| 205 | 'subtitle' => '', |
| 206 | 'rating' => '', |
| 207 | 'link' => '', |
| 208 | 'customer_img' => '', |
| 209 | 'show_image' => true, |
| 210 | 'image_html' => '', |
| 211 | 'image_size' => 'thumbnail', |
| 212 | 'content' => '', |
| 213 | 'extra_classes' => '', // custom css class names for this element |
| 214 | 'custom_el_id' => '', // custom id attribute for this element |
| 215 | 'base_class' => 'aux-widget-testimonial-container' // base class name for container |
| 216 | |
| 217 | ); |
| 218 | |
| 219 | $result = auxin_get_widget_scafold( $atts, $default_atts ); |
| 220 | |
| 221 | extract( $result['parsed_atts'] ); |
| 222 | |
| 223 | // Validate boolean variables |
| 224 | $show_image = auxin_is_true( $show_image ); |
| 225 | |
| 226 | $image_above_content = $template === 'image-top'; |
| 227 | |
| 228 | $image = empty( $image_html ) ? wp_get_attachment_image( $customer_img, $image_size, "", array( "class" => "img-square" ) ) : $image_html; |
| 229 | $content = empty( $content ) ? $shortcode_content : $content ; |
| 230 | $main_class = ' aux-widget-testimonial aux-testimonial-' . $template ; |
| 231 | |
| 232 | ob_start(); |
| 233 | |
| 234 | // widget header ------------------------------ |
| 235 | echo $result['widget_header']; |
| 236 | ?> |
| 237 | <div class=" <?php echo esc_attr( $main_class );?> "> |
| 238 | <?php if( ! empty( $content ) && ! $image_above_content ) { ?> |
| 239 | <div class="aux-testimonial-content"> |
| 240 | <div class="entry-content"> |
| 241 | <?php $encoding_flag = defined('ENT_HTML401') ? ENT_HTML401 : ENT_QUOTES; ?> |
| 242 | <?php echo do_shortcode( html_entity_decode( $content, $encoding_flag, 'UTF-8') ); ?> |
| 243 | </div> |
| 244 | </div> |
| 245 | <?php } ?> |
| 246 | <div class="aux-testimonial-infobox"> |
| 247 | <?php if ( !empty( $image ) && $show_image ) { ?> |
| 248 | <div class="aux-testimonial-image"> |
| 249 | <?php echo $image ;?> |
| 250 | </div> |
| 251 | <?php } ?> |
| 252 | <div class="aux-testimonial-info"> |
| 253 | <?php if( ! empty( $title ) && empty( $link ) ) { ?> |
| 254 | <h4 class="col-title"><?php echo $title; ?></h4> |
| 255 | <?php } elseif( ! empty( $title ) && ! empty( $link ) ) {?> |
| 256 | <h4 class="col-title"><a href="<?php echo esc_url( $link ); ?>"> |
| 257 | <?php echo $title; ?></a> |
| 258 | </h4> |
| 259 | <?php } if( ! empty( $subtitle ) ) { ?> |
| 260 | <h5 class="col-subtitle"><?php echo $subtitle; ?></h5> |
| 261 | <?php } if ( 'none' !== $rating ) { ?> |
| 262 | <div class="aux-rating-box aux-star-rating"> |
| 263 | <span class="aux-star-rating-avg" style="width: <?php echo ( $rating / 5 ) * 100 ;?>%"> </span> |
| 264 | </div> |
| 265 | <?php } ?> |
| 266 | </div> |
| 267 | </div> |
| 268 | <?php if( ! empty( $content ) && $image_above_content ) { ?> |
| 269 | <div class="aux-testimonial-content"> |
| 270 | <div class="entry-content"> |
| 271 | <?php $encoding_flag = defined('ENT_HTML401') ? ENT_HTML401 : ENT_QUOTES; ?> |
| 272 | <?php echo do_shortcode( html_entity_decode( $content, $encoding_flag, 'UTF-8') ); ?> |
| 273 | </div> |
| 274 | </div> |
| 275 | <?php } ?> |
| 276 | </div> |
| 277 | |
| 278 | <?php |
| 279 | |
| 280 | // widget footer ------------------------------ |
| 281 | echo $result['widget_footer']; |
| 282 | return ob_get_clean(); |
| 283 | |
| 284 | } |
| 285 |