-
Notifications
You must be signed in to change notification settings - Fork 1
/
q2apro-popular-questions-widget.php
110 lines (96 loc) · 2.03 KB
/
q2apro-popular-questions-widget.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/*
Plugin Name: q2apro Popular questions widget
Plugin Author: q2apro
*/
class q2apro_popular_questions_widget
{
function allow_template($template)
{
$allow=false;
switch ($template)
{
case 'activity':
case 'qa':
case 'questions':
case 'hot':
case 'ask':
case 'categories':
case 'question':
case 'tag':
case 'tags':
case 'unanswered':
case 'user':
case 'users':
case 'search':
case 'admin':
case 'custom':
$allow=true;
break;
}
return $allow;
}
function allow_region($region)
{
$allow=false;
switch ($region)
{
case 'side':
$allow=true;
break;
case 'main':
case 'full':
break;
}
return $allow;
}
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
if(time() - qa_opt('q2apro_popularqu_checktime') > qa_opt('q2apro_popularqu_checkhours')*60*60)
{
q2apro_save_most_viewed_questions();
}
// output widget using cached values
$output = '';
$output .= '
<div class="popularquestions-widget">
<p>
'.qa_lang('q2apro_popularqu_lang/most_popqu').' '.qa_opt('q2apro_popularqu_lastdays').' '.qa_lang('q2apro_popularqu_lang/days').'
</p>
<ol>
'.qa_opt('q2apro_popularqu_cached').'
</ol>
</div>
';
// css (could also go into your theme css to save load)
$output .= '
<style type="text/css">
.popularquestions-widget {
margin:30px 0 30px 0;
}
.popularquestions-widget p {
font-size:14px;
}
.popularquestions-widget ol {
padding:0 10px 0 15px;
font-size:12px;
}
.popularquestions-widget ol li {
padding:5px 0;
}
.popularquestions-widget ol li a {
color:#05B;
word-wrap:break-word;
}
.popularquestions-widget ol li span {
cursor:default;color:#555;
}
</style>
';
// output widget into theme
$themeobject->output($output);
} // end output_widget
} // end class q2apro_popular_questions_days_widget
/*
Omit PHP closing tag to help avoid accidental output
*/