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
//===================================== 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) {
            if ($number < 3) {
                $columns = 3;
Example #3
0
 function axiom_query_add_posts_per_page($query)
 {
     if (is_admin() || !$query->is_main_query()) {
         return;
     }
     $orderby_set = true;
     $orderby = $order = $ppp = '';
     // Check template page settings
     if ($query->get('post_type') == 'product' || $query->get('product_cat') != '' || $query->get('product_tag') != '') {
         $orderby_set = false;
         $page_id = get_option('woocommerce_shop_page_id');
     } else {
         if ($query->is_archive()) {
             $page_id = axiom_get_template_page_id('archive');
         } else {
             if ($query->is_search()) {
                 $page_id = axiom_get_template_page_id('search');
                 if (axiom_get_theme_option('use_ajax_search') == 'yes') {
                     $show_types = axiom_get_theme_option('ajax_search_types');
                     if (!empty($show_types)) {
                         $query->set('post_type', explode(',', $show_types));
                     }
                 }
             } else {
                 if ($query->is_posts_page == 1) {
                     $page_id = isset($query->queried_object_id) ? $query->queried_object_id : axiom_get_template_page_id('blog');
                 } else {
                     $page_id = 0;
                 }
             }
         }
     }
     if ($page_id > 0) {
         $post_options = get_post_meta($page_id, 'post_custom_options', true);
         if (isset($post_options['posts_per_page']) && !empty($post_options['posts_per_page']) && !axiom_is_inherit_option($post_options['posts_per_page'])) {
             $ppp = (int) $post_options['posts_per_page'];
         }
         if ($orderby_set) {
             if (isset($post_options['blog_sort']) && !empty($post_options['blog_sort']) && !axiom_is_inherit_option($post_options['blog_sort'])) {
                 $orderby = $post_options['blog_sort'];
             }
             if (isset($post_options['blog_order']) && !empty($post_options['blog_order']) && !axiom_is_inherit_option($post_options['blog_order'])) {
                 $order = $post_options['blog_order'];
             }
         }
     }
     // Check taxonomy settings
     if (!empty($query->tax_query->queried_terms)) {
         foreach ($query->tax_query->queried_terms as $tax => $terms) {
             if (!empty($terms['terms'][0])) {
                 $term = $terms['terms'][0];
                 $tax_options = axiom_taxonomy_get_inherited_properties($tax, $term);
                 if (empty($ppp) && isset($tax_options['posts_per_page']) && !empty($tax_options['posts_per_page']) && !axiom_is_inherit_option($tax_options['posts_per_page'])) {
                     $ppp = (int) $tax_options['posts_per_page'];
                 }
                 if ($orderby_set) {
                     if (isset($tax_options['blog_sort']) && !empty($tax_options['blog_sort']) && !axiom_is_inherit_option($tax_options['blog_sort'])) {
                         $orderby = $tax_options['blog_sort'];
                     }
                     if (isset($tax_options['blog_order']) && !empty($tax_options['blog_order']) && !axiom_is_inherit_option($tax_options['blog_order'])) {
                         $order = $tax_options['blog_order'];
                     }
                 }
             }
             break;
         }
     }
     // Add parameters into query
     if (empty($ppp)) {
         $ppp = (int) axiom_get_theme_option('posts_per_page');
     }
     if ($ppp > 0) {
         $query->set('posts_per_page', $ppp);
     }
     if ($orderby_set) {
         if (empty($orderby)) {
             $orderby = axiom_get_theme_option('blog_sort');
         }
         if (empty($order)) {
             $order = axiom_get_theme_option('blog_order');
         }
         axiom_query_add_sort_order($query, $orderby, $order);
     }
     // Exclude categories
     $ex = axiom_get_theme_option('exclude_cats');
     if (!empty($ex)) {
         $query->set('category__not_in', explode(',', $ex));
     }
 }
Example #4
0
File: blog.php Project: pcuervo/odc
}
$page_number = get_query_var('paged') ? get_query_var('paged') : (get_query_var('page') ? get_query_var('page') : 1);
$wp_query_need_restore = false;
$args = $wp_query->query_vars;
$args['post_status'] = current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish';
if (is_page() || !empty($AXIOM_GLOBALS['blog_filters'])) {
    unset($args['p']);
    unset($args['page_id']);
    unset($args['pagename']);
    unset($args['name']);
    $args['posts_per_page'] = $ppp;
    if ($page_number > 1) {
        $args['paged'] = $page_number;
        $args['ignore_sticky_posts'] = 1;
    }
    $args = axiom_query_add_sort_order($args);
    $args = axiom_query_add_filters($args, !empty($AXIOM_GLOBALS['blog_filters']) ? $AXIOM_GLOBALS['blog_filters'] : '');
    query_posts($args);
    $wp_query_need_restore = true;
}
$per_page = count($wp_query->posts);
$post_number = 0;
$parent_tax_id = (int) axiom_get_custom_option('taxonomy_id');
$flt_ids = array();
$container = apply_filters('axiom_filter_blog_container', axiom_get_template_property($blog_style, 'container'), array('style' => $blog_style, 'dir' => 'horizontal'));
$container_start = $container_end = '';
if (!empty($container)) {
    $container = explode('%s', $container);
    $container_start = !empty($container[0]) ? $container[0] : '';
    $container_end = !empty($container[1]) ? $container[1] : '';
}