From 2cf790ef6baa99b2f4ff8e9bfe495e492c824b93 Mon Sep 17 00:00:00 2001 From: sebastian-rink <91717299+sebastian-rink@users.noreply.github.com> Date: Wed, 13 Aug 2025 06:54:01 +0200 Subject: [PATCH] Update class-h5p-content-query.php - extended search targets Exetended search that searches the contents, too (not only the manually added tags and the title). --- admin/class-h5p-content-query.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/admin/class-h5p-content-query.php b/admin/class-h5p-content-query.php index a973f22..8a8908c 100644 --- a/admin/class-h5p-content-query.php +++ b/admin/class-h5p-content-query.php @@ -109,7 +109,23 @@ public function __construct($fields, $offset = NULL, $limit = NULL, $order_by = if (!isset($filter[0]) || !isset($filter[1])) { throw new Exception('Missing filter options.'); } - + + // Additional search in field 'parameters' + if ($filter[0] === 'title' && ( !isset($filter[2]) || $filter[2] === 'LIKE' )) { + // Search in title OR in parameters + $this->where .= ($this->where ? ' AND ' : ' WHERE ') + . '(' + . "hc.title" . $this->valid_operators['LIKE'] + . " OR hc.parameters" . $this->valid_operators['LIKE'] + . ')'; + + // Add both terms + $this->where_args[] = $filter[1]; + $this->where_args[] = preg_quote(substr(json_encode($filter[1]), 1, -1)); + + continue; + } + $field = $this->get_valid_field($filter[0]); // Add join