Version Description
- 2021-07-31 add - security on search result.
- 2021-07-31 remove - remove ajax search result for fixing pagination issue.
- 2021-07-31 add - added submit button on search form
Download this release
Release Info
Developer | pickplugins |
Plugin | Post Grid |
Version | 2.1.9 |
Comparing to | |
See all releases |
Code changes from version 2.1.8 to 2.1.9
- assets/frontend/css/style.css +26 -6
- assets/frontend/js/scripts.js +37 -35
- includes/functions.php +35 -5
- post-grid.php +2 -2
- readme.txt +7 -1
- templates/post-grid-hook.php +111 -10
assets/frontend/css/style.css
CHANGED
@@ -43,17 +43,37 @@
|
|
43 |
}
|
44 |
|
45 |
|
46 |
-
/*
|
47 |
-
|
|
|
48 |
display: inline-block;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
padding: 10px 0;
|
50 |
text-align: center;
|
51 |
-
|
52 |
}
|
53 |
|
|
|
|
|
|
|
54 |
|
|
|
55 |
|
56 |
-
.post-grid
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
background: #ddd none repeat scroll 0 0;
|
58 |
cursor: pointer;
|
59 |
display: inline-block;
|
@@ -64,7 +84,7 @@
|
|
64 |
}
|
65 |
|
66 |
|
67 |
-
.post-grid .grid-
|
68 |
|
69 |
border: 1px solid #ddd;
|
70 |
border-radius: 0;
|
@@ -74,7 +94,7 @@
|
|
74 |
}
|
75 |
|
76 |
|
77 |
-
.post-grid .grid-
|
78 |
position: absolute;
|
79 |
top: 50%;
|
80 |
transform: translateY(-50%);
|
43 |
}
|
44 |
|
45 |
|
46 |
+
/*post-grid-search*/
|
47 |
+
|
48 |
+
.field-wrap{
|
49 |
display: inline-block;
|
50 |
+
vertical-align: middle;
|
51 |
+
}
|
52 |
+
|
53 |
+
.field-wrap-keyword{
|
54 |
+
position: relative;
|
55 |
+
}
|
56 |
+
|
57 |
+
.post-grid .post-grid-search{
|
58 |
+
display: block;
|
59 |
padding: 10px 0;
|
60 |
text-align: center;
|
61 |
+
|
62 |
}
|
63 |
|
64 |
+
.post-grid .post-grid-search .keyword-wrap{
|
65 |
+
position: relative;
|
66 |
+
display: inline-block;
|
67 |
|
68 |
+
}
|
69 |
|
70 |
+
.post-grid .post-grid-search .search-loading{
|
71 |
+
display: none;
|
72 |
+
}
|
73 |
+
.post-grid .post-grid-search .search-loading.active{
|
74 |
+
display: inline-block;
|
75 |
+
}
|
76 |
+
.post-grid .grid-nav-top .submit-search {
|
77 |
background: #ddd none repeat scroll 0 0;
|
78 |
cursor: pointer;
|
79 |
display: inline-block;
|
84 |
}
|
85 |
|
86 |
|
87 |
+
.post-grid .post-grid-search .search {
|
88 |
|
89 |
border: 1px solid #ddd;
|
90 |
border-radius: 0;
|
94 |
}
|
95 |
|
96 |
|
97 |
+
.post-grid .post-grid-search .search-icon{
|
98 |
position: absolute;
|
99 |
top: 50%;
|
100 |
transform: translateY(-50%);
|
assets/frontend/js/scripts.js
CHANGED
@@ -1,52 +1,54 @@
|
|
1 |
jQuery(document).ready(function($){
|
2 |
|
3 |
-
$(document).on('
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
6 |
var grid_id = $(this).attr('grid_id');
|
7 |
-
var key = e.which;
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
$.ajax({
|
17 |
-
type: 'POST',
|
18 |
-
context: this,
|
19 |
-
url:post_grid_ajax.post_grid_ajaxurl,
|
20 |
-
data: {"action": "post_grid_ajax_search", "grid_id":grid_id,"keyword":keyword,"is_reset":is_reset,},
|
21 |
-
success: function(data){
|
22 |
-
|
23 |
-
console.log(data);
|
24 |
-
|
25 |
-
$('#post-grid-'+grid_id+' .grid-items').html(data);
|
26 |
-
$('#post-grid-'+grid_id+' .search-icon').html('<i class="fas fa-search"></i>');
|
27 |
-
}
|
28 |
-
});
|
29 |
-
}
|
30 |
-
else{
|
31 |
var is_reset = 'no';
|
32 |
-
if(keyword.length>3){
|
33 |
-
|
34 |
|
35 |
-
|
36 |
|
37 |
$.ajax({
|
38 |
type: 'POST',
|
39 |
context: this,
|
40 |
url:post_grid_ajax.post_grid_ajaxurl,
|
41 |
-
data: {"action": "post_grid_ajax_search", "grid_id":grid_id,"
|
42 |
-
success: function(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
$('#post-grid-'+grid_id+' .grid-items').html(data);
|
45 |
-
$('#post-grid-'+grid_id+' .search-icon').html('<i class="fas fa-search"></i>');
|
46 |
}
|
47 |
});
|
48 |
-
}
|
49 |
-
|
50 |
})
|
51 |
|
52 |
|
1 |
jQuery(document).ready(function($){
|
2 |
|
3 |
+
$(document).on('submit', '.post-grid .post-grid-search forms', function(e){
|
4 |
|
5 |
+
e.preventDefault();
|
6 |
+
|
7 |
+
|
8 |
+
|
9 |
+
//var keyword = $(this).val();
|
10 |
var grid_id = $(this).attr('grid_id');
|
11 |
+
//var key = e.which;
|
12 |
+
$('#post-grid-'+grid_id+' .search-loading').addClass('active');
|
13 |
+
|
14 |
+
formData = $(this).serialize();
|
15 |
+
|
16 |
+
// console.log(formData);
|
17 |
+
// console.log(grid_id);
|
18 |
+
|
19 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
var is_reset = 'no';
|
21 |
+
//if(keyword.length>3){
|
22 |
+
//$('#post-grid-'+grid_id+' .search-icon').html('<i class="fas fa-spin fa-spinner"></i>');
|
23 |
|
24 |
+
//$('.pagination').fadeOut();
|
25 |
|
26 |
$.ajax({
|
27 |
type: 'POST',
|
28 |
context: this,
|
29 |
url:post_grid_ajax.post_grid_ajaxurl,
|
30 |
+
data: {"action": "post_grid_ajax_search", "grid_id":grid_id,"is_reset":is_reset,"formData":formData, },
|
31 |
+
success: function(response){
|
32 |
+
|
33 |
+
var datas = JSON.parse( response );
|
34 |
+
pagination = datas['pagination'];
|
35 |
+
html = datas['html'];
|
36 |
+
// console.log(html);
|
37 |
+
// console.log('No enter');
|
38 |
+
// console.log(pagination);
|
39 |
+
console.log('Hello');
|
40 |
+
|
41 |
+
|
42 |
+
$('#post-grid-'+grid_id+' .grid-items').html(html);
|
43 |
+
//$('#post-grid-'+grid_id+' .search-icon').html('<i class="fas fa-search"></i>');
|
44 |
+
$('#post-grid-'+grid_id+' .paginate').html(pagination);
|
45 |
+
$('#post-grid-'+grid_id+' .search-loading').removeClass('active');
|
46 |
+
|
47 |
|
|
|
|
|
48 |
}
|
49 |
});
|
50 |
+
//}
|
51 |
+
|
52 |
})
|
53 |
|
54 |
|
includes/functions.php
CHANGED
@@ -1080,10 +1080,26 @@ function post_grid_ajax_search(){
|
|
1080 |
|
1081 |
$post_grid_options = get_post_meta($grid_id, 'post_grid_meta_options', true);
|
1082 |
|
1083 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1084 |
|
1085 |
|
1086 |
$post_types = isset($post_grid_options['post_types']) ? $post_grid_options['post_types'] : array('post');
|
|
|
|
|
1087 |
//$keyword = isset($post_grid_options['keyword']) ? $post_grid_options['keyword'] : '';
|
1088 |
$exclude_post_id = isset($post_grid_options['exclude_post_id']) ? $post_grid_options['exclude_post_id'] : '';
|
1089 |
|
@@ -1130,7 +1146,7 @@ function post_grid_ajax_search(){
|
|
1130 |
|
1131 |
/* ################################ Keyword query ######################################*/
|
1132 |
|
1133 |
-
|
1134 |
|
1135 |
|
1136 |
/* ################################ Single pages ######################################*/
|
@@ -1207,9 +1223,13 @@ function post_grid_ajax_search(){
|
|
1207 |
|
1208 |
$loop_count = 0;
|
1209 |
|
1210 |
-
|
|
|
|
|
1211 |
|
1212 |
if ( $post_grid_wp_query->have_posts() ) :
|
|
|
|
|
1213 |
while ( $post_grid_wp_query->have_posts() ) : $post_grid_wp_query->the_post();
|
1214 |
$post_id = get_the_ID();
|
1215 |
$args['post_id'] = $post_id;
|
@@ -1218,15 +1238,25 @@ function post_grid_ajax_search(){
|
|
1218 |
do_action('post_grid_loop', $args);
|
1219 |
|
1220 |
$loop_count++;
|
|
|
1221 |
endwhile;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1222 |
|
1223 |
wp_reset_query();
|
1224 |
wp_reset_postdata();
|
1225 |
endif;
|
1226 |
|
1227 |
-
|
|
|
1228 |
|
1229 |
-
echo $
|
1230 |
|
1231 |
die();
|
1232 |
|
1080 |
|
1081 |
$post_grid_options = get_post_meta($grid_id, 'post_grid_meta_options', true);
|
1082 |
|
1083 |
+
|
1084 |
+
$formData = isset($_POST['formData']) ? ($_POST['formData']) : '';
|
1085 |
+
|
1086 |
+
//error_log($formData);
|
1087 |
+
|
1088 |
+
parse_str($formData, $form_data);
|
1089 |
+
|
1090 |
+
//error_log(serialize($form_data));
|
1091 |
+
|
1092 |
+
$form_data = apply_filters('post_grid_ajax_search_form_data', $form_data);
|
1093 |
+
|
1094 |
+
$keyword = isset($form_data['keyword']) ? sanitize_text_field($form_data['keyword']) : '';
|
1095 |
+
|
1096 |
+
//error_log($keyword);
|
1097 |
+
|
1098 |
|
1099 |
|
1100 |
$post_types = isset($post_grid_options['post_types']) ? $post_grid_options['post_types'] : array('post');
|
1101 |
+
$pagination_type = isset($post_grid_options['nav_bottom']['pagination_type']) ? $post_grid_options['nav_bottom']['pagination_type'] : 'normal';
|
1102 |
+
|
1103 |
//$keyword = isset($post_grid_options['keyword']) ? $post_grid_options['keyword'] : '';
|
1104 |
$exclude_post_id = isset($post_grid_options['exclude_post_id']) ? $post_grid_options['exclude_post_id'] : '';
|
1105 |
|
1146 |
|
1147 |
/* ################################ Keyword query ######################################*/
|
1148 |
|
1149 |
+
//$keyword = isset($_GET['keyword']) ? sanitize_text_field($_GET['keyword']) : $keyword;
|
1150 |
|
1151 |
|
1152 |
/* ################################ Single pages ######################################*/
|
1223 |
|
1224 |
$loop_count = 0;
|
1225 |
|
1226 |
+
$response = array();
|
1227 |
+
|
1228 |
+
|
1229 |
|
1230 |
if ( $post_grid_wp_query->have_posts() ) :
|
1231 |
+
|
1232 |
+
ob_start();
|
1233 |
while ( $post_grid_wp_query->have_posts() ) : $post_grid_wp_query->the_post();
|
1234 |
$post_id = get_the_ID();
|
1235 |
$args['post_id'] = $post_id;
|
1238 |
do_action('post_grid_loop', $args);
|
1239 |
|
1240 |
$loop_count++;
|
1241 |
+
|
1242 |
endwhile;
|
1243 |
+
$response['html'] = ob_get_clean();
|
1244 |
+
|
1245 |
+
ob_start();
|
1246 |
+
|
1247 |
+
$args['grid_id'] = $grid_id;
|
1248 |
+
|
1249 |
+
do_action('post_grid_pagination_'.$pagination_type, $args, $post_grid_wp_query);
|
1250 |
+
$response['pagination'] = ob_get_clean();
|
1251 |
|
1252 |
wp_reset_query();
|
1253 |
wp_reset_postdata();
|
1254 |
endif;
|
1255 |
|
1256 |
+
//$html = ob_get_clean();
|
1257 |
+
|
1258 |
|
1259 |
+
echo json_encode($response);
|
1260 |
|
1261 |
die();
|
1262 |
|
post-grid.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Post Grid by PickPlugins
|
4 |
Plugin URI: https://www.pickplugins.com/item/post-grid-create-awesome-grid-from-any-post-type-for-wordpress/
|
5 |
Description: Awesome post grid for query post from any post type and display on grid.
|
6 |
-
Version: 2.1.
|
7 |
Author: PickPlugins
|
8 |
Author URI: https://www.pickplugins.com/
|
9 |
License: GPLv2 or later
|
@@ -21,7 +21,7 @@ if( !class_exists( 'PostGrid' )){
|
|
21 |
define('post_grid_plugin_dir', plugin_dir_path(__FILE__));
|
22 |
define('post_grid_plugin_basename', plugin_basename(__FILE__));
|
23 |
define('post_grid_plugin_name', 'Post Grid');
|
24 |
-
define('post_grid_version', '2.1.
|
25 |
define('post_grid_server_url', 'https://www.pickplugins.com/demo/post-grid/');
|
26 |
|
27 |
|
3 |
Plugin Name: Post Grid by PickPlugins
|
4 |
Plugin URI: https://www.pickplugins.com/item/post-grid-create-awesome-grid-from-any-post-type-for-wordpress/
|
5 |
Description: Awesome post grid for query post from any post type and display on grid.
|
6 |
+
Version: 2.1.9
|
7 |
Author: PickPlugins
|
8 |
Author URI: https://www.pickplugins.com/
|
9 |
License: GPLv2 or later
|
21 |
define('post_grid_plugin_dir', plugin_dir_path(__FILE__));
|
22 |
define('post_grid_plugin_basename', plugin_basename(__FILE__));
|
23 |
define('post_grid_plugin_name', 'Post Grid');
|
24 |
+
define('post_grid_version', '2.1.9');
|
25 |
define('post_grid_server_url', 'https://www.pickplugins.com/demo/post-grid/');
|
26 |
|
27 |
|
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: 5.7
|
7 |
-
Stable tag: 2.1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -222,6 +222,12 @@ then paste this shortcode anywhere in your page to display grid<br />
|
|
222 |
|
223 |
== Changelog ==
|
224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
= 2.1.8 =
|
226 |
* 2021-06-27 fix - escaping issue fixed.
|
227 |
|
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: 5.7
|
7 |
+
Stable tag: 2.1.9
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
222 |
|
223 |
== Changelog ==
|
224 |
|
225 |
+
= 2.1.9 =
|
226 |
+
* 2021-07-31 add - security on search result.
|
227 |
+
* 2021-07-31 remove - remove ajax search result for fixing pagination issue.
|
228 |
+
* 2021-07-31 add - added submit button on search form
|
229 |
+
|
230 |
+
|
231 |
= 2.1.8 =
|
232 |
* 2021-06-27 fix - escaping issue fixed.
|
233 |
|
templates/post-grid-hook.php
CHANGED
@@ -132,16 +132,19 @@ function post_grid_container_search($args){
|
|
132 |
|
133 |
|
134 |
$keyword = isset($_GET['keyword']) ? sanitize_text_field($_GET['keyword']) : '';
|
135 |
-
|
136 |
?>
|
137 |
-
<div class="grid-
|
138 |
-
<
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
</div>
|
143 |
|
|
|
144 |
|
|
|
|
|
|
|
145 |
|
146 |
<?php
|
147 |
|
@@ -149,8 +152,83 @@ function post_grid_container_search($args){
|
|
149 |
|
150 |
}
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
|
156 |
|
@@ -217,7 +295,7 @@ function post_grid_posts_loop($args){
|
|
217 |
|
218 |
/* ################################ Keyword query ######################################*/
|
219 |
|
220 |
-
|
221 |
|
222 |
|
223 |
/* ################################ Single pages ######################################*/
|
@@ -344,6 +422,28 @@ function post_grid_posts_loop($args){
|
|
344 |
|
345 |
}
|
346 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
add_action('post_grid_loop_no_post', 'post_grid_loop_no_post', 10);
|
348 |
|
349 |
function post_grid_loop_no_post($args){
|
@@ -712,7 +812,7 @@ function post_grid_pagination_normal($args, $post_grid_wp_query){
|
|
712 |
$paged = get_query_var('paged');
|
713 |
}elseif ( get_query_var('page') ) {
|
714 |
$paged = get_query_var('page');
|
715 |
-
}else
|
716 |
$paged = 1;
|
717 |
}
|
718 |
|
@@ -734,12 +834,13 @@ function post_grid_pagination_normal($args, $post_grid_wp_query){
|
|
734 |
|
735 |
$big = 999999999; // need an unlikely integer
|
736 |
|
|
|
737 |
echo paginate_links(
|
738 |
array(
|
739 |
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
|
740 |
'format' => '?paged=%#%',
|
741 |
'current' => max( 1, $paged ),
|
742 |
-
'total'
|
743 |
'prev_text' => $pagination_prev_text,
|
744 |
'next_text' => $pagination_next_text,
|
745 |
)
|
132 |
|
133 |
|
134 |
$keyword = isset($_GET['keyword']) ? sanitize_text_field($_GET['keyword']) : '';
|
135 |
+
$page_url = get_permalink(get_the_ID());
|
136 |
?>
|
137 |
+
<div class="post-grid-search">
|
138 |
+
<form grid_id="<?php echo $grid_id; ?>" action="<?php echo $page_url; ?>" method="get">
|
139 |
+
<?php
|
140 |
+
|
141 |
+
do_action('post_grid_search', $args);
|
|
|
142 |
|
143 |
+
?>
|
144 |
|
145 |
+
</form>
|
146 |
+
|
147 |
+
</div>
|
148 |
|
149 |
<?php
|
150 |
|
152 |
|
153 |
}
|
154 |
|
155 |
+
add_action('post_grid_search', 'post_grid_search_keyword_field', 10);
|
156 |
+
|
157 |
+
function post_grid_search_keyword_field($args){
|
158 |
+
|
159 |
+
$post_grid_options = $args['options'];
|
160 |
+
|
161 |
+
$grid_id = isset($args['grid_id']) ? $args['grid_id'] : '';
|
162 |
+
$font_aw_version = isset($post_grid_settings['font_aw_version']) ? $post_grid_settings['font_aw_version'] : 'v_5';
|
163 |
+
if($font_aw_version == 'v_5'){
|
164 |
+
$nav_top_search_icon = '<i class="fas fa-search"></i>';
|
165 |
+
}elseif($font_aw_version == 'v_4'){
|
166 |
+
$nav_top_search_icon = '<i class="fa fa-search"></i>';
|
167 |
+
}
|
168 |
+
|
169 |
+
|
170 |
+
// if($grid_id != 2147) return;
|
171 |
+
// 7 is grid ID where you want to display this input field
|
172 |
+
$nav_top_search_placeholder = isset($post_grid_options['nav_top']['search_placeholder']) ? $post_grid_options['nav_top']['search_placeholder'] : __('Start typing', 'post-grid');
|
173 |
+
$nav_top_search_icon = isset($post_grid_options['nav_top']['search_icon']) ? $post_grid_options['nav_top']['search_icon'] : $nav_top_search_icon;
|
174 |
+
|
175 |
+
|
176 |
+
$keyword = isset($_GET['keyword']) ? sanitize_text_field($_GET['keyword']) : '';
|
177 |
+
|
178 |
+
?>
|
179 |
+
<div class="field-wrap field-wrap-keyword">
|
180 |
+
|
181 |
+
<span class="search-icon"><?php echo $nav_top_search_icon; ?></span>
|
182 |
+
<input grid_id="<?php echo $grid_id; ?>" title="<?php echo __('Press enter to reset', 'post-grid'); ?>" class="search" type="text" name="keyword" placeholder="<?php echo $nav_top_search_placeholder; ?>" value="<?php echo $keyword; ?>">
|
183 |
+
|
184 |
+
</div>
|
185 |
+
|
186 |
+
|
187 |
+
<?php
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
+
|
193 |
+
add_action('post_grid_search', 'post_grid_search_submit_field', 90);
|
194 |
+
|
195 |
+
function post_grid_search_submit_field($args){
|
196 |
+
|
197 |
+
$post_grid_options = $args['options'];
|
198 |
+
|
199 |
+
$grid_id = isset($args['grid_id']) ? $args['grid_id'] : '';
|
200 |
|
201 |
|
202 |
+
$font_aw_version = isset($post_grid_settings['font_aw_version']) ? $post_grid_settings['font_aw_version'] : 'v_5';
|
203 |
+
if($font_aw_version == 'v_5'){
|
204 |
+
$nav_top_search_icon = '<i class="fas fa-search"></i>';
|
205 |
+
}elseif($font_aw_version == 'v_4'){
|
206 |
+
$nav_top_search_icon = '<i class="fa fa-search"></i>';
|
207 |
+
}
|
208 |
+
|
209 |
+
|
210 |
+
// if($grid_id != 2147) return;
|
211 |
+
// 7 is grid ID where you want to display this input field
|
212 |
+
$nav_top_search_placeholder = isset($post_grid_options['nav_top']['search_placeholder']) ? $post_grid_options['nav_top']['search_placeholder'] : __('Start typing', 'post-grid');
|
213 |
+
$nav_top_search_icon = isset($post_grid_options['nav_top']['search_icon']) ? $post_grid_options['nav_top']['search_icon'] : $nav_top_search_icon;
|
214 |
+
$search_loading_icon = isset($post_grid_options['nav_top']['search_loading_icon']) ? $post_grid_options['nav_top']['search_loading_icon'] : '';
|
215 |
+
|
216 |
+
|
217 |
+
|
218 |
+
?>
|
219 |
+
<div class="field-wrap field-wrap-submit">
|
220 |
+
|
221 |
+
<?php wp_nonce_field( 'post_grid_search_nonce','_wpnonce', false ); ?>
|
222 |
+
|
223 |
+
<input type="submit" value="Search">
|
224 |
+
<span class="search-loading"><?php echo $search_loading_icon; ?></span>
|
225 |
+
|
226 |
+
</div>
|
227 |
+
|
228 |
+
|
229 |
+
<?php
|
230 |
+
|
231 |
+
}
|
232 |
|
233 |
|
234 |
|
295 |
|
296 |
/* ################################ Keyword query ######################################*/
|
297 |
|
298 |
+
//$keyword = isset($_GET['keyword']) ? sanitize_text_field($_GET['keyword']) : $keyword;
|
299 |
|
300 |
|
301 |
/* ################################ Single pages ######################################*/
|
422 |
|
423 |
}
|
424 |
|
425 |
+
add_filter('post_grid_query_args', 'post_grid_query_args_search', 10, 2);
|
426 |
+
|
427 |
+
function post_grid_query_args_search($query_args, $args){
|
428 |
+
|
429 |
+
if( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'post_grid_search_nonce' ) ){
|
430 |
+
|
431 |
+
$keyword = isset($_GET['keyword']) ? sanitize_text_field($_GET['keyword']) : '';
|
432 |
+
|
433 |
+
if(!empty($keyword))
|
434 |
+
$query_args['s'] = $keyword;
|
435 |
+
}
|
436 |
+
|
437 |
+
//echo '<pre>'.var_export($query_args, true).'</pre>';
|
438 |
+
|
439 |
+
|
440 |
+
|
441 |
+
return $query_args;
|
442 |
+
}
|
443 |
+
|
444 |
+
|
445 |
+
|
446 |
+
|
447 |
add_action('post_grid_loop_no_post', 'post_grid_loop_no_post', 10);
|
448 |
|
449 |
function post_grid_loop_no_post($args){
|
812 |
$paged = get_query_var('paged');
|
813 |
}elseif ( get_query_var('page') ) {
|
814 |
$paged = get_query_var('page');
|
815 |
+
}else{
|
816 |
$paged = 1;
|
817 |
}
|
818 |
|
834 |
|
835 |
$big = 999999999; // need an unlikely integer
|
836 |
|
837 |
+
|
838 |
echo paginate_links(
|
839 |
array(
|
840 |
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
|
841 |
'format' => '?paged=%#%',
|
842 |
'current' => max( 1, $paged ),
|
843 |
+
'total' => $pagination_max_num_pages,
|
844 |
'prev_text' => $pagination_prev_text,
|
845 |
'next_text' => $pagination_next_text,
|
846 |
)
|