Adding offset support to searcher for pagination
This commit is contained in:
parent
96d893fd58
commit
f81ebc88a1
|
@ -1084,6 +1084,7 @@ if ( !class_exists( 'Simple_Map' ) ) {
|
|||
}
|
||||
|
||||
var bounds = new google.maps.LatLngBounds();
|
||||
//- CALL TO RENDER EACH LOCATION
|
||||
markers.each( function () {
|
||||
var locationData = this;
|
||||
locationData.distance = parseFloat(locationData.distance);
|
||||
|
@ -1390,6 +1391,7 @@ if ( !class_exists( 'Simple_Map' ) ) {
|
|||
return marker;
|
||||
}
|
||||
|
||||
//- FUNCTION THAT GENERATES LIST ITEMS
|
||||
function createSidebarEntry(marker, locationData, searchData) {
|
||||
var div = document.createElement('div');
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ if ( !class_exists( 'SM_XML_Search' ) ){
|
|||
'onlyzip' => false,
|
||||
'country' => false,
|
||||
'limit' => false,
|
||||
'page' => false,
|
||||
'pid' => 0,
|
||||
);
|
||||
$input = array_filter( array_intersect_key( $_GET, $defaults ) ) + $defaults;
|
||||
|
@ -49,6 +50,12 @@ if ( !class_exists( 'SM_XML_Search' ) ){
|
|||
|
||||
$limit = apply_filters( 'sm-xml-search-limit', $limit );
|
||||
|
||||
|
||||
if ( $input['page'] && $input['page'] < 250 )
|
||||
$offset = 'OFFSET ' . ( absint($input['page']) - 1) * $limit;
|
||||
else
|
||||
$offset = '';
|
||||
|
||||
// Locations within specific distance or just get them all?
|
||||
$distance_select = $wpdb->prepare( "( 3959 * ACOS( COS( RADIANS(%s) ) * COS( RADIANS( lat_tbl.meta_value ) ) * COS( RADIANS( lng_tbl.meta_value ) - RADIANS(%s) ) + SIN( RADIANS(%s) ) * SIN( RADIANS( lat_tbl.meta_value ) ) ) ) AS distance", $input['lat'], $input['lng'], $input['lat'] ) . ', ';
|
||||
$distance_order = 'distance, ';
|
||||
|
@ -108,7 +115,7 @@ if ( !class_exists( 'SM_XML_Search' ) ){
|
|||
GROUP BY
|
||||
posts.ID
|
||||
$distance_having
|
||||
ORDER BY " . apply_filters( 'sm-location-sort-order', $distance_order . ' posts.post_name ASC', $input ) . " " . $limit;
|
||||
ORDER BY " . apply_filters( 'sm-location-sort-order', $distance_order . ' posts.post_name ASC', $input ) . " " . $limit . " " . $offset;
|
||||
|
||||
$sql = apply_filters( 'sm-xml-search-locations-sql', $sql );
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user