Пример #1
0
function posts($atts, $content = null)
{
    $atts = vc_map_get_attributes('posts', $atts);
    extract($atts);
    if ($column != 1) {
        wp_enqueue_script('isotop');
    }
    $out = $grid = $metaAuthor = $date = $comments = $views = $category = $thumb = $width = $height = $isotope = $format_icon = $args = $my_query = '';
    global $paged;
    $args = array('post_type' => 'post', 'category_name' => $cats, 'pagination' => true, 'posts_per_page' => $number, 'ignore_sticky_postss' => 1, 'paged' => $paged);
    $my_query = new WP_Query($args);
    if ($column == 1) {
        $grid = 'grid_12';
        $metaAuthor = $date = $comments = $views = $category = 'view';
        if ($social == 1) {
            $thumb = 'blog_column1_bar_share';
            $width = 706;
            $height = 350;
        } else {
            $thumb = 'blog_column1_bar';
            $width = 786;
            $height = 380;
        }
    } else {
        if ($column == 2) {
            $grid = 'grid_6';
            $metaAuthor = $date = $comments = 'view';
        }
        if ($column == 3) {
            $grid = 'grid_4';
            $date = $comments = 'view';
        }
        if ($layout_mode == 'masonry') {
            $thumb = 'blog_masonry';
            $width = 697;
            $height = 9999;
        } else {
            $thumb = 'blog_nomasonry';
            $width = 697;
            $height = 480;
        }
    }
    $grids_wrap = ' grids_wrap';
    if ($layout_mode == 'masonry' && $column != 1) {
        $isotope = ' data-layout-mode="masonry"';
    }
    if ($layout_mode == 'fitRows' && $column != 1) {
        $isotope = ' data-layout-mode="fitRows"';
    }
    if ($column == 1) {
        $grids_wrap = '';
    }
    if ($social != 'yes') {
        $format_icon = ' hide_angle';
    }
    $out .= '<div class="wpb_content_element posts_wrap column_' . $column . '">';
    $out .= wpb_widget_title(array('title' => $title));
    $out .= '<div class="posts_layout' . $grids_wrap . '">';
    $out .= '<div class="row_inner clearfix">';
    $out .= '<ul class="grid_layout"' . $isotope . '>';
    while ($my_query->have_posts()) {
        $my_query->the_post();
        $disqus_shortname = $gallery = $audioURL = $videoURL = $format = $icon = $post_comment = '';
        if (get_field('post_gallery')) {
            $gallery = get_field('post_gallery');
        }
        if (get_field('post_video')) {
            $videoURL = get_field('post_video');
        }
        if (get_field('post_audio')) {
            $audioURL = get_field('post_audio');
        }
        if (has_post_format('video')) {
            $icon = 'icons-play';
            $format = __('Video', 'corporative');
        } elseif (has_post_format('audio')) {
            $icon = 'icons-music';
            $format = __('Audio', 'corporative');
        } elseif (has_post_format('gallery')) {
            $icon = 'icons-sliders-vertical';
            $format = __('Gallery', 'corporative');
        } else {
            $icon = 'icons-document-fill';
            $format = '';
        }
        if (get_field('post_comment')) {
            $post_comment = get_field('post_comment');
        }
        if ($post_comment == 'comment_default' || empty($post_comment)) {
            $post_comment = rd_options('reedwan_post_comment');
        }
        if ($post_comment == 'comment_disqus') {
            $disqus_shortname = rd_options('reedwan_disqus_shortname');
        }
        $out .= '<li id="post-' . get_the_ID() . '" class="grid_item no_title_thumb ' . $grid . '">';
        $out .= '<div class="post_b">';
        if ($social == 'yes') {
            $out .= '<a href="' . get_permalink() . '" class="post_format lefttip" title="' . $format . '"><i class="' . $icon . '"></i></a>';
            $out .= '<div class="social post_social">';
            $out .= '<a href="http://twitter.com/home?status=' . get_the_title() . ' ' . get_permalink() . '" target="_blank" class="lefttip" title="Twitter"><i class="icons-social-twitter"></i></a>';
            $thumbx = '';
            $thumbx = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'facebook');
            $out .= '<a href="http://www.facebook.com/sharer.php?s=100&amp;p[title]=' . urlencode(get_the_title()) . '&amp;p[summary]=' . urlencode(get_the_excerpt()) . '&amp;p[url]=' . urlencode(get_permalink()) . '&amp;p[images][0]=' . urlencode($thumbx[0]) . '" target="_blank" class="lefttip" title="Facebook"><i class="icons-social-facebook"></i></a>';
            $out .= '<a href="https://plus.google.com/share?url=' . get_permalink() . '" onclick="javascript:window.open(this.href,"", "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600");return false;" target="_blank" class="lefttip" title="Google Plus"><i class="icons-social-google-plus"></i></a>';
            $thumby = '';
            $thumby = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'medium');
            $out .= '<a href="http://pinterest.com/pin/create/button/?url=' . urlencode(get_permalink()) . '&amp;description=' . urlencode(get_the_title()) . '&amp;media=' . urlencode($thumby[0]) . '" target="_blank" class="lefttip" title="Pinterest"><i class="icons-social-pinterest"></i></a>';
            $out .= '</div>';
        }
        $out .= '<div class="post_content' . $format_icon . '">';
        if ($layout_mode == 'masonry') {
            $out .= mediaholder('', $format, $thumb, $videoURL, $audioURL, $gallery);
        } else {
            $out .= mediaholder_caption('', $format, $width, $height, $thumb, $videoURL, $audioURL, $gallery);
        }
        $out .= '<div class="post_inner_content clearfix">';
        $out .= '<h2 class="post_title"> <a href="' . get_permalink() . '" title="">' . get_the_title() . '</a></h2>';
        if ($meta == 'yes') {
            $out .= '<div class="f_meta clearfix">';
            $out .= post_meta($disqus_shortname, $metaAuthor, $date, $comments, $views, $category);
            $out .= '</div>';
        }
        $out .= excerpt($excerpt);
        if ($more == 'yes') {
            $out .= '<div class="right more"><a href="' . get_permalink() . '">' . __('Read More', 'corporative') . ' &rarr;</a></div>';
        }
        $out .= '</div>';
        $out .= '</div>';
        $out .= '</div>';
        $out .= '</li>';
    }
    wp_reset_postdata();
    $out .= '</ul>';
    $out .= '</div>';
    if ($pagination == 'yes') {
        $out .= new_pagination($my_query->max_num_pages);
    }
    $out .= '</div>';
    $out .= '</div>';
    return $out;
}
Пример #2
0
function portfolio($atts, $content = null)
{
    $atts = vc_map_get_attributes('portfolio', $atts);
    extract($atts);
    wp_enqueue_script('isotop');
    $out = $sidebar = $isotope = $grid = $width = $height = $thumb = $with_title = $mediatitle = $args = $my_query = $portfolio_taxs = $without_padding = $cats_array = '';
    global $paged;
    if ($cats) {
        $cats_array = explode(",", $cats);
        $args = array('post_type' => 'portfolio', 'posts_per_page' => $number, 'paged' => $paged, 'tax_query' => array(array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $cats_array)));
    } else {
        $args = array('post_type' => 'portfolio', 'posts_per_page' => $number, 'paged' => $paged);
    }
    $my_query = new WP_Query($args);
    if ($pagination != 'yes' && $filters == 'yes') {
        if (is_array($my_query->posts) && !empty($my_query->posts)) {
            foreach ($my_query->posts as $my_post) {
                $post_taxs = wp_get_post_terms($my_post->ID, 'portfolio_category', array("fields" => "all"));
                if (is_array($post_taxs) && !empty($post_taxs)) {
                    foreach ($post_taxs as $post_tax) {
                        if (is_array($cats_array) && !empty($cats_array) && (in_array($post_tax->term_id, $cats_array) || in_array($post_tax->parent, $cats_array))) {
                            $portfolio_taxs[urldecode($post_tax->slug)] = $post_tax->name;
                        }
                        if (empty($cats_array) || !isset($cats_array)) {
                            $portfolio_taxs[urldecode($post_tax->slug)] = $post_tax->name;
                        }
                    }
                }
            }
        }
        $all_terms = get_terms('portfolio_category');
        if (!empty($all_terms) && is_array($all_terms)) {
            foreach ($all_terms as $term) {
                if ($portfolio_taxs[urldecode($term->slug)]) {
                    $sorted_taxs[urldecode($term->slug)] = $term->name;
                }
            }
        }
        $portfolio_taxs = $sorted_taxs;
        $portfolio_category = get_terms('portfolio_category');
    }
    if ($layout_mode == 'masonry') {
        $isotope = ' data-layout-mode="masonry"';
        $width = 515;
        $height = 9999;
        $thumb = 'portfolio_masonry';
    } else {
        $isotope = ' data-layout-mode="fitRows"';
        $width = 515;
        $height = 339;
        $thumb = 'portfolio';
    }
    if ($column == '2') {
        $grid = 'grid_6';
    } else {
        if ($column == '3') {
            $grid = 'grid_4';
        } else {
            $grid = 'grid_3';
        }
    }
    if ($desc != 'yes') {
        $with_title = 'with_title';
    } else {
        $mediatitle = ' no_title_thumb';
    }
    if ($padding == 'yes') {
        $without_padding = ' nospace';
    }
    $out .= '<div class="wpb_content_element portfolios_wrap column_' . $column . '">';
    $out .= wpb_widget_title(array('title' => $title));
    $out .= '<div class="posts_layout grids_wrap">';
    $out .= '<div class="row_inner clearfix">';
    if (is_array($portfolio_taxs) && !empty($portfolio_taxs) && $filters == 'yes') {
        $out .= '<div class="filterable grid_12">';
        $out .= '<ul class="categories_filter clearfix">';
        $out .= '<li class="active"><a data-filter="*" href="#">' . __('All', 'corporative') . '</a></li>';
        foreach ($portfolio_taxs as $portfolio_cat_slug => $portfolio_cat_name) {
            $out .= '<li><a data-filter=".' . $portfolio_cat_slug . '" href="#">' . $portfolio_cat_name . '</a></li>';
        }
        $out .= '</ul>';
        $out .= '</div>';
    }
    $out .= '</div>';
    $out .= '<div class="row_inner clearfix">';
    $out .= '<ul class="grid_layout"' . $isotope . ' clearfix>';
    while ($my_query->have_posts()) {
        $my_query->the_post();
        $gallery = $videoURL = $format = $categories_css = '';
        if (get_field('portfolio_gallery')) {
            $gallery = get_field('portfolio_gallery');
        }
        if (get_field('portfolio_video')) {
            $videoURL = get_field('portfolio_video');
        }
        if (get_field('portfolio_format') == 'video') {
            $format = 'Video';
        } elseif (get_field('portfolio_format') == 'gallery') {
            $format = 'Gallery';
        } else {
            $format = 'Standard';
        }
        $item_classes = '';
        $item_cats = get_the_terms(get_the_ID(), 'portfolio_category');
        if ($item_cats) {
            foreach ($item_cats as $item_cat) {
                $item_classes .= urldecode($item_cat->slug) . ' ';
            }
        }
        $out .= '<li id="' . get_the_ID() . '" class="grid_item ' . $grid . $without_padding . $mediatitle . ' ' . $item_classes . '">';
        $out .= mediaholder_caption($with_title, $format, $width, $height, $thumb, $videoURL, '', $gallery);
        if ($desc == 'yes') {
            $out .= '<div class="folio-desc">';
            $out .= '<h2 class="post_title"> <a href="' . get_permalink() . '" title="">' . get_the_title() . '</a></h2>';
            if ($cats_info == 'yes') {
                $out .= '<p class="folio-cats">' . get_the_term_list(get_the_ID(), 'portfolio_category', '', ', ', '') . '</p>';
            }
            $out .= excerpt($excerpt);
            if ($view_project == 'yes' && $view_project_text != '') {
                $out .= '<div class="folio-more"><a href="' . get_permalink() . '"><span>' . $view_project_text . ' </span></a></div>';
            }
            $out .= '</div>';
        }
        $out .= '</li>';
    }
    wp_reset_postdata();
    $out .= '</ul>';
    $out .= '</div>';
    if ($pagination == 'yes') {
        $out .= new_pagination($my_query->max_num_pages);
    }
    $out .= '</div>';
    $out .= '</div>';
    return $out;
}