PluginProbe
Sight – Professional Image Gallery and Portfolio / 1.0.4
Sight – Professional Image Gallery and Portfolio v1.0.4
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
sight / render / handler / post-area-projects.php

post-area-projects.php in Sight – Professional Image Gallery and Portfolio 1.0.4, at render/handler/post-area-projects.php

156 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Portfolio Projects
4 *
5 * @var $attributes - attributes
6 * @var $options - options
7 *
8 * @link https://codesupply.co
9 * @since 1.0.0
10 *
11 * @package Sight
12 */
13
14 $class_name = sight_portfolio_area_classes( $attributes, $options );
15
16 // Args Query.
17 $args_query = array(
18 'post_type' => $attributes['projects_filter_post_type'],
19 'ignore_sticky_posts' => true,
20 'posts_per_page' => $attributes['number_items'],
21 );
22
23 // Filter Categories.
24 if ( 'sight-projects' === $attributes['projects_filter_post_type'] ) {
25
26 if ( isset( $attributes['projects_filter_categories'] ) ) {
27 $filter_categories = $attributes['projects_filter_categories'];
28
29 if ( $filter_categories ) {
30 $args_query['tax_query'][] = array(
31 'taxonomy' => 'sight-categories',
32 'field' => 'id',
33 'terms' => $filter_categories,
34 );
35
36 $args_query['tax_query']['relation'] = 'OR';
37 }
38 }
39 }
40
41 // Filter Offset.
42 if ( isset( $attributes['projects_filter_offset'] ) ) {
43 $args_query['offset'] = (int) $attributes['projects_filter_offset'];
44 }
45
46 // Filter Orderby.
47 if ( $attributes['projects_orderby'] ) {
48 $type_post_views = sight_post_views_enabled();
49 // Order by Views.
50 if ( $type_post_views && 'views' === $attributes['projects_orderby'] ) {
51 $args_query['orderby'] = $type_post_views;
52 // Don't hide posts without views.
53 $args_query['views_query']['hide_empty'] = false;
54
55 } else {
56 $args_query['orderby'] = $attributes['projects_orderby'];
57 }
58 }
59
60 // Filter Order.
61 if ( $attributes['projects_order'] ) {
62 $args_query['order'] = $attributes['projects_order'];
63 }
64
65 /** ---------------------------------- */
66 /** ---------------------------------- */
67
68 // WP Query.
69 $portfolio_list = new WP_Query( $args_query );
70
71 // WP Query Data.
72 if ( isset( $options['pagination_type'] ) ) {
73 $portfolio_list->pagination_type = $options['pagination_type'];
74 } else {
75 $portfolio_list->pagination_type = 'none';
76 }
77
78 // Theme data.
79 $data = array(
80 'max_num_pages' => $portfolio_list->max_num_pages,
81 'pagination_type' => $portfolio_list->pagination_type,
82 'query_vars' => $portfolio_list->query,
83 );
84
85 $args = sight_portfolio_get_load_more_args( $data, $attributes, $options );
86
87 // Set posts per page.
88 $args['posts_per_page'] = $args_query['posts_per_page'];
89
90 $query_data = sight_encode_data( $args );
91
92 if ( $portfolio_list->have_posts() ) {
93 ?>
94 <div class="<?php echo esc_attr( $class_name ); ?>" data-items-area="<?php echo esc_attr( $query_data ); ?>">
95
96 <?php if ( isset( $options['filter_items'] ) && $options['filter_items'] ) { ?>
97 <div class="sight-portfolio-area-filter">
98 <div class="sight-portfolio-area-filter__title"><?php esc_html_e( 'Categories', 'sight' ); ?></div>
99
100 <ul class="sight-portfolio-area-filter__list">
101
102 <li class="sight-portfolio-area-filter__list-item sight-filter-all sight-filter-active">
103 <a href="#" data-filter="*">
104 <?php esc_html_e( 'All', 'sight' ); ?>
105 </a>
106 </li>
107
108 <?php
109 $categories = get_terms(
110 array(
111 'taxonomy' => 'sight-categories',
112 'hide_empty' => false,
113 'include' => isset( $filter_categories ) && $filter_categories ? $filter_categories : array(),
114 )
115 );
116
117 foreach ( $categories as $category ) {
118 ?>
119 <li class="sight-portfolio-area-filter__list-item">
120 <a href="#" data-filter="<?php echo esc_attr( $category->slug ); ?>">
121 <?php echo esc_html( $category->name ); ?>
122 </a>
123 </li>
124 <?php
125 }
126 ?>
127 </ul>
128 </div>
129 <?php } ?>
130
131 <div class="sight-portfolio-area__outer">
132 <div class="sight-portfolio-area__main" <?php sight_portfolio_area_main_attrs( $attributes, $options ); ?>>
133 <?php
134 // Start the Loop.
135 while ( $portfolio_list->have_posts() ) {
136 $portfolio_list->the_post();
137
138 $portfolio_entry = new Sight_Entry( $attributes, $options );
139
140 // Init portfolio entry.
141 $portfolio_entry->init();
142
143 // Get item project.
144 require apply_filters( 'sight_portfolio_item_path', SIGHT_PATH . 'render/handler/portfolio-entry.php', $attributes, $options, $portfolio_entry );
145 }
146 ?>
147 </div>
148 </div>
149 </div>
150 <?php
151 } else {
152 require SIGHT_PATH . 'render/handler/post-area-none.php';
153 }
154
155 wp_reset_postdata();
156