Example #1
0
function axiom_sc_testimonials($atts, $content = null)
{
    if (axiom_sc_in_shortcode_blogger()) {
        return '';
    }
    extract(axiom_sc_html_decode(shortcode_atts(array("controls" => "yes", "controls_top" => "no", "interval" => "", "autoheight" => "no", "align" => "", "custom" => "no", "ids" => "", "cat" => "", "count" => "3", "offset" => "", "orderby" => "date", "order" => "desc", "bg_tint" => "", "bg_color" => "", "bg_image" => "", "bg_overlay" => "", "bg_texture" => "", "id" => "", "class" => "", "animation" => "", "css" => "", "width" => "", "height" => "", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts)));
    if (empty($id)) {
        $id = "sc_testimonials_" . str_replace('.', '', mt_rand());
    }
    if (empty($width)) {
        $width = "100%";
    }
    if (!empty($height) && axiom_sc_param_is_on($autoheight)) {
        $autoheight = "no";
    }
    if (empty($interval)) {
        $interval = mt_rand(5000, 10000);
    }
    if ($bg_image > 0) {
        $attach = wp_get_attachment_image_src($bg_image, 'full');
        if (isset($attach[0]) && $attach[0] != '') {
            $bg_image = $attach[0];
        }
    }
    if ($bg_overlay > 0) {
        if ($bg_color == '') {
            $bg_color = apply_filters('axiom_filter_get_theme_bgcolor', '');
        }
        $rgb = axiom_hex2rgb($bg_color);
    }
    global $AXIOM_GLOBALS;
    $AXIOM_GLOBALS['sc_testimonials_width'] = axiom_prepare_css_value($width);
    $AXIOM_GLOBALS['sc_testimonials_height'] = axiom_prepare_css_value($height);
    $ms = axiom_get_css_position_from_values($top, $right, $bottom, $left);
    $ws = axiom_get_css_position_from_values('', '', '', '', $width);
    $hs = axiom_get_css_position_from_values('', '', '', '', '', $height);
    $css .= $ms . $hs . $ws;
    axiom_enqueue_slider('swiper');
    $output = ($bg_color != '' || $bg_image != '' || $bg_overlay > 0 || $bg_texture > 0 || axiom_strlen($bg_texture) > 2 ? '<div class="sc_testimonials_wrap sc_section' . ($bg_tint ? ' bg_tint_' . esc_attr($bg_tint) : '') . '"' . ' style="' . ($bg_color !== '' && $bg_overlay == 0 ? 'background-color:' . esc_attr($bg_color) . ';' : '') . ($bg_image !== '' ? 'background-image:url(' . esc_url($bg_image) . ');' : '') . '"' . (!axiom_sc_param_is_off($animation) ? ' data-animation="' . esc_attr(axiom_sc_get_animation_classes($animation)) . '"' : '') . '>' . '<div class="sc_section_overlay' . ($bg_texture > 0 ? ' texture_bg_' . esc_attr($bg_texture) : '') . '"' . ' style="' . ($bg_overlay > 0 ? 'background-color:rgba(' . (int) $rgb['r'] . ',' . (int) $rgb['g'] . ',' . (int) $rgb['b'] . ',' . min(1, max(0, $bg_overlay)) . ');' : '') . (axiom_strlen($bg_texture) > 2 ? 'background-image:url(' . esc_url($bg_texture) . ');' : '') . '"' . ($bg_overlay > 0 ? ' data-overlay="' . esc_attr($bg_overlay) . '" data-bg_color="' . esc_attr($bg_color) . '"' : '') . '>' : '') . '<div' . ($id ? ' id="' . esc_attr($id) . '"' : '') . ' class="sc_testimonials sc_slider_swiper swiper-slider-container sc_slider_nopagination' . (axiom_sc_param_is_on($controls) ? ' sc_slider_controls sc_slider_pagination' : ' sc_slider_nocontrols sc_slider_nopagination') . (axiom_sc_param_is_on($autoheight) ? ' sc_slider_height_auto' : '') . ($hs ? ' sc_slider_height_fixed' : '') . (!empty($class) ? ' ' . esc_attr($class) : '') . ($align != '' && $align != 'none' ? ' align' . esc_attr($align) : '') . '"' . ($bg_color == '' && $bg_image == '' && $bg_overlay == 0 && ($bg_texture == '' || $bg_texture == '0') && !axiom_sc_param_is_off($animation) ? ' data-animation="' . esc_attr(axiom_sc_get_animation_classes($animation)) . '"' : '') . (!empty($width) && axiom_strpos($width, '%') === false ? ' data-old-width="' . esc_attr($width) . '"' : '') . (!empty($height) && axiom_strpos($height, '%') === false ? ' data-old-height="' . esc_attr($height) . '"' : '') . ((int) $interval > 0 ? ' data-interval="' . esc_attr($interval) . '"' : '') . ($css != '' ? ' style="' . esc_attr($css) . '"' : '') . '>' . '<div class="slides swiper-wrapper">';
    $content = do_shortcode($content);
    if (axiom_sc_param_is_on($custom) && $content) {
        $output .= $content;
    } else {
        global $post;
        if (!empty($ids)) {
            $posts = explode(',', $ids);
            $count = count($posts);
        }
        $args = array('post_type' => 'testimonial', 'post_status' => 'publish', 'posts_per_page' => $count, 'ignore_sticky_posts' => 1, 'order' => $order == 'asc' ? 'asc' : 'desc');
        if ($offset > 0 && empty($ids)) {
            $args['offset'] = $offset;
        }
        $args = axiom_query_add_sort_order($args, $orderby, $order);
        $args = axiom_query_add_posts_and_cats($args, $ids, 'testimonial', $cat, 'testimonial_group');
        $query = new WP_Query($args);
        $post_number = 0;
        while ($query->have_posts()) {
            $query->the_post();
            $post_number++;
            $post_id = get_the_ID();
            $post_title = get_the_title();
            $post_meta = get_post_meta($post_id, 'testimonial_data', true);
            $author = $post_meta['testimonial_author'];
            $link = $post_meta['testimonial_link'];
            $email = $post_meta['testimonial_email'];
            $content = apply_filters('the_content', get_the_content());
            $photo = wp_get_attachment_url(get_post_thumbnail_id($post_id));
            if (empty($photo)) {
                if (!empty($email)) {
                    $photo = get_avatar($email, 70 * min(2, max(1, axiom_get_theme_option("retina_ready"))));
                }
            } else {
                $photo = axiom_get_resized_image_tag($photo, 70, 70);
            }
            $output .= '<div class="swiper-slide" data-style="' . esc_attr($ws . $hs) . '" style="' . esc_attr($ws . $hs) . '">' . '<div class="sc_testimonial_item">' . '<div class="sc_testimonial_content">' . $content . '</div>' . '<div class="sc_testimonials_item_author">' . ($photo ? '<div class="sc_testimonial_avatar">' . balanceTags($photo) . '</div>' : '') . ($author ? '<div class="sc_testimonial_author">' . ($link ? '<a href="' . esc_url($link) . '">' . esc_html($author) . '</a>' : esc_html($author)) . '</div>' : '') . '</div>' . '</div>' . '</div>';
        }
        wp_reset_postdata();
    }
    $output .= '</div>';
    if (axiom_sc_param_is_on($controls)) {
        $output .= '<div class="sc_slider_controls_wrap' . (axiom_sc_param_is_on($controls) ? " controls_top" : "") . '"><a class="sc_slider_prev" href="#"></a><a class="sc_slider_next" href="#"></a></div><div class="sc_slider_pagination_wrap"></div>';
    }
    $output .= '</div>' . ($bg_color != '' || $bg_image != '' || $bg_overlay > 0 || $bg_texture > 0 || axiom_strlen($bg_texture) > 2 ? '</div></div>' : '');
    return apply_filters('axiom_shortcode_output', $output, 'trx_testimonials', $atts, $content);
}
Example #2
0
<?php

//===================================== Related posts =====================================
$need_dummy = true;
if (axiom_get_custom_option("show_post_related") == 'yes') {
    if (empty($body_style)) {
        $body_style = axiom_get_custom_option('body_style');
    }
    $sidebar_present = !axiom_sc_param_is_off(axiom_get_custom_option('show_sidebar_main'));
    if ($body_style != 'fullscreen' && !$sidebar_present) {
        axiom_close_all_wrappers();
    }
    $need_wrap = $body_style == 'fullscreen' || !$sidebar_present;
    $args = array('posts_per_page' => axiom_get_custom_option('post_related_count'), 'post_type' => $post_data['post_type'], 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'post__not_in' => array($post_data['post_id']));
    if (!empty($post_data['post_terms'][$post_data['post_taxonomy']]->terms_ids)) {
        $args = axiom_query_add_posts_and_cats($args, '', $post_data['post_type'], $post_data['post_terms'][$post_data['post_taxonomy']]->terms_ids, $post_data['post_taxonomy']);
    }
    $args = axiom_query_add_sort_order($args, axiom_get_custom_option('post_related_sort'), axiom_get_custom_option('post_related_order'));
    // Uncomment this section if you want filter related posts on post formats
    if ($post_data['post_type'] == 'post' && $post_data['post_format'] != '' && $post_data['post_format'] != 'standard') {
        if (!isset($args['tax_query'])) {
            $args['tax_query'] = array();
        }
        $args['tax_query'] = array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => 'post-format-' . $post_data['post_format']));
    }
    $args = apply_filters('axiom_filter_related_posts_args', $args, $post_data);
    $recent_posts = get_posts($args, OBJECT);
    $number = is_array($recent_posts) ? count($recent_posts) : 0;
    if ($number > 0) {
        $columns = max(1, axiom_get_custom_option('post_related_columns'));
        if ($columns < 2) {