/**
 * This function displays the testimonial.
 * 
 * @param array $katb_widget_tdata testimonial data
 * @param string $katb_widget_tnumber total number of testimonials
 * @param boolean $rotate 
 * @param string $group_name group name from widget data
 * 
 * @uses katb_get_options() user options from katb_functions.php
 * @uses katb_validate_gravatar() check for gravatar from this file
 * @uses katb_widget_popup() set up popup  from this file
 * @uses katb_widget_testimonial_wrap_div() sets up main formatting div wrap from this file
 * @uses katb_meta_widget_top() html for top meta from this file
 * @uses katb_testimonial_excerpt_filter()  from this file
 * @uses katb_widget_insert_gravatar()  from this file
 * @uses katb_meta_widget_bottom() html for bottom meta from this file
 */
function katb_widget_display_testimonial($use_schema, $katb_widget_tdata, $katb_widget_tnumber, $rotate, $group_name, $layout_override)
{
    //get user options
    global $katb_options;
    //$katb_options = katb_get_options();
    $use_ratings = intval($katb_options['katb_use_ratings']);
    $use_css_ratings = intval($katb_options['katb_use_css_ratings']);
    $use_excerpts = intval($katb_options['katb_widget_use_excerpts']);
    $use_gravatars = intval($katb_options['katb_widget_use_gravatars']);
    $use_round_images = intval($katb_options['katb_widget_use_round_images']);
    $use_gravatar_substitute = intval($katb_options['katb_widget_use_gravatar_substitute']);
    $gravatar_size = intval($katb_options['katb_widget_gravatar_size']);
    $layout = sanitize_text_field($katb_options['katb_widget_layout_option']);
    $use_individual_group_name = intval($katb_options['katb_individual_group_name']);
    $custom_individual_name = sanitize_text_field($katb_options['katb_individual_custom_name']);
    $use_title_non_schema = intval($katb_options['katb_widget_show_title']);
    $use_formatted_display = intval($katb_options['katb_widget_use_formatted_display']);
    $katb_widget_height = intval($katb_options['katb_widget_rotator_height']);
    //set up widget height restriction if any
    if ($katb_widget_height != 'variable') {
        $katb_widget_height_option = 'style="min-height:' . $katb_widget_height . 'px;overflow:hidden;"';
        $katb_widget_height_outside = $katb_widget_height + 20;
        $katb_widget_height_option_outside = 'style="min-height:' . $katb_widget_height_outside . 'px;overflow:hidden;"';
    } else {
        $katb_widget_height_option = '';
        $katb_widget_height_option_outside = '';
    }
    /* since 4.1.0 added layout override */
    if ($layout_override != '0') {
        if ($layout_override == '1') {
            $layout = 'Top Meta';
            $use_formatted_display = '0';
        } elseif ($layout_override == '2') {
            $layout = 'Bottom Meta';
            $use_formatted_display = '0';
        } elseif ($layout_override == '3') {
            $layout = 'Image & Meta Top';
            $use_formatted_display = '0';
        } elseif ($layout_override == '4') {
            $layout = 'Image & Meta Bottom';
            $use_formatted_display = '0';
        } elseif ($layout_override == '5') {
            $layout = 'Centered Image & Meta Top';
            $use_formatted_display = '0';
        } elseif ($layout_override == '6') {
            $layout = 'Centered Image & Meta Bottom';
            $use_formatted_display = '0';
        } elseif ($layout_override == '7') {
            $layout = 'Top Meta';
            $use_formatted_display = '1';
        } elseif ($layout_override == '8') {
            $layout = 'Bottom Meta';
            $use_formatted_display = '1';
        } elseif ($layout_override == '9') {
            $layout = 'Image & Meta Top';
            $use_formatted_display = '1';
        } elseif ($layout_override == '10') {
            $layout = 'Image & Meta Bottom';
            $use_formatted_display = '1';
        } elseif ($layout_override == '11') {
            $layout = 'Centered Image & Meta Top';
            $use_formatted_display = '1';
        } elseif ($layout_override == '12') {
            $layout = 'Centered Image & Meta Bottom';
            $use_formatted_display = '1';
        }
    }
    /* since ver 4.1.0 added Image & Meta Top and Image & Meta Bottom layouts
       to allow independent styling will add the following classes when needed
       note this is different from the content mods as an extra class was added 
       rather then appending classes */
    if ($layout == 'Image & Meta Top') {
        $new_layout_class = ' img_meta_top';
    } elseif ($layout == 'Image & Meta Bottom') {
        $new_layout_class = ' img_meta_bot';
    } else {
        $new_layout_class = '';
    }
    if ($rotate == 1) {
        $katb_widget_speed = $katb_options['katb_widget_rotator_speed'];
        $katb_widget_transition = $katb_options['katb_widget_rotator_transition'];
        if ($use_formatted_display == 1) {
            ?>
			<div class="katb_widget_rotate katb_widget_rotator_wrap<?php 
            echo ' ' . $new_layout_class;
            ?>
" <?php 
            echo $katb_widget_height_option_outside;
            ?>
 
				data-katb_speed="<?php 
            echo esc_attr($katb_widget_speed);
            ?>
" 
				data-katb_transition="<?php 
            echo esc_attr($katb_widget_transition);
            ?>
">
		<?php 
        } else {
            ?>
			<div class="katb_widget_rotate katb_widget_rotator_wrap_basic<?php 
            echo ' ' . $new_layout_class;
            ?>
" <?php 
            echo $katb_widget_height_option_outside;
            ?>
 
				data-katb_speed="<?php 
            echo esc_attr($katb_widget_speed);
            ?>
" 
				data-katb_transition="<?php 
            echo esc_attr($katb_widget_transition);
            ?>
">
		<?php 
        }
    } else {
        if ($use_formatted_display == 1) {
            ?>
			<div class="katb_widget_wrap<?php 
            echo $new_layout_class;
            ?>
">
		<?php 
        } else {
            ?>
			<div class="katb_widget_wrap_basic<?php 
            echo $new_layout_class;
            ?>
">
		<?php 
        }
    }
    for ($i = 0; $i < $katb_widget_tnumber; $i++) {
        //if gravatars are enabled, check for valid avatar
        if ($use_gravatars == 1 && $use_gravatar_substitute != 1) {
            $has_valid_avatar = katb_validate_gravatar($katb_widget_tdata[$i]['tb_email']);
        } else {
            $has_valid_avatar = 0;
        }
        //set up hidden popup if excerpt is used
        if ($use_excerpts == 1) {
            katb_widget_popup($has_valid_avatar, $katb_widget_tdata, $i, $layout);
        }
        //<div class=.... > wrap
        $div_prop = katb_widget_testimonial_wrap_div($use_formatted_display, $use_schema, $rotate, $katb_widget_height_option, $i);
        //title html
        $title = katb_widget_insert_title($use_schema, $use_title_non_schema, $katb_widget_tdata, $i, $use_individual_group_name, $custom_individual_name);
        //rating html
        $rating = katb_widget_insert_rating($use_schema, $use_ratings, $use_css_ratings, $katb_widget_tdata, $i);
        //get gravatar html
        $photo_or_gravatar = katb_widget_insert_gravatar($katb_widget_tdata[$i]['tb_pic_url'], $gravatar_size, $use_gravatars, $use_round_images, $use_gravatar_substitute, $has_valid_avatar, $katb_widget_tdata[$i]['tb_email']);
        //get widget testimonial content
        $widget_content = katb_widget_content($use_excerpts, $katb_widget_tdata, $i, $use_schema, $photo_or_gravatar, $use_formatted_display, $layout);
        echo $div_prop;
        //<div class=.... > wrap
        if ($layout == "Top Meta") {
            echo $title;
            echo $rating;
            katb_meta_widget_top($i, $katb_widget_tdata, $use_schema);
            echo $widget_content;
        } elseif ($layout == "Bottom Meta") {
            echo $title;
            echo $rating;
            echo $widget_content;
            katb_meta_widget_bottom($i, $katb_widget_tdata, $use_schema);
        } elseif ($layout == "Image & Meta Top") {
            $width_adj = $gravatar_size + 10;
            echo '<div class="katb_image_meta_top">';
            echo '<div class="katb_gravatar_top">' . $photo_or_gravatar . '</div>';
            echo '<div class="katb_meta_rating_top_wrap" style="width:calc(100% - ' . $width_adj . 'px);">';
            katb_meta_widget_with_image($i, $katb_widget_tdata, $use_schema);
            echo $rating;
            echo '</div>';
            echo '</div>';
            echo $title;
            echo $widget_content;
        } elseif ($layout == "Image & Meta Bottom") {
            $width_adj = $gravatar_size + 10;
            echo $title;
            echo $widget_content;
            echo '<div class="katb_image_meta_bottom">';
            echo '<div class="katb_gravatar_bottom">' . $photo_or_gravatar . '</div>';
            echo '<div class="katb_meta_rating_bottom_wrap" style="width:calc(100% - ' . $width_adj . 'px);">';
            katb_meta_widget_with_image($i, $katb_widget_tdata, $use_schema);
            echo $rating;
            echo '</div>';
            echo '</div>';
        } elseif ($layout == "Centered Image & Meta Top") {
            echo '<div class="katb_centered_image_meta_top">';
            echo '<div class="katb_centered_gravatar_top">' . $photo_or_gravatar . '</div>';
            echo '<div class="katb_centered_meta_rating_top_wrap">';
            katb_meta_widget_with_image($i, $katb_widget_tdata, $use_schema);
            echo $rating;
            echo '</div>';
            echo '</div>';
            echo $title;
            echo $widget_content;
        } elseif ($layout == "Centered Image & Meta Bottom") {
            $width_adj = $gravatar_size + 10;
            echo $title;
            echo $widget_content;
            echo '<div class="katb_centered_image_meta_bottom">';
            echo '<div class="katb_centered_gravatar_bottom">' . $photo_or_gravatar . '</div>';
            echo '<div class="katb_centered_meta_rating_bottom_wrap" >';
            katb_meta_widget_with_image($i, $katb_widget_tdata, $use_schema);
            echo $rating;
            echo '</div>';
            echo '</div>';
        }
        echo '</div>';
        // close katb_widget_box/katb_widget_box_basic
    }
    echo '</div>';
}
Ejemplo n.º 2
0
/**
 * This is the initial function call to display the testimonials in the content area.
 * 
 * @param boolean $use_formatted_display yes or no
 * @param boolean $use_schema yes or no
 * @param string $katb_tnumber total number of testimonials
 * @param array $katb_tdata array of testimonial data
 * @param boolean $katb_rotate yes or no
 * @param string $layout top meta or bottom meta
 * @param string $group_name group name from shortcode
 * 
 * @uses katb_get_options() user options for plugin from katb_functions.php
 * @uses katb_company_aggregate_display() displays summary of testimonials from this file
 * @uses katb_validate_gravatar() checks for valid gravatar from katb_functions.php
 * @uses katb_setup_popup() setups the popup from this file
 * @uses katb_testimonial_wrap_div() sets up div wrap for options from this file
 * @uses katb_meta_top() supplies top meta string if required from this file
 * @uses katb_insert_gravatar () returns gravatar set up from this file
 * @uses katb_testimonial_excerpt_filter() excerpt for testimonial from katb_functions.php
 * @uses katb_meta_bottom () returns the bottom meta strip from this file
 * 
 * @return $html html string with content
 */
function katb_content_display($use_formatted_display, $use_schema, $katb_tnumber, $katb_tdata, $katb_rotate, $layout, $group_name, $layout_override)
{
    //get user options
    global $katb_options;
    $use_ratings = intval($katb_options['katb_use_ratings']);
    $use_css_ratings = intval($katb_options['katb_use_css_ratings']);
    $use_excerpts = intval($katb_options['katb_use_excerpts']);
    $use_title = intval($katb_options['katb_show_title']);
    $use_gravatars = intval($katb_options['katb_use_gravatars']);
    $use_round_images = intval($katb_options['katb_use_round_images']);
    $use_gravatar_substitute = intval($katb_options['katb_use_gravatar_substitute']);
    $gravatar_size = intval($katb_options['katb_gravatar_size']);
    $company_name = sanitize_text_field($katb_options['katb_schema_company_name']);
    $company_website = esc_url($katb_options['katb_schema_company_url']);
    $display_company = intval($katb_options['katb_schema_display_company']);
    $display_aggregate = intval($katb_options['katb_schema_display_aggregate']);
    $display_reviews = intval($katb_options['katb_schema_display_reviews']);
    $use_group_name_for_aggregate = intval($katb_options['katb_use_group_name_for_aggregate']);
    $custom_aggregate_name = sanitize_text_field($katb_options['katb_custom_aggregate_review_name']);
    $use_individual_group_name = intval($katb_options['katb_individual_group_name']);
    $custom_individual_name = sanitize_text_field($katb_options['katb_individual_custom_name']);
    $katb_height = intval($katb_options['katb_rotator_height']);
    $katb_speed = intval($katb_options['katb_rotator_speed']);
    $katb_transition = sanitize_text_field($katb_options['katb_rotator_transition']);
    //set up constant height option for rotated testimonials
    if ($katb_rotate == 1 && $katb_height != 'variable') {
        $katb_height_option = 'style="min-height:' . esc_attr($katb_height) . 'px;overflow:hidden;"';
        $katb_height_outside = $katb_height + 20;
        $katb_height_option_outside = 'style="min-height:' . esc_attr($katb_height_outside) . 'px;overflow:hidden;"';
    } else {
        $katb_height_option = '';
        $katb_height_option_outside = '';
    }
    //apply layout overide if applicable
    if ($layout_override == '0') {
        //don't change the default
    } elseif ($layout_override == '1') {
        $layout = 'Top Meta';
        $use_formatted_display = '0';
    } elseif ($layout_override == '2') {
        $layout = 'Bottom Meta';
        $use_formatted_display = '0';
    } elseif ($layout_override == '3') {
        $layout = 'Side Meta';
        $use_formatted_display = '0';
    } elseif ($layout_override == '4') {
        $layout = 'Top Meta';
        $use_formatted_display = '1';
    } elseif ($layout_override == '5') {
        $layout = 'Bottom Meta';
        $use_formatted_display = '1';
    } elseif ($layout_override == '6') {
        $layout = 'Side Meta';
        $use_formatted_display = '1';
    }
    //If we are not displaying anything turn off the schema
    if ($display_company == 0 && $display_aggregate == 0 && $display_reviews == 0) {
        $use_schema = 0;
    }
    $html = '';
    // Set up the schema wrap, company summary, and aggregate sumary
    if ($use_schema == 1) {
        $html .= '<div itemscope itemtype="http://schema.org/Organization">';
        $html .= katb_company_aggregate_display($use_formatted_display, $group_name, $layout);
    }
    //Set up the wrap for all testimonials...lots of code but only one div wrap
    if ($use_schema == 1 && $display_reviews != 1) {
        // do not display any individual reviews
    } else {
        //display individual reviews
        if ($katb_rotate == 1) {
            if ($use_formatted_display == 1) {
                if ($layout == "Side Meta") {
                    $html .= '<div ' . $katb_height_option_outside . ' class="katb_test_wrap_side_meta katb_rotate" data-katb_speed="' . esc_attr($katb_speed) . '" data-katb_transition="' . esc_attr($katb_transition) . '">';
                } else {
                    $html .= '<div ' . $katb_height_option_outside . ' class="katb_test_wrap katb_rotate" data-katb_speed="' . esc_attr($katb_speed) . '" data-katb_transition="' . esc_attr($katb_transition) . '">';
                }
            } else {
                if ($layout == "Side Meta") {
                    $html .= '<div ' . $katb_height_option_outside . ' class="katb_test_wrap_basic_side_meta katb_rotate" data-katb_speed="' . esc_attr($katb_speed) . '" data-katb_transition="' . esc_attr($katb_transition) . '">';
                } else {
                    $html .= '<div ' . $katb_height_option_outside . ' class="katb_test_wrap_basic katb_rotate" data-katb_speed="' . esc_attr($katb_speed) . '" data-katb_transition="' . esc_attr($katb_transition) . '">';
                }
            }
        } else {
            if ($use_formatted_display == 1) {
                if ($layout == "Side Meta") {
                    $html .= '<div class="katb_test_wrap_side_meta">';
                } else {
                    $html .= '<div class="katb_test_wrap">';
                }
            } else {
                if ($layout == "Side Meta") {
                    $html .= '<div class="katb_test_wrap_basic_side_meta">';
                } else {
                    $html .= '<div class="katb_test_wrap_basic">';
                }
            }
        }
        //Display Individual Testimonials
        for ($i = 0; $i < $katb_tnumber; $i++) {
            //if gravatars are enabled, check for valid avatar
            if ($use_gravatars == 1 && $use_gravatar_substitute != 1) {
                $has_valid_avatar = katb_validate_gravatar($katb_tdata[$i]['tb_email']);
            } else {
                $has_valid_avatar = 0;
            }
            //get the gravatar or photo html
            $gravatar_or_photo = katb_insert_gravatar($katb_tdata[$i]['tb_pic_url'], $gravatar_size, $use_gravatars, $use_round_images, $use_gravatar_substitute, $has_valid_avatar, $katb_tdata[$i]['tb_email']);
            //set up hidden popup if excerpt is used
            if ($use_excerpts == 1) {
                $html .= katb_setup_popup($i, $katb_tdata, $has_valid_avatar);
            }
            //Set up the testimonial wrap div
            $html .= katb_testimonial_wrap_div($use_formatted_display, $use_schema, $katb_rotate, $katb_height_option, $i, $layout);
            if ($layout == "Side Meta") {
                //left box contains the gravatar, and the meta
                $html .= '<div class="katb_left_box">';
                if ($gravatar_or_photo != '') {
                    $html .= '<div class="katb_side_gravatar">' . $gravatar_or_photo . '</div>';
                }
                $html .= katb_meta_side($i, $katb_tdata, $use_schema);
                $html .= '</div>';
                //right box contains the title, rating and content
                $html .= '<div class="katb_right_box">';
                //Set up and return html for title bar
                $html .= katb_insert_title($use_schema, $use_title, $katb_tdata, $i, $use_individual_group_name, $custom_individual_name);
                //Set up and return html for ratings
                $html .= katb_insert_rating($use_schema, $use_ratings, $use_css_ratings, $katb_tdata, $i);
                //display the testimonial, note $gravatar_or_photo passed variable set to ''
                $html .= katb_insert_content($use_excerpts, $use_schema, $use_formatted_display, $layout, intval($katb_options['katb_excerpt_length']), '', $i, $katb_tdata);
                $html .= '</div>';
            } else {
                //Set up and return array for title bar
                $html .= katb_insert_title($use_schema, $use_title, $katb_tdata, $i, $use_individual_group_name, $custom_individual_name);
                //Set up and return html for ratings
                $html .= katb_insert_rating($use_schema, $use_ratings, $use_css_ratings, $katb_tdata, $i);
                //dispay top meta
                if ($layout == 'Top Meta') {
                    $html .= katb_meta_top($i, $katb_tdata, $use_schema);
                }
                //display the testimonial
                $html .= katb_insert_content($use_excerpts, $use_schema, $use_formatted_display, $layout, intval($katb_options['katb_excerpt_length']), $gravatar_or_photo, $i, $katb_tdata);
                //display bottom meta
                if ($layout == 'Bottom Meta') {
                    $html .= katb_meta_bottom($i, $katb_tdata, $use_schema);
                }
            }
            $html .= '</div>';
            // close the testimonial content wrap
            if ($layout == "Side Meta" && $katb_rotate == 1) {
                $html .= '</div>';
            }
            //close the <div class="katb_side_meta_block katb_rotate_show">
        }
        //close i loop
        $html .= '</div>';
        //close all testimonials wrap
    }
    //close the schema
    if ($use_schema == 1) {
        $html .= '</div>';
        //close itemscope itemtype="http://schema.org/Organization"
    }
    return $html;
}