-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
executable file
·74 lines (69 loc) · 2.23 KB
/
search.php
File metadata and controls
executable file
·74 lines (69 loc) · 2.23 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php $options = get_option(THEME_OPTIONS_NAME);?>
<?php if ($options['enable_google'] or $options['enable_google'] === null):?>
<?php
$domain = $options['search_domain'];
$limit = (int)$options['search_per_page'];
$start = (is_numeric($_GET['start'])) ? (int)$_GET['start'] : 0;
$results = get_search_results($_GET['s'], $start, $limit, $domain);
?>
<?php get_header(); ?>
<div class="row page-content" id="search-results">
<div class="span12">
<article>
<h1>Search Results</h1>
<?php if(count($results['items'])):?>
<ul class="result-list">
<?php foreach($results['items'] as $result):?>
<li class="item">
<h3>
<a class="<?=mimetype_to_application(($result['mime']) ? $result['mime'] : 'text/html')?>" href="<?=$result['url']?>">
<?php if($result['title']):?>
<?=$result['title']?>
<?php else:?>
<?=substr($result['url'], 0, 45)?>...
<?php endif;?>
</a>
</h3>
<a href="<?=$result['url']?>" class="ignore-external url sans"><?=$result['url']?></a>
<div class="snippet">
<?=str_replace('<br>', '', $result['snippet'])?>
</div>
</li>
<?php endforeach;?>
</ul>
<?php if($start + $limit < $results['number']):?>
<a class="button more" href="./?s=<?=$_GET['s']?>&start=<?=$start + $limit?>">More Results</a>
<?php endif;?>
<?php else:?>
<p>No results found for "<?=htmlentities($_GET['s'])?>".</p>
<?php endif;?>
</article>
</div>
</div>
<?php get_footer();?>
<?php else:?>
<?php get_header(); the_post();?>
<div class="row page-content" id="search-results">
<div class="span12">
<article>
<h1>Search Results</h1>
<?php if(have_posts()):?>
<ul class="result-list">
<?php while(have_posts()): the_post();?>
<li class="item">
<h3><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>
<a href="<?php the_permalink();?>"><?php the_permalink();?></a>
<div class="snippet">
<?php the_excerpt();?>
</div>
</li>
<?php endwhile;?>
</ul>
<?php else:?>
<p>No results found for "<?=htmlentities($_GET['s'])?>".</p>
<?php endif;?>
</article>
</div>
</div>
<?php get_footer();?>
<?php endif;?>