Testimonials Widget - Version 0.2.2

Version Description

  • Show newest testimonials first in admin list by default
  • Quick locallization
  • Quotes Collection recommendation
Download this release

Release Info

Developer comprock
Plugin Icon wp plugin Testimonials Widget
Version 0.2.2
Comparing to
See all releases

Version 0.2.2

languages/testimonials-widget.pot ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2010 Testimonials Widget
2
+ # This file is distributed under the same license as the Testimonials Widget package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Testimonials Widget 0.2.1\n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/testimonials-widget\n"
7
+ "POT-Creation-Date: 2012-01-14 08:49:15+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+
15
+ #: testimonials-widget-admin.php:72
16
+ msgid "Go to the first page"
17
+ msgstr ""
18
+
19
+ #: testimonials-widget-admin.php:73
20
+ msgid "Go to the previous page"
21
+ msgstr ""
22
+
23
+ #: testimonials-widget-admin.php:75
24
+ msgid "Go to the next page"
25
+ msgstr ""
26
+
27
+ #: testimonials-widget-admin.php:76
28
+ msgid "Go to the last page"
29
+ msgstr ""
30
+
31
+ #: testimonials-widget-admin.php:80
32
+ msgid "Goto page:"
33
+ msgstr ""
34
+
35
+ #: testimonials-widget-admin.php:96
36
+ msgid "Nothing added to the database."
37
+ msgstr ""
38
+
39
+ #: testimonials-widget-admin.php:100 testimonials-widget-admin.php:136
40
+ msgid "Database table not found"
41
+ msgstr ""
42
+
43
+ #: testimonials-widget-admin.php:123 testimonials-widget-admin.php:164
44
+ #: testimonials-widget-admin.php:178
45
+ msgid "There was an error in the MySQL query"
46
+ msgstr ""
47
+
48
+ #: testimonials-widget-admin.php:125
49
+ msgid "Testimonial added"
50
+ msgstr ""
51
+
52
+ #: testimonials-widget-admin.php:131
53
+ msgid "Testimonial not updated."
54
+ msgstr ""
55
+
56
+ #: testimonials-widget-admin.php:166
57
+ msgid "Changes saved"
58
+ msgstr ""
59
+
60
+ #: testimonials-widget-admin.php:180
61
+ msgid "Testimonial deleted"
62
+ msgstr ""
63
+
64
+ #: testimonials-widget-admin.php:182
65
+ msgid "The testimonial cannot be deleted"
66
+ msgstr ""
67
+
68
+ #: testimonials-widget-admin.php:198 testimonials-widget-admin.php:300
69
+ msgid "Add Testimonial"
70
+ msgstr ""
71
+
72
+ #: testimonials-widget-admin.php:215 testimonials-widget-admin.php:304
73
+ msgid "Save changes"
74
+ msgstr ""
75
+
76
+ #: testimonials-widget-admin.php:216
77
+ msgid "Back"
78
+ msgstr ""
79
+
80
+ #: testimonials-widget-admin.php:220 testimonials-widget-admin.php:459
81
+ msgid "The testimonial"
82
+ msgstr ""
83
+
84
+ #: testimonials-widget-admin.php:221 testimonials-widget-admin.php:443
85
+ #: testimonials-widget-admin.php:461
86
+ msgid "Author"
87
+ msgstr ""
88
+
89
+ #: testimonials-widget-admin.php:222 testimonials-widget-admin.php:444
90
+ #: testimonials-widget-admin.php:461
91
+ msgid "Source"
92
+ msgstr ""
93
+
94
+ #: testimonials-widget-admin.php:223 testimonials-widget-admin.php:463
95
+ msgid "Tags"
96
+ msgstr ""
97
+
98
+ #: testimonials-widget-admin.php:224 testimonials-widget-admin.php:464
99
+ msgid "Public?"
100
+ msgstr ""
101
+
102
+ #: testimonials-widget-admin.php:225
103
+ msgid "optional"
104
+ msgstr ""
105
+
106
+ #: testimonials-widget-admin.php:226
107
+ msgid "email address or website URL"
108
+ msgstr ""
109
+
110
+ #: testimonials-widget-admin.php:227
111
+ msgid "comma separated"
112
+ msgstr ""
113
+
114
+ #: testimonials-widget-admin.php:264 testimonials-widget-admin.php:280
115
+ msgid "Nothing done!"
116
+ msgstr ""
117
+
118
+ #: testimonials-widget-admin.php:272
119
+ msgid "Selected testimonials made public"
120
+ msgstr ""
121
+
122
+ #: testimonials-widget-admin.php:274
123
+ msgid "Selected testimonials made private"
124
+ msgstr ""
125
+
126
+ #: testimonials-widget-admin.php:285
127
+ msgid "Testimonial(s) deleted"
128
+ msgstr ""
129
+
130
+ #: testimonials-widget-admin.php:311
131
+ msgid "Edit testimonial"
132
+ msgstr ""
133
+
134
+ #: testimonials-widget-admin.php:337 testimonials-widget-admin.php:346
135
+ #: testimonials-widget-admin.php:483
136
+ msgid "Add new testimonial"
137
+ msgstr ""
138
+
139
+ #: testimonials-widget-admin.php:342 testimonials-widget-admin.php:479
140
+ msgid "No testimonials in the database"
141
+ msgstr ""
142
+
143
+ #: testimonials-widget-admin.php:412
144
+ msgid "Edit"
145
+ msgstr ""
146
+
147
+ #: testimonials-widget-admin.php:412
148
+ msgid "Are you sure you want to delete this testimonial?"
149
+ msgstr ""
150
+
151
+ #: testimonials-widget-admin.php:412 testimonials-widget-admin.php:433
152
+ msgid "Delete"
153
+ msgstr ""
154
+
155
+ #: testimonials-widget-admin.php:419
156
+ msgid "No"
157
+ msgstr ""
158
+
159
+ #: testimonials-widget-admin.php:420
160
+ msgid "Yes"
161
+ msgstr ""
162
+
163
+ #: testimonials-widget-admin.php:432
164
+ msgid "Bulk Actions"
165
+ msgstr ""
166
+
167
+ #: testimonials-widget-admin.php:434
168
+ msgid "Make public"
169
+ msgstr ""
170
+
171
+ #: testimonials-widget-admin.php:435
172
+ msgid "Keep private"
173
+ msgstr ""
174
+
175
+ #: testimonials-widget-admin.php:437
176
+ msgid "Apply"
177
+ msgstr ""
178
+
179
+ #: testimonials-widget-admin.php:439
180
+ msgid "Sort by: "
181
+ msgstr ""
182
+
183
+ #: testimonials-widget-admin.php:441 testimonials-widget-admin.php:442
184
+ msgid "Testimonial"
185
+ msgstr ""
186
+
187
+ #: testimonials-widget-admin.php:445
188
+ msgid "Date added"
189
+ msgstr ""
190
+
191
+ #: testimonials-widget-admin.php:446
192
+ msgid "Date updated"
193
+ msgstr ""
194
+
195
+ #: testimonials-widget-admin.php:447
196
+ msgid "Visibility"
197
+ msgstr ""
198
+
199
+ #: testimonials-widget-admin.php:450
200
+ msgid "Go"
201
+ msgstr ""
202
+
203
+ #: testimonials-widget-admin.php:452 testimonials-widget-admin.php:470
204
+ msgid "%d testimonials"
205
+ msgid_plural "%d testimonials"
206
+ msgstr[0] ""
207
+ msgstr[1] ""
208
+
209
+ #: testimonials-widget-widget.php:23
210
+ msgid ""
211
+ "Testimonial widget plugin allows you display testimonials in a sidebar on "
212
+ "your WordPress blog."
213
+ msgstr ""
214
+
215
+ #. #-#-#-#-# testimonials-widget.pot (Testimonials Widget 0.2.1) #-#-#-#-#
216
+ #. Plugin Name of the plugin/theme
217
+ #: testimonials-widget-widget.php:29
218
+ msgid "Testimonials Widget"
219
+ msgstr ""
220
+
221
+ #: testimonials-widget-widget.php:79
222
+ msgid "none"
223
+ msgstr ""
224
+
225
+ #: testimonials-widget-widget.php:96
226
+ msgid "Testimonials"
227
+ msgstr ""
228
+
229
+ #: testimonials-widget-widget.php:116
230
+ msgid "Title"
231
+ msgstr ""
232
+
233
+ #: testimonials-widget-widget.php:117
234
+ msgid "Minimum Height"
235
+ msgstr ""
236
+
237
+ #: testimonials-widget-widget.php:117
238
+ msgid ""
239
+ "Minimum height in px, this must be set to a value that suits your logest "
240
+ "testimonial (increase this value if you find that your testimonials are "
241
+ "getting cut off)."
242
+ msgstr ""
243
+
244
+ #: testimonials-widget-widget.php:118
245
+ msgid "Show author?"
246
+ msgstr ""
247
+
248
+ #: testimonials-widget-widget.php:119
249
+ msgid "Show source?"
250
+ msgstr ""
251
+
252
+ #: testimonials-widget-widget.php:120
253
+ msgid "Advanced options"
254
+ msgstr ""
255
+
256
+ #: testimonials-widget-widget.php:122
257
+ msgid "Refresh Interval"
258
+ msgstr ""
259
+
260
+ #: testimonials-widget-widget.php:122
261
+ msgid "In seconds or 0 for no refresh."
262
+ msgstr ""
263
+
264
+ #: testimonials-widget-widget.php:123
265
+ msgid "Random order"
266
+ msgstr ""
267
+
268
+ #: testimonials-widget-widget.php:123
269
+ msgid ""
270
+ "Unchecking this will rotate testimonials in the order added, latest first."
271
+ msgstr ""
272
+
273
+ #: testimonials-widget-widget.php:124
274
+ msgid "Tags filter"
275
+ msgstr ""
276
+
277
+ #: testimonials-widget-widget.php:124
278
+ msgid "Comma separated"
279
+ msgstr ""
280
+
281
+ #: testimonials-widget-widget.php:125
282
+ msgid "Character limit"
283
+ msgstr ""
284
+
285
+ #. Description of the plugin/theme
286
+ msgid ""
287
+ "Testimonial widget plugin helps you display testimonials in a sidebar on "
288
+ "your WordPress blog."
289
+ msgstr ""
290
+
291
+ #. Author of the plugin/theme
292
+ msgid "comprock, j0hnsmith"
293
+ msgstr ""
readme.txt ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Testimonials Widget ===
2
+ Contributors: comprock, j0hnsmith
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GGPVLS64ZMNV8
4
+ Tags: testimonials, quotes, quotations, random quote, sidebar, widget
5
+ Requires at least: 3.0
6
+ Tested up to: 3.3.1
7
+ Stable tag: 0.2.2
8
+
9
+ Testimonials widget plugin allows you display testimonials in a widget on your WordPress blog.
10
+
11
+ == Description ==
12
+
13
+ Testimonial widget plugin allows you display testimonials in a widget on your WordPress blog.
14
+
15
+ More than one widget can be displayed, each pulling from testimonial sets by using tags. Each displayed widget has its own identifier allowing for custom CSS styling.
16
+
17
+ You can make a simple client or portfolio rotator by using the testimonial field as the client or organization name, and the source field with the URL and tag as "portfolio". Then in the widget, show source and require tag "portfolio".
18
+
19
+
20
+ **Features and notes**
21
+
22
+ * All testimonials (subject to filters) are in the html source so will be seen by google etc.
23
+ * Testimony, author and source fields are clickable
24
+ * **Admin interface**: A nice admin interface to add, edit and manage testimonials. Details such as author and source of the quote, and attributes like tags and visibility, can be specified. The 'Testimonials' menu in the WP admin navigation leads to the admin interface.
25
+ * **Sidebar widget**: The Testimonials sidebar widget loads a testimonial then rotates through all available testimonials. Following is the list of options in the widget control panel:
26
+ * Widget title
27
+ * Option to show/hide author
28
+ * Option to show/hide source
29
+ * Choose refresh interval in seconds or set to 0 for static display
30
+ * Choose random or sequential order for refresh
31
+ * Show only quotes with certain tags
32
+ * Specify a character limit to filter out longer quotes
33
+ * Allows for multiple widgets. Useful for using tags to keep widgets separated.
34
+ * Compatible with WordPress 3.0 multi-site functionality.
35
+
36
+ = Need More Power? =
37
+ Check out the [Quotes Collection](http://wordpress.org/extend/plugins/quotes-collection/) plugin by [SriniG](http://profiles.wordpress.org/users/SriniG/profile/public/)
38
+
39
+ == Installation ==
40
+ 1. Upload `testimonials-widget` directory to the `/wp-content/plugins/` directory
41
+ 1. Activate the 'Testimonials Widget' plugin through the 'Plugins' menu in WordPress
42
+ 1. Add and manage the quotes through the 'Testimonials' menu in the WordPress admin area
43
+ 1. To display testimonials in the sidebar, go to 'Widgets' menu and drag the 'Testimonials' widget into the sidebar
44
+
45
+ == Frequently Asked Questions ==
46
+
47
+ = How to stop testimonial text/author/source being cut off? =
48
+
49
+ Specify a larger minimum height in the testimonials widget, see screenshot 2.
50
+
51
+ = How to get rid of the quotation marks that surround the random quote? =
52
+
53
+ Open the testimonials-widget.css file that comes along with the plugin, scroll down and look towards the bottom.
54
+
55
+ = How to change the random quote text color? =
56
+
57
+ Styling such as text color, font size, background color, etc., of the random quote can be customized by editing the testimonials-widget.css file.
58
+
59
+ = How to change the admin access level setting for the quotes collection admin page? =
60
+
61
+ Change the value of the variable `$testimonialswidget_admin_userlevel` on line 33 of the testimonials-widget.php file. Refer [WordPress documentation](http://codex.wordpress.org/Roles_and_Capabilities) for more information about user roles and capabilities.
62
+
63
+ == Screenshots ==
64
+
65
+ 1. Admin interface (WordPress 3.2)
66
+ 2. Add new testimonial
67
+ 3. 'Testimonials' widget options (WordPress 3.2)
68
+ 4. A testimonial in the sidebar
69
+ 5. Edit testimonial
70
+
71
+
72
+ == Installation ==
73
+ 1. Upload `testimonials-widget` directory to the `/wp-content/plugins/` directory
74
+ 1. Activate the 'Testimonials Widget' plugin through the 'Plugins' menu in WordPress
75
+ 1. Add and manage the quotes through the 'Testimonials' menu in the WordPress admin area
76
+ 1. To display testimonials in the sidebar, go to 'Widgets' menu and drag the 'Testimonials' widget into the sidebar
77
+
78
+ == Upgrade Notice ==
79
+ * If you have no tags fields, deactivate and activate the plugin as normal to perform database upgrades
80
+
81
+ ==Changelog==
82
+ = trunk =
83
+ -
84
+
85
+ = 0.2.2 =
86
+ * Show newest testimonials first in admin list by default
87
+ * Quick locallization
88
+ * Quotes Collection recommendation
89
+
90
+ = 2011-10-03: Version 0.2 =
91
+ * Multi-widget enabled
92
+ * Testimonial, author & source text are clickable automatically
93
+ * Allow 0 refresh to make widget static
94
+ * Allow pressing return when editing testimonial to save record
95
+
96
+ = 2011-08-12: Version 0.1 =
97
+ * initial release
98
+
99
+ == TODO ==
100
+ * Add shortcodes: list, single, by tag
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file
screenshot-5.png ADDED
Binary file
testimonials-widget-admin.php ADDED
@@ -0,0 +1,514 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function testimonialswidget_admin_menu()
4
+ {
5
+ global $testimonialswidget_admin_userlevel;
6
+ add_object_page('Testimonials Widget', 'Testimonials', $testimonialswidget_admin_userlevel, 'testimonials-widget', 'testimonialswidget_testimonials_management');
7
+ }
8
+ add_action('admin_menu', 'testimonialswidget_admin_menu');
9
+
10
+
11
+ function testimonialswidget_count($condition = "")
12
+ {
13
+ global $wpdb;
14
+ $sql = "SELECT COUNT(*) FROM " . $wpdb->prefix . "testimonialswidget ".$condition;
15
+ $count = $wpdb->get_var($sql);
16
+ return $count;
17
+ }
18
+
19
+
20
+ function testimonialswidget_pagenav($total, $current = 1, $format = 0, $paged = 'paged', $url = "")
21
+ {
22
+ if($total == 1 && $current == 1) return "";
23
+
24
+ if(!$url) {
25
+ $url = 'http';
26
+ if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {$url .= "s";}
27
+ $url .= "://";
28
+ if ($_SERVER["SERVER_PORT"] != "80") {
29
+ $url .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["PHP_SELF"];
30
+ } else {
31
+ $url .= $_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"];
32
+ }
33
+ if($query_string = $_SERVER['QUERY_STRING']) {
34
+ $parms = explode('&', $query_string);
35
+ $y = '?';
36
+ foreach($parms as $parm) {
37
+ $x = explode('=', $parm);
38
+ if($x[0] == $paged) {
39
+ $query_string = str_replace($y.$parm, '', $query_string);
40
+ }
41
+ else $y = '&';
42
+ }
43
+ if($query_string) {
44
+ $url .= '?'.$query_string;
45
+ $a = '&';
46
+ }
47
+ else $a = '?';
48
+ }
49
+ else $a = '?';
50
+ }
51
+ else {
52
+ $a = '?';
53
+ if(strpos($url, '?')) $a = '&';
54
+ }
55
+
56
+ if(!$format || $format > 2 || $format < 0 || !is_numeric($format)) {
57
+ if($total <= 8) $format = 1;
58
+ else $format = 2;
59
+ }
60
+
61
+
62
+ if($current > $total) $current = $total;
63
+ $pagenav = "";
64
+
65
+ if($format == 2) {
66
+ $first_disabled = $prev_disabled = $next_disabled = $last_disabled = '';
67
+ if($current == 1)
68
+ $first_disabled = $prev_disabled = ' disabled';
69
+ if($current == $total)
70
+ $next_disabled = $last_disabled = ' disabled';
71
+
72
+ $pagenav .= "<a class=\"first-page{$first_disabled}\" title=\"".__('Go to the first page', 'testimonials-widget')."\" href=\"{$url}\">&laquo;</a>&nbsp;&nbsp;";
73
+ $pagenav .= "<a class=\"prev-page{$prev_disabled}\" title=\"".__('Go to the previous page', 'testimonials-widget')."\" href=\"{$url}{$a}{$paged}=".($current - 1)."\">&#139;</a>&nbsp;&nbsp;";
74
+ $pagenav .= '<span class="paging-input">'.$current.' of <span class="total-pages">'.$total.'</span></span>';
75
+ $pagenav .= "&nbsp;&nbsp;<a class=\"next-page{$next_disabled}\" title=\"".__('Go to the next page', 'testimonials-widget')."\" href=\"{$url}{$a}{$paged}=".($current + 1)."\">&#155;</a>";
76
+ $pagenav .= "&nbsp;&nbsp;<a class=\"last-page{$last_disabled}\" title=\"".__('Go to the last page', 'testimonials-widget')."\" href=\"{$url}{$a}{$paged}={$total}\">&raquo;</a>";
77
+
78
+ }
79
+ else {
80
+ $pagenav = __("Goto page:", 'testimonials-widget');
81
+ for( $i = 1; $i <= $total; $i++ ) {
82
+ if($i == $current)
83
+ $pagenav .= "&nbsp<strong>{$i}</strong>";
84
+ else if($i == 1)
85
+ $pagenav .= "&nbsp;<a href=\"{$url}\">{$i}</a>";
86
+ else
87
+ $pagenav .= "&nbsp;<a href=\"{$url}{$a}{$paged}={$i}\">{$i}</a>";
88
+ }
89
+ }
90
+ return $pagenav;
91
+ }
92
+
93
+
94
+ function testimonialswidget_addtestimonial($testimonial, $author = "", $source = "", $tags = "", $public = 'yes')
95
+ {
96
+ if(!$testimonial) return __('Nothing added to the database.', 'testimonials-widget');
97
+ global $wpdb;
98
+ $table_name = $wpdb->prefix . "testimonialswidget";
99
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
100
+ return __('Database table not found', 'testimonials-widget');
101
+ else //Add the testimonial data to the database
102
+ {
103
+ $testimonial = trim( stripslashes($testimonial) );
104
+ $author = trim( stripslashes($author) );
105
+ $source = trim( stripslashes($source) );
106
+ $tags = trim( stripslashes($tags) );
107
+
108
+ $testimonial = "'".$wpdb->escape($testimonial)."'";
109
+ $author = $author?"'".$wpdb->escape($author)."'":"NULL";
110
+ $source = $source?"'".$wpdb->escape($source)."'":"NULL";
111
+ $tags = explode(',', $tags);
112
+ foreach ($tags as $key => $tag)
113
+ $tags[$key] = trim($tag);
114
+ $tags = implode(',', $tags);
115
+ $tags = $tags?"'".$wpdb->escape($tags)."'":"NULL";
116
+ if(!$public) $public = "'no'";
117
+ else $public = "'yes'";
118
+ $insert = "INSERT INTO " . $table_name .
119
+ "(testimonial, author, source, tags, public, time_added)" .
120
+ "VALUES ({$testimonial}, {$author}, {$source}, {$tags}, {$public}, NOW())";
121
+ $results = $wpdb->query( $insert );
122
+ if(FALSE === $results)
123
+ return __('There was an error in the MySQL query', 'testimonials-widget');
124
+ else
125
+ return __('Testimonial added', 'testimonials-widget');
126
+ }
127
+ }
128
+
129
+ function testimonialswidget_edittestimonial($testimonial_id, $testimonial, $author = "", $source = "", $tags = "", $public = 'yes')
130
+ {
131
+ if(!$testimonial) return __('Testimonial not updated.', 'testimonials-widget');
132
+ if(!$testimonial_id) return srgq_addtestimonial($testimonial, $author, $source, $public);
133
+ global $wpdb;
134
+ $table_name = $wpdb->prefix . "testimonialswidget";
135
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
136
+ return __('Database table not found', 'testimonials-widget');
137
+ else //Update database
138
+ {
139
+ $testimonial = trim( stripslashes($testimonial) );
140
+ $author = trim( stripslashes($author) );
141
+ $source = trim( stripslashes($source) );
142
+ $tags = trim( stripslashes($tags) );
143
+
144
+ $testimonial = "'".$wpdb->escape($testimonial)."'";
145
+ $author = $author?"'".$wpdb->escape($author)."'":"NULL";
146
+ $source = $source?"'".$wpdb->escape($source)."'":"NULL";
147
+ $tags = explode(',', $tags);
148
+ foreach ($tags as $key => $tag)
149
+ $tags[$key] = trim($tag);
150
+ $tags = implode(',', $tags);
151
+ $tags = $tags?"'".$wpdb->escape($tags)."'":"NULL";
152
+ if(!$public) $public = "'no'";
153
+ else $public = "'yes'";
154
+ $update = "UPDATE " . $table_name . "
155
+ SET testimonial = {$testimonial},
156
+ author = {$author},
157
+ source = {$source},
158
+ tags = {$tags},
159
+ public = {$public},
160
+ time_updated = NOW()
161
+ WHERE testimonial_id = $testimonial_id";
162
+ $results = $wpdb->query( $update );
163
+ if(FALSE === $results)
164
+ return __('There was an error in the MySQL query', 'testimonials-widget');
165
+ else
166
+ return __('Changes saved', 'testimonials-widget');
167
+ }
168
+ }
169
+
170
+
171
+ function testimonialswidget_deletetestimonial($testimonial_id)
172
+ {
173
+ if($testimonial_id) {
174
+ global $wpdb;
175
+ $sql = "DELETE from " . $wpdb->prefix ."testimonialswidget" .
176
+ " WHERE testimonial_id = " . $testimonial_id;
177
+ if(FALSE === $wpdb->query($sql))
178
+ return __('There was an error in the MySQL query', 'testimonials-widget');
179
+ else
180
+ return __('Testimonial deleted', 'testimonials-widget');
181
+ }
182
+ else return __('The testimonial cannot be deleted', 'testimonials-widget');
183
+ }
184
+
185
+ function testimonialswidget_gettestimonialdata($testimonial_id)
186
+ {
187
+ global $wpdb;
188
+ $sql = "SELECT testimonial_id, testimonial, author, source, tags, public
189
+ FROM " . $wpdb->prefix . "testimonialswidget
190
+ WHERE testimonial_id = {$testimonial_id}";
191
+ $testimonial_data = $wpdb->get_row($sql, ARRAY_A);
192
+ return $testimonial_data;
193
+ }
194
+
195
+ function testimonialswidget_editform($testimonial_id = 0)
196
+ {
197
+ $public_selected = " checked=\"checked\"";
198
+ $submit_value = __('Add Testimonial', 'testimonials-widget');
199
+ $form_name = "addtestimonial";
200
+ $action_url = get_bloginfo('wpurl')."/wp-admin/admin.php?page=testimonials-widget#addnew";
201
+ $testimonial = $author = $source = $tags = $hidden_input = $back = "";
202
+
203
+ if($testimonial_id) {
204
+ $form_name = "edittestimonial";
205
+ $testimonial_data = testimonialswidget_gettestimonialdata($testimonial_id);
206
+ foreach($testimonial_data as $key => $value)
207
+ $testimonial_data[$key] = $testimonial_data[$key];
208
+ extract($testimonial_data);
209
+ $testimonial = htmlspecialchars($testimonial);
210
+ $author = htmlspecialchars($author);
211
+ $source = htmlspecialchars($source);
212
+ $tags = implode(', ', explode(',', $tags));
213
+ $hidden_input = "<input type=\"hidden\" name=\"testimonial_id\" value=\"{$testimonial_id}\" />";
214
+ if($public == 'no') $public_selected = "";
215
+ $submit_value = __('Save changes', 'testimonials-widget');
216
+ $back = "<input type=\"submit\" name=\"submit\" value=\"".__('Back', 'testimonials-widget')."\" />&nbsp;";
217
+ $action_url = get_bloginfo('wpurl')."/wp-admin/admin.php?page=testimonials-widget";
218
+ }
219
+
220
+ $testimonial_label = __('The testimonial', 'testimonials-widget');
221
+ $author_label = __('Author', 'testimonials-widget');
222
+ $source_label = __('Source', 'testimonials-widget');
223
+ $tags_label = __('Tags', 'testimonials-widget');
224
+ $public_label = __('Public?', 'testimonials-widget');
225
+ $optional_text = __('optional', 'testimonials-widget');
226
+ $url_text = __('email address or website URL', 'testimonials-widget');
227
+ $comma_separated_text = __('comma separated', 'testimonials-widget');
228
+
229
+
230
+ $display =<<< EDITFORM
231
+ <form name="{$form_name}" method="post" action="{$action_url}">
232
+ {$hidden_input}
233
+ <table class="form-table" cellpadding="5" cellspacing="2" width="100%">
234
+ <tbody><tr class="form-field form-required">
235
+ <th style="text-align:left;" scope="row" valign="top"><label for="testimonialswidget_testimonial">{$testimonial_label}</label></th>
236
+ <td><textarea id="testimonialswidget_testimonial" name="testimonial" rows="5" cols="50" style="width: 97%;">{$testimonial}</textarea></td>
237
+ </tr>
238
+ <tr class="form-field">
239
+ <th style="text-align:left;" scope="row" valign="top"><label for="testimonialswidget_author">{$author_label}</label></th>
240
+ <td><input type="text" id="testimonialswidget_author" name="author" size="40" value="{$author}" /><br />{$optional_text}</td>
241
+ </tr>
242
+ <tr class="form-field">
243
+ <th style="text-align:left;" scope="row" valign="top"><label for="testimonialswidget_source">{$source_label}</label></th>
244
+ <td><input type="text" id="testimonialswidget_source" name="source" size="40" value="{$source}" /><br />{$optional_text}, {$url_text}</td>
245
+ </tr>
246
+ <tr class="form-field">
247
+ <th style="text-align:left;" scope="row" valign="top"><label for="testimonialswidget_tags">{$tags_label}</label></th>
248
+ <td><input type="text" id="testimonialswidget_tags" name="tags" size="40" value="{$tags}" /><br />{$optional_text}, {$comma_separated_text}</small></td>
249
+ </tr>
250
+ <tr>
251
+ <th style="text-align:left;" scope="row" valign="top"><label for="testimonialswidget_public">{$public_label}</label></th>
252
+ <td><input type="checkbox" id="testimonialswidget_public" name="public"{$public_selected} />
253
+ </tr></tbody>
254
+ </table>
255
+ <p class="submit"><input name="submit" value="{$submit_value}" type="submit" class="button button-primary" />{$back}</p>
256
+ </form>
257
+ EDITFORM;
258
+ return $display;
259
+ }
260
+
261
+ function testimonialswidget_changevisibility($testimonial_ids, $public = 'yes')
262
+ {
263
+ if(!$testimonial_ids)
264
+ return __('Nothing done!', 'testimonials-widget');
265
+ global $wpdb;
266
+ $sql = "UPDATE ".$wpdb->prefix."testimonialswidget
267
+ SET public = '".$public."',
268
+ time_updated = NOW()
269
+ WHERE testimonial_id IN (".implode(', ', $testimonial_ids).")";
270
+ $wpdb->query($sql);
271
+ if($public == 'yes')
272
+ return __("Selected testimonials made public", 'testimonials-widget');
273
+ else
274
+ return __("Selected testimonials made private", 'testimonials-widget');
275
+ }
276
+
277
+ function testimonialswidget_bulkdelete($testimonial_ids)
278
+ {
279
+ if(!$testimonial_ids)
280
+ return __('Nothing done!', 'testimonials-widget');
281
+ global $wpdb;
282
+ $sql = "DELETE FROM ".$wpdb->prefix."testimonialswidget
283
+ WHERE testimonial_id IN (".implode(', ', $testimonial_ids).")";
284
+ $wpdb->query($sql);
285
+ return __('Testimonial(s) deleted', 'testimonials-widget');
286
+ }
287
+
288
+
289
+ function testimonialswidget_testimonials_management()
290
+ {
291
+
292
+ global $testimonialswidget_db_version;
293
+ $options = get_option('testimonialswidget');
294
+ $display = $msg = $testimonials_list = $alternate = "";
295
+
296
+ if($options['db_version'] != $testimonialswidget_db_version )
297
+ testimonialswidget_install();
298
+
299
+ if(isset($_REQUEST['submit'])) {
300
+ if($_REQUEST['submit'] == __('Add Testimonial', 'testimonials-widget')) {
301
+ extract($_REQUEST);
302
+ $msg = testimonialswidget_addtestimonial($testimonial, $author, $source, $tags, $public);
303
+ }
304
+ else if($_REQUEST['submit'] == __('Save changes', 'testimonials-widget')) {
305
+ extract($_REQUEST);
306
+ $msg = testimonialswidget_edittestimonial($testimonial_id, $testimonial, $author, $source, $tags, $public);
307
+ }
308
+ }
309
+ else if(isset($_REQUEST['action'])) {
310
+ if($_REQUEST['action'] == 'edittestimonial') {
311
+ $display .= "<div class=\"wrap\">\n<h2>Testimonials Widget &raquo; ".__('Edit testimonial', 'testimonials-widget')."</h2>";
312
+ $display .= testimonialswidget_editform($_REQUEST['id']);
313
+ $display .= "</div>";
314
+ echo $display;
315
+ return;
316
+ }
317
+ else if($_REQUEST['action'] == 'deltestimonial') {
318
+ $msg = testimonialswidget_deletetestimonial($_REQUEST['id']);
319
+ }
320
+ }
321
+ else if(isset($_REQUEST['bulkactionsubmit'])) {
322
+ if($_REQUEST['bulkaction'] == 'delete')
323
+ $msg = testimonialswidget_bulkdelete($_REQUEST['bulkcheck']);
324
+ if($_REQUEST['bulkaction'] == 'make_public') {
325
+ $msg = testimonialswidget_changevisibility($_REQUEST['bulkcheck'], 'yes');
326
+ }
327
+ if($_REQUEST['bulkaction'] == 'keep_private') {
328
+ $msg = testimonialswidget_changevisibility($_REQUEST['bulkcheck'], 'no');
329
+ }
330
+ }
331
+
332
+ $display .= "<div class=\"wrap\">";
333
+
334
+ if($msg)
335
+ $display .= "<div id=\"message\" class=\"updated fade\"><p>{$msg}</p></div>";
336
+
337
+ $display .= "<h2>Testimonials Widget <a href=\"#addnew\" class=\"add-new-h2\">".__('Add new testimonial', 'testimonials-widget')."</a></h2>";
338
+
339
+ $num_testimonials = testimonialswidget_count();
340
+
341
+ if(!$num_testimonials) {
342
+ $display .= "<p>".__('No testimonials in the database', 'testimonials-widget')."</p>";
343
+
344
+ $display .= "</div>";
345
+
346
+ $display .= "<div id=\"addnew\" class=\"wrap\">\n<h2>".__('Add new testimonial', 'testimonials-widget')."</h2>";
347
+ $display .= testimonialswidget_editform();
348
+ $display .= "</div>";
349
+
350
+ echo $display;
351
+ return;
352
+ }
353
+
354
+ global $wpdb;
355
+
356
+ $sql = "SELECT testimonial_id, testimonial, author, source, tags, public
357
+ FROM " . $wpdb->prefix . "testimonialswidget";
358
+
359
+ $option_selected = array (
360
+ 'testimonial_id' => '',
361
+ 'testimonial' => '',
362
+ 'author' => '',
363
+ 'source' => '',
364
+ 'time_added' => '',
365
+ 'time_updated' => '',
366
+ 'public' => '',
367
+ 'ASC' => '',
368
+ 'DESC' => '',
369
+ );
370
+ if(isset($_REQUEST['orderby'])) {
371
+ $sql .= " ORDER BY " . $_REQUEST['orderby'] . " " . $_REQUEST['order'];
372
+ $option_selected[$_REQUEST['orderby']] = " selected=\"selected\"";
373
+ $option_selected[$_REQUEST['order']] = " selected=\"selected\"";
374
+ }
375
+ else {
376
+ $sql .= " ORDER BY testimonial_id DESC";
377
+ $option_selected['testimonial_id'] = " selected=\"selected\"";
378
+ $option_selected['DESC'] = " selected=\"selected\"";
379
+ }
380
+
381
+ if(isset($_REQUEST['paged']) && $_REQUEST['paged'] && is_numeric($_REQUEST['paged']))
382
+ $paged = $_REQUEST['paged'];
383
+ else
384
+ $paged = 1;
385
+
386
+ $limit_per_page = 20;
387
+ $total_pages = ceil($num_testimonials / $limit_per_page);
388
+
389
+ if($paged > $total_pages) $paged = $total_pages;
390
+
391
+ $admin_url = get_bloginfo('wpurl'). "/wp-admin/admin.php?page=testimonials-widget";
392
+ if(isset($_REQUEST['orderby']))
393
+ $admin_url .= "&orderby=".$_REQUEST['orderby']."&order=".$_REQUEST['order'];
394
+
395
+ $page_nav = testimonialswidget_pagenav($total_pages, $paged, 2, 'paged', $admin_url);
396
+
397
+ $start = ($paged - 1) * $limit_per_page;
398
+
399
+ $sql .= " LIMIT {$start}, {$limit_per_page}";
400
+
401
+ // Get all the testimonials from the database
402
+ $testimonials = $wpdb->get_results($sql);
403
+
404
+ foreach($testimonials as $testimonial_data) {
405
+ if($alternate) $alternate = "";
406
+ else $alternate = " class=\"alternate\"";
407
+ $testimonials_list .= "<tr{$alternate}>";
408
+ $testimonials_list .= "<th scope=\"row\" class=\"check-column\"><input type=\"checkbox\" name=\"bulkcheck[]\" value=\"".$testimonial_data->testimonial_id."\" /></th>";
409
+ $testimonials_list .= "<td>" . $testimonial_data->testimonial_id . "</td>";
410
+ $testimonials_list .= "<td>";
411
+ $testimonials_list .= wptexturize(nl2br(make_clickable($testimonial_data->testimonial)));
412
+ $testimonials_list .= "<div class=\"row-actions\"><span class=\"edit\"><a href=\"{$admin_url}&action=edittestimonial&amp;id=".$testimonial_data->testimonial_id."\" class=\"edit\">".__('Edit', 'testimonials-widget')."</a></span> | <span class=\"trash\"><a href=\"{$admin_url}&action=deltestimonial&amp;id=".$testimonial_data->testimonial_id."\" onclick=\"return confirm( '".__('Are you sure you want to delete this testimonial?', 'testimonials-widget')."');\" class=\"delete\">".__('Delete', 'testimonials-widget')."</a></span></div>";
413
+ $testimonials_list .= "</td>";
414
+ $testimonials_list .= "<td>" . make_clickable($testimonial_data->author);
415
+ if($testimonial_data->author && $testimonial_data->source)
416
+ $testimonials_list .= " / ";
417
+ $testimonials_list .= make_clickable($testimonial_data->source) ."</td>";
418
+ $testimonials_list .= "<td>" . implode(', ', explode(',', $testimonial_data->tags)) . "</td>";
419
+ if($testimonial_data->public == 'no') $public = __('No', 'testimonials-widget');
420
+ else $public = __('Yes', 'testimonials-widget');
421
+ $testimonials_list .= "<td>" . $public ."</td>";
422
+ $testimonials_list .= "</tr>";
423
+ }
424
+
425
+ if($testimonials_list) {
426
+ $testimonials_count = testimonialswidget_count();
427
+
428
+ $display .= "<form id=\"testimonialswidget\" method=\"post\" action=\"".get_bloginfo('wpurl')."/wp-admin/admin.php?page=testimonials-widget\">";
429
+ $display .= "<div class=\"tablenav\">";
430
+ $display .= "<div class=\"alignleft actions\">";
431
+ $display .= "<select name=\"bulkaction\">";
432
+ $display .= "<option value=\"0\">".__('Bulk Actions', 'testimonials-widget')."</option>";
433
+ $display .= "<option value=\"delete\">".__('Delete', 'testimonials-widget')."</option>";
434
+ $display .= "<option value=\"make_public\">".__('Make public', 'testimonials-widget')."</option>";
435
+ $display .= "<option value=\"keep_private\">".__('Keep private', 'testimonials-widget')."</option>";
436
+ $display .= "</select>";
437
+ $display .= "<input type=\"submit\" name=\"bulkactionsubmit\" value=\"".__('Apply', 'testimonials-widget')."\" class=\"button-secondary\" />";
438
+ $display .= "&nbsp;&nbsp;&nbsp;";
439
+ $display .= __('Sort by: ', 'testimonials-widget');
440
+ $display .= "<select name=\"orderby\">";
441
+ $display .= "<option value=\"testimonial_id\"{$option_selected['testimonial_id']}>".__('Testimonial', 'testimonials-widget')." ID</option>";
442
+ $display .= "<option value=\"testimonial\"{$option_selected['testimonial']}>".__('Testimonial', 'testimonials-widget')."</option>";
443
+ $display .= "<option value=\"author\"{$option_selected['author']}>".__('Author', 'testimonials-widget')."</option>";
444
+ $display .= "<option value=\"source\"{$option_selected['source']}>".__('Source', 'testimonials-widget')."</option>";
445
+ $display .= "<option value=\"time_added\"{$option_selected['time_added']}>".__('Date added', 'testimonials-widget')."</option>";
446
+ $display .= "<option value=\"time_updated\"{$option_selected['time_updated']}>".__('Date updated', 'testimonials-widget')."</option>";
447
+ $display .= "<option value=\"public\"{$option_selected['public']}>".__('Visibility', 'testimonials-widget')."</option>";
448
+ $display .= "</select>";
449
+ $display .= "<select name=\"order\"><option{$option_selected['ASC']}>ASC</option><option{$option_selected['DESC']}>DESC</option></select>";
450
+ $display .= "<input type=\"submit\" name=\"orderbysubmit\" value=\"".__('Go', 'testimonials-widget')."\" class=\"button-secondary\" />";
451
+ $display .= "</div>";
452
+ $display .= '<div class="tablenav-pages"><span class="displaying-num">'.sprintf(_n('%d testimonials', '%d testimonials', $testimonials_count, 'testimonials-widget'), $testimonials_count).'</span><span class="pagination-links">'. $page_nav. "</span></div>";
453
+ $display .= "<div class=\"clear\"></div>";
454
+ $display .= "</div>";
455
+
456
+ $display .= "<table class=\"widefat\">";
457
+ $display .= "<thead><tr>
458
+ <th class=\"check-column\"><input type=\"checkbox\" onclick=\"testimonialswidget_checkAll(document.getElementById('testimonialswidget'));\" /></th>
459
+ <th>ID</th><th>".__('The testimonial', 'testimonials-widget')."</th>
460
+ <th>
461
+ ".__('Author', 'testimonials-widget')." / ".__('Source', 'testimonials-widget')."
462
+ </th>
463
+ <th>".__('Tags', 'testimonials-widget')."</th>
464
+ <th>".__('Public?', 'testimonials-widget')."</th>
465
+ </tr></thead>";
466
+ $display .= "<tbody id=\"the-list\">{$testimonials_list}</tbody>";
467
+ $display .= "</table>";
468
+
469
+ $display .= "<div class=\"tablenav\">";
470
+ $display .= '<div class="tablenav-pages"><span class="displaying-num">'.sprintf(_n('%d testimonials', '%d testimonials', $testimonials_count, 'testimonials-widget'), $testimonials_count).'</span><span class="pagination-links">'. $page_nav. "</span></div>";
471
+ $display .= "<div class=\"clear\"></div>";
472
+ $display .= "</div>";
473
+
474
+ $display .= "</form>";
475
+ $display .= "<br style=\"clear:both;\" />";
476
+
477
+ }
478
+ else
479
+ $display .= "<p>".__('No testimonials in the database', 'testimonials-widget')."</p>";
480
+
481
+ $display .= "</div>";
482
+
483
+ $display .= "<div id=\"addnew\" class=\"wrap\">\n<h2>".__('Add new testimonial', 'testimonials-widget')."</h2>";
484
+ $display .= testimonialswidget_editform();
485
+ $display .= "</div>";
486
+
487
+
488
+ echo $display;
489
+
490
+ }
491
+
492
+
493
+ function testimonialswidget_admin_footer()
494
+ {
495
+ ?>
496
+ <script type="text/javascript">
497
+ function testimonialswidget_checkAll(form) {
498
+ for (i = 0, n = form.elements.length; i < n; i++) {
499
+ if(form.elements[i].type == "checkbox" && !(form.elements[i].hasAttribute('onclick'))) {
500
+ if(form.elements[i].checked == true)
501
+ form.elements[i].checked = false;
502
+ else
503
+ form.elements[i].checked = true;
504
+ }
505
+ }
506
+ }
507
+ </script>
508
+
509
+ <?php
510
+ }
511
+
512
+ add_action('admin_footer', 'testimonialswidget_admin_footer');
513
+
514
+ ?>
testimonials-widget-widget.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Add function to widgets_init that'll load our widget.
4
+ */
5
+ add_action( 'widgets_init', 'testimonials_widgets' );
6
+
7
+ /*
8
+ * Register widget.
9
+ */
10
+ function testimonials_widgets() {
11
+ register_widget( 'Testimonials_Widget' );
12
+ load_plugin_textdomain( 'testimonials-widget', null, '/testimonials-widget/languages/' );
13
+ }
14
+
15
+ /*
16
+ * Widget class.
17
+ */
18
+ class testimonials_widget extends WP_Widget {
19
+ /* ---------------------------- */
20
+ /* -------- Widget setup -------- */
21
+ /* ---------------------------- */
22
+ function Testimonials_Widget() {
23
+ /* Widget settings. */
24
+ $widget_ops = array( 'classname' => 'testimonials_widget', 'description' => __('Testimonial widget plugin allows you display testimonials in a sidebar on your WordPress blog.', 'testimonials-widget') );
25
+
26
+ /* Widget control settings. */
27
+ $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'testimonials_widget' );
28
+
29
+ /* Create the widget. */
30
+ $this->WP_Widget( 'testimonials_widget', __('Testimonials Widget', 'testimonials-widget'), $widget_ops, $control_ops );
31
+ }
32
+
33
+ /* ---------------------------- */
34
+ /* ------- Display Widget -------- */
35
+ /* ---------------------------- */
36
+ function widget( $args, $instance ) {
37
+ extract( $args );
38
+
39
+ /* Our variables from the widget settings. */
40
+ $title = apply_filters('the_title', $instance['title']);
41
+ $min_height = $instance['min_height'];
42
+ $show_author = $instance['show_author'];
43
+ $show_source = $instance['show_source'];
44
+ $random_order = $instance['random_order'];
45
+ $refresh_interval = $instance['refresh_interval'];
46
+ $char_limit = $instance['char_limit'];
47
+ $tags = $instance['tags'];
48
+
49
+ $testimonials = testimonialswidget_display_testimonials($title, $random_order, $min_height, $refresh_interval, $show_source, $show_author, $tags, $char_limit, $this->number);
50
+
51
+ /* Before widget (defined by themes). */
52
+ echo $before_widget;
53
+
54
+ /* Display the widget title if one was input (before and after defined by themes). */
55
+ if ( $title )
56
+ echo $before_title . $title . $after_title;
57
+
58
+ /* Display Widget */
59
+ echo $testimonials;
60
+
61
+ /* After widget (defined by themes). */
62
+ echo $after_widget;
63
+ }
64
+
65
+ /* ---------------------------- */
66
+ /* ------- Update Widget -------- */
67
+ /* ---------------------------- */
68
+ function update( $new_instance, $old_instance ) {
69
+ $instance = $old_instance;
70
+
71
+ $instance['title'] = strip_tags(stripslashes($new_instance['title']));
72
+ $instance['min_height'] = strip_tags(stripslashes($new_instance['min_height']));
73
+ $instance['show_author'] = (isset($new_instance['show_author']) && $new_instance['show_author'])?1:0;
74
+ $instance['show_source'] = (isset($new_instance['show_source']) && $new_instance['show_source'])?1:0;
75
+ $instance['refresh_interval'] = strip_tags(stripslashes($new_instance['refresh_interval']));
76
+ $instance['random_order'] = (isset($new_instance['random_order']) && $new_instance['random_order'])?1:0;
77
+ $instance['tags'] = strip_tags(stripslashes($new_instance['tags']));
78
+ $instance['char_limit'] = strip_tags(stripslashes($new_instance['char_limit']));
79
+ if(!$instance['char_limit'])
80
+ $instance['char_limit'] = __('none', 'testimonials-widget');
81
+
82
+ return $instance;
83
+ }
84
+
85
+ /* ---------------------------- */
86
+ /* ------- Widget Settings ------- */
87
+ /* ---------------------------- */
88
+
89
+ /**
90
+ * Displays the widget settings controls on the widget panel.
91
+ * Make use of the get_field_id() and get_field_name() function
92
+ * when creating your form elements. This handles the confusing stuff.
93
+ */
94
+ function form( $instance ) {
95
+ /* Set up some default widget settings. */
96
+ $defaults = array(
97
+ 'title' => __('Testimonials', 'testimonials-widget'),
98
+ 'min_height' => 150,
99
+ 'show_author' => 1,
100
+ 'show_source' => 1,
101
+ 'random_order' => 1,
102
+ 'refresh_interval' => 10,
103
+ 'tags' => '',
104
+ 'char_limit' => 500
105
+ );
106
+ $instance = wp_parse_args( (array) $instance, $defaults );
107
+
108
+ // Now we define the display of widget options menu
109
+ $show_author_checked = $show_source_checked = $random_order_checked = '';
110
+ if($instance['show_author'])
111
+ $show_author_checked = ' checked="checked"';
112
+ if($instance['show_source'])
113
+ $show_source_checked = ' checked="checked"';
114
+ if($instance['random_order'])
115
+ $random_order_checked = ' checked="checked"';
116
+
117
+ echo '<p><label for="'.$this->get_field_id( 'title' ).'">'.__('Title', 'testimonials-widget').' </label><input class="widefat" type="text" id="'.$this->get_field_id( 'title' ).'" name="'.$this->get_field_name( 'title' ).'" value="'.htmlspecialchars($instance['title'], ENT_QUOTES).'" /></p>';
118
+ echo '<p><label for="'.$this->get_field_id( 'min_height' ).'">'.__('Minimum Height', 'testimonials-widget').' </label><input class="widefat" type="text" id="'.$this->get_field_id( 'min_height' ).'" name="'.$this->get_field_name( 'min_height' ).'" value="'.htmlspecialchars($instance['min_height'], ENT_QUOTES).'" /><br/><span class="setting-description"><small>'.__('Minimum height in px, this must be set to a value that suits your logest testimonial (increase this value if you find that your testimonials are getting cut off).', 'testimonials-widget').'</small></span></p>';
119
+ echo '<p><input type="checkbox" id="'.$this->get_field_id( 'show_author' ).'" name="'.$this->get_field_name( 'show_author' ).'" value="1"'.$show_author_checked.' /> <label for="'.$this->get_field_id( 'show_author' ).'">'.__('Show author?', 'testimonials-widget').'</label></p>';
120
+ echo '<p><input type="checkbox" id="'.$this->get_field_id( 'show_source' ).'" name="'.$this->get_field_name( 'show_source' ).'" value="1"'.$show_source_checked.' /> <label for="'.$this->get_field_id( 'show_source' ).'">'.__('Show source?', 'testimonials-widget').'</label></p>';
121
+ echo "<p style=\"text-align:left;\"><small><a id=\"".$this->get_field_id( 'adv_key' )."\" style=\"cursor:pointer;\" onclick=\"jQuery('div#".$this->get_field_id( 'adv_opts' )."').slideToggle();\">".__('Advanced options', 'testimonials-widget')." &raquo;</a></small></p>";
122
+ echo '<div id="'.$this->get_field_id( 'adv_opts' ).'" style="display:none">';
123
+ echo '<p><label for="'.$this->get_field_id( 'refresh_interval' ).'">'.__('Refresh Interval', 'testimonials-widget').' </label><input class="widefat" type="text" id="'.$this->get_field_id( 'refresh_interval' ).'" name="'.$this->get_field_name( 'refresh_interval' ).'" value="'.htmlspecialchars($instance['refresh_interval'], ENT_QUOTES).'" /><br/><span class="setting-description"><small>'.__('In seconds or 0 for no refresh.', 'testimonials-widget').'</small></span></p>';
124
+ echo '<p><input type="checkbox" id="'.$this->get_field_id( 'random_order' ).'" name="'.$this->get_field_name( 'random_order' ).'" value="1"'.$random_order_checked.' /> <label for="'.$this->get_field_id( 'random_order' ).'">'.__('Random order', 'testimonials-widget').'</label><br/><span class="setting-description"><small>'.__('Unchecking this will rotate testimonials in the order added, latest first.', 'testimonials-widget').'</small></span></p>';
125
+ echo '<p><label for="'.$this->get_field_id( 'tags' ).'">'.__('Tags filter', 'testimonials-widget').' </label><input class="widefat" type="text" id="'.$this->get_field_id( 'tags' ).'" name="'.$this->get_field_name( 'tags' ).'" value="'.htmlspecialchars($instance['tags'], ENT_QUOTES).'" /><br/><span class="setting-description"><small>'.__('Comma separated', 'testimonials-widget').'</small></span></p>';
126
+ echo '<p><label for="'.$this->get_field_id( 'char_limit' ).'">'.__('Character limit', 'testimonials-widget').' </label><input class="widefat" type="text" id="'.$this->get_field_id( 'char_limit' ).'" name="'.$this->get_field_name( 'char_limit' ).'" value="'.htmlspecialchars($instance['char_limit'], ENT_QUOTES).'" /></p>';
127
+ echo '</div>';
128
+ }
129
+ }
130
+ ?>
testimonials-widget.css ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Random quote */
2
+ .testimonialswidget_testimonial q {
3
+ }
4
+
5
+ .testimonialswidget_testimonial cite {
6
+ display:block; /* To display author and source in a new line */
7
+ text-align:right;
8
+ }
9
+
10
+ .testimonialswidget_testimonial { /* author */
11
+ font-style:normal;
12
+ }
13
+
14
+ .testimonialswidget_testimonial { /* source */
15
+ font-style: italic;
16
+ }
17
+
18
+
19
+ /* See http://www.w3schools.com/css/pr_gen_quotes.asp */
20
+ q:lang(en)
21
+ {
22
+ quotes: "“" "”" "‘" "’";
23
+ }
24
+
25
+ /* Uncomment the block below if you want to get rid of the quotation marks before and after the quote */
26
+ /*
27
+ q:before, q:after {
28
+ content:"";
29
+ }
30
+ */
31
+
32
+ .testimonialswidget_testimonials {
33
+ position: relative;
34
+ }
35
+ .testimonialswidget_testimonial {
36
+ position: absolute;
37
+ top: 0;
38
+ left: 0;
39
+ display: none;
40
+ }
41
+ .testimonialswidget_testimonials .testimonialswidget_active {
42
+ display: block;
43
+ }
44
+ .testimonialswidget_testimonials p {
45
+ margin: 0 0 1em;
46
+ }
47
+ h4.testimonialswidget {
48
+ margin: 0;
49
+ }
testimonials-widget.php ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Testimonials Widget
4
+ Description: Testimonial widget plugin helps you display testimonials in a widget on your WordPress blog.
5
+ Version: 0.2.2
6
+ Author: comprock, j0hnsmith
7
+ License: GPL2
8
+ */
9
+
10
+ /* Copyright 2011 j0hnsmith
11
+
12
+ This program is free software; you can redistribute it and/or modify
13
+ it under the terms of the GNU General Public License as published by
14
+ the Free Software Foundation; either version 2 of the License, or
15
+ (at your option) any later version.
16
+
17
+ This program is distributed in the hope that it will be useful,
18
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ GNU General Public License for more details.
21
+
22
+ You should have received a copy of the GNU General Public License
23
+ along with this program; if not, write to the Free Software
24
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
+ */
26
+
27
+ /* This plugin borrows code from the Quotes Collection plugin by Srini G
28
+ http://srinig.com/wordpress/plugins/quotes-collection/
29
+
30
+ Additional contributions from comprock and ChrisCree
31
+ */
32
+
33
+
34
+ /* Refer http://codex.wordpress.org/Roles_and_Capabilities */
35
+ $testimonialswidget_admin_userlevel = 'edit_posts';
36
+
37
+ $testimonialswidget_db_version = '0.1';
38
+
39
+
40
+ require_once('testimonials-widget-widget.php');
41
+ require_once('testimonials-widget-admin.php');
42
+
43
+
44
+ function testimonialswidget_display_testimonials($title = '', $random = 1, $min_height, $refresh_interval = 10, $show_source = 0, $show_author = 1, $tags = '', $char_limit = 500, $widget_number = '') {
45
+ $conditions = " WHERE public = 'yes'";
46
+
47
+ if(char_limit && is_numeric($char_limit)) {
48
+ $conditions .= " AND CHAR_LENGTH(testimonial) <= ".$char_limit;
49
+ } else {
50
+ $options['char_limit'] = 0;
51
+ }
52
+
53
+ if($tags) {
54
+ $taglist = explode(',', $tags);
55
+ $tag_conditions = '';
56
+ foreach($taglist as $tag) {
57
+ $tag = mysql_real_escape_string(strip_tags(trim($tag)));
58
+ if($tag_conditions) $tag_conditions .= " OR ";
59
+ $tag_conditions .= "tags = '{$tag}'";
60
+ }
61
+ $conditions .= " AND ({$tag_conditions})";
62
+ }
63
+
64
+ if($random) {
65
+ $conditions .= " ORDER BY RAND()";
66
+ } else {
67
+ $conditions .= " ORDER BY testimonial_id DESC";
68
+ }
69
+
70
+ if ( 0 == $refresh_interval )
71
+ $conditions .= " LIMIT 1";
72
+
73
+ $testimonials = testimonialswidget_get_testimonials($conditions);
74
+
75
+ $min_height .= 'px';
76
+ $id = 'testimonialswidget_testimonials';
77
+ $id_base = $id . $widget_number;
78
+ $html = <<<EOF
79
+ <style>
80
+ .$id_base {
81
+ min-height: $min_height;
82
+ }
83
+ </style>
84
+ EOF;
85
+ if ( 0 != $refresh_interval ) {
86
+ $html .= <<<EOF
87
+ <script type="text/javascript">
88
+ function nextTestimonial$widget_number() {
89
+ if (!jQuery('.$id_base').first().hasClass('hovered')) {
90
+ var active = jQuery('.$id_base .testimonialswidget_active');
91
+ var next = (jQuery('.$id_base .testimonialswidget_active').next().length > 0) ? jQuery('.$id_base .testimonialswidget_active').next() : jQuery('.$id_base .testimonialswidget_testimonial:first');
92
+ active.fadeOut(1250, function(){
93
+ active.removeClass('testimonialswidget_active');
94
+ next.fadeIn(500);
95
+ next.addClass('testimonialswidget_active');
96
+ });
97
+ }
98
+ }
99
+
100
+ jQuery(document).ready(function(){
101
+ jQuery('.$id_base').hover(function() { jQuery(this).addClass('hovered') }, function() { jQuery(this).removeClass('hovered') });
102
+ setInterval('nextTestimonial$widget_number()', $refresh_interval * 1000);
103
+ });
104
+ </script>
105
+ EOF;
106
+ }
107
+
108
+ $html .= '<div class="'.$id.' '.$id_base.'">';
109
+ $first = true;
110
+
111
+ foreach ($testimonials as $testimonial) {
112
+
113
+ if (!$first) {
114
+ $html .= '<div class="testimonialswidget_testimonial">';
115
+ } else {
116
+ $html .= '<div class="testimonialswidget_testimonial testimonialswidget_active">';
117
+ $first = false;
118
+ }
119
+ $html .= "<p><q>". make_clickable( $testimonial['testimonial'] ) ."</q>";
120
+ $cite = '';
121
+ if($show_author && ! empty( $testimonial['author'] ) )
122
+ $cite = '<span class="testimonialswidget_author">'. make_clickable( $testimonial['author'] ) .'</span>';
123
+
124
+ if($show_source && ! empty( $testimonial['source'] ) ) {
125
+ if($cite) $cite .= ', ';
126
+ $cite .= '<span class="testimonialswidget_source">'. make_clickable( $testimonial['source'] ) .'</span>';
127
+ }
128
+ if($cite) $cite = " <cite>&mdash;&nbsp;{$cite}</cite>";
129
+ $html .= $cite."</p></div>";
130
+
131
+ }
132
+ $html .= '</div>';
133
+
134
+ return $html;
135
+ }
136
+
137
+
138
+ function testimonialswidget_get_testimonials($conditions = '')
139
+ {
140
+ global $wpdb;
141
+ $sql = "SELECT testimonial_id, testimonial, author, source, tags, public
142
+ FROM " . $wpdb->prefix . "testimonialswidget"
143
+ . $conditions;
144
+
145
+ if($testimonials = $wpdb->get_results($sql, ARRAY_A))
146
+ return $testimonials;
147
+ else
148
+ return array();
149
+ }
150
+
151
+
152
+ function testimonialswidget_install()
153
+ {
154
+ global $wpdb;
155
+ $table_name = $wpdb->prefix . "testimonialswidget";
156
+
157
+ if(!defined('DB_CHARSET') || !($db_charset = DB_CHARSET))
158
+ $db_charset = 'utf8';
159
+ $db_charset = "CHARACTER SET ".$db_charset;
160
+ if(defined('DB_COLLATE') && $db_collate = DB_COLLATE)
161
+ $db_collate = "COLLATE ".$db_collate;
162
+
163
+ // if table name already exists
164
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
165
+ $wpdb->query("ALTER TABLE `{$table_name}` {$db_charset} {$db_collate}");
166
+
167
+ $wpdb->query("ALTER TABLE `{$table_name}` MODIFY testimonial TEXT {$db_charset} {$db_collate}");
168
+
169
+ $wpdb->query("ALTER TABLE `{$table_name}` MODIFY author VARCHAR(255) {$db_charset} {$db_collate}");
170
+
171
+ $wpdb->query("ALTER TABLE `{$table_name}` MODIFY source VARCHAR(255) {$db_charset} {$db_collate}");
172
+
173
+ if(!($wpdb->get_results("SHOW COLUMNS FROM {$table_name} LIKE 'tags'"))) {
174
+ $wpdb->query("ALTER TABLE `{$table_name}` ADD `tags` VARCHAR(255) {$db_charset} {$db_collate} AFTER `source`");
175
+ }
176
+ if(!($wpdb->get_results("SHOW COLUMNS FROM {$table_name} LIKE 'public'"))) {
177
+ $wpdb->query("ALTER TABLE `{$table_name}` CHANGE `visible` `public` enum('yes', 'no') DEFAULT 'yes' NOT NULL");
178
+ }
179
+ }
180
+ else {
181
+ //Creating the table ... fresh!
182
+ $sql = "CREATE TABLE " . $table_name . " (
183
+ testimonial_id mediumint(9) NOT NULL AUTO_INCREMENT,
184
+ testimonial TEXT NOT NULL,
185
+ author VARCHAR(255),
186
+ source VARCHAR(255),
187
+ tags VARCHAR(255),
188
+ public enum('yes', 'no') DEFAULT 'yes' NOT NULL,
189
+ time_added datetime NOT NULL,
190
+ time_updated datetime,
191
+ PRIMARY KEY (testimonial_id)
192
+ ) {$db_charset} {$db_collate};";
193
+ $results = $wpdb->query( $sql );
194
+ }
195
+
196
+ global $testimonialswidget_db_version;
197
+ $options = get_option('testimonialswidget');
198
+ $options['db_version'] = $testimonialswidget_db_version;
199
+ update_option('testimonialswidget', $options);
200
+
201
+ }
202
+
203
+
204
+ function testimonialswidget_css_head()
205
+ {
206
+ ?>
207
+ <link rel="stylesheet" type="text/css" href="<?php echo plugins_url(); ?>/testimonials-widget/testimonials-widget.css" />
208
+ <?php
209
+ }
210
+
211
+
212
+ function testimonialswidget_enqueue_scripts()
213
+ {
214
+ wp_enqueue_script('jquery');
215
+ }
216
+
217
+ add_action('wp_head', 'testimonialswidget_css_head' );
218
+ add_action('wp_enqueue_scripts', 'testimonialswidget_enqueue_scripts');
219
+
220
+ register_activation_hook( __FILE__, 'testimonialswidget_install' );
221
+
222
+ function testimonialswidget_init() {
223
+ load_plugin_textdomain( 'testimonials-widget', null, '/testimonials-widget/languages/' );
224
+ }
225
+
226
+ add_action('init', 'testimonialswidget_init');
227
+
228
+ ?>