Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.

Commit ef0d77d

Browse files
authored
Merge pull request #334 from crowdfavorite/feat/plugin_search_operators
2 parents 5451864 + b59626a commit ef0d77d

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

app/Values/WpOrg/Plugins/QueryPluginsRequest.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,32 @@ public static function fromRequest(Request $request): array
3434
{
3535
$query = $request->query();
3636

37-
$query['tags'] = (array)Arr::pull($query, 'tag', []);
37+
$tags = [];
38+
39+
if (isset($query['tags'])) {
40+
$tags = (array) Arr::pull($query, 'tags', []);
41+
} elseif (isset($query['tag'])) {
42+
$tags = (array) Arr::pull($query, 'tag', []);
43+
}
44+
45+
// Normalize additional tag operators
46+
$tagAnd = array_filter((array) Arr::pull($query, 'tag-and', []));
47+
$tagOr = array_filter((array) Arr::pull($query, 'tag-or', []));
48+
$tagNot = array_filter((array) Arr::pull($query, 'tag-not', []));
49+
50+
// Merge base tags, ANDs, and ORs
51+
$merged = array_values(array_unique([
52+
...$tags,
53+
...$tagAnd,
54+
...$tagOr,
55+
]));
56+
57+
// Exclude NOT tags if present
58+
if (!empty($tagNot)) {
59+
$merged = array_values(array_diff($merged, $tagNot));
60+
}
61+
62+
$query['tags'] = $merged;
3863

3964
// $defaultFields = [
4065
// 'description' => true,

0 commit comments

Comments
 (0)