-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
executable file
·50 lines (38 loc) · 1.19 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Search results page
*/
namespace App;
use App\Cards\BasicCard;
use App\Http\Controllers\Controller;
use Rareloop\Lumberjack\Http\Responses\TimberResponse;
use Timber\Timber;
class SearchController extends Controller
{
public function handle()
{
$context = Timber::get_context();
$search_query = trim(get_search_query());
$context['title'] = 'Search results for \'' . htmlspecialchars($search_query) . '\'';
$context['search']['i18n']['next_page_label'] = _x(
'Next Page',
'The next page label on search results',
'ocp'
);
$context['search']['i18n']['no_results_label'] = _x(
'No results found.',
'The no results found label on search results',
'ocp'
);
global $wp_query;
$context['search']['results'] = BasicCard::convertCollection(
$wp_query->posts,
function ($post) {
$post['show_excerpt'] = true;
return $post;
}
);
$context['search']['pagination'] = Timber::get_pagination();
return new TimberResponse('templates/search.twig', $context);
}
}