コード例 #1
0
ファイル: breadcrumbs.php プロジェクト: sergey-h/naman
    function wpex_breadcrumbs($post_id = '')
    {
        // Globals
        global $wp_query, $wp_rewrite;
        // Get post id
        $post_id = $post_id ? $post_id : wpex_get_the_id();
        // Define main variables
        $breadcrumb = '';
        $trail = array();
        $path = '';
        $item_type_scope = 'itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"';
        // Default arguments
        $args = array('separator' => wpex_element('angle_right'), 'front_page' => false, 'echo' => false, 'show_posts_page' => true);
        // Extract args for easy variable naming.
        extract($args);
        /*-----------------------------------------------------------------------------------*/
        /*	- If not on the front page of the site, link to the home page
        		/*-----------------------------------------------------------------------------------*/
        if (!is_front_page()) {
            $home_title = get_theme_mod('breadcrumbs_home_title') ? get_theme_mod('breadcrumbs_home_title') : __('Home', 'wpex');
            $trail[] = '<span ' . $item_type_scope . '>
							<a href="' . home_url() . '" title="' . esc_attr(get_bloginfo('name')) . '" rel="home" class="trail-begin">
								<span itemprop="title">' . $home_title . '</span>
							</a>
						</span>';
        }
        /*-----------------------------------------------------------------------------------*/
        /*	- Front Page
        		/*-----------------------------------------------------------------------------------*/
        if (is_front_page()) {
            if (!$front_page) {
                $trail = false;
            } elseif ($show_home) {
                $trail['trail_end'] = "{$show_home}";
            }
        } elseif (is_home()) {
            $home_page = get_page($wp_query->get_queried_object_id());
            $trail = array_merge($trail, wpex_breadcrumbs_get_parents($home_page->post_parent, ''));
            $trail['trail_end'] = get_the_title($home_page->ID);
        } elseif (is_singular()) {
            // Get singular vars
            $post = $wp_query->get_queried_object();
            $post_id = absint($wp_query->get_queried_object_id());
            $post_type = $post->post_type;
            $parent = $post->post_parent;
            // If a custom post type, check if there are any pages in its hierarchy based on the slug.
            if (!in_array($post_type, array('page', 'post', 'product', 'portfolio', 'staff', 'testimonials'))) {
                $post_type_object = get_post_type_object($post_type);
                // Add $front to the path
                if ('post' == $post_type || 'attachment' == $post_type || $post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                    $path .= trailingslashit($wp_rewrite->front);
                }
                // Add slug to $path
                if (!empty($post_type_object->rewrite['slug'])) {
                    $path .= $post_type_object->rewrite['slug'];
                }
                // If $path exists check for parents
                if (!empty($path)) {
                    $trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $path));
                }
                // If archive page exists add to trail
                if (!empty($post_type_object->has_archive) && function_exists('get_post_type_archive_link')) {
                    if (!is_singular('product')) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-type-archive">
										<a href="' . get_post_type_archive_link($post_type) . '" title="' . esc_attr($post_type_object->labels->name) . '">
											<span itemprop="title">' . $post_type_object->labels->name . '</span>
										</a>
									</span>';
                    }
                }
            }
            // Add shop page to cart
            if (is_singular('page') && class_exists('Woocommerce')) {
                if (is_cart() || is_checkout()) {
                    // Get shop page
                    if (class_exists('Woocommerce') && function_exists('wc_get_page_id')) {
                        $shop_id = wc_get_page_id('shop');
                        $shop_page_url = get_permalink($shop_id);
                        $shop_title = get_the_title($shop_id);
                        if (function_exists('icl_object_id')) {
                            $shop_title = get_the_title(icl_object_id($shop_id, 'page'));
                        }
                        $shop_title = apply_filters('wpex_bcrums_shop_title', $shop_title);
                    }
                    // Shop page
                    if ($shop_id && $shop_title) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-type-archive">
								<a href="' . get_permalink($shop_id) . '" title="' . esc_attr($shop_title) . '">
									<span itemprop="title">' . $shop_title . '</span>
								</a>
							</span>';
                    }
                }
            }
            // Standard Posts
            if ('post' == $post_type) {
                // Main Blog URL
                if ($blog_page = get_theme_mod('blog_page')) {
                    $blog_url = get_permalink($blog_page);
                    $blog_name = get_the_title($blog_page);
                    if (function_exists('icl_object_id')) {
                        $blog_name = get_the_title(icl_object_id($blog_page, 'page'));
                    }
                    $trail[] = '<span ' . $item_type_scope . ' class="trail-blog-url">
									<a href="' . $blog_url . '" title="' . $blog_name . '" itemprop="url">
										<span itemprop="title">' . $blog_name . '</span>
									</a>
								</span>';
                }
                // 1st Category
                if (get_theme_mod('breadcrumbs_blog_cat', '1')) {
                    $terms = get_the_terms($post_id, 'category');
                    if ($terms) {
                        $term = reset($terms);
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-blog-cat">
										<a href="' . get_term_link($term) . '" itemprop="url" title="' . $term->name . '">
											<span itemprop="title">' . $term->name . '</span>
										</a>
									</span>';
                    }
                }
            }
            // Tribe Events
            if ('tribe_events' == $post_type && function_exists('tribe_get_events_link')) {
                $trail[] = '<span ' . $item_type_scope . ' class="trail-portfolio-url">
								<a href="' . tribe_get_events_link() . '" title="' . __('All Events', 'wpex') . '">
									<span itemprop="title">' . __('All Events', 'wpex') . '</span>
								</a>
							</span>';
            }
            //  Main Portfolio
            if ($post_type == 'portfolio') {
                if ($portfolio_page = get_theme_mod('portfolio_page')) {
                    $portfolio_url = get_permalink($portfolio_page);
                    $portfolio_name = get_the_title($portfolio_page);
                    if (function_exists('icl_object_id')) {
                        $portfolio_name = get_the_title(icl_object_id($portfolio_page, 'page'));
                    }
                    if ($portfolio_url) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-portfolio-url">
									<a href="' . $portfolio_url . '" title="' . $portfolio_name . '">
										<span itemprop="title">' . $portfolio_name . '</span>
									</a>
								</span>';
                    }
                }
                // Portfolio 1st Category
                if (get_theme_mod('breadcrumbs_portfolio_cat', '1') && taxonomy_exists('portfolio_category')) {
                    $terms = get_the_terms($post_id, 'portfolio_category');
                    if ($terms) {
                        $term = reset($terms);
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-portfolio-cat">
										<a href="' . get_term_link($term) . '" itemprop="url" title="' . $term->name . '">
											<span itemprop="title">' . $term->name . '</span>
										</a>
									</span>';
                    }
                }
            }
            //  Main Staff
            if ($post_type == 'staff') {
                // Display staff page
                if ($staff_page = get_theme_mod('staff_page')) {
                    $staff_url = get_permalink($staff_page);
                    $staff_name = get_the_title($staff_page);
                    if (function_exists('icl_object_id')) {
                        $staff_name = get_the_title(icl_object_id($staff_page, 'page'));
                    }
                    if ($staff_url) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-staff-url">
									<a href="' . $staff_url . '" title="' . $staff_name . '">
										<span itemprop="title">' . $staff_name . '</span>
									</a>
								</span>';
                    }
                }
                // Staff 1st Category
                if (get_theme_mod('breadcrumbs_staff_cat', '1') && taxonomy_exists('staff_category')) {
                    $terms = get_the_terms($post_id, 'staff_category');
                    if ($terms) {
                        $term = reset($terms);
                        $trail[] = '<span ' . $item_type_scope . '>
										<a href="' . get_term_link($term) . '" itemprop="url" title="' . $term->name . '">
											<span itemprop="title">' . $term->name . '</span>
										</a>
									</span>';
                    }
                }
            }
            //  Main Testimonials
            if ($post_type == 'testimonials') {
                // Display testimonials page
                if ($testimonials_page = get_theme_mod('testimonials_page')) {
                    $testimonials_url = get_permalink($testimonials_page);
                    $testimonials_name = get_the_title($testimonials_page);
                    if (function_exists('icl_object_id')) {
                        $testimonials_name = get_the_title(icl_object_id($testimonials_page, 'page'));
                    }
                    if ($testimonials_url) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-testimonials-url">
									<a href="' . $testimonials_url . '" title="' . $testimonials_name . '">
										<span itemprop="title">' . $testimonials_name . '</span>
									</a>
								</span>';
                    }
                }
                // Testimonials 1st Category
                if (get_theme_mod('breadcrumbs_testimonials_cat', '1') && taxonomy_exists('testimonials_category')) {
                    $terms = get_the_terms($post_id, 'testimonials_category');
                    if ($terms) {
                        $term = reset($terms);
                        $trail[] = '<span ' . $item_type_scope . '>
										<a href="' . get_term_link($term) . '" itemprop="url" title="' . $term->name . '">
											<span itemprop="title">' . $term->name . '</span>
										</a>
									</span>';
                    }
                }
            }
            // Products
            if (is_singular('product') && class_exists('Woocommerce')) {
                // Globals
                global $woocommerce;
                // Get shop page
                if (class_exists('Woocommerce') && function_exists('wc_get_page_id')) {
                    $shop_id = wc_get_page_id('shop');
                    $shop_page_url = get_permalink($shop_id);
                    $shop_title = get_the_title($shop_id);
                    if (function_exists('icl_object_id')) {
                        $shop_title = get_the_title(icl_object_id($shop_id, 'page'));
                    }
                    $shop_title = apply_filters('wpex_bcrums_shop_title', $shop_title);
                }
                // Shop page
                if ($shop_id && $shop_title) {
                    $trail[] = '<span ' . $item_type_scope . ' class="trail-type-archive">
							<a href="' . get_permalink($shop_id) . '" title="' . esc_attr($shop_title) . '">
								<span itemprop="title">' . $shop_title . '</span>
							</a>
						</span>';
                }
                // Cart page
                if (sizeof($woocommerce->cart->cart_contents) > 0) {
                    $cart_id = wc_get_page_id('cart');
                    $cart_title = get_the_title($cart_id);
                    if ($cart_id) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-type-archive">
								<a href="' . get_permalink($cart_id) . '" title="' . esc_attr($cart_title) . '">
									<span itemprop="title">' . $cart_title . '</span>
								</a>
							</span>';
                    }
                }
            }
            // If the post type path returns nothing and there is a parent, get its parents.
            if (empty($path) && 0 !== $parent || 'attachment' == $post_type) {
                $trail = array_merge($trail, wpex_breadcrumbs_get_parents($parent, ''));
            }
            // End trail with post title
            $post_title = get_the_title($post_id);
            if (!empty($post_title)) {
                if ($trim_title = get_theme_mod('breadcrumbs_title_trim', '4')) {
                    $post_title = wp_trim_words($post_title, $trim_title);
                    $trail['trail_end'] = $post_title;
                } else {
                    $trail['trail_end'] = $post_title;
                }
            }
        } elseif (is_archive()) {
            // Add cart to shop
            if (function_exists('is_shop') && is_shop()) {
                global $woocommerce;
                if (sizeof($woocommerce->cart->cart_contents) > 0) {
                    $cart_id = wc_get_page_id('cart');
                    $cart_title = get_the_title($cart_id);
                    if ($cart_id) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-type-archive">
								<a href="' . get_permalink($cart_id) . '" title="' . esc_attr($cart_title) . '">
									<span itemprop="title">' . $cart_title . '</span>
								</a>
							</span>';
                    }
                }
            }
            // Topics
            if (is_post_type_archive('topic')) {
                $forums_link = get_post_type_archive_link('forum');
                $forum_obj = get_post_type_object('forum');
                $forum_name = $forum_obj->labels->name;
                if ($forums_link) {
                    $trail[] = '<span ' . $item_type_scope . '><a href="' . $forums_link . '" title="' . $forum_name . '">' . $forum_name . '</a></span>';
                }
            }
            /*-----------------------------------------------------------------------------------*/
            /*	- Taxonomies
            			/*-----------------------------------------------------------------------------------*/
            if (is_tax() || is_category() || is_tag()) {
                // Get some taxonomy variables
                $term = $wp_query->get_queried_object();
                $taxonomy = get_taxonomy($term->taxonomy);
                // Link to main portfolio page
                if (function_exists('wpex_is_portfolio_tax') && wpex_is_portfolio_tax() && ($portfolio_page = get_theme_mod('portfolio_page'))) {
                    $portfolio_url = get_permalink($portfolio_page);
                    $portfolio_name = get_the_title($portfolio_page);
                    if (function_exists('icl_object_id')) {
                        $portfolio_name = get_the_title(icl_object_id($portfolio_page, 'page'));
                    }
                    if ($portfolio_url) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-portfolio-url">
									<a href="' . $portfolio_url . '" title="' . $portfolio_name . '">
										<span itemprop="title">' . $portfolio_name . '</span>
									</a>
								</span>';
                    }
                }
                // Link to main staff page
                if (function_exists('wpex_is_staff_tax') && wpex_is_staff_tax() && ($staff_page = get_theme_mod('staff_page'))) {
                    $staff_url = get_permalink($staff_page);
                    $staff_name = get_the_title($staff_page);
                    if (function_exists('icl_object_id')) {
                        $staff_name = get_the_title(icl_object_id($staff_page, 'page'));
                    }
                    if ($staff_url) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-staff-url">
									<a href="' . $staff_url . '" title="' . $staff_name . '">
										<span itemprop="title">' . $staff_name . '</span>
									</a>
								</span>';
                    }
                }
                // Testimonials Tax
                if (function_exists('wpex_is_testimonials_tax') && wpex_is_testimonials_tax() && ($testimonials_page = get_theme_mod('testimonials_page'))) {
                    $testimonials_url = get_permalink($testimonials_page);
                    $testimonials_name = get_the_title($testimonials_page);
                    if (function_exists('icl_object_id')) {
                        $testimonials_name = get_the_title(icl_object_id($testimonials_page, 'page'));
                    }
                    if ($testimonials_url) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-testimonials-url">
									<a href="' . $testimonials_url . '" title="' . $testimonials_name . '">
										<span itemprop="title">' . $testimonials_name . '</span>
									</a>
								</span>';
                    }
                }
                // Woo Product Tax
                if (function_exists('wpex_is_woo_tax') && wpex_is_woo_tax()) {
                    // Get shop page
                    if (class_exists('Woocommerce') && function_exists('wc_get_page_id')) {
                        $shop_id = wc_get_page_id('shop');
                        $shop_page_url = get_permalink($shop_id);
                        $shop_title = get_the_title($shop_id);
                        if (function_exists('icl_object_id')) {
                            $shop_title = get_the_title(icl_object_id($shop_id, 'page'));
                        }
                        $shop_title = apply_filters('wpex_bcrums_shop_title', $shop_title);
                    }
                    if ($shop_page_url && $shop_title) {
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-shop">
										<a href="' . $shop_page_url . '" title="' . $shop_title . '" itemprop="url">
											<span itemprop="title">' . $shop_title . '</span>
										</a>
									</span>';
                    }
                }
                // Display main blog page on Categories & archives
                if (is_category() || is_tag()) {
                    if ($blog_page = get_theme_mod('blog_page')) {
                        $blog_url = get_permalink($blog_page);
                        $blog_name = get_the_title($blog_page);
                        if (function_exists('icl_object_id')) {
                            $blog_name = get_the_title(icl_object_id($blog_page, 'page'));
                        }
                        $trail[] = '<span ' . $item_type_scope . ' class="trail-blog-url">
										<a href="' . $blog_url . '" title="' . $blog_name . '" itemprop="url">
											<span itemprop="title">' . $blog_name . '</span>
										</a>
									</span>';
                    }
                }
                // Get the path to the term archive. Use this to determine if a page is present with it.
                if (is_category()) {
                    $path = get_option('category_base');
                } elseif (is_tag()) {
                    $path = get_option('tag_base');
                } else {
                    if ($taxonomy->rewrite['with_front'] && $wp_rewrite->front) {
                        $path = trailingslashit($wp_rewrite->front);
                    }
                    $path .= $taxonomy->rewrite['slug'];
                }
                // Get parent pages if they exist
                if ($path) {
                    $trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $path));
                }
                // Add term parents
                if (is_taxonomy_hierarchical($term->taxonomy) && $term->parent) {
                    $trail = array_merge($trail, wpex_breadcrumbs_get_term_parents($term->parent, $term->taxonomy));
                }
                // Add term name to trail end
                $trail['trail_end'] = $term->name;
            } elseif (is_post_type_archive()) {
                // Get post type object
                $post_type_object = get_post_type_object(get_query_var('post_type'));
                // Add $front to $path
                if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                    $path .= trailingslashit($wp_rewrite->front);
                }
                // Add slug to 4path
                if (!empty($post_type_object->rewrite['archive'])) {
                    $path .= $post_type_object->rewrite['archive'];
                }
                // If patch exists check for parents
                if (!empty($path)) {
                    $trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $path));
                }
                // Add post type name to trail end
                $trail['trail_end'] = $post_type_object->labels->name;
            } elseif (is_author()) {
                /* If $front has been set, add it to $path. */
                if (!empty($wp_rewrite->front)) {
                    $path .= trailingslashit($wp_rewrite->front);
                }
                /* If an $author_base exists, add it to $path. */
                if (!empty($wp_rewrite->author_base)) {
                    $path .= $wp_rewrite->author_base;
                }
                /* If $path exists, check for parent pages. */
                if (!empty($path)) {
                    $trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $path));
                }
                /* Add the author's display name to the trail end. */
                $trail['trail_end'] = get_the_author_meta('display_name', get_query_var('author'));
            } elseif (is_time()) {
                if (get_query_var('minute') && get_query_var('hour')) {
                    $trail['trail_end'] = get_the_time(__('g:i a', 'wpex'));
                } elseif (get_query_var('minute')) {
                    $trail['trail_end'] = sprintf(__('Minute %1$s', 'wpex'), get_the_time(__('i', 'wpex')));
                } elseif (get_query_var('hour')) {
                    $trail['trail_end'] = get_the_time(__('g a', 'wpex'));
                }
            } elseif (is_date()) {
                // If $front is set check for parents
                if ($wp_rewrite->front) {
                    $trail = array_merge($trail, wpex_breadcrumbs_get_parents('', $wp_rewrite->front));
                }
                if (is_day()) {
                    $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'wpex')) . '">' . get_the_time(__('Y', 'wpex')) . '</a>';
                    $trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'wpex')) . '">' . get_the_time(__('F', 'wpex')) . '</a>';
                    $trail['trail_end'] = get_the_time(__('j', 'wpex'));
                } elseif (get_query_var('w')) {
                    $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'wpex')) . '">' . get_the_time(__('Y', 'wpex')) . '</a>';
                    $trail['trail_end'] = sprintf(__('Week %1$s', 'wpex'), get_the_time(esc_attr__('W', 'wpex')));
                } elseif (is_month()) {
                    $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'wpex')) . '">' . get_the_time(__('Y', 'wpex')) . '</a>';
                    $trail['trail_end'] = get_the_time(__('F', 'wpex'));
                } elseif (is_year()) {
                    $trail['trail_end'] = get_the_time(__('Y', 'wpex'));
                }
            }
        } elseif (is_search()) {
            $trail['trail_end'] = sprintf(__('Search results for &quot;%1$s&quot;', 'wpex'), esc_attr(get_search_query()));
        } elseif (is_404()) {
            $trail['trail_end'] = get_theme_mod('error_page_title') ? get_theme_mod('error_page_title') : __('404 Not Found', 'wpex');
        } elseif (function_exists('tribe_is_month') && tribe_is_month()) {
            $trail['trail_end'] = __('Events Calendar', 'wpex');
        }
        /*-----------------------------------------------------------------------------------*/
        /*	- Create and return the breadcrumbs
        		/*-----------------------------------------------------------------------------------*/
        if ($trail && is_array($trail)) {
            $classes = 'site-breadcrumbs clr';
            if ($breadcrumbs_position = get_theme_mod('breadcrumbs_position')) {
                $classes .= ' position-' . $breadcrumbs_position;
            }
            // Open Breadcrumbs
            $breadcrumb = '<nav class="' . $classes . '"><div class="breadcrumb-trail">';
            // Seperator HTML
            $separator = '<span class="sep">' . $separator . '</span>';
            // Join all trail items into a string
            $breadcrumb .= implode($separator, $trail);
            // Close breadcrumbs
            $breadcrumb .= '</div></nav>';
        }
        // Return the breadcrumbs trail
        return $breadcrumb;
    }
コード例 #2
0
                ?>
"<?php 
                echo $url_target;
                echo $readmore_style;
                echo $readmore_data;
                ?>
>
											<?php 
                echo $read_more_text;
                ?>
											<?php 
                // Display readmore button rarr if enabled
                if ('true' == $readmore_rarr) {
                    ?>
												<span class="vcex-readmore-rarr"><?php 
                    echo wpex_element('rarr');
                    ?>
</span>
											<?php 
                }
                ?>
										</a>

									</div><!-- .vcex-blog-entry-readmore-wrap -->

								<?php 
            }
            ?>

								<?php 
            // Close equal heights div if equal heights is enabled
コード例 #3
0
ファイル: portfolio_grid.php プロジェクト: sergey-h/naman
    function vcex_portfolio_grid_shortcode($atts)
    {
        extract(shortcode_atts(array('unique_id' => '', 'term_slug' => '', 'include_categories' => '', 'exclude_categories' => '', 'posts_per_page' => '8', 'grid_style' => 'fit_columns', 'masonry_layout_mode' => '', 'filter_speed' => '', 'columns' => '4', 'order' => 'DESC', 'orderby' => 'date', 'orderby_meta_key' => '', 'filter' => '', 'center_filter' => 'no', 'thumb_link' => 'post', 'thumb_lightbox_gallery' => '', 'thumb_lightbox_title' => '', 'img_crop' => 'true', 'img_width' => '9999', 'img_height' => '9999', 'img_filter' => '', 'title' => 'true', 'title_link' => 'post', 'excerpt' => 'true', 'excerpt_length' => 30, 'custom_excerpt_trim' => '', 'read_more' => '', 'read_more_text' => __('read more', 'wpex'), 'pagination' => '', 'filter_content' => 'false', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'img_hover_style' => '', 'img_overlay_disable' => '', 'img_rendering' => '', 'all_text' => '', 'overlay_style' => '', 'content_heading_margin' => '', 'content_background' => '', 'content_margin' => '', 'content_font_size' => '', 'content_padding' => '', 'content_border' => '', 'content_color' => '', 'content_opacity' => '', 'content_heading_color' => '', 'content_heading_size' => '', 'content_alignment' => '', 'readmore_background' => '', 'readmore_color' => '', 'equal_heights_grid' => '', 'single_column_style' => '', 'entry_media' => ''), $atts));
        // Turn output buffer on
        ob_start();
        // Global $post
        global $post;
        // Don't create custom tax if tax doesn't exist
        if (taxonomy_exists('portfolio_category')) {
            // Include categories
            $include_categories = '' != $include_categories ? $include_categories : $term_slug;
            $include_categories = 'all' == $include_categories ? '' : $include_categories;
            $filter_cats_include = '';
            if ($include_categories) {
                $include_categories = explode(',', $include_categories);
                $filter_cats_include = array();
                foreach ($include_categories as $key) {
                    $key = get_term_by('slug', $key, 'portfolio_category');
                    $filter_cats_include[] = $key->term_id;
                }
            }
            // Exclude categories
            $filter_cats_exclude = '';
            if ($exclude_categories) {
                $exclude_categories = explode(',', $exclude_categories);
                if (!empty($exclude_categories) && is_array($exclude_categories)) {
                    $filter_cats_exclude = array();
                    foreach ($exclude_categories as $key) {
                        $key = get_term_by('slug', $key, 'portfolio_category');
                        $filter_cats_exclude[] = $key->term_id;
                    }
                    $exclude_categories = array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $exclude_categories, 'operator' => 'NOT IN');
                } else {
                    $exclude_categories = '';
                }
            }
            // Start Tax Query
            if (!empty($include_categories) && is_array($include_categories)) {
                $include_categories = array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $include_categories, 'operator' => 'IN');
            } else {
                $include_categories = '';
            }
        }
        // Meta key for orderby
        if ($orderby_meta_key && ('meta_value_num' == $orderby || 'meta_value' == $orderby)) {
            $meta_key = $orderby_meta_key;
        } else {
            $meta_key = NULL;
        }
        // Pagination variables
        $paged = NULL;
        $no_found_rows = true;
        if ('true' == $pagination) {
            global $paged;
            $paged = get_query_var('paged') ? get_query_var('paged') : 1;
            $no_found_rows = false;
        }
        // The Query
        $wpex_query = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => $posts_per_page, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'meta_key' => $meta_key, 'filter_content' => $filter_content, 'paged' => $paged, 'tax_query' => array('relation' => 'AND', $include_categories, $exclude_categories), 'no_found_rows' => $no_found_rows));
        //Output posts
        if ($wpex_query->posts) {
            // Set unique ID
            $unique_id = $unique_id ? $unique_id : 'portfolio-' . rand(1, 100);
            // Image hard crop
            if ('9999' == $img_height) {
                $img_crop = false;
            } else {
                $img_crop = true;
            }
            // Is Isotope var
            if ('true' == $filter || 'masonry' == $grid_style || 'no_margins' == $grid_style) {
                $is_isotope = true;
            } else {
                $is_isotope = false;
            }
            // No need for masonry if not enough columns and filter is disabled
            if ('true' != $filter && 'masonry' == $grid_style) {
                $post_count = count($wpex_query->posts);
                if ($post_count <= $columns) {
                    $is_isotope = false;
                }
            }
            // Output script for inline JS for the Visual composer front-end builder
            if ($is_isotope) {
                vcex_front_end_grid_js('isotope');
            }
            // Display filter links
            if ('true' == $filter && taxonomy_exists('portfolio_category')) {
                // Get the terms for the filter
                $terms = get_terms('portfolio_category', array('include' => $filter_cats_include, 'exclude' => $filter_cats_exclude));
                // Display filter only if terms exist and there is more then 1
                if ($terms && count($terms) > '1') {
                    // Center filter links
                    $center_filter = 'yes' == $center_filter ? 'center' : '';
                    // All text
                    if ($all_text) {
                        $all_text = $all_text;
                    } else {
                        $all_text = __('All', 'wpex');
                    }
                    ?>
						<ul class="vcex-portfolio-filter filter-<?php 
                    echo $unique_id;
                    ?>
 vcex-filter-links <?php 
                    echo $center_filter;
                    ?>
 clr">
							<li class="active"><a href="#" data-filter="*"><span><?php 
                    echo $all_text;
                    ?>
</span></a></li>
							<?php 
                    foreach ($terms as $term) {
                        ?>
								<li><a href="#" data-filter=".cat-<?php 
                        echo $term->term_id;
                        ?>
"><?php 
                        echo $term->name;
                        ?>
</a></li>
							<?php 
                    }
                    ?>
						</ul><!-- .vcex-portfolio-filter -->
					<?php 
                }
                ?>
				<?php 
            }
            // Content Design
            $content_style = '';
            if ($content_background) {
                $content_style .= 'background:' . $content_background . ';';
            }
            if ($content_padding) {
                $content_style .= 'padding:' . $content_padding . ';';
            }
            if ($content_margin) {
                $content_style .= 'margin:' . $content_margin . ';';
            }
            if ($content_border) {
                $content_style .= 'border:' . $content_border . ';';
            }
            if ($content_font_size) {
                $content_style .= 'font-size:' . $content_font_size . ';';
            }
            if ($content_color) {
                $content_style .= 'color:' . $content_color . ';';
            }
            if ($content_opacity) {
                $content_style .= 'opacity:' . $content_opacity . ';';
            }
            if ($content_alignment) {
                $content_style .= 'text-align:' . $content_alignment . ';';
            }
            if ($content_style) {
                $content_style = 'style="' . $content_style . '"';
            }
            // Heading Design
            $heading_style = '';
            if ($content_heading_margin) {
                $heading_style .= 'margin: ' . $content_heading_margin . ';';
            }
            if ($content_heading_size) {
                $heading_style .= 'font-size: ' . $content_heading_size . ';';
            }
            if ($content_heading_color) {
                $heading_style .= 'color: ' . $content_heading_color . ';';
            }
            if ($heading_style) {
                $heading_style = 'style="' . $heading_style . '"';
            }
            // Readmore design
            if ('false' != $read_more) {
                $read_more = 'true';
                // Set readmore to true
                $readmore_style = '';
                if ($readmore_background) {
                    $readmore_style .= 'background: ' . $readmore_background . ';';
                }
                if ($readmore_color) {
                    $readmore_style .= 'color: ' . $readmore_color . ';';
                }
                if ($readmore_style) {
                    $readmore_style = 'style="' . $readmore_style . '"';
                }
            }
            // Set title to true if not false
            if ('false' != $title) {
                $title = 'true';
            }
            // Set excerpt to true if not false
            if ('false' != $excerpt) {
                $excerpt = 'true';
            }
            // Default excerpt length
            if ('' == $excerpt_length) {
                $excerpt_length = '30';
            } elseif ('false' == $excerpt) {
                $excerpt_length = '0';
            }
            // Trim custom Excerpts?
            if ('false' == $custom_excerpt_trim) {
                $custom_excerpt_trim = false;
            } else {
                $custom_excerpt_trim = true;
            }
            // Only use articles if title is enabled for HTML5 validity
            if ($title == 'true') {
                $main_element_type = 'article';
            } else {
                $main_element_type = 'div';
            }
            // Main wrap classes
            $wrap_classes = 'wpex-row vcex-portfolio-grid clr';
            // Equal heights class
            if ('1' != $columns && ('fit_columns' == $grid_style && 'true' == $equal_heights_grid)) {
                $equal_heights_grid = true;
            } else {
                $equal_heights_grid = false;
            }
            // Isotope classes
            if ($is_isotope) {
                $wrap_classes .= ' vcex-isotope-grid';
            }
            // No margins grid
            if ('no_margins' == $grid_style) {
                $wrap_classes .= ' vcex-no-margin-grid';
            }
            // Left thumbnail 1 column style
            if ('left_thumbs' == $single_column_style) {
                $wrap_classes .= ' left-thumbs';
            }
            // Lightbox classes
            if ('true' == $thumb_lightbox_gallery) {
                $wrap_classes .= ' lightbox-group';
                $lightbox_single_class = ' lightbox-group-item';
            } else {
                $lightbox_single_class = ' wpex-lightbox';
            }
            // Data
            $data = '';
            if ($is_isotope && 'true' == $filter) {
                if ('no_margins' != $grid_style && $masonry_layout_mode) {
                    $data .= ' data-layout-mode="' . $masonry_layout_mode . '"';
                }
                if ($filter_speed) {
                    $data .= ' data-transition-duration="' . $filter_speed . '"';
                }
            }
            if ('no_margins' == $grid_style && 'true' != $filter) {
                $data .= ' data-transition-duration="0.0"';
            }
            ?>
		
				<div class="<?php 
            echo $wrap_classes;
            ?>
" id="<?php 
            echo $unique_id;
            ?>
"<?php 
            echo $data;
            ?>
>
					<?php 
            // Define counter var to clear floats
            $count = $count_all = '';
            // Start loop
            foreach ($wpex_query->posts as $post) {
                setup_postdata($post);
                // Open match-height-row div for equal heights
                if ($equal_heights_grid && !$is_isotope) {
                    if (0 == $count) {
                        ?>
								<div class="match-height-row clr">
							<?php 
                    }
                    $count_all++;
                }
                // Post Data
                $post_id = $post->ID;
                $post_title = get_the_title();
                $post_title_esc = esc_attr(the_title_attribute('echo=0'));
                $post_permalink = get_permalink($post_id);
                // Add to the counter var
                $count++;
                // Add classes to the entries
                $entry_classes = 'portfolio-entry col';
                $entry_classes .= ' span_1_of_' . $columns;
                $entry_classes .= ' col-' . $count;
                if ($is_isotope) {
                    $entry_classes .= ' vcex-isotope-entry';
                }
                if ('no_margins' == $grid_style) {
                    $entry_classes .= ' vcex-no-margin-entry';
                }
                if (taxonomy_exists('portfolio_category')) {
                    $post_terms = get_the_terms($post, 'portfolio_category');
                    if ($post_terms) {
                        foreach ($post_terms as $post_term) {
                            $entry_classes .= ' cat-' . $post_term->term_id;
                        }
                    }
                }
                ?>
						<<?php 
                echo $main_element_type;
                ?>
 class="<?php 
                echo $entry_classes;
                ?>
">
							<?php 
                // Entry Media
                if ('false' != $entry_media) {
                    // Video
                    if (function_exists('wpex_get_portfolio_featured_video_url') && wpex_get_portfolio_featured_video_url()) {
                        ?>
									<div class="portfolio-entry-media clr">
										<?php 
                        wpex_portfolio_post_video();
                        ?>
									</div>
								<?php 
                    } elseif (has_post_thumbnail()) {
                        // Get cropped image
                        $cropped_img = wpex_image_resize(wp_get_attachment_url(get_post_thumbnail_id()), intval($img_width), intval($img_height), $img_crop, 'array');
                        // Filter style
                        $img_filter_class = $img_filter ? 'vcex-' . $img_filter : '';
                        // Media classes
                        $media_classes = $img_filter_class;
                        if ($img_hover_style) {
                            $media_classes .= ' vcex-img-hover-parent vcex-img-hover-' . $img_hover_style;
                        }
                        if ($img_rendering) {
                            $media_classes .= ' vcex-image-rendering-' . $img_rendering;
                        }
                        if ($overlay_style) {
                            $media_classes .= ' ' . wpex_overlay_classname($overlay_style);
                        }
                        ?>
									<div class="portfolio-entry-media <?php 
                        echo $media_classes;
                        ?>
">
										<?php 
                        // No link
                        if ('nowhere' == $thumb_link) {
                            ?>
											<img src="<?php 
                            echo $cropped_img['url'];
                            ?>
" alt="<?php 
                            echo $post_title;
                            ?>
" class="portfolio-entry-img" height="<?php 
                            echo $cropped_img['height'];
                            ?>
" width="<?php 
                            echo $cropped_img['width'];
                            ?>
" />
										<?php 
                            // Lightbox
                        } elseif ('lightbox' == $thumb_link) {
                            // Display lightbox title
                            $data = '';
                            if ('true' == $thumb_lightbox_title) {
                                $data = ' data-title="' . $post_title_esc . '"';
                            }
                            ?>
												<a href="<?php 
                            echo wp_get_attachment_url(get_post_thumbnail_id());
                            ?>
" title="<?php 
                            echo $post_title_esc;
                            ?>
" class="portfolio-entry-media-link<?php 
                            echo $lightbox_single_class;
                            ?>
"<?php 
                            echo $data;
                            ?>
>
												<img src="<?php 
                            echo $cropped_img['url'];
                            ?>
" alt="<?php 
                            echo $post_title_esc;
                            ?>
" class="portfolio-entry-img" height="<?php 
                            echo $cropped_img['height'];
                            ?>
" width="<?php 
                            echo $cropped_img['width'];
                            ?>
" />
										<?php 
                            // Standarad post link
                        } else {
                            ?>
												<a href="<?php 
                            echo $post_permalink;
                            ?>
" title="<?php 
                            echo $post_title_esc;
                            ?>
" class="portfolio-entry-media-link">
												<img src="<?php 
                            echo $cropped_img['url'];
                            ?>
" alt="<?php 
                            echo $post_title_esc;
                            ?>
" class="portfolio-entry-img" height="<?php 
                            echo $cropped_img['height'];
                            ?>
" width="<?php 
                            echo $cropped_img['width'];
                            ?>
" />
										<?php 
                        }
                        ?>
											
										<?php 
                        // Close link and output overlay code
                        if ('nowhere' != $thumb_link) {
                            // Inner Overlay
                            if ($overlay_style) {
                                wpex_overlay('inside_link', $overlay_style);
                            }
                            // Close links
                            echo '</a>';
                            // Outside Overlay
                            if ($overlay_style) {
                                wpex_overlay('outside_link', $overlay_style);
                            }
                        }
                        ?>
									</div><!-- .portfolio-entry-media -->
								<?php 
                    }
                    ?>
							<?php 
                }
                ?>
							<?php 
                // Display content if there is either a title or excerpt
                if ('true' == $title || 'true' == $excerpt) {
                    ?>
								<div class="portfolio-entry-details clr" <?php 
                    echo $content_style;
                    ?>
>
									<?php 
                    // Equal height div
                    if ($equal_heights_grid && !$is_isotope) {
                        ?>
									<div class="match-height-content">
									<?php 
                    }
                    // Display the title
                    if ('false' != $title) {
                        ?>
										<h2 class="portfolio-entry-title" <?php 
                        echo $heading_style;
                        ?>
>
											<?php 
                        // Link title to post
                        if ('post' == $title_link) {
                            ?>
												<a href="<?php 
                            echo $post_permalink;
                            ?>
" title="<?php 
                            echo $post_title_esc;
                            ?>
" <?php 
                            echo $heading_style;
                            ?>
><?php 
                            echo $post_title;
                            ?>
</a>
											<?php 
                        } elseif ('lightbox' == $title_link) {
                            ?>
												<a href="<?php 
                            echo wp_get_attachment_url(get_post_thumbnail_id());
                            ?>
" title="<?php 
                            echo $post_title_esc;
                            ?>
" class="wpex-lightbox" <?php 
                            echo $heading_style;
                            ?>
><?php 
                            echo $post_title;
                            ?>
</a>
											<?php 
                        } else {
                            echo $post_title;
                        }
                        ?>
										</h2>
									<?php 
                    }
                    // Display excerpt and readmore
                    if ('true' == $excerpt || 'true' == $read_more) {
                        ?>
										<div class="portfolio-entry-excerpt clr">
											<?php 
                        // Display full content
                        if ('9999' == $excerpt_length) {
                            the_content();
                        } elseif (function_exists('wpex_excerpt')) {
                            $args = array('post_id' => $post_id, 'length' => intval($excerpt_length), 'trim_custom_excerpts' => $custom_excerpt_trim);
                            wpex_excerpt($args);
                        } else {
                            the_excerpt();
                        }
                        // Display Readmore
                        if ('false' != $read_more) {
                            // Read more string fallback
                            if ('' == $read_more_text) {
                                $read_more_text = __('read more', 'wpex');
                            }
                            ?>
												<a href="<?php 
                            echo $post_permalink;
                            ?>
" title="<?php 
                            echo $read_more_text;
                            ?>
" rel="bookmark" class="vcex-readmore theme-button" <?php 
                            echo $readmore_style;
                            ?>
>
													<?php 
                            echo $read_more_text;
                            ?>
 <span class="vcex-readmore-rarr"><?php 
                            echo wpex_element('rarr');
                            ?>
</span>
												</a>
											<?php 
                        }
                        ?>
										</div>
									<?php 
                    }
                    // Close Equal height div
                    if ($equal_heights_grid && !$is_isotope) {
                        ?>
										</div>
									<?php 
                    }
                    ?>
								</div><!-- .portfolio-entry-details -->
							<?php 
                }
                ?>
						</<?php 
                echo $main_element_type;
                ?>
><!-- .portfolio-entry -->
					<?php 
                // Check if counter equal columns
                if ($count == $columns) {
                    // Close equal height row
                    if ($equal_heights_grid && !$is_isotope) {
                        echo '</div><!-- .match-height-row -->';
                    }
                    // Reset counter
                    $count = '';
                }
                // End foreach
            }
            // Make sure match-height-row is closed
            if ($equal_heights_grid && !$is_isotope) {
                if ('4' == $columns && $count_all % 4 != 0) {
                    echo '</div><!-- .match-height-row -->';
                }
                if ('3' == $columns && $count_all % 3 != 0) {
                    echo '</div><!-- .match-height-row -->';
                }
                if ('2' == $columns && $count_all % 2 != 0) {
                    echo '</div><!-- .match-height-row -->';
                }
            }
            ?>
				</div><!-- .vcex-portfolio-grid -->
				
				<?php 
            // Paginate Posts
            if ('true' == $pagination) {
                wpex_pagination($wpex_query);
            }
            // Reset the WP query
            wp_reset_postdata();
            // End has posts check
        }
        // Return outbut buffer
        return ob_get_clean();
    }
コード例 #4
0
ファイル: breadcrumbs.php プロジェクト: iq007/MadScape
 private function generate_crumbs()
 {
     // Globals
     global $wp_query, $wp_rewrite;
     // Get post id
     $post_id = $this->post_id;
     // Define main variables
     $breadcrumb = $path = '';
     $trail = array();
     $item_type_scope = $this->itemscope;
     // Home text
     $home_text = wpex_get_translated_theme_mod('breadcrumbs_home_title');
     $home_text = $home_text ? $home_text : '<span class="fa fa-home"></span><span class="display-none">' . esc_html_x('Home', 'breadcrumbs', 'total') . '</span>';
     // Default arguments
     $args = apply_filters('wpex_breadcrumbs_args', array('home_text' => $home_text, 'home_link' => home_url('/'), 'separator' => wpex_element('angle_right'), 'front_page' => false, 'show_posts_page' => true));
     // Extract args for easy variable naming.
     extract($args);
     /*-----------------------------------------------------------------------------------*/
     /*  - Homepage link
     			/*-----------------------------------------------------------------------------------*/
     $trail['trail_start'] = '<span ' . esc_attr($item_type_scope) . '><a href="' . esc_url($home_link) . '" title="' . esc_attr(get_bloginfo('name')) . '" rel="home" class="trail-begin" itemprop="url"><span itemprop="title">' . $home_text . '</span></a></span>';
     /*-----------------------------------------------------------------------------------*/
     /*  - Front Page
     			/*-----------------------------------------------------------------------------------*/
     if (is_front_page()) {
         if (!$front_page) {
             $trail = false;
         } elseif ($show_home) {
             $trail['trail_end'] = "{$show_home}";
         }
     } elseif (is_home()) {
         $home_page = get_page($wp_query->get_queried_object_id());
         if (is_object($home_page)) {
             $trail = array_merge($trail, $this->get_post_parents($home_page->post_parent, ''));
             $trail['trail_end'] = '<span itemprop="title">' . get_the_title($home_page->ID) . '</span>';
         }
     } elseif (is_singular()) {
         // Get singular vars
         $post = $wp_query->get_queried_object();
         $post_id = absint($wp_query->get_queried_object_id());
         $post_type = $post->post_type;
         $parent = $post->post_parent;
         // Pages
         if ('page' == $post_type) {
             // Woo pages
             if (WPEX_WOOCOMMERCE_ACTIVE) {
                 // Add shop page to cart
                 if (is_cart() || is_checkout()) {
                     // Get shop data
                     $shop_data = $this->get_shop_data();
                     $shop_url = $shop_data['url'];
                     $shop_title = $shop_data['title'];
                     // Add shop link
                     if ($shop_url && $shop_title) {
                         $trail['shop'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-shop"><a href="' . esc_url($shop_url) . '" title="' . esc_attr($shop_title) . '" itemprop="url"><span itemprop="title">' . esc_html($shop_title) . '</span></a></span>';
                     }
                 }
                 // Add cart to checkout
                 if (is_checkout()) {
                     $cart_id = wpex_parse_obj_id(wc_get_page_id('cart'), 'page');
                     if ($cart_id) {
                         $cart_title = get_the_title($cart_id);
                         $trail['cart'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-type-archive trail-cart"><a href="' . esc_url(get_permalink($cart_id)) . '" title="' . esc_attr($cart_title) . '" itemprop="url"><span itemprop="title">' . $cart_title . '</span></a></span>';
                     }
                 }
             }
         } elseif ('post' == $post_type) {
             // Main Blog URL
             $page_id = wpex_parse_obj_id(wpex_get_mod('blog_page'), 'page');
             if ($page_id) {
                 $page_permalink = get_permalink($page_id);
                 $page_name = get_the_title($page_id);
                 if ($page_permalink && $page_name) {
                     $trail['blog'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-blog-url"> <a href="' . esc_url($page_permalink) . '" title="' . esc_attr($page_name) . '" itemprop="url"><span itemprop="title">' . $page_name . '</span></a></span>';
                 }
             }
             // Categories
             if ($terms = $this->get_post_terms($taxonomy = 'category')) {
                 $trail['categories'] = '<span class="trail-post-categories">' . $terms . '</span>';
             }
         } elseif ('tribe_events' == $post_type) {
             if (function_exists('tribe_get_events_link')) {
                 $trail['tribe_events'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-all-events"><a href="' . esc_url(tribe_get_events_link()) . '" title="' . esc_attr__('All Events', 'total') . '" itemprop="url"><span itemprop="title">' . esc_html__('All Events', 'total') . '</span></a></span>';
             }
         } elseif ('portfolio' == $post_type) {
             // Portfolio main page
             $page_id = wpex_parse_obj_id(wpex_get_mod('portfolio_page'), 'page');
             if ($page_id) {
                 $page_permalink = get_permalink($page_id);
                 $page_name = get_the_title($page_id);
                 if ($page_permalink && $page_name) {
                     $trail['portfolio'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-portfolio-url"> <a href="' . esc_url($page_permalink) . '" title="' . esc_attr($page_name) . '" itemprop="url"><span itemprop="title">' . $page_name . '</span></a></span>';
                 }
             }
             // Portfolio Categories
             if ($terms = $this->get_post_terms($taxonomy = 'portfolio_category')) {
                 $trail['categories'] = '<span class="trail-post-categories">' . $terms . '</span>';
             }
         } elseif ('staff' == $post_type) {
             // Staff main page
             $page_id = wpex_parse_obj_id(wpex_get_mod('staff_page'), 'page');
             if ($page_id) {
                 $page_permalink = get_permalink($page_id);
                 $page_name = get_the_title($page_id);
                 if ($page_permalink && $page_name) {
                     $trail['staff'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-staff-url"> <a href="' . esc_url($page_permalink) . '" title="' . esc_attr($page_name) . '" itemprop="url"><span itemprop="title">' . $page_name . '</span></a></span>';
                 }
             }
             // Staff Categories
             if ($terms = $this->get_post_terms($taxonomy = 'staff_category')) {
                 $trail['categories'] = '<span class="trail-post-categories">' . $terms . '</span>';
             }
         } elseif ('testimonials' == $post_type) {
             // Testimonials main page
             $page_id = wpex_parse_obj_id(wpex_get_mod('testimonials_page'), 'page');
             if ($page_id) {
                 $page_permalink = get_permalink($page_id);
                 $page_name = get_the_title($page_id);
                 if ($page_permalink && $page_name) {
                     $trail['testimonials'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-testimonials-url"> <a href="' . esc_url($page_permalink) . '" title="' . esc_attr($page_name) . '" itemprop="url"><span itemprop="title">' . $page_name . '</span></a></span>';
                 }
             }
             // Testimonials Categories
             if ($terms = $this->get_post_terms($taxonomy = 'testimonials_category')) {
                 $trail['categories'] = '<span class="trail-post-categories">' . $terms . '</span>';
             }
         } elseif ('product' == $post_type) {
             // Get shop data
             $shop_data = $this->get_shop_data();
             $shop_url = $shop_data['url'];
             $shop_title = $shop_data['title'];
             // Add shop page to product post
             if ($shop_url && $shop_title) {
                 $trail['shop'] = '<span ' . esc_attr($item_type_scope) . '><a href="' . esc_url($shop_url) . '" title="' . esc_attr($shop_title) . '" itemprop="url"><span itemprop="title">' . $shop_title . '</span></a></span>';
             }
             // Add categories to product post
             if ($terms = $this->get_post_terms($taxonomy = 'product_cat')) {
                 $trail['categories'] = '<span class="trail-post-categories">' . $terms . '</span>';
             }
             // Add cart to product post
             if (apply_filters('wpex_breadcrumbs_single_product_cart', false)) {
                 $cart_id = wpex_parse_obj_id(wc_get_page_id('cart'));
                 if ($cart_id) {
                     $cart_title = get_the_title($cart_id);
                     $trail['cart'] = '<span ' . esc_attr($item_type_scope) . '><a href="' . esc_url(get_permalink($cart_id)) . '" title="' . esc_attr($cart_title) . '" itemprop="url"><span itemprop="title">' . $cart_title . '</span></a></span>';
                 }
             }
         } else {
             $post_type_object = get_post_type_object($post_type);
             // Add $front to the path
             if ('post' == $post_type || $post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                 $path .= trailingslashit($wp_rewrite->front);
             }
             // Add slug to $path
             if (!empty($post_type_object->rewrite['slug'])) {
                 $path .= $post_type_object->rewrite['slug'];
             }
             // If archive page exists add to trail
             if (!empty($post_type_object->has_archive) && !is_singular('product')) {
                 $trail['post_type_archive'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-type-archive"><a href="' . esc_url(get_post_type_archive_link($post_type)) . '" title="' . esc_attr($post_type_object->labels->name) . '" itemprop="url"><span itemprop="title">' . $post_type_object->labels->name . '</span></a></span>';
             } else {
                 // If $path exists check for parents
                 if (!empty($path)) {
                     $trail = array_merge($trail, $this->get_post_parents('', $path));
                 }
             }
         }
         // If the post type path returns nothing and there is a parent, get its parents.
         if (empty($path) && $parent && 'attachment' != $post_type) {
             $trail = array_merge($trail, $this->get_post_parents($parent));
         }
         // End trail with post title
         if ($post_title = get_the_title($post_id)) {
             if ($trim_title = wpex_get_mod('breadcrumbs_title_trim')) {
                 $post_title = wp_trim_words($post_title, $trim_title);
             }
             $trail['trail_end'] = $post_title;
         }
     } elseif (is_archive()) {
         /*-----------------------------------------------------------------------------------*/
         /*  - Post Type Archive
         				/*-----------------------------------------------------------------------------------*/
         if (is_post_type_archive()) {
             // Shop Archive
             if (function_exists('is_shop') && is_shop()) {
                 global $woocommerce;
                 if (sizeof($woocommerce->cart->cart_contents) > 0) {
                     $cart_id = wc_get_page_id('cart');
                     if (function_exists('icl_object_id')) {
                         $cart_id = icl_object_id($cart_id, 'page');
                     }
                     $cart_title = get_the_title($cart_id);
                     if ($cart_id) {
                         $trail['cart'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-type-archive"><a href="' . esc_url(get_permalink($cart_id)) . '" title="' . esc_attr($cart_title) . '" itemprop="url"><span itemprop="title">' . $cart_title . '</span></a></span>';
                     }
                 }
                 // Get shop page
                 $shop_data = $this->get_shop_data();
                 // Add shop page title to trail end
                 if ($shop_data['title']) {
                     $trail['trail_end'] = $shop_data['title'];
                 }
             } elseif (is_post_type_archive('topic')) {
                 $forums_link = get_post_type_archive_link('forum');
                 $forum_obj = get_post_type_object('forum');
                 $forum_name = $forum_obj->labels->name;
                 if ($forums_link) {
                     $trail['topics'] = '<span ' . esc_attr($item_type_scope) . '><a href="' . esc_url($forums_link) . '" title="' . esc_attr($forum_name) . '" itemprop="url">' . esc_html($forum_name) . '</a></span>';
                 }
                 $trail['trail_end'] = $post_type_object->labels->name;
                 // All other post type archives
             } else {
                 // Get post type object
                 $post_type_object = get_post_type_object(get_query_var('post_type'));
                 // Add $front to $path
                 if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
                     $path .= trailingslashit($wp_rewrite->front);
                 }
                 // Add slug to $path
                 if (!empty($post_type_object->rewrite['archive'])) {
                     $path .= $post_type_object->rewrite['archive'];
                 }
                 // If patch exists check for parents
                 if (!empty($path)) {
                     $trail = array_merge($trail, $this->get_post_parents('', $path));
                 }
                 // Add post type name to trail end
                 $trail['trail_end'] = $post_type_object->labels->name;
             }
         } elseif (!is_search() && (is_tax() || is_category() || is_tag())) {
             // Get some taxonomy variables
             $term = $wp_query->get_queried_object();
             $taxonomy = get_taxonomy($term->taxonomy);
             // Link to main portfolio page
             if (function_exists('wpex_is_portfolio_tax') && wpex_is_portfolio_tax() && ($portfolio_page = wpex_get_mod('portfolio_page'))) {
                 $portfolio_url = get_permalink($portfolio_page);
                 $portfolio_name = get_the_title($portfolio_page);
                 if (function_exists('icl_object_id')) {
                     $portfolio_page = icl_object_id($portfolio_page, 'page');
                     $portfolio_url = get_permalink($portfolio_page);
                     $portfolio_name = get_the_title($portfolio_page);
                 }
                 if ($portfolio_url) {
                     $trail['portfolio'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-portfolio-url"><a href="' . esc_url($portfolio_url) . '" title="' . esc_attr($portfolio_name) . '" itemprop="url"><span itemprop="title">' . $portfolio_name . '</span></a></span>';
                 }
             }
             // Link to main staff page
             if (function_exists('wpex_is_staff_tax') && wpex_is_staff_tax() && ($staff_page = wpex_get_mod('staff_page'))) {
                 if (function_exists('icl_object_id')) {
                     $staff_page = icl_object_id($staff_page, 'page');
                 }
                 $staff_url = get_permalink($staff_page);
                 $staff_name = get_the_title($staff_page);
                 if ($staff_url) {
                     $trail['staff'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-staff-url"><a href="' . esc_url($staff_url) . '" title="' . esc_attr($staff_name) . '" itemprop="url"><span itemprop="title">' . $staff_name . '</span></a></span>';
                 }
             }
             // Testimonials Tax
             if (function_exists('wpex_is_testimonials_tax') && wpex_is_testimonials_tax() && ($testimonials_page = wpex_get_mod('testimonials_page'))) {
                 $testimonials_url = get_permalink($testimonials_page);
                 $testimonials_name = get_the_title($testimonials_page);
                 if (function_exists('icl_object_id')) {
                     $testimonials_page = icl_object_id($testimonials_page, 'page');
                     $testimonials_url = get_permalink($testimonials_page);
                     $testimonials_name = get_the_title($testimonials_page);
                 }
                 if ($testimonials_url) {
                     $trail['testimonials'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-testimonials-url"><a href="' . esc_url($testimonials_url) . '" title="' . esc_attr($testimonials_name) . '" itemprop="url"><span itemprop="title">' . $testimonials_name . '</span></a></span>';
                 }
             }
             // Woo Product Tax
             if (function_exists('wpex_is_woo_tax') && wpex_is_woo_tax()) {
                 // Get shop data
                 $shop_data = $this->get_shop_data();
                 $shop_url = $shop_data['url'];
                 $shop_title = $shop_data['title'];
                 // Add shop link
                 if ($shop_url && $shop_title) {
                     $trail['shop'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-shop"><a href="' . esc_url($shop_url) . '" title="' . esc_attr($shop_title) . '" itemprop="url"><span itemprop="title">' . $shop_title . '</span></a></span>';
                 }
             }
             // Display main blog page on Categories & archives
             if (is_category() || is_tag()) {
                 if ($blog_page = wpex_get_mod('blog_page')) {
                     $blog_url = get_permalink($blog_page);
                     $blog_name = get_the_title($blog_page);
                     if (function_exists('icl_object_id')) {
                         $blog_page = icl_object_id($blog_page, 'page');
                         $blog_url = get_permalink($blog_page);
                         $blog_name = get_the_title($blog_page);
                     }
                     $trail['blog'] = '<span ' . esc_attr($item_type_scope) . ' class="trail-blog-url"><a href="' . esc_url($blog_url) . '" title="' . esc_attr($blog_name) . '" itemprop="url"><span itemprop="title">' . $blog_name . '</span></a></span>';
                 }
             }
             // Get the path to the term archive. Use this to determine if a page is present with it.
             if (is_category()) {
                 $path = get_option('category_base');
             } elseif (is_tag()) {
                 $path = get_option('tag_base');
             } else {
                 if ($taxonomy->rewrite['with_front'] && $wp_rewrite->front) {
                     $path = trailingslashit($wp_rewrite->front);
                 }
                 $path .= $taxonomy->rewrite['slug'];
             }
             // Get parent pages if they exist
             if ($path) {
                 $trail = array_merge($trail, $this->get_post_parents('', $path));
             }
             // Add term parents
             if (is_taxonomy_hierarchical($term->taxonomy) && $term->parent) {
                 $trail = array_merge($trail, $this->get_term_parents($term));
             }
             // Add term name to trail end
             $trail['trail_end'] = $term->name;
         } elseif (is_author()) {
             // If $front has been set, add it to $path.
             if (!empty($wp_rewrite->front)) {
                 $path .= trailingslashit($wp_rewrite->front);
             }
             // If an $author_base exists, add it to $path.
             if (!empty($wp_rewrite->author_base)) {
                 $path .= $wp_rewrite->author_base;
             }
             // If $path exists, check for parent pages.
             if (!empty($path)) {
                 $trail = array_merge($trail, $this->get_post_parents('', $path));
             }
             // Add the author's display name to the trail end.
             $trail['trail_end'] = get_the_author_meta('display_name', get_query_var('author'));
         } elseif (is_time()) {
             // Display minute and hour
             if (get_query_var('minute') && get_query_var('hour')) {
                 $trail['trail_end'] = get_the_time('g:i a');
             } elseif (get_query_var('minute')) {
                 $trail['trail_end'] = sprintf(esc_html__('Minute %1$s', 'total'), get_the_time('i'));
             } elseif (get_query_var('hour')) {
                 $trail['trail_end'] = get_the_time('g a');
             }
         } elseif (is_date()) {
             // If $front is set check for parents
             if ($wp_rewrite->front) {
                 $trail = array_merge($trail, $this->get_post_parents('', $wp_rewrite->front));
             }
             // Day archive
             if (is_day()) {
                 // Display year
                 $title = date_i18n('Y', strtotime(get_the_time('Y')));
                 $trail['year'] = '<a href="' . esc_url(get_year_link(get_the_time('Y'))) . '" title="' . esc_attr($title) . '" itemprop="url">' . esc_html($title) . '</a>';
                 // Display month
                 $title = date_i18n('F', strtotime(get_the_time('F')));
                 $trail['month'] = '<a href="' . esc_url(get_month_link(get_the_time('Y'), get_the_time('m'))) . '" title="' . esc_attr($title) . '" itemprop="url">' . esc_html($title) . '</a>';
                 // Display Time
                 $trail['trail_end'] = date_i18n('j', strtotime(get_the_time('j')));
             } elseif (get_query_var('w')) {
                 // Display year
                 $title = date_i18n('Y', strtotime(get_the_time('Y')));
                 $trail['year'] = '<a href="' . esc_url(get_year_link(get_the_time('Y'))) . '" title="' . esc_attr($title) . '" itemprop="url">' . esc_html($title) . '</a>';
                 // Display week
                 $trail['trail_end'] = sprintf(esc_html__('Week %1$s', 'total'), get_the_time('W'));
             } elseif (is_month()) {
                 $title = date_i18n('F', strtotime(get_the_time('F')));
                 $trail[] = '<a href="' . esc_url(get_year_link(get_the_time('Y'))) . '" title="' . esc_attr($title) . '" itemprop="url">' . esc_html($title) . '</a>';
                 $trail['trail_end'] = esc_html($title);
             } elseif (is_year()) {
                 $trail['trail_end'] = date_i18n('Y', strtotime(get_the_time('Y')));
             }
         }
     } elseif (is_search()) {
         $trail['trail_end'] = sprintf(esc_html__('Search results for &quot;%1$s&quot;', 'total'), esc_html(get_search_query()));
     } elseif (is_404()) {
         $trail['trail_end'] = wpex_get_mod('error_page_title') ? wpex_get_mod('error_page_title') : esc_html__('404 Not Found', 'total');
     } elseif (function_exists('tribe_is_month') && tribe_is_month()) {
         $trail['trail_end'] = esc_html__('Events Calendar', 'total');
     }
     /*-----------------------------------------------------------------------------------*/
     /*  - Create and return the breadcrumbs
     			/*-----------------------------------------------------------------------------------*/
     // Apply filters so developers can alter the trail
     $trail = apply_filters('wpex_breadcrumbs_trail', $trail);
     // Return trail
     if ($trail && is_array($trail)) {
         $classes = 'site-breadcrumbs wpex-clr';
         $classes .= ' position-' . wpex_get_mod('breadcrumbs_position', 'default');
         // Open Breadcrumbs
         $breadcrumb = '<nav class="' . $classes . '"><div class="breadcrumb-trail">';
         // Separator HTML
         $separator = '<span class="sep"> ' . $separator . ' </span>';
         // Join all trail items into a string
         $breadcrumb .= implode($separator, $trail);
         // Close breadcrumbs
         $breadcrumb .= '</div></nav>';
     }
     // Update output var
     $this->output = $breadcrumb;
 }
コード例 #5
0
ファイル: blog_grid.php プロジェクト: sergey-h/naman
    function vcex_blog_grid_shortcode($atts)
    {
        extract(shortcode_atts(array('unique_id' => '', 'term_slug' => '', 'include_categories' => '', 'exclude_categories' => '', 'posts_per_page' => '4', 'grid_style' => 'fit_columns', 'columns' => '3', 'order' => 'DESC', 'orderby' => 'date', 'filter' => 'false', 'masonry_layout_mode' => '', 'filter_speed' => '', 'center_filter' => '', 'thumbnail_link' => 'post', 'entry_media' => "true", 'img_width' => '9999', 'img_height' => '9999', 'thumb_link' => 'post', 'img_filter' => '', 'title' => 'true', 'date' => 'true', 'excerpt' => 'true', 'excerpt_length' => '15', 'custom_excerpt_trim' => 'true', 'read_more' => 'false', 'read_more_text' => __('read more', 'wpex'), 'pagination' => 'false', 'filter_content' => 'false', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'all_text' => __('All', 'wpex'), 'featured_video' => 'true', 'url_target' => '_self', 'date_color' => '', 'content_heading_margin' => '', 'content_background' => '', 'content_margin' => '', 'content_font_size' => '', 'content_padding' => '', 'content_border' => '', 'content_color' => '', 'content_opacity' => '', 'content_heading_color' => '', 'content_heading_size' => '', 'content_alignment' => '', 'readmore_background' => '', 'readmore_color' => '', 'equal_heights_grid' => '', 'single_column_style' => ''), $atts));
        // Turn output buffer on
        ob_start();
        // Get global $post var
        global $post;
        // Include categories
        $include_categories = '' != $include_categories ? $include_categories : $term_slug;
        $include_categories = 'all' == $include_categories ? '' : $include_categories;
        $filter_cats_include = '';
        if ($include_categories) {
            $include_categories = explode(',', $include_categories);
            $filter_cats_include = array();
            foreach ($include_categories as $key) {
                $key = get_term_by('slug', $key, 'category');
                $filter_cats_include[] = $key->term_id;
            }
        }
        // Exclude categories
        $filter_cats_exclude = '';
        if ($exclude_categories) {
            $exclude_categories = explode(',', $exclude_categories);
            if (!empty($exclude_categories) && is_array($exclude_categories)) {
                $filter_cats_exclude = array();
                foreach ($exclude_categories as $key) {
                    $key = get_term_by('slug', $key, 'category');
                    $filter_cats_exclude[] = $key->term_id;
                }
                $exclude_categories = array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $exclude_categories, 'operator' => 'NOT IN');
            } else {
                $exclude_categories = '';
            }
        }
        // Start Tax Query
        if (!empty($include_categories) && is_array($include_categories)) {
            $include_categories = array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $include_categories, 'operator' => 'IN');
        } else {
            $include_categories = '';
        }
        // Pagination var
        $paged = NULL;
        $no_found_rows = true;
        if ('true' == $pagination) {
            global $paged;
            $paged = get_query_var('paged') ? get_query_var('paged') : 1;
            $no_found_rows = false;
        }
        // The Query
        $wpex_query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => $posts_per_page, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'filter_content' => $filter_content, 'paged' => $paged, 'tax_query' => array('relation' => 'AND', $include_categories, $exclude_categories), 'no_found_rows' => $no_found_rows));
        //Output posts
        if ($wpex_query->posts) {
            // Custom excerpts trim
            $custom_excerpt_trim = 'true' == $custom_excerpt_trim ? true : false;
            // Image hard crop
            if ('9999' == $img_height) {
                $img_crop = false;
            } else {
                $img_crop = true;
            }
            // Equal heights class
            if ('1' != $columns && ('fit_columns' == $grid_style && 'true' == $equal_heights_grid)) {
                $equal_heights_grid = true;
            } else {
                $equal_heights_grid = false;
            }
            // Is Isotope var
            if ('true' == $filter || 'masonry' == $grid_style) {
                $is_isotope = true;
            } else {
                $is_isotope = false;
            }
            // No need for masonry if not enough columns and filter is disabled
            if ('true' != $filter && 'masonry' == $grid_style) {
                $post_count = count($wpex_query->posts);
                if ($post_count <= $columns) {
                    $is_isotope = false;
                }
            }
            // Output script for inline JS for the Visual composer front-end builder
            if ($is_isotope) {
                vcex_front_end_grid_js('isotope');
            }
            // Display filter links
            if ($filter == 'true') {
                $terms = get_terms('category', array('include' => $filter_cats_include, 'exclude' => $filter_cats_exclude));
                if ($terms && count($terms) > '1') {
                    $center_filter = 'yes' == $center_filter ? 'center' : '';
                    ?>
					<ul class="vcex-blog-filter vcex-filter-links <?php 
                    echo $center_filter;
                    ?>
 clr">
						<li class="active"><a href="#" data-filter="*"><span><?php 
                    echo $all_text;
                    ?>
</span></a></li>
						<?php 
                    foreach ($terms as $term) {
                        ?>
							<li><a href="#" data-filter=".cat-<?php 
                        echo $term->term_id;
                        ?>
"><?php 
                        echo $term->name;
                        ?>
</a></li>
						<?php 
                    }
                    ?>
					</ul><!-- .vcex-blog-filter -->
				<?php 
                }
                ?>
			<?php 
            }
            // Content Design
            $content_style = '';
            if ($content_background) {
                $content_style .= 'background:' . $content_background . ';';
            }
            if ($content_padding) {
                $content_style .= 'padding:' . $content_padding . ';';
            }
            if ($content_margin) {
                $content_style .= 'margin:' . $content_margin . ';';
            }
            if ($content_border) {
                $content_style .= 'border:' . $content_border . ';';
            }
            if ($content_font_size) {
                $content_style .= 'font-size:' . $content_font_size . ';';
            }
            if ($content_color) {
                $content_style .= 'color:' . $content_color . ';';
            }
            if ($content_opacity) {
                $content_style .= 'opacity:' . $content_opacity . ';';
            }
            if ($content_alignment) {
                $content_style .= 'text-align:' . $content_alignment . ';';
            }
            if ($content_style) {
                $content_style = 'style="' . $content_style . '"';
            }
            // Heading Design
            $heading_style = '';
            if ($content_heading_margin) {
                $heading_style .= 'margin:' . $content_heading_margin . ';';
            }
            if ($content_heading_size) {
                $heading_style .= 'font-size:' . $content_heading_size . ';';
            }
            if ($content_heading_color) {
                $heading_style .= 'color:' . $content_heading_color . ';';
            }
            if ($heading_style) {
                $heading_style = 'style="' . $heading_style . '"';
            }
            // Readmore design
            if ('true' == $read_more) {
                $readmore_style = '';
                if ($readmore_background) {
                    $readmore_style .= 'background:' . $readmore_background . ';';
                }
                if ($readmore_color) {
                    $readmore_style .= 'color:' . $readmore_color . ';';
                }
                if ($readmore_style) {
                    $readmore_style = 'style="' . $readmore_style . '"';
                }
            }
            // Date design
            $date_style = '';
            if ('true' == $date) {
                if ($date_color) {
                    $date_style .= 'color:' . $date_color . ';';
                }
                if ($date_style) {
                    $date_style = 'style="' . $date_style . '"';
                }
            }
            // Wrap classes
            $wrap_classes = 'wpex-row vcex-blog-grid clr';
            if ($is_isotope) {
                $wrap_classes .= ' vcex-isotope-grid';
            }
            if ('left_thumbs' == $single_column_style) {
                $wrap_classes .= ' left-thumbs';
            }
            // Unique ID
            if ($unique_id) {
                $unique_id = ' id="' . $unique_id . '"';
            }
            // Data
            $data = '';
            if ($is_isotope && 'true' == $filter) {
                if ($masonry_layout_mode) {
                    $data .= ' data-layout-mode="' . $masonry_layout_mode . '"';
                }
                if ($filter_speed) {
                    $data .= ' data-transition-duration="' . $filter_speed . '"';
                }
            }
            ?>
	
			<div class="<?php 
            echo $wrap_classes;
            ?>
"<?php 
            echo $unique_id . $data;
            ?>
>
				<?php 
            // Define counter var to clear floats
            $count = $count_all = '';
            // Loop through posts
            foreach ($wpex_query->posts as $post) {
                setup_postdata($post);
                // Open match-height-row div for equal heights
                if ($equal_heights_grid && !$is_isotope) {
                    if (0 == $count) {
                        ?>
							<div class="match-height-row clr">
						<?php 
                    }
                    $count_all++;
                }
                // Post Vars
                $post_id = $post->ID;
                $format = get_post_format($post_id);
                $post_title = get_the_title();
                $post_title_esc = esc_attr(the_title_attribute('echo=0'));
                $link = get_permalink();
                // Counter
                $count++;
                // Link format tweaks
                if ('link' == $format) {
                    $link = wpex_permalink();
                    $url_target = '_blank';
                }
                // Get video
                if ('video' == $format) {
                    $video_url = get_post_meta($post_id, 'wpex_post_oembed', true);
                }
                // Entry Classes
                $entry_classes = 'vcex-blog-entry col';
                $entry_classes .= ' col-' . $count;
                $entry_classes .= ' span_1_of_' . $columns;
                if ($is_isotope) {
                    $entry_classes .= ' vcex-isotope-entry';
                }
                // Create a list of terms to add as classes to the entry
                if ($post_terms = get_the_terms($post, 'category')) {
                    foreach ($post_terms as $post_term) {
                        $entry_classes .= ' cat-' . $post_term->term_id;
                    }
                }
                if ("false" == $entry_media) {
                    $entry_classes .= ' vcex-blog-no-media-entry';
                }
                ?>
					<article id="#post-<?php 
                the_ID();
                ?>
" class="<?php 
                echo $entry_classes;
                ?>
">
						<?php 
                if ("true" == $entry_media) {
                    ?>
							<?php 
                    $img_filter_class = $img_filter ? 'vcex-' . $img_filter : '';
                    ?>
							<?php 
                    if ("video" == $format && 'true' == $featured_video && $video_url) {
                        ?>
								<div class="vcex-blog-entry-media">
									<div class="vcex-video-wrap">
										<?php 
                        echo wp_oembed_get($video_url);
                        ?>
									</div>
								</div><!-- .vcex-blog-entry-media -->
							<?php 
                    } elseif (has_post_thumbnail()) {
                        ?>
								<div class="vcex-blog-entry-media <?php 
                        echo $img_filter_class;
                        ?>
">
									<?php 
                        if ($thumb_link == 'post' || $thumb_link == 'lightbox') {
                            ?>
										<?php 
                            // Post links
                            if ($thumb_link == 'post') {
                                ?>
											<a href="<?php 
                                echo $link;
                                ?>
" title="<?php 
                                echo $post_title_esc;
                                ?>
" target="<?php 
                                echo $url_target;
                                ?>
">
										<?php 
                            }
                            ?>
										<?php 
                            // Lightbox Links
                            if ($thumb_link == 'lightbox') {
                                ?>
											<?php 
                                // Video Lightbox
                                if ('video' == $format) {
                                    ?>
												<a href="<?php 
                                    echo $video_url;
                                    ?>
" title="<?php 
                                    echo $post_title_esc;
                                    ?>
" class="wpex-lightbox-video">
											<?php 
                                } else {
                                    ?>
												<a href="<?php 
                                    echo wp_get_attachment_url(get_post_thumbnail_id());
                                    ?>
" title="<?php 
                                    echo $post_title_esc;
                                    ?>
" class="wpex-lightbox">
											<?php 
                                }
                                ?>
										<?php 
                            }
                            ?>
									<?php 
                        }
                        // Get cropped image array and display image
                        $cropped_img = wpex_image_resize(wp_get_attachment_url(get_post_thumbnail_id()), intval($img_width), intval($img_height), $img_crop, 'array');
                        ?>
										<img src="<?php 
                        echo $cropped_img['url'];
                        ?>
" alt="<?php 
                        the_title();
                        ?>
" class="vcex-blog-entry-img" height="<?php 
                        echo $cropped_img['height'];
                        ?>
" width="<?php 
                        echo $cropped_img['width'];
                        ?>
" />
									<?php 
                        if ($thumb_link == 'post' || $thumb_link == 'lightbox') {
                            ?>
										</a>
									<?php 
                        }
                        ?>
								</div><!-- .blog-entry-media -->
							<?php 
                    }
                    ?>
						<?php 
                }
                ?>
						<?php 
                // Display entry details if the title or excerpt are enabled
                if ('true' == $title || 'true' == $excerpt) {
                    ?>
							<div class="vcex-blog-entry-details clr" <?php 
                    echo $content_style;
                    ?>
>
								<?php 
                    // Equal height div
                    if ($equal_heights_grid && !$is_isotope) {
                        ?>
								<div class="match-height-content">
								<?php 
                    }
                    // Post Title
                    if ($title == 'true') {
                        ?>
									<h2 class="vcex-blog-entry-title" <?php 
                        echo $heading_style;
                        ?>
>
										<a href="<?php 
                        echo $link;
                        ?>
" title="<?php 
                        echo $post_title_esc;
                        ?>
" target="<?php 
                        echo $url_target;
                        ?>
" <?php 
                        echo $heading_style;
                        ?>
>
											<?php 
                        the_title();
                        ?>
										</a>
									</h2>
								<?php 
                    }
                    // Post Date
                    if ($date == 'true') {
                        ?>
									<div class="vcex-blog-entry-date" <?php 
                        echo $date_style;
                        ?>
><?php 
                        echo get_the_date();
                        ?>
</div>
								<?php 
                    }
                    // Excerpt
                    if ('true' == $excerpt || 'true' == $read_more) {
                        if ('true' != $excerpt) {
                            $excerpt_length = '0';
                        }
                        ?>
									<div class="vcex-blog-entry-excerpt clr">
										<?php 
                        // Show full content
                        if ('9999' == $excerpt_length) {
                            the_content();
                        } else {
                            // Custom Excerpt
                            $excerpt_array = array('post_id' => $post_id, 'length' => intval($excerpt_length), 'trim_custom_excerpts' => $custom_excerpt_trim);
                            vcex_excerpt($excerpt_array);
                        }
                        // Read more
                        if ('true' == $read_more) {
                            if ('link' == $format) {
                                $read_more_text = __('Visit Website', 'wpex');
                            }
                            ?>
											<a href="<?php 
                            echo $link;
                            ?>
" title="<?php 
                            echo $read_more_text;
                            ?>
" rel="bookmark" class="vcex-readmore theme-button" target="<?php 
                            echo $url_target;
                            ?>
" <?php 
                            echo $readmore_style;
                            ?>
>
												<?php 
                            echo $read_more_text;
                            ?>
 <span class="vcex-readmore-rarr"><?php 
                            echo wpex_element('rarr');
                            ?>
</span>
											</a>
										<?php 
                        }
                        ?>
									</div>
								<?php 
                    }
                    // Close Equal height div
                    if ($equal_heights_grid && !$is_isotope) {
                        ?>
								</div>
								<?php 
                    }
                    ?>
							</div><!-- .blog-entry-details -->
						<?php 
                }
                ?>
					</article><!-- .blog-entry -->
				<?php 
                // Reset counter
                if ($count == $columns) {
                    // Close equal height row
                    if ($equal_heights_grid && !$is_isotope) {
                        echo '</div><!-- .match-height-row -->';
                    }
                    $count = '0';
                }
                // End foreach
            }
            // Make sure match-height-row is closed
            if ($equal_heights_grid && !$is_isotope) {
                if ('4' == $columns && $count_all % 4 != 0) {
                    echo '</div><!-- .match-height-row -->';
                }
                if ('3' == $columns && $count_all % 3 != 0) {
                    echo '</div><!-- .match-height-row -->';
                }
                if ('2' == $columns && $count_all % 2 != 0) {
                    echo '</div><!-- .match-height-row -->';
                }
            }
            ?>
			</div><!-- .vcex-blog-grid -->
			
			<?php 
            // Paginate Posts
            if ('true' == $pagination) {
                wpex_pagination($wpex_query);
            }
            // End has posts check
        }
        // Reset the WP query
        wp_reset_postdata();
        // Return outbut buffer
        return ob_get_clean();
    }
コード例 #6
0
ファイル: post_type_grid.php プロジェクト: sergey-h/naman2
    function vcex_post_type_grid_shortcode($atts)
    {
        extract(shortcode_atts(array('unique_id' => '', 'post_types' => '', 'tax_query' => '', 'tax_query_taxonomy' => '', 'tax_query_terms' => '', 'posts_per_page' => '12', 'grid_style' => 'fit_columns', 'columns' => '3', 'order' => 'DESC', 'orderby' => 'date', 'orderby_meta_key' => '', 'filter' => '', 'masonry_layout_mode' => '', 'filter_speed' => '', 'center_filter' => '', 'thumbnail_link' => 'post', 'entry_media' => "true", 'img_width' => '9999', 'img_height' => '9999', 'thumb_link' => 'post', 'img_filter' => '', 'title' => 'true', 'date' => 'true', 'excerpt' => 'true', 'excerpt_length' => '15', 'custom_excerpt_trim' => 'true', 'read_more' => 'false', 'read_more_text' => __('read more', 'wpex'), 'pagination' => 'false', 'filter_content' => 'false', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'all_text' => __('All', 'wpex'), 'featured_video' => 'true', 'url_target' => '_self', 'thumbnail_query' => 'no', 'overlay_style' => '', 'img_hover_style' => '', 'date_color' => '', 'content_heading_margin' => '', 'content_background' => '', 'content_margin' => '', 'content_font_size' => '', 'content_padding' => '', 'content_border' => '', 'content_color' => '', 'content_opacity' => '', 'content_heading_color' => '', 'content_heading_size' => '', 'content_alignment' => '', 'readmore_background' => '', 'readmore_color' => '', 'equal_heights_grid' => ''), $atts));
        // Turn output buffer on
        ob_start();
        // Get global $post var
        global $post;
        // Meta key for orderby
        if ($orderby_meta_key && ('meta_value_num' == $orderby || 'meta_value' == $orderby)) {
            $meta_key = $orderby_meta_key;
        } else {
            $meta_key = NULL;
        }
        // Pagination var
        $paged = NULL;
        $no_found_rows = true;
        if ('true' == $pagination) {
            global $paged;
            $paged = get_query_var('paged') ? get_query_var('paged') : 1;
            $paged = NULL;
            $no_found_rows = false;
        }
        // Post types
        $post_types = $post_types ? $post_types : 'post';
        $post_types = explode(',', $post_types);
        $post_types_count = count($post_types);
        // Thumbnail meta query
        if ('true' == $thumbnail_query) {
            $meta_query = array(array('key' => '_thumbnail_id'));
        } else {
            $meta_query = NULL;
        }
        // Tax Query
        if ('' != $tax_query && '' != $tax_query_taxonomy && '' != $tax_query_terms) {
            $tax_query_terms = explode(',', $tax_query_terms);
            $tax_query = array(array('taxonomy' => $tax_query_taxonomy, 'field' => 'slug', 'terms' => $tax_query_terms));
        } else {
            $tax_query = '';
        }
        // Query args
        $args = array('post_type' => $post_types, 'posts_per_page' => $posts_per_page, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'tax_query' => $tax_query, 'meta_key' => $meta_key, 'filter_content' => $filter_content, 'paged' => $paged, 'meta_query' => $meta_query, 'no_found_rows' => $no_found_rows);
        // Build new query
        $wpex_query = new WP_Query($args);
        //Output posts
        if ($wpex_query->posts) {
            // Main Vars
            $unique_id = $unique_id ? $unique_id : 'post-type-' . rand(1, 100);
            $img_crop = $img_height == '9999' ? false : true;
            $read_more = $read_more == 'true' ? true : false;
            // Is Isotope var
            if ('true' == $filter && $post_types_count > '1' || 'masonry' == $grid_style || 'no_margins' == $grid_style) {
                $is_isotope = true;
            } else {
                $is_isotope = false;
            }
            // No need for masonry if not enough columns and filter is disabled
            if ('true' != $filter && 'masonry' == $grid_style) {
                $post_count = count($wpex_query->posts);
                if ($post_count <= $columns) {
                    $is_isotope = false;
                }
            }
            // Main wrap classes
            $wrap_classes = 'wpex-row vcex-post-type-grid vcex-clearfix';
            // Equal heights class
            if ('1' != $columns && ('fit_columns' == $grid_style && 'true' == $equal_heights_grid)) {
                $equal_heights_grid = true;
            } else {
                $equal_heights_grid = false;
            }
            // Isotope classes
            if ($is_isotope) {
                $wrap_classes .= ' vcex-isotope-grid';
            }
            // No margins grid
            if ('no_margins' == $grid_style) {
                $wrap_classes .= ' vcex-no-margin-grid';
            }
            // Output script for inline JS for the Visual composer front-end builder
            if ($is_isotope) {
                vcex_front_end_grid_js('isotope');
            }
            // Content Design
            $content_style = '';
            if ($content_background) {
                $content_style .= 'background:' . $content_background . ';';
            }
            if ($content_padding) {
                $content_style .= 'padding:' . $content_padding . ';';
            }
            if ($content_margin) {
                $content_style .= 'margin:' . $content_margin . ';';
            }
            if ($content_border) {
                $content_style .= 'border:' . $content_border . ';';
            }
            if ($content_font_size) {
                $content_style .= 'font-size:' . $content_font_size . ';';
            }
            if ($content_color) {
                $content_style .= 'color:' . $content_color . ';';
            }
            if ($content_opacity) {
                $content_style .= 'opacity:' . $content_opacity . ';';
            }
            if ($content_alignment) {
                $content_style .= 'text-align:' . $content_alignment . ';';
            }
            if ($content_style) {
                $content_style = 'style="' . $content_style . '"';
            }
            // Heading Design
            $heading_style = '';
            if ($content_heading_margin) {
                $heading_style .= 'margin:' . $content_heading_margin . ';';
            }
            if ($content_heading_size) {
                $heading_style .= 'font-size:' . $content_heading_size . ';';
            }
            if ($content_heading_color) {
                $heading_style .= 'color:' . $content_heading_color . ';';
            }
            if ($heading_style) {
                $heading_style = 'style="' . $heading_style . '"';
            }
            // Readmore design
            if ('true' == $read_more) {
                $readmore_style = '';
                if ($readmore_background) {
                    $readmore_style .= 'background:' . $readmore_background . ';';
                }
                if ($readmore_color) {
                    $readmore_style .= 'color:' . $readmore_color . ';';
                }
                if ($readmore_style) {
                    $readmore_style = 'style="' . $readmore_style . '"';
                }
            }
            // Date design
            $date_style = '';
            if ('true' == $date) {
                if ($date_color) {
                    $date_style .= 'color:' . $date_color . ';';
                }
                if ($date_style) {
                    $date_style = 'style="' . $date_style . '"';
                }
            }
            // Display filter links
            if ('true' == $filter && $post_types_count > '1') {
                $center_filter = 'yes' == $center_filter ? 'center' : '';
                ?>
					<ul class="vcex-post-type-filter filter-<?php 
                echo $unique_id;
                ?>
 vcex-filter-links <?php 
                echo $center_filter;
                ?>
 clr">
						<li class="active"><a href="#" data-filter="*"><span><?php 
                echo $all_text;
                ?>
</span></a></li>
						<?php 
                foreach ($post_types as $post_type) {
                    $obj = get_post_type_object($post_type);
                    ?>
							<li><a href="#" data-filter=".post-type-<?php 
                    echo $post_type;
                    ?>
"><?php 
                    echo $obj->labels->name;
                    ?>
</a></li>
						<?php 
                }
                ?>
					</ul><!-- .vcex-post-type-filter -->
				<?php 
            }
            ?>

				<?php 
            // Data
            $data = '';
            if ($is_isotope && 'true' == $filter) {
                if ('no_margins' != $grid_style && $masonry_layout_mode) {
                    $data .= ' data-layout-mode="' . $masonry_layout_mode . '"';
                }
                if ($filter_speed) {
                    $data .= ' data-transition-duration="' . $filter_speed . '"';
                }
            }
            if ('no_margins' == $grid_style && 'true' != $filter) {
                $data .= ' data-transition-duration="0.0"';
            }
            ?>

				<div class="<?php 
            echo $wrap_classes;
            ?>
" id="<?php 
            echo $unique_id;
            ?>
"<?php 
            echo $data;
            ?>
>
					<?php 
            // Define counter var to clear floats
            $count = $count_all = '';
            // Loop through posts
            foreach ($wpex_query->posts as $post) {
                setup_postdata($post);
                // Open match-height-row div for equal heights
                if ($equal_heights_grid && !$is_isotope) {
                    if (0 == $count) {
                        ?>
								<div class="match-height-row clr">
							<?php 
                    }
                    $count_all++;
                }
                // Post ID var
                $post_id = $post->ID;
                // Add to counter var
                $count++;
                // Get post format
                $format = get_post_format($post_id);
                // Get video
                if ('true' == $featured_video) {
                    $video_url = get_post_meta($post_id, 'wpex_post_oembed', true);
                }
                // General Class
                $entry_classes = 'vcex-post-type-entry col';
                // Counter class
                $entry_classes .= ' col-' . $count;
                // Column class
                $entry_classes .= ' span_1_of_' . $columns;
                // Post type class
                $entry_classes .= ' post-type-' . get_post_type($post_id);
                // Isotope
                if ($is_isotope) {
                    $entry_classes .= ' vcex-isotope-entry';
                }
                // No margins grid
                if ('no_margins' == $grid_style) {
                    $entry_classes .= ' vcex-no-margin-entry';
                }
                // No media entry class
                if ("false" == $entry_media) {
                    $entry_classes .= ' vcex-post-type-no-media-entry';
                }
                if ($title == 'true') {
                    $main_element_type = 'article';
                } else {
                    $main_element_type = 'div';
                }
                ?>
						<<?php 
                echo $main_element_type;
                ?>
 id="#post-<?php 
                the_ID();
                ?>
" class="<?php 
                echo $entry_classes;
                ?>
">
							<?php 
                if ("true" == $entry_media) {
                    ?>
								<?php 
                    // Video Embed
                    if ("video" == $format && 'true' == $featured_video && $video_url) {
                        ?>
									<div class="vcex-post-type-entry-media">
										<div class="vcex-video-wrap">
											<?php 
                        echo wp_oembed_get($video_url);
                        ?>
										</div>
									</div><!-- .vcex-post-type-entry-media -->
								<?php 
                    } elseif (has_post_thumbnail()) {
                        // Filter style
                        $img_filter_class = $img_filter ? 'vcex-' . $img_filter : '';
                        // Image hover styles
                        $img_hover_style_class = $img_hover_style ? 'vcex-img-hover-parent vcex-img-hover-' . $img_hover_style : '';
                        // Media classes
                        $media_classes = $img_filter_class;
                        $media_classes .= ' ' . $img_hover_style_class;
                        $overlay_classnames = wpex_overlay_classname($overlay_style);
                        $media_classes .= ' ' . $overlay_classnames;
                        ?>
									<div class="vcex-post-type-entry-media <?php 
                        echo $media_classes;
                        ?>
">
										<?php 
                        if ($thumb_link == 'post' || $thumb_link == 'lightbox') {
                            ?>
											<?php 
                            // Post links
                            if ($thumb_link == 'post') {
                                ?>
												<a href="<?php 
                                the_permalink();
                                ?>
" title="<?php 
                                echo esc_attr(the_title_attribute('echo=0'));
                                ?>
" target="<?php 
                                echo $url_target;
                                ?>
">
											<?php 
                            }
                            ?>
											<?php 
                            // Lightbox Links
                            if ($thumb_link == 'lightbox') {
                                ?>
												<?php 
                                // Video Lightbox
                                if ($format == 'video') {
                                    ?>
													<a href="<?php 
                                    echo $video_url;
                                    ?>
" title="<?php 
                                    echo esc_attr(the_title_attribute('echo=0'));
                                    ?>
" class="wpex-lightbox-video">
												<?php 
                                } else {
                                    ?>
													<a href="<?php 
                                    echo wp_get_attachment_url(get_post_thumbnail_id());
                                    ?>
" title="<?php 
                                    echo esc_attr(the_title_attribute('echo=0'));
                                    ?>
" class="wpex-lightbox">
												<?php 
                                }
                                ?>
											<?php 
                            }
                            ?>
										<?php 
                        }
                        // Get cropped image array and display image
                        $cropped_img = wpex_image_resize(wp_get_attachment_url(get_post_thumbnail_id()), intval($img_width), intval($img_height), $img_crop, 'array');
                        ?>
											<img src="<?php 
                        echo $cropped_img['url'];
                        ?>
" alt="<?php 
                        the_title();
                        ?>
" class="vcex-post-type-entry-img" height="<?php 
                        echo $cropped_img['height'];
                        ?>
" width="<?php 
                        echo $cropped_img['width'];
                        ?>
" />
										<?php 
                        if ($thumb_link == 'post' || $thumb_link == 'lightbox') {
                            ?>
										<?php 
                        }
                        ?>
										<?php 
                        // Overlay
                        if ('post' == $thumb_link || 'lightbox' == $thumb_link) {
                            // Inner Overlay
                            wpex_overlay('inside_link', $overlay_style);
                            ?>
											</a>
											<?php 
                            // Outside Overlay
                            wpex_overlay('outside_link', $overlay_style);
                        }
                        ?>
									</div><!-- .post_type-entry-media -->
								<?php 
                    }
                    ?>
							<?php 
                }
                ?>
							<?php 
                if ('true' == $title || 'true' == $excerpt || 'true' == $read_more) {
                    ?>
								<div class="vcex-post-type-entry-details clr" <?php 
                    echo $content_style;
                    ?>
>
									<?php 
                    // Equal height div
                    if ($equal_heights_grid && !$is_isotope) {
                        ?>
									<div class="match-height-content">
									<?php 
                    }
                    // Post Title
                    if ('false' != $title) {
                        ?>
										<h2 class="vcex-post-type-entry-title" <?php 
                        echo $heading_style;
                        ?>
>
											<a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        echo esc_attr(the_title_attribute('echo=0'));
                        ?>
" target="<?php 
                        echo $url_target;
                        ?>
" <?php 
                        echo $heading_style;
                        ?>
><?php 
                        the_title();
                        ?>
</a>
										</h2>
									<?php 
                    }
                    ?>
									<?php 
                    // Post Date
                    if ($date == 'true') {
                        ?>
										<div class="vcex-post-type-entry-date" <?php 
                        echo $date_style;
                        ?>
><?php 
                        echo get_the_date();
                        ?>
</div>
									<?php 
                    }
                    ?>
									<?php 
                    // Excerpt
                    if ('true' == $excerpt || 'true' == $read_more) {
                        if ('true' != $excerpt) {
                            $excerpt_length = '0';
                        }
                        ?>
										<div class="vcex-post-type-entry-excerpt clr">
											<?php 
                        // Show full content
                        if ('9999' == $excerpt_length) {
                            the_content();
                        } else {
                            $trim_custom_excerpts = 'true' == $custom_excerpt_trim ? true : false;
                            $excerpt_array = array('length' => intval($excerpt_length), 'trim_custom_excerpts' => $trim_custom_excerpts);
                            vcex_excerpt($excerpt_array);
                        }
                        // Read more
                        if ($read_more) {
                            ?>
												<a href="<?php 
                            the_permalink();
                            ?>
" title="<?php 
                            echo $read_more_text;
                            ?>
" rel="bookmark" class="vcex-readmore theme-button" target="<?php 
                            echo $url_target;
                            ?>
" <?php 
                            echo $readmore_style;
                            ?>
>
													<?php 
                            echo $read_more_text;
                            ?>
 <span class="vcex-readmore-rarr"><?php 
                            echo wpex_element('rarr');
                            ?>
</span>
												</a>
											<?php 
                        }
                        ?>
										</div>
									<?php 
                    }
                    // Close Equal height div
                    if ($equal_heights_grid && !$is_isotope) {
                        ?>
									</div>
									<?php 
                    }
                    ?>
								</div><!-- .post_type-entry-details -->
							<?php 
                }
                ?>
						</<?php 
                echo $main_element_type;
                ?>
><!-- .post_type-entry -->
					<?php 
                // Check if counter equal columns
                if ($count == $columns) {
                    // Close equal height row
                    if ($equal_heights_grid && !$is_isotope) {
                        echo '</div><!-- .match-height-row -->';
                    }
                    // Reset counter
                    $count = '';
                }
                // End foreach
            }
            // Make sure match-height-row is closed
            if ($equal_heights_grid && !$is_isotope) {
                if ('4' == $columns && $count_all % 4 != 0) {
                    echo '</div><!-- .match-height-row -->';
                }
                if ('3' == $columns && $count_all % 3 != 0) {
                    echo '</div><!-- .match-height-row -->';
                }
                if ('2' == $columns && $count_all % 2 != 0) {
                    echo '</div><!-- .match-height-row -->';
                }
            }
            ?>
				</div><!-- .vcex-post-type-grid -->
				
				<?php 
            // Paginate Posts
            if ('true' == $pagination) {
                wpex_pagination($wpex_query);
            }
            // End has posts check
        }
        // Reset the WP query
        wp_reset_postdata();
        // Return outbut buffer
        return ob_get_clean();
    }