Version Description
- A bug was left in the post ordering code. That bug is now squashed.
Download this release
Release Info
| Developer | msaari |
| Plugin | |
| Version | 3.6.2.1 |
| Comparing to | |
| See all releases | |
Code changes from version 3.6.2 to 3.6.2.1
- lib/common.php +34 -21
- readme.txt +10 -1
- relevanssi.php +1 -1
lib/common.php
CHANGED
|
@@ -42,7 +42,7 @@ function relevanssi_wpml_filter($data) {
|
|
| 42 |
* when necessary and seeds the random generator, if required.
|
| 43 |
*/
|
| 44 |
function relevanssi_get_next_key(&$orderby) {
|
| 45 |
-
if (!is_array($orderby) || count($orderby) < 1) return array(null, null);
|
| 46 |
|
| 47 |
list($key) = array_keys($orderby);
|
| 48 |
$dir = $orderby[$key];
|
|
@@ -75,13 +75,18 @@ function relevanssi_get_next_key(&$orderby) {
|
|
| 75 |
if ($dir != "asc") $dir = "desc";
|
| 76 |
}
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
}
|
| 80 |
|
| 81 |
/*
|
| 82 |
* Fetches the key values for the item pair. If random order is required, will randomize the order.
|
| 83 |
*/
|
| 84 |
-
function
|
| 85 |
function_exists('mb_strtolower') ? $strtolower = 'mb_strtolower' : $strtolower = 'strtolower';
|
| 86 |
|
| 87 |
if ($key == "rand") {
|
|
@@ -89,7 +94,11 @@ function relevanssi_get_compare_keys($key, $item_1, $item_2) {
|
|
| 89 |
$key1 = rand();
|
| 90 |
$key2 = rand();
|
| 91 |
} while ($key1 == $key2);
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
}
|
| 94 |
|
| 95 |
$key1 = "";
|
|
@@ -120,16 +129,21 @@ function relevanssi_get_compare_keys($key, $item_1, $item_2) {
|
|
| 120 |
$key2 = apply_filters('relevanssi_missing_sort_key', $key2, $key);
|
| 121 |
}
|
| 122 |
}
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
}
|
| 125 |
|
| 126 |
-
function
|
| 127 |
$val = 0;
|
| 128 |
if ($compare == "date") {
|
| 129 |
if (strtotime($key1) > strtotime($key2)) {
|
| 130 |
$val = 1;
|
| 131 |
}
|
| 132 |
-
else if (strtotime($key1) <
|
| 133 |
$val = -1;
|
| 134 |
}
|
| 135 |
}
|
|
@@ -165,13 +179,13 @@ function relevanssi_object_sort(&$data, $orderby) {
|
|
| 165 |
$dirs = array();
|
| 166 |
$compares = array();
|
| 167 |
do {
|
| 168 |
-
|
| 169 |
-
if ($key
|
| 170 |
-
$keys[] = $key;
|
| 171 |
-
$dirs[] = $dir;
|
| 172 |
-
$compares[] = $compare;
|
| 173 |
}
|
| 174 |
-
} while ($key
|
| 175 |
|
| 176 |
$primary_key = $keys[0];
|
| 177 |
if (!isset($data[0]->$primary_key)) return; // trying to sort by a non-existent key
|
|
@@ -183,20 +197,19 @@ function relevanssi_object_sort(&$data, $orderby) {
|
|
| 183 |
$key2 = "";
|
| 184 |
|
| 185 |
$level = -1;
|
| 186 |
-
|
| 187 |
-
$compare = $compares[$level];
|
| 188 |
-
$val = relevanssi_compare_keys($key1, $key2, $compare);
|
| 189 |
|
| 190 |
while ($val == 0) {
|
| 191 |
-
|
| 192 |
-
|
| 193 |
$level--;
|
| 194 |
break; // give up – we can't sort these two
|
| 195 |
}
|
| 196 |
-
|
| 197 |
-
$
|
|
|
|
| 198 |
}
|
| 199 |
-
|
| 200 |
if ('asc' == $dirs[$level]) {
|
| 201 |
if ($val == 1) {
|
| 202 |
$tmp = $data[$j];
|
| 42 |
* when necessary and seeds the random generator, if required.
|
| 43 |
*/
|
| 44 |
function relevanssi_get_next_key(&$orderby) {
|
| 45 |
+
if (!is_array($orderby) || count($orderby) < 1) return array('key' => null, 'dir' => null, 'compare' => null);
|
| 46 |
|
| 47 |
list($key) = array_keys($orderby);
|
| 48 |
$dir = $orderby[$key];
|
| 75 |
if ($dir != "asc") $dir = "desc";
|
| 76 |
}
|
| 77 |
|
| 78 |
+
$values = array(
|
| 79 |
+
'key' => $key,
|
| 80 |
+
'dir' => $dir,
|
| 81 |
+
'compare' => $compare
|
| 82 |
+
);
|
| 83 |
+
return $values;
|
| 84 |
}
|
| 85 |
|
| 86 |
/*
|
| 87 |
* Fetches the key values for the item pair. If random order is required, will randomize the order.
|
| 88 |
*/
|
| 89 |
+
function relevanssi_get_compare_values($key, $item_1, $item_2) {
|
| 90 |
function_exists('mb_strtolower') ? $strtolower = 'mb_strtolower' : $strtolower = 'strtolower';
|
| 91 |
|
| 92 |
if ($key == "rand") {
|
| 94 |
$key1 = rand();
|
| 95 |
$key2 = rand();
|
| 96 |
} while ($key1 == $key2);
|
| 97 |
+
$keys = array(
|
| 98 |
+
'key1' => $key1,
|
| 99 |
+
'key2' => $key2,
|
| 100 |
+
);
|
| 101 |
+
return $keys;
|
| 102 |
}
|
| 103 |
|
| 104 |
$key1 = "";
|
| 129 |
$key2 = apply_filters('relevanssi_missing_sort_key', $key2, $key);
|
| 130 |
}
|
| 131 |
}
|
| 132 |
+
|
| 133 |
+
$keys = array(
|
| 134 |
+
'key1' => $key1,
|
| 135 |
+
'key2' => $key2,
|
| 136 |
+
);
|
| 137 |
+
return $keys;
|
| 138 |
}
|
| 139 |
|
| 140 |
+
function relevanssi_compare_values($key1, $key2, $compare) {
|
| 141 |
$val = 0;
|
| 142 |
if ($compare == "date") {
|
| 143 |
if (strtotime($key1) > strtotime($key2)) {
|
| 144 |
$val = 1;
|
| 145 |
}
|
| 146 |
+
else if (strtotime($key1) < strtotime($key2)) {
|
| 147 |
$val = -1;
|
| 148 |
}
|
| 149 |
}
|
| 179 |
$dirs = array();
|
| 180 |
$compares = array();
|
| 181 |
do {
|
| 182 |
+
$values = relevanssi_get_next_key($orderby);
|
| 183 |
+
if (!empty($values['key'])) {
|
| 184 |
+
$keys[] = $values['key'];
|
| 185 |
+
$dirs[] = $values['dir'];
|
| 186 |
+
$compares[] = $values['compare'];
|
| 187 |
}
|
| 188 |
+
} while (!empty($values['key']));
|
| 189 |
|
| 190 |
$primary_key = $keys[0];
|
| 191 |
if (!isset($data[0]->$primary_key)) return; // trying to sort by a non-existent key
|
| 197 |
$key2 = "";
|
| 198 |
|
| 199 |
$level = -1;
|
| 200 |
+
$val = 0;
|
|
|
|
|
|
|
| 201 |
|
| 202 |
while ($val == 0) {
|
| 203 |
+
$level++;
|
| 204 |
+
if (!isset($keys[$level])) {
|
| 205 |
$level--;
|
| 206 |
break; // give up – we can't sort these two
|
| 207 |
}
|
| 208 |
+
$compare = $compares[$level];
|
| 209 |
+
$compare_values = relevanssi_get_compare_values($keys[$level], $data[$j], $data[$j + 1]);
|
| 210 |
+
$val = relevanssi_compare_values($compare_values['key1'], $compare_values['key2'], $compare);
|
| 211 |
}
|
| 212 |
+
|
| 213 |
if ('asc' == $dirs[$level]) {
|
| 214 |
if ($val == 1) {
|
| 215 |
$tmp = $data[$j];
|
readme.txt
CHANGED
|
@@ -5,7 +5,7 @@ Tags: search, relevance, better search
|
|
| 5 |
Requires at least: 4.0
|
| 6 |
Tested up to: 4.9
|
| 7 |
Requires PHP: 5.6
|
| 8 |
-
Stable tag: 3.6.2
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 11 |
|
|
@@ -269,6 +269,9 @@ Each document database is full of useless words. All the little words that appea
|
|
| 269 |
|
| 270 |
== Changelog ==
|
| 271 |
|
|
|
|
|
|
|
|
|
|
| 272 |
= 3.6.2 =
|
| 273 |
* Simple Membership plugin is now supported automatically to restrict access to posts.
|
| 274 |
* Relevanssi can now handle orderby parameter in array format.
|
|
@@ -1088,6 +1091,12 @@ Each document database is full of useless words. All the little words that appea
|
|
| 1088 |
|
| 1089 |
== Upgrade notice ==
|
| 1090 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1091 |
= 3.6.1 =
|
| 1092 |
* Fix for a security vulnerability where a site admin could inject SQL code into search queries.
|
| 1093 |
|
| 5 |
Requires at least: 4.0
|
| 6 |
Tested up to: 4.9
|
| 7 |
Requires PHP: 5.6
|
| 8 |
+
Stable tag: 3.6.2.1
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 11 |
|
| 269 |
|
| 270 |
== Changelog ==
|
| 271 |
|
| 272 |
+
= 3.6.2.1 =
|
| 273 |
+
* A bug was left in the post ordering code. That bug is now squashed.
|
| 274 |
+
|
| 275 |
= 3.6.2 =
|
| 276 |
* Simple Membership plugin is now supported automatically to restrict access to posts.
|
| 277 |
* Relevanssi can now handle orderby parameter in array format.
|
| 1091 |
|
| 1092 |
== Upgrade notice ==
|
| 1093 |
|
| 1094 |
+
= 3.6.2.1 =
|
| 1095 |
+
* Fixes a bug in the post sorting algorithm.
|
| 1096 |
+
|
| 1097 |
+
= 3.6.2 =
|
| 1098 |
+
* Support for array orderby and other fine features.
|
| 1099 |
+
|
| 1100 |
= 3.6.1 =
|
| 1101 |
* Fix for a security vulnerability where a site admin could inject SQL code into search queries.
|
| 1102 |
|
relevanssi.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
Plugin Name: Relevanssi
|
| 4 |
Plugin URI: http://www.relevanssi.com/
|
| 5 |
Description: This plugin replaces WordPress search with a relevance-sorting search.
|
| 6 |
-
Version: 3.6.2
|
| 7 |
Author: Mikko Saari
|
| 8 |
Author URI: http://www.mikkosaari.fi/
|
| 9 |
*/
|
| 3 |
Plugin Name: Relevanssi
|
| 4 |
Plugin URI: http://www.relevanssi.com/
|
| 5 |
Description: This plugin replaces WordPress search with a relevance-sorting search.
|
| 6 |
+
Version: 3.6.2.1
|
| 7 |
Author: Mikko Saari
|
| 8 |
Author URI: http://www.mikkosaari.fi/
|
| 9 |
*/
|
