Post Grid - Version 2.0.15

Version Description

  • 12/12/2016 add - Taxonomy query added.
Download this release

Release Info

Developer pickplugins
Plugin Icon 128x128 Post Grid
Version 2.0.15
Comparing to
See all releases

Code changes from version 2.0.14 to 2.0.15

grid-items/query.php CHANGED
@@ -13,44 +13,47 @@ if(isset($_GET['keyword'])){
13
14
}
15
16
17
18
- /*More Query parameter string to array*/
19
- if(!empty($extra_query_parameter)){
20
-
21
- $extra_query_parameter = explode('&', $extra_query_parameter);
22
-
23
24
-
25
- foreach($extra_query_parameter as $parameter){
26
-
27
28
-
29
- $parameter = explode('=', $parameter);
30
-
31
32
33
- if (strpos($parameter[1], ',') !== false) {
34
- //var_dump('Comma found');
35
- $parameter_args = explode(',', $parameter[1]);
36
- $query_parameter[$parameter[0]] = $parameter_args;
37
-
38
39
- }
40
- else{
41
- $query_parameter[$parameter[0]] = $parameter[1];
42
- }
43
44
-
45
-
46
- }
47
-
48
- }
49
- else{
50
-
51
- $query_parameter = array();
52
- }
53
54
55
56
@@ -73,6 +76,7 @@ if(is_search()){
73
'order' => $query_order,
74
'orderby' => $query_orderby,
75
'meta_key' => $query_orderby_meta_key,
76
'posts_per_page' => (int)$posts_per_page,
77
'paged' => (int)$paged,
78
'offset' => $offset,
@@ -81,12 +85,10 @@ if(is_search()){
81
);
82
83
84
-
85
- $query_merge = array_merge($default_query, $query_parameter);
86
87
- $query_merge = apply_filters('post_grid_filter_query_args', $query_merge);
88
89
-
90
91
$wp_query = new WP_Query($query_merge);
92
13
14
}
15
16
+ /* ################################ tax_query ######################################*/
17
18
+ foreach($categories as $category){
19
+
20
+ $tax_cat = explode(',',$category);
21
+
22
+ $tax_terms[$tax_cat[0]][] = $tax_cat[1];
23
+
24
+ }
25
26
+ if(empty($tax_terms)){
27
+
28
+ $tax_terms = array();
29
+ }
30
31
32
+ foreach($tax_terms as $taxonomy=>$terms){
33
+
34
+ $tax_query[] = array(
35
+ 'taxonomy' => $taxonomy,
36
+ 'field' => 'term_id',
37
+ 'terms' => $terms,
38
+ 'operator' => $terms_relation,
39
+ );
40
+
41
+
42
+ }
43
44
+ if(empty($tax_query)){
45
+
46
+ $tax_query = array();
47
+
48
+ }
49
50
+ $tax_query_relation = array( 'relation' => $categories_relation );
51
52
+ $tax_query = array_merge($tax_query_relation, $tax_query );
53
54
+ //echo '<pre>'.var_export($tax_query,true).'</pre>';
55
56
+ /* ################################ tax_query ######################################*/
57
58
59
76
'order' => $query_order,
77
'orderby' => $query_orderby,
78
'meta_key' => $query_orderby_meta_key,
79
+ 'tax_query' => $tax_query,
80
'posts_per_page' => (int)$posts_per_page,
81
'paged' => (int)$paged,
82
'offset' => $offset,
85
);
86
87
88
89
+ $query_merge = apply_filters('post_grid_filter_query_args', $default_query);
90
91
+ //echo '<pre>'.var_export($query_merge,true).'</pre>';
92
93
$wp_query = new WP_Query($query_merge);
94
grid-items/variables.php CHANGED
@@ -20,7 +20,7 @@ if ( ! defined('ABSPATH')) exit; // if direct access
20
21
22
23
- /*
24
25
if(!empty($post_grid_meta_options['categories'])){
26
$categories = $post_grid_meta_options['categories'];
@@ -29,6 +29,14 @@ if ( ! defined('ABSPATH')) exit; // if direct access
29
$categories = array();
30
}
31
32
if(!empty($post_grid_meta_options['categories_relation'])){
33
$categories_relation = $post_grid_meta_options['categories_relation'];
34
}
@@ -36,7 +44,7 @@ if ( ! defined('ABSPATH')) exit; // if direct access
36
$categories_relation = 'OR';
37
}
38
39
-
40
if(!empty($post_grid_meta_options['extra_query_parameter'])){
41
$extra_query_parameter = $post_grid_meta_options['extra_query_parameter'];
42
}
20
21
22
23
+
24
25
if(!empty($post_grid_meta_options['categories'])){
26
$categories = $post_grid_meta_options['categories'];
29
$categories = array();
30
}
31
32
+ if(!empty($post_grid_meta_options['terms_relation'])){
33
+ $terms_relation = $post_grid_meta_options['terms_relation'];
34
+ }
35
+ else{
36
+ $terms_relation = 'IN';
37
+ }
38
+
39
+
40
if(!empty($post_grid_meta_options['categories_relation'])){
41
$categories_relation = $post_grid_meta_options['categories_relation'];
42
}
44
$categories_relation = 'OR';
45
}
46
47
+ /*
48
if(!empty($post_grid_meta_options['extra_query_parameter'])){
49
$extra_query_parameter = $post_grid_meta_options['extra_query_parameter'];
50
}
includes/functions.php CHANGED
@@ -1146,7 +1146,128 @@ add_action('wp_ajax_post_grid_layout_add_elements', 'post_grid_layout_add_elemen
1146
1147
1148
1149
1150
1151
1152
1146
1147
1148
1149
+ function post_grid_get_categories($post_id){
1150
+
1151
+ if(current_user_can('manage_options')){
1152
1153
+ if(isset($_POST['post_types'])){
1154
+
1155
+ //var_dump($_POST['post_types']);
1156
+
1157
+ $post_types = stripslashes_deep($_POST['post_types']);
1158
+ //var_dump($post_types);
1159
+
1160
+ $post_id = sanitize_text_field($_POST['post_id']);
1161
+ $post_grid_meta_options = get_post_meta( $post_id, 'post_grid_meta_options', true );
1162
+ //$categories = $post_grid_meta_options['categories'];
1163
+
1164
+ if(!empty($post_grid_meta_options['categories'])){
1165
+ $categories = $post_grid_meta_options['categories'];
1166
+ }
1167
+ else{
1168
+ $categories = array();
1169
+ }
1170
+
1171
+
1172
+
1173
+ }
1174
+ else{
1175
+ $post_grid_meta_options = get_post_meta( $post_id, 'post_grid_meta_options', true );
1176
+
1177
+ if(!empty($post_grid_meta_options['post_types'])){
1178
+ $post_types = $post_grid_meta_options['post_types'];
1179
+ }
1180
+ else{
1181
+ $post_types = array();
1182
+ }
1183
+
1184
+ //$post_types = $post_grid_meta_options['post_types'];
1185
+
1186
+ if(!empty($post_grid_meta_options['categories'])){
1187
+ $categories = $post_grid_meta_options['categories'];
1188
+ }
1189
+ else{
1190
+ $categories = array();
1191
+ }
1192
+
1193
+ //$categories = $post_grid_meta_options['categories'];
1194
+
1195
+
1196
+ }
1197
+
1198
+
1199
+ if(isset($_POST['post_id'])){
1200
+ $post_id = sanitize_text_field($_POST['post_id']);
1201
+ }
1202
+
1203
+
1204
+ $taxonomies = get_object_taxonomies( $post_types );
1205
+
1206
+ if(!empty($taxonomies)){
1207
+
1208
+ echo '<select class="categories" name="post_grid_meta_options[categories][]" multiple="multiple" size="10">';
1209
+
1210
+ foreach ($taxonomies as $taxonomy ) {
1211
+
1212
+ $the_taxonomy = get_taxonomy($taxonomy);
1213
+
1214
+ $args=array(
1215
+ 'orderby' => 'name',
1216
+ 'order' => 'ASC',
1217
+ 'taxonomy' => $taxonomy,
1218
+ 'hide_empty' => false,
1219
+ );
1220
+
1221
+ $categories_all = get_categories($args);
1222
+
1223
+ if(!empty($categories_all)){
1224
+
1225
+ ?>
1226
+ <option disabled value="<?php echo $taxonomy; ?>" > - - - <?php echo $the_taxonomy->labels->name; ?> - - -</option>
1227
+
1228
+ <?php
1229
+ foreach($categories_all as $category_info){
1230
+
1231
+ if(in_array($taxonomy.','.$category_info->cat_ID, $categories)){
1232
+ $selected = 'selected';
1233
+ }
1234
+ else{
1235
+ $selected = '';
1236
+ }
1237
+
1238
+ ?>
1239
+ <option <?php echo $selected; ?> value="<?php echo $taxonomy.','.$category_info->cat_ID; ?>" ><?php echo $category_info->cat_name; echo ' (Total Post: '.$category_info->count.')'; ?></option>
1240
+ <?php
1241
+
1242
+
1243
+ }
1244
+
1245
+ }
1246
+
1247
+
1248
+ }
1249
+
1250
+ echo '</select>';
1251
+
1252
+ }
1253
+ else{
1254
+ echo 'No categories found.';
1255
+ }
1256
+
1257
+ }
1258
+
1259
+
1260
+
1261
+
1262
+ if(isset($_POST['post_types'])){
1263
+ die();
1264
+ }
1265
+
1266
+
1267
+ }
1268
+
1269
+
1270
+ add_action('wp_ajax_post_grid_get_categories', 'post_grid_get_categories');
1271
1272
1273
includes/meta.php CHANGED
@@ -83,7 +83,7 @@ function meta_boxes_post_grid_input( $post ) {
83
84
85
86
- /*
87
88
if(!empty($post_grid_meta_options['categories'])){
89
$categories = $post_grid_meta_options['categories'];
@@ -92,6 +92,18 @@ function meta_boxes_post_grid_input( $post ) {
92
$categories = array();
93
}
94
95
if(!empty($post_grid_meta_options['categories_relation'])){
96
$categories_relation = $post_grid_meta_options['categories_relation'];
97
}
@@ -100,6 +112,13 @@ function meta_boxes_post_grid_input( $post ) {
100
}
101
102
103
if(!empty($post_grid_meta_options['extra_query_parameter'])){
104
$extra_query_parameter = $post_grid_meta_options['extra_query_parameter'];
105
}
@@ -796,6 +815,42 @@ function meta_boxes_post_grid_input( $post ) {
796
797
</div>
798
799
800
<div class="option-box">
801
<p class="option-title"><?php _e('Post Status',post_grid_textdomain); ?></p>
83
84
85
86
+
87
88
if(!empty($post_grid_meta_options['categories'])){
89
$categories = $post_grid_meta_options['categories'];
92
$categories = array();
93
}
94
95
+
96
+
97
+ if(!empty($post_grid_meta_options['terms_relation'])){
98
+ $terms_relation = $post_grid_meta_options['terms_relation'];
99
+ }
100
+ else{
101
+ $terms_relation = 'IN';
102
+ }
103
+
104
+
105
+
106
+
107
if(!empty($post_grid_meta_options['categories_relation'])){
108
$categories_relation = $post_grid_meta_options['categories_relation'];
109
}
112
}
113
114
115
+
116
+
117
+
118
+
119
+
120
+
121
+ /*
122
if(!empty($post_grid_meta_options['extra_query_parameter'])){
123
$extra_query_parameter = $post_grid_meta_options['extra_query_parameter'];
124
}
815
816
</div>
817
818
+
819
+ <div class="option-box">
820
+ <p class="option-title"><?php _e('Taxonomy & Terms (Categories)',post_grid_textdomain); ?></p>
821
+ <p class="option-info"><?php _e('Select categories. <br />Hint: Ctrl + click to select mulitple',post_grid_textdomain); ?></p>
822
+
823
+ <div title="Clear categories selection." onClick="" class="button clear-categories"> Clear</div>
824
+ <br/><br/>
825
+
826
+ <div class="categories-container">
827
+
828
+ <?php
829
+ echo post_grid_get_categories(get_the_ID());
830
+ ?>
831
+
832
+ </div>
833
+
834
+ <p class="option-title"><?php _e('Terms relation',post_grid_textdomain); ?></p>
835
+
836
+ <label><input type="radio" name="post_grid_meta_options[terms_relation]" <?php if($terms_relation == 'IN') echo 'checked';?> value="IN" >IN</label>
837
+ <label><input type="radio" name="post_grid_meta_options[terms_relation]" <?php if($terms_relation == 'NOT IN') echo 'checked';?> value="NOT IN" >NOT IN</label> <label><input type="radio" name="post_grid_meta_options[terms_relation]" <?php if($terms_relation == 'AND') echo 'checked';?> value="AND" >AND</label>
838
+ <label><input type="radio" name="post_grid_meta_options[terms_relation]" <?php if($terms_relation == 'EXISTS') echo 'checked';?> value="EXISTS" >EXISTS</label> <label><input type="radio" name="post_grid_meta_options[terms_relation]" <?php if($terms_relation == 'NOT EXISTS') echo 'checked';?> value="NOT EXISTS" >NOT EXISTS</label>
839
+
840
+ <p class="option-title"><?php _e('Taxonomy relation',post_grid_textdomain); ?></p>
841
+
842
+ <label><input type="radio" name="post_grid_meta_options[categories_relation]" <?php if($categories_relation == 'OR') echo 'checked';?> value="OR" >OR</label>
843
+ <label><input type="radio" name="post_grid_meta_options[categories_relation]" <?php if($categories_relation == 'AND') echo 'checked';?> value="AND" >AND</label>
844
+
845
+
846
+
847
+ </div>
848
+
849
+
850
+
851
+
852
+
853
+
854
855
<div class="option-box">
856
<p class="option-title"><?php _e('Post Status',post_grid_textdomain); ?></p>
post-grid.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Post Grid
4
Plugin URI: http://pickplugins.com
5
Description: Awesome post grid for query post from any post type and display on grid.
6
- Version: 2.0.14
7
Author: pickplugins
8
Author URI: http://pickplugins.com
9
Text Domain: post-grid
@@ -28,7 +28,7 @@ class PostGrid{
28
define('post_grid_conatct_url', 'http://pickplugins.com/contact/' );
29
define('post_grid_qa_url', 'http://www.pickplugins.com/questions/' );
30
define('post_grid_plugin_name', 'Post Grid' );
31
- define('post_grid_version', '2.0.14' );
32
define('post_grid_customer_type', 'free' );
33
define('post_grid_share_url', 'https://wordpress.org/plugins/post-grid/' );
34
define('post_grid_textdomain', 'post_grid' );
3
Plugin Name: Post Grid
4
Plugin URI: http://pickplugins.com
5
Description: Awesome post grid for query post from any post type and display on grid.
6
+ Version: 2.0.15
7
Author: pickplugins
8
Author URI: http://pickplugins.com
9
Text Domain: post-grid
28
define('post_grid_conatct_url', 'http://pickplugins.com/contact/' );
29
define('post_grid_qa_url', 'http://www.pickplugins.com/questions/' );
30
define('post_grid_plugin_name', 'Post Grid' );
31
+ define('post_grid_version', '2.0.15' );
32
define('post_grid_customer_type', 'free' );
33
define('post_grid_share_url', 'https://wordpress.org/plugins/post-grid/' );
34
define('post_grid_textdomain', 'post_grid' );
readme.txt CHANGED
@@ -4,7 +4,7 @@
4
Tags: post grid, grid, custom post grid, post type grid, grid display, category filter, custom post, filter, filtering, grid, layout, list, masonry, post, post filter, post layout, taxonomy, taxonomy filter,
5
Requires at least: 3.8
6
Tested up to: 4.7
7
- Stable tag: 2.0.14
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -96,6 +96,10 @@ then paste this shortcode anywhere in your page to display grid<br />
96
== Changelog ==
97
98
99
= 2.0.14 =
100
* 03/12/2016 fix - Color Picker class issue fixed.
101
4
Tags: post grid, grid, custom post grid, post type grid, grid display, category filter, custom post, filter, filtering, grid, layout, list, masonry, post, post filter, post layout, taxonomy, taxonomy filter,
5
Requires at least: 3.8
6
Tested up to: 4.7
7
+ Stable tag: 2.0.15
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
96
== Changelog ==
97
98
99
+
100
+ = 2.0.15 =
101
+ * 12/12/2016 add - Taxonomy query added.
102
+
103
= 2.0.14 =
104
* 03/12/2016 fix - Color Picker class issue fixed.
105