Skip to content

Commit

Permalink
Fix option filters not working in pagination
Browse files Browse the repository at this point in the history
This fixes an issue where some option filters like `map_position` and
`grid_view` are dropped when using the pagination links.
  • Loading branch information
CodyReichert committed Feb 27, 2024
1 parent 706d81e commit cc78d81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/simply-rets-api-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SimplyRetsApiHelper {
public static function retrieveRetsListings( $params, $settings = NULL ) {
$request_url = SimplyRetsApiHelper::srRequestUrlBuilder( $params );
$request_response = SimplyRetsApiHelper::srApiRequest( $request_url );
$response_markup = SimplyRetsApiHelper::srResidentialResultsGenerator($request_response, $settings, $params);
$response_markup = SimplyRetsApiHelper::srResidentialResultsGenerator($request_response, $settings);

return $response_markup;
}
Expand Down Expand Up @@ -1371,7 +1371,7 @@ public static function resultDataColumnMarkup($val, $name, $reverse=false, $id="
}


public static function srResidentialResultsGenerator($request_response, $settings, $params = array()) {
public static function srResidentialResultsGenerator($request_response, $settings) {
$cont = "";
$pagination = $request_response['pagination'];
$lastUpdate = $request_response['lastUpdate'];
Expand All @@ -1391,7 +1391,7 @@ public static function srResidentialResultsGenerator($request_response, $setting

/** Build pagination links HTML **/
$page_count = count($response);
$limit = isset($params['limit']) ? $params['limit'] : 20;
$limit = isset($settings['limit']) ? $settings['limit'] : 20;
$pag = SrUtils::buildPaginationLinks( $pagination );
$prev_link = $pag['prev'];
$next_link = $page_count < $limit ? "" : $pag['next'];
Expand Down
8 changes: 2 additions & 6 deletions src/simply-rets-shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ public static function parseShortcodeAttributes($atts, $setting_atts = array())
// Parse settings, don't add them to the API query
if (array_key_exists($param, $setting_atts)) {
$attributes["settings"][$param] = $value;
continue;
}

$values = explode(";", $value);
Expand All @@ -244,11 +243,6 @@ public static function parseShortcodeAttributes($atts, $setting_atts = array())
}

$attributes["params"][$name] = count($values) > 1 ? $values : $value;

// Add vendor to params and settings
if ($param === "vendor") {
$attributes["settings"]["vendor"] = $value;
}
}

return $attributes;
Expand Down Expand Up @@ -276,6 +270,8 @@ public static function sr_residential_shortcode($atts = array ()) {
"map_position" => get_option('sr_search_map_position', 'map_above'),
"show_map" => "true",
"grid_view" => false,
"vendor" => "",
"limit" => 20
);

$data = SrShortcodes::parseShortcodeAttributes($atts, $setting_atts);
Expand Down

0 comments on commit cc78d81

Please sign in to comment.