Version Description
- CSS and JavaScript renaming
-
bottom_text
renamed tobottom-text
-
close_quote
renamed toclose-quote
-
display_none
renamed todisplay-none
-
join_location
renamed tojoin-location
-
join_title
renamed tojoin-title
-
open_quote
renamed toopen-quote
-
testimonialswidget_testimonial
renamed totestimonials-widget-testimonial
-
testimonialswidget_testimonials
renamed totestimonials-widget-testimonials
-
Download this release
Release Info
Developer | comprock |
Plugin | Testimonials Widget |
Version | 2.12.0 |
Comparing to | |
See all releases |
Code changes from version 2.11.3 to 2.12.0
- changelog.txt +32 -0
- languages/testimonials-widget.pot +172 -184
- lib/class-redrokk-metabox-class.php +1433 -0
- lib/class-settings-testimonials-widget.php +1091 -0
- lib/class-testimonials-widget-widget.php +304 -0
- lib/metabox.class.php +0 -1458
- lib/settings.testimonials-widget.php +0 -1070
- lib/testimonials-widget-widget.php +0 -273
- phpcs.ruleset.xml +29 -0
- phpmd.ruleset.xml +24 -0
- project.ruleset.xml +0 -35
- readme.txt +61 -33
- testimonials-widget.css +39 -39
- testimonials-widget.php +690 -614
changelog.txt
CHANGED
@@ -4,6 +4,38 @@
|
|
4 |
|
5 |
= trunk =
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
= 2.11.3 =
|
8 |
* BUGFIX [Can't set featured image](http://wordpress.org/support/topic/cant-set-featured-image-3)
|
9 |
* Begin WordPress coding standard cleanup
|
4 |
|
5 |
= trunk =
|
6 |
|
7 |
+
= 2.12.0 =
|
8 |
+
* Add file headers to lib/class*
|
9 |
+
* Add filter testimonials_widget_widget_options to alter displayed widget options
|
10 |
+
* BUGFIX Correct settings required validation `break 2`
|
11 |
+
* BUGFIX Non-static method Testimonials_Widget::get_testimonials_html() should not be called statically
|
12 |
+
* CSS rename testimonialswidget_testimonial(s) to testimonials-widget-testimonial(s)
|
13 |
+
* Correct static get_testimonials_html, get_testimonials_htmls, widget_options function declaration
|
14 |
+
* Correct static validators call
|
15 |
+
* Explain options inheritance
|
16 |
+
* FEATURE Remove Plugin Data on Deletion? - Delete all Testimonials Widget data and options from database on plugin deletion
|
17 |
+
* FEATURE Settings export/import
|
18 |
+
* Refactor out get_quote and get_cite from get_testimonial_html
|
19 |
+
* Refactor excess settings grab in widget_options
|
20 |
+
* Remove $blank from testimonials_truncate()
|
21 |
+
* Remove unused code
|
22 |
+
* Rename metabox.class.php class-redrokk-metabox-class.php
|
23 |
+
* Rename settings.testimonials-widget.php class-settings-testimonials-widget.php
|
24 |
+
* Rename testimonials-widget-widget.php class-testimonials-widget-widget.php
|
25 |
+
* Revise FAQ
|
26 |
+
* SCREENSHOT 17. Testimonials Widget Settings > Compatibility & Reset tab
|
27 |
+
* Show latest updates notice on activation
|
28 |
+
* Spellcheck readme.txt
|
29 |
+
* Update CSS for WordPress Coding standards
|
30 |
+
* Update FAQ
|
31 |
+
* Update JavaScript for WordPress Coding standards
|
32 |
+
* Update PHP for WordPress Coding Standards
|
33 |
+
* Update POT
|
34 |
+
* Update TODOs
|
35 |
+
* Update premium features
|
36 |
+
* Update rulesets
|
37 |
+
* Use ID for widget
|
38 |
+
|
39 |
= 2.11.3 =
|
40 |
* BUGFIX [Can't set featured image](http://wordpress.org/support/topic/cant-set-featured-image-3)
|
41 |
* Begin WordPress coding standard cleanup
|
languages/testimonials-widget.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the same license as the Testimonials Widget package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Testimonials Widget 2.
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/testimonials-widget\n"
|
7 |
-
"POT-Creation-Date: 2013-04-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -12,625 +12,613 @@ msgstr ""
|
|
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
|
15 |
-
#: lib/settings
|
16 |
msgid "General"
|
17 |
msgstr ""
|
18 |
|
19 |
-
#: lib/settings
|
20 |
msgid "Selection"
|
21 |
msgstr ""
|
22 |
|
23 |
-
#: lib/settings
|
24 |
msgid "Ordering"
|
25 |
msgstr ""
|
26 |
|
27 |
-
#: lib/settings
|
28 |
msgid "Widget"
|
29 |
msgstr ""
|
30 |
|
31 |
-
#: lib/settings
|
32 |
msgid "Post Type"
|
33 |
msgstr ""
|
34 |
|
35 |
-
#: lib/settings
|
36 |
msgid "Compatibility & Reset"
|
37 |
msgstr ""
|
38 |
|
39 |
-
#: lib/settings
|
40 |
msgid "About Testimonials Widget"
|
41 |
msgstr ""
|
42 |
|
43 |
-
#: lib/settings
|
44 |
msgid "Widget Title"
|
45 |
msgstr ""
|
46 |
|
47 |
-
#: lib/settings
|
48 |
-
#: testimonials-widget.php:
|
49 |
msgid "Testimonials"
|
50 |
msgstr ""
|
51 |
|
52 |
-
#: lib/settings
|
53 |
msgid "Title Link"
|
54 |
msgstr ""
|
55 |
|
56 |
-
#: lib/settings
|
57 |
msgid "URL or Post ID to link widget title to. Ex: 123 or http://example.com"
|
58 |
msgstr ""
|
59 |
|
60 |
-
#: lib/settings
|
61 |
msgid "Character Limit"
|
62 |
msgstr ""
|
63 |
|
64 |
-
#: lib/settings
|
65 |
msgid "Number of characters to limit non-single testimonial views to"
|
66 |
msgstr ""
|
67 |
|
68 |
-
#: lib/settings
|
69 |
msgid "Height"
|
70 |
msgstr ""
|
71 |
|
72 |
-
#: lib/settings
|
73 |
msgid "Testimonials height, in pixels. Overrides minimum and maximum height"
|
74 |
msgstr ""
|
75 |
|
76 |
-
#: lib/settings
|
77 |
msgid "Rotation Speed"
|
78 |
msgstr ""
|
79 |
|
80 |
-
#: lib/settings
|
81 |
msgid ""
|
82 |
"Number of seconds between testimonial rotations or 0 for no rotation at all "
|
83 |
"refresh"
|
84 |
msgstr ""
|
85 |
|
86 |
-
#: lib/settings
|
87 |
msgid "Additional Widget Options"
|
88 |
msgstr ""
|
89 |
|
90 |
-
#: lib/settings
|
91 |
msgid "Keep Whitespace?"
|
92 |
msgstr ""
|
93 |
|
94 |
-
#: lib/settings
|
95 |
msgid "Keeps testimonials looking as entered than sans auto-formatting"
|
96 |
msgstr ""
|
97 |
|
98 |
-
#: lib/settings
|
99 |
msgid "Minimum Height"
|
100 |
msgstr ""
|
101 |
|
102 |
-
#: lib/settings
|
103 |
msgid "Set for minimum display height, in pixels"
|
104 |
msgstr ""
|
105 |
|
106 |
-
#: lib/settings
|
107 |
msgid "Maximum Height"
|
108 |
msgstr ""
|
109 |
|
110 |
-
#: lib/settings
|
111 |
msgid "Set for maximum display height, in pixels"
|
112 |
msgstr ""
|
113 |
|
114 |
-
#: lib/settings
|
115 |
msgid "Testimonial Bottom Text"
|
116 |
msgstr ""
|
117 |
|
118 |
-
#: lib/settings
|
119 |
msgid "Custom text or HTML for bottom of testimonials"
|
120 |
msgstr ""
|
121 |
|
122 |
-
#: lib/settings
|
123 |
msgid "General Options"
|
124 |
msgstr ""
|
125 |
|
126 |
-
#: lib/settings
|
127 |
msgid "Hide built-in quotes?"
|
128 |
msgstr ""
|
129 |
|
130 |
-
#: lib/settings
|
131 |
msgid "Remove open and close quote span tags surrounding testimonial content"
|
132 |
msgstr ""
|
133 |
|
134 |
-
#: lib/settings
|
135 |
msgid "Hide \"Testimonials Not Found\"?"
|
136 |
msgstr ""
|
137 |
|
138 |
-
#: lib/settings
|
139 |
msgid "Hide Gravatar Image?"
|
140 |
msgstr ""
|
141 |
|
142 |
-
#: lib/settings
|
143 |
msgid "Hide Image?"
|
144 |
msgstr ""
|
145 |
|
146 |
-
#: lib/settings
|
147 |
msgid "Hide Image in Single View?"
|
148 |
msgstr ""
|
149 |
|
150 |
-
#: lib/settings
|
151 |
msgid "Hide Testimonial Content?"
|
152 |
msgstr ""
|
153 |
|
154 |
-
#: lib/settings
|
155 |
msgid "Hide Author/Source?"
|
156 |
msgstr ""
|
157 |
|
158 |
-
#: lib/settings
|
159 |
msgid "Don't display \"Post Title\" in cite"
|
160 |
msgstr ""
|
161 |
|
162 |
-
#: lib/settings
|
163 |
msgid "Hide Email?"
|
164 |
msgstr ""
|
165 |
|
166 |
-
#: lib/settings
|
167 |
msgid "Hide Title?"
|
168 |
msgstr ""
|
169 |
|
170 |
-
#: lib/settings
|
171 |
msgid "Hide Location?"
|
172 |
msgstr ""
|
173 |
|
174 |
-
#: lib/settings
|
175 |
msgid "Hide Company?"
|
176 |
msgstr ""
|
177 |
|
178 |
-
#: lib/settings
|
179 |
msgid "Hide URL?"
|
180 |
msgstr ""
|
181 |
|
182 |
-
#: lib/settings
|
183 |
msgid "URL Target"
|
184 |
msgstr ""
|
185 |
|
186 |
-
#: lib/settings
|
187 |
-
msgid "
|
188 |
msgstr ""
|
189 |
|
190 |
-
#: lib/settings
|
191 |
msgid "Enable Paging?"
|
192 |
msgstr ""
|
193 |
|
194 |
-
#: lib/settings
|
195 |
msgid "For `[testimonialswidget_list]`"
|
196 |
msgstr ""
|
197 |
|
198 |
-
#: lib/settings
|
199 |
msgid "Disable"
|
200 |
msgstr ""
|
201 |
|
202 |
-
#: lib/settings
|
203 |
msgid "Enable"
|
204 |
msgstr ""
|
205 |
|
206 |
-
#: lib/settings
|
207 |
msgid "Before testimonials"
|
208 |
msgstr ""
|
209 |
|
210 |
-
#: lib/settings
|
211 |
msgid "After testimonials"
|
212 |
msgstr ""
|
213 |
|
214 |
-
#: lib/settings
|
215 |
msgid "Selection Options"
|
216 |
msgstr ""
|
217 |
|
218 |
-
#: lib/settings
|
219 |
msgid "Category Filter"
|
220 |
msgstr ""
|
221 |
|
222 |
-
#: lib/settings
|
223 |
msgid "Comma separated category slug-names. Ex: category-a, another-category"
|
224 |
msgstr ""
|
225 |
|
226 |
-
#: lib/settings
|
227 |
msgid "Tags Filter"
|
228 |
msgstr ""
|
229 |
|
230 |
-
#: lib/settings
|
231 |
msgid "Comma separated tag slug-names. Ex: tag-a, another-tag"
|
232 |
msgstr ""
|
233 |
|
234 |
-
#: lib/settings
|
235 |
msgid "Require All Tags?"
|
236 |
msgstr ""
|
237 |
|
238 |
-
#: lib/settings
|
239 |
msgid "Select only testimonials with all of the given tags"
|
240 |
msgstr ""
|
241 |
|
242 |
-
#: lib/settings
|
243 |
msgid "Include IDs Filter"
|
244 |
msgstr ""
|
245 |
|
246 |
-
#: lib/settings
|
247 |
-
#: lib/settings
|
248 |
msgid "Comma separated testimonial IDs. Ex: 3,1,2"
|
249 |
msgstr ""
|
250 |
|
251 |
-
#: lib/settings
|
252 |
msgid "Exclude IDs Filter"
|
253 |
msgstr ""
|
254 |
|
255 |
-
#: lib/settings
|
256 |
msgid "Limit"
|
257 |
msgstr ""
|
258 |
|
259 |
-
#: lib/settings
|
260 |
msgid "Number of testimonials to select per instance"
|
261 |
msgstr ""
|
262 |
|
263 |
-
#: lib/settings
|
264 |
msgid "Ordering Options"
|
265 |
msgstr ""
|
266 |
|
267 |
-
#: lib/settings
|
268 |
msgid "Random Order?"
|
269 |
msgstr ""
|
270 |
|
271 |
-
#: lib/settings
|
272 |
msgid ""
|
273 |
"If checked, ignores ORDER BY, ORDER BY meta_key, and ORDER BY Order. Widgets "
|
274 |
"are random by default automatically"
|
275 |
msgstr ""
|
276 |
|
277 |
-
#: lib/settings
|
278 |
msgid "ORDER BY"
|
279 |
msgstr ""
|
280 |
|
281 |
-
#: lib/settings
|
282 |
msgid "Used when \"Random Order\" is disabled"
|
283 |
msgstr ""
|
284 |
|
285 |
-
#: lib/settings
|
286 |
msgid "Testimonial ID"
|
287 |
msgstr ""
|
288 |
|
289 |
-
#: lib/settings
|
290 |
msgid "Author"
|
291 |
msgstr ""
|
292 |
|
293 |
-
#: lib/settings
|
294 |
msgid "Date"
|
295 |
msgstr ""
|
296 |
|
297 |
-
#: lib/settings
|
298 |
msgid "Menu Order"
|
299 |
msgstr ""
|
300 |
|
301 |
-
#: lib/settings
|
302 |
msgid "Source"
|
303 |
msgstr ""
|
304 |
|
305 |
-
#: lib/settings
|
306 |
msgid "No order"
|
307 |
msgstr ""
|
308 |
|
309 |
-
#: lib/settings
|
310 |
msgid "ORDER BY meta_key"
|
311 |
msgstr ""
|
312 |
|
313 |
-
#: lib/settings
|
314 |
msgid ""
|
315 |
"Used when \"Random Order\" is disabled and sorting by a testimonials meta "
|
316 |
"key is needed. Overrides ORDER BY"
|
317 |
msgstr ""
|
318 |
|
319 |
-
#: lib/settings
|
320 |
msgid "None"
|
321 |
msgstr ""
|
322 |
|
323 |
-
#: lib/settings
|
324 |
-
#: testimonials-widget.php:
|
325 |
msgid "Title"
|
326 |
msgstr ""
|
327 |
|
328 |
-
#: lib/settings
|
329 |
-
#: testimonials-widget.php:
|
330 |
msgid "Email"
|
331 |
msgstr ""
|
332 |
|
333 |
-
#: lib/settings
|
334 |
-
#: testimonials-widget.php:
|
335 |
msgid "Location"
|
336 |
msgstr ""
|
337 |
|
338 |
-
#: lib/settings
|
339 |
-
#: testimonials-widget.php:
|
340 |
msgid "Company"
|
341 |
msgstr ""
|
342 |
|
343 |
-
#: lib/settings
|
344 |
-
#: testimonials-widget.php:
|
345 |
msgid "URL"
|
346 |
msgstr ""
|
347 |
|
348 |
-
#: lib/settings
|
349 |
msgid "ORDER BY Order"
|
350 |
msgstr ""
|
351 |
|
352 |
-
#: lib/settings
|
353 |
msgid "Descending"
|
354 |
msgstr ""
|
355 |
|
356 |
-
#: lib/settings
|
357 |
msgid "Ascending"
|
358 |
msgstr ""
|
359 |
|
360 |
-
#: lib/settings
|
361 |
msgid "Debug Mode?"
|
362 |
msgstr ""
|
363 |
|
364 |
-
#: lib/settings
|
365 |
msgid "Not implemented yet"
|
366 |
msgstr ""
|
367 |
|
368 |
-
#: lib/settings
|
369 |
msgid "Allow Comments?"
|
370 |
msgstr ""
|
371 |
|
372 |
-
#: lib/settings
|
373 |
msgid ""
|
374 |
"Only affects the Testimonials Widget post edit page. Your theme controls the "
|
375 |
"front-end view."
|
376 |
msgstr ""
|
377 |
|
378 |
-
#: lib/settings
|
379 |
msgid ""
|
380 |
"URL slug-name for <a href=\"%1s\">testimonials archive</a> page. After "
|
381 |
"changing, you must click \"Save Changes\" on <a href=\"%2s\">Permalink "
|
382 |
"Settings</a> to update them."
|
383 |
msgstr ""
|
384 |
|
385 |
-
#: lib/settings
|
386 |
msgid "Archive Page URL"
|
387 |
msgstr ""
|
388 |
|
389 |
-
#: lib/settings
|
390 |
msgid ""
|
391 |
"URL slug-name for testimonial view pages. After changing, you must click "
|
392 |
"\"Save Changes\" on <a href=\"%1s\">Permalink Settings</a> to update them."
|
393 |
msgstr ""
|
394 |
|
395 |
-
#: lib/settings
|
396 |
msgid "Testimonial Page URL"
|
397 |
msgstr ""
|
398 |
|
399 |
-
#: lib/settings
|
400 |
msgid "Compatiblity Options"
|
401 |
msgstr ""
|
402 |
|
403 |
-
#: lib/settings
|
404 |
msgid "Remove `.hentry` CSS?"
|
405 |
msgstr ""
|
406 |
|
407 |
-
#: lib/settings
|
408 |
msgid ""
|
409 |
"Pre 2.6.4. Some themes use class `.hentry` in a manner that breaks "
|
410 |
"Testimonials Widgets CSS"
|
411 |
msgstr ""
|
412 |
|
413 |
-
#: lib/settings
|
414 |
msgid "Use `<q>` tag?"
|
415 |
msgstr ""
|
416 |
|
417 |
-
#: lib/settings
|
418 |
msgid "Pre 2.11.0. Not HTML5 compliant"
|
419 |
msgstr ""
|
420 |
|
421 |
-
#: lib/settings
|
422 |
-
msgid "
|
423 |
-
msgstr ""
|
424 |
-
|
425 |
-
#: lib/settings.testimonials-widget.php:427
|
426 |
-
msgid "Check this box to reset options to their defaults"
|
427 |
-
msgstr ""
|
428 |
-
|
429 |
-
#: lib/settings.testimonials-widget.php:439
|
430 |
-
msgid "Example Text Input"
|
431 |
msgstr ""
|
432 |
|
433 |
-
#: lib/settings
|
434 |
-
msgid "
|
435 |
-
|
436 |
-
|
437 |
-
#: lib/settings.testimonials-widget.php:445
|
438 |
-
msgid "Example Textarea Input"
|
439 |
-
msgstr ""
|
440 |
-
|
441 |
-
#: lib/settings.testimonials-widget.php:446
|
442 |
-
msgid "This is a description for the textarea input."
|
443 |
-
msgstr ""
|
444 |
-
|
445 |
-
#: lib/settings.testimonials-widget.php:452
|
446 |
-
msgid "Example Checkbox"
|
447 |
-
msgstr ""
|
448 |
-
|
449 |
-
#: lib/settings.testimonials-widget.php:453
|
450 |
-
msgid "This is a description for the checkbox."
|
451 |
msgstr ""
|
452 |
|
453 |
-
#: lib/settings
|
454 |
-
msgid "
|
455 |
msgstr ""
|
456 |
|
457 |
-
#: lib/settings
|
458 |
-
msgid "
|
|
|
|
|
|
|
459 |
msgstr ""
|
460 |
|
461 |
-
#: lib/settings
|
462 |
-
msgid "
|
463 |
msgstr ""
|
464 |
|
465 |
-
#: lib/settings
|
466 |
-
msgid "
|
467 |
msgstr ""
|
468 |
|
469 |
-
#: lib/settings
|
470 |
-
#: lib/settings
|
471 |
msgid "Testimonials Widget Settings"
|
472 |
msgstr ""
|
473 |
|
474 |
-
#: lib/settings
|
475 |
msgid "Settings"
|
476 |
msgstr ""
|
477 |
|
478 |
-
#: lib/settings
|
479 |
msgid "Save Changes"
|
480 |
msgstr ""
|
481 |
|
482 |
-
#: lib/settings
|
483 |
msgid "Copyright ©%1$s %2$s."
|
484 |
msgstr ""
|
485 |
|
486 |
-
#: lib/settings
|
487 |
msgid "Required"
|
488 |
msgstr ""
|
489 |
|
490 |
-
#: lib/testimonials-widget-widget.php:
|
491 |
msgid "Display testimonials with multiple selection and display options"
|
492 |
msgstr ""
|
493 |
|
494 |
-
#. #-#-#-#-# testimonials-widget.pot (Testimonials Widget 2.
|
495 |
#. Plugin Name of the plugin/theme
|
496 |
-
#: lib/testimonials-widget-widget.php:
|
497 |
msgid "Testimonials Widget"
|
498 |
msgstr ""
|
499 |
|
500 |
-
#: lib/testimonials-widget-widget.php:
|
501 |
msgid "CSS Class"
|
502 |
msgstr ""
|
503 |
|
504 |
-
#: lib/testimonials-widget-widget.php:
|
505 |
msgid "This widget's unique CSS class for styling"
|
506 |
msgstr ""
|
507 |
|
508 |
-
#: lib/testimonials-widget-widget.php:
|
509 |
msgid "Expand/Collapse"
|
510 |
msgstr ""
|
511 |
|
512 |
-
#: testimonials-widget.php:
|
513 |
msgid "Deleting Testimonials Widget plugin will remove all data and settings."
|
514 |
msgstr ""
|
515 |
|
516 |
-
#: testimonials-widget.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
517 |
msgid "Image"
|
518 |
msgstr ""
|
519 |
|
520 |
-
#: testimonials-widget.php:
|
521 |
msgid "Shortcodes"
|
522 |
msgstr ""
|
523 |
|
524 |
-
#: testimonials-widget.php:
|
525 |
msgid "Published by"
|
526 |
msgstr ""
|
527 |
|
528 |
-
#: testimonials-widget.php:
|
529 |
msgid "Category"
|
530 |
msgstr ""
|
531 |
|
532 |
-
#: testimonials-widget.php:
|
533 |
msgid "Tags"
|
534 |
msgstr ""
|
535 |
|
536 |
-
#: testimonials-widget.php:
|
537 |
msgid "Add New"
|
538 |
msgstr ""
|
539 |
|
540 |
-
#: testimonials-widget.php:
|
541 |
msgid "Add New Testimonial"
|
542 |
msgstr ""
|
543 |
|
544 |
-
#: testimonials-widget.php:
|
545 |
msgid "Edit Testimonial"
|
546 |
msgstr ""
|
547 |
|
548 |
-
#: testimonials-widget.php:
|
549 |
msgid "No testimonials found"
|
550 |
msgstr ""
|
551 |
|
552 |
-
#: testimonials-widget.php:
|
553 |
msgid "No testimonials found in Trash"
|
554 |
msgstr ""
|
555 |
|
556 |
-
#: testimonials-widget.php:
|
557 |
msgid "Search Testimonials"
|
558 |
msgstr ""
|
559 |
|
560 |
-
#: testimonials-widget.php:
|
561 |
msgid "Testimonial"
|
562 |
msgstr ""
|
563 |
|
564 |
-
#: testimonials-widget.php:
|
565 |
msgid "View Testimonial"
|
566 |
msgstr ""
|
567 |
|
568 |
-
#: testimonials-widget.php:
|
569 |
msgid "…"
|
570 |
msgstr ""
|
571 |
|
572 |
-
#: testimonials-widget.php:
|
573 |
msgid "«"
|
574 |
msgstr ""
|
575 |
|
576 |
-
#: testimonials-widget.php:
|
577 |
msgid "»"
|
578 |
msgstr ""
|
579 |
|
580 |
-
#: testimonials-widget.php:
|
581 |
msgid "Testimonial Data"
|
582 |
msgstr ""
|
583 |
|
584 |
-
#: testimonials-widget.php:
|
585 |
msgid "Enter title here"
|
586 |
msgstr ""
|
587 |
|
588 |
-
#: testimonials-widget.php:
|
589 |
msgid "Enter testimonial source here"
|
590 |
msgstr ""
|
591 |
|
592 |
-
#: testimonials-widget.php:
|
593 |
msgid "Testimonial updated. <a href=\"%s\">View testimonial</a>"
|
594 |
msgstr ""
|
595 |
|
596 |
-
#: testimonials-widget.php:
|
597 |
msgid "Custom field updated."
|
598 |
msgstr ""
|
599 |
|
600 |
-
#: testimonials-widget.php:
|
601 |
msgid "Custom field deleted."
|
602 |
msgstr ""
|
603 |
|
604 |
-
#: testimonials-widget.php:
|
605 |
msgid "Testimonial updated."
|
606 |
msgstr ""
|
607 |
|
608 |
#. translators: %s: date and time of the revision
|
609 |
-
#: testimonials-widget.php:
|
610 |
msgid "Testimonial restored to revision from %s"
|
611 |
msgstr ""
|
612 |
|
613 |
-
#: testimonials-widget.php:
|
614 |
msgid "Testimonial published. <a href=\"%s\">View testimonial</a>"
|
615 |
msgstr ""
|
616 |
|
617 |
-
#: testimonials-widget.php:
|
618 |
msgid "Testimonial saved."
|
619 |
msgstr ""
|
620 |
|
621 |
-
#: testimonials-widget.php:
|
622 |
msgid ""
|
623 |
"Testimonial submitted. <a target=\"_blank\" href=\"%s\">Preview testimonial</"
|
624 |
"a>"
|
625 |
msgstr ""
|
626 |
|
627 |
-
#: testimonials-widget.php:
|
628 |
msgid ""
|
629 |
"Testimonial scheduled for: <strong>%1$s</strong>. <a target=\"_blank\" href="
|
630 |
"\"%2$s\">Preview testimonial</a>"
|
631 |
msgstr ""
|
632 |
|
633 |
-
#: testimonials-widget.php:
|
634 |
msgid ""
|
635 |
"Testimonial draft updated. <a target=\"_blank\" href=\"%s\">Preview "
|
636 |
"testimonial</a>"
|
2 |
# This file is distributed under the same license as the Testimonials Widget package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Testimonials Widget 2.12.0\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/testimonials-widget\n"
|
7 |
+
"POT-Creation-Date: 2013-04-27 22:14:53+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
|
15 |
+
#: lib/class-settings-testimonials-widget.php:64
|
16 |
msgid "General"
|
17 |
msgstr ""
|
18 |
|
19 |
+
#: lib/class-settings-testimonials-widget.php:65
|
20 |
msgid "Selection"
|
21 |
msgstr ""
|
22 |
|
23 |
+
#: lib/class-settings-testimonials-widget.php:66
|
24 |
msgid "Ordering"
|
25 |
msgstr ""
|
26 |
|
27 |
+
#: lib/class-settings-testimonials-widget.php:67
|
28 |
msgid "Widget"
|
29 |
msgstr ""
|
30 |
|
31 |
+
#: lib/class-settings-testimonials-widget.php:69
|
32 |
msgid "Post Type"
|
33 |
msgstr ""
|
34 |
|
35 |
+
#: lib/class-settings-testimonials-widget.php:70
|
36 |
msgid "Compatibility & Reset"
|
37 |
msgstr ""
|
38 |
|
39 |
+
#: lib/class-settings-testimonials-widget.php:71
|
40 |
msgid "About Testimonials Widget"
|
41 |
msgstr ""
|
42 |
|
43 |
+
#: lib/class-settings-testimonials-widget.php:86
|
44 |
msgid "Widget Title"
|
45 |
msgstr ""
|
46 |
|
47 |
+
#: lib/class-settings-testimonials-widget.php:87 testimonials-widget.php:464
|
48 |
+
#: testimonials-widget.php:492
|
49 |
msgid "Testimonials"
|
50 |
msgstr ""
|
51 |
|
52 |
+
#: lib/class-settings-testimonials-widget.php:93
|
53 |
msgid "Title Link"
|
54 |
msgstr ""
|
55 |
|
56 |
+
#: lib/class-settings-testimonials-widget.php:94
|
57 |
msgid "URL or Post ID to link widget title to. Ex: 123 or http://example.com"
|
58 |
msgstr ""
|
59 |
|
60 |
+
#: lib/class-settings-testimonials-widget.php:100
|
61 |
msgid "Character Limit"
|
62 |
msgstr ""
|
63 |
|
64 |
+
#: lib/class-settings-testimonials-widget.php:101
|
65 |
msgid "Number of characters to limit non-single testimonial views to"
|
66 |
msgstr ""
|
67 |
|
68 |
+
#: lib/class-settings-testimonials-widget.php:107
|
69 |
msgid "Height"
|
70 |
msgstr ""
|
71 |
|
72 |
+
#: lib/class-settings-testimonials-widget.php:108
|
73 |
msgid "Testimonials height, in pixels. Overrides minimum and maximum height"
|
74 |
msgstr ""
|
75 |
|
76 |
+
#: lib/class-settings-testimonials-widget.php:114
|
77 |
msgid "Rotation Speed"
|
78 |
msgstr ""
|
79 |
|
80 |
+
#: lib/class-settings-testimonials-widget.php:115
|
81 |
msgid ""
|
82 |
"Number of seconds between testimonial rotations or 0 for no rotation at all "
|
83 |
"refresh"
|
84 |
msgstr ""
|
85 |
|
86 |
+
#: lib/class-settings-testimonials-widget.php:122
|
87 |
msgid "Additional Widget Options"
|
88 |
msgstr ""
|
89 |
|
90 |
+
#: lib/class-settings-testimonials-widget.php:128
|
91 |
msgid "Keep Whitespace?"
|
92 |
msgstr ""
|
93 |
|
94 |
+
#: lib/class-settings-testimonials-widget.php:129
|
95 |
msgid "Keeps testimonials looking as entered than sans auto-formatting"
|
96 |
msgstr ""
|
97 |
|
98 |
+
#: lib/class-settings-testimonials-widget.php:135
|
99 |
msgid "Minimum Height"
|
100 |
msgstr ""
|
101 |
|
102 |
+
#: lib/class-settings-testimonials-widget.php:136
|
103 |
msgid "Set for minimum display height, in pixels"
|
104 |
msgstr ""
|
105 |
|
106 |
+
#: lib/class-settings-testimonials-widget.php:142
|
107 |
msgid "Maximum Height"
|
108 |
msgstr ""
|
109 |
|
110 |
+
#: lib/class-settings-testimonials-widget.php:143
|
111 |
msgid "Set for maximum display height, in pixels"
|
112 |
msgstr ""
|
113 |
|
114 |
+
#: lib/class-settings-testimonials-widget.php:149
|
115 |
msgid "Testimonial Bottom Text"
|
116 |
msgstr ""
|
117 |
|
118 |
+
#: lib/class-settings-testimonials-widget.php:150
|
119 |
msgid "Custom text or HTML for bottom of testimonials"
|
120 |
msgstr ""
|
121 |
|
122 |
+
#: lib/class-settings-testimonials-widget.php:162
|
123 |
msgid "General Options"
|
124 |
msgstr ""
|
125 |
|
126 |
+
#: lib/class-settings-testimonials-widget.php:167
|
127 |
msgid "Hide built-in quotes?"
|
128 |
msgstr ""
|
129 |
|
130 |
+
#: lib/class-settings-testimonials-widget.php:168
|
131 |
msgid "Remove open and close quote span tags surrounding testimonial content"
|
132 |
msgstr ""
|
133 |
|
134 |
+
#: lib/class-settings-testimonials-widget.php:173
|
135 |
msgid "Hide \"Testimonials Not Found\"?"
|
136 |
msgstr ""
|
137 |
|
138 |
+
#: lib/class-settings-testimonials-widget.php:178
|
139 |
msgid "Hide Gravatar Image?"
|
140 |
msgstr ""
|
141 |
|
142 |
+
#: lib/class-settings-testimonials-widget.php:183
|
143 |
msgid "Hide Image?"
|
144 |
msgstr ""
|
145 |
|
146 |
+
#: lib/class-settings-testimonials-widget.php:188
|
147 |
msgid "Hide Image in Single View?"
|
148 |
msgstr ""
|
149 |
|
150 |
+
#: lib/class-settings-testimonials-widget.php:194
|
151 |
msgid "Hide Testimonial Content?"
|
152 |
msgstr ""
|
153 |
|
154 |
+
#: lib/class-settings-testimonials-widget.php:199
|
155 |
msgid "Hide Author/Source?"
|
156 |
msgstr ""
|
157 |
|
158 |
+
#: lib/class-settings-testimonials-widget.php:201
|
159 |
msgid "Don't display \"Post Title\" in cite"
|
160 |
msgstr ""
|
161 |
|
162 |
+
#: lib/class-settings-testimonials-widget.php:205
|
163 |
msgid "Hide Email?"
|
164 |
msgstr ""
|
165 |
|
166 |
+
#: lib/class-settings-testimonials-widget.php:211
|
167 |
msgid "Hide Title?"
|
168 |
msgstr ""
|
169 |
|
170 |
+
#: lib/class-settings-testimonials-widget.php:216
|
171 |
msgid "Hide Location?"
|
172 |
msgstr ""
|
173 |
|
174 |
+
#: lib/class-settings-testimonials-widget.php:221
|
175 |
msgid "Hide Company?"
|
176 |
msgstr ""
|
177 |
|
178 |
+
#: lib/class-settings-testimonials-widget.php:226
|
179 |
msgid "Hide URL?"
|
180 |
msgstr ""
|
181 |
|
182 |
+
#: lib/class-settings-testimonials-widget.php:231
|
183 |
msgid "URL Target"
|
184 |
msgstr ""
|
185 |
|
186 |
+
#: lib/class-settings-testimonials-widget.php:232
|
187 |
+
msgid "Add target to all URLs; leave blank if none"
|
188 |
msgstr ""
|
189 |
|
190 |
+
#: lib/class-settings-testimonials-widget.php:237
|
191 |
msgid "Enable Paging?"
|
192 |
msgstr ""
|
193 |
|
194 |
+
#: lib/class-settings-testimonials-widget.php:238
|
195 |
msgid "For `[testimonialswidget_list]`"
|
196 |
msgstr ""
|
197 |
|
198 |
+
#: lib/class-settings-testimonials-widget.php:241
|
199 |
msgid "Disable"
|
200 |
msgstr ""
|
201 |
|
202 |
+
#: lib/class-settings-testimonials-widget.php:242
|
203 |
msgid "Enable"
|
204 |
msgstr ""
|
205 |
|
206 |
+
#: lib/class-settings-testimonials-widget.php:243
|
207 |
msgid "Before testimonials"
|
208 |
msgstr ""
|
209 |
|
210 |
+
#: lib/class-settings-testimonials-widget.php:244
|
211 |
msgid "After testimonials"
|
212 |
msgstr ""
|
213 |
|
214 |
+
#: lib/class-settings-testimonials-widget.php:257
|
215 |
msgid "Selection Options"
|
216 |
msgstr ""
|
217 |
|
218 |
+
#: lib/class-settings-testimonials-widget.php:263
|
219 |
msgid "Category Filter"
|
220 |
msgstr ""
|
221 |
|
222 |
+
#: lib/class-settings-testimonials-widget.php:264
|
223 |
msgid "Comma separated category slug-names. Ex: category-a, another-category"
|
224 |
msgstr ""
|
225 |
|
226 |
+
#: lib/class-settings-testimonials-widget.php:270
|
227 |
msgid "Tags Filter"
|
228 |
msgstr ""
|
229 |
|
230 |
+
#: lib/class-settings-testimonials-widget.php:271
|
231 |
msgid "Comma separated tag slug-names. Ex: tag-a, another-tag"
|
232 |
msgstr ""
|
233 |
|
234 |
+
#: lib/class-settings-testimonials-widget.php:277
|
235 |
msgid "Require All Tags?"
|
236 |
msgstr ""
|
237 |
|
238 |
+
#: lib/class-settings-testimonials-widget.php:278
|
239 |
msgid "Select only testimonials with all of the given tags"
|
240 |
msgstr ""
|
241 |
|
242 |
+
#: lib/class-settings-testimonials-widget.php:284
|
243 |
msgid "Include IDs Filter"
|
244 |
msgstr ""
|
245 |
|
246 |
+
#: lib/class-settings-testimonials-widget.php:285
|
247 |
+
#: lib/class-settings-testimonials-widget.php:292
|
248 |
msgid "Comma separated testimonial IDs. Ex: 3,1,2"
|
249 |
msgstr ""
|
250 |
|
251 |
+
#: lib/class-settings-testimonials-widget.php:291
|
252 |
msgid "Exclude IDs Filter"
|
253 |
msgstr ""
|
254 |
|
255 |
+
#: lib/class-settings-testimonials-widget.php:298
|
256 |
msgid "Limit"
|
257 |
msgstr ""
|
258 |
|
259 |
+
#: lib/class-settings-testimonials-widget.php:299
|
260 |
msgid "Number of testimonials to select per instance"
|
261 |
msgstr ""
|
262 |
|
263 |
+
#: lib/class-settings-testimonials-widget.php:312
|
264 |
msgid "Ordering Options"
|
265 |
msgstr ""
|
266 |
|
267 |
+
#: lib/class-settings-testimonials-widget.php:318
|
268 |
msgid "Random Order?"
|
269 |
msgstr ""
|
270 |
|
271 |
+
#: lib/class-settings-testimonials-widget.php:319
|
272 |
msgid ""
|
273 |
"If checked, ignores ORDER BY, ORDER BY meta_key, and ORDER BY Order. Widgets "
|
274 |
"are random by default automatically"
|
275 |
msgstr ""
|
276 |
|
277 |
+
#: lib/class-settings-testimonials-widget.php:325
|
278 |
msgid "ORDER BY"
|
279 |
msgstr ""
|
280 |
|
281 |
+
#: lib/class-settings-testimonials-widget.php:326
|
282 |
msgid "Used when \"Random Order\" is disabled"
|
283 |
msgstr ""
|
284 |
|
285 |
+
#: lib/class-settings-testimonials-widget.php:329
|
286 |
msgid "Testimonial ID"
|
287 |
msgstr ""
|
288 |
|
289 |
+
#: lib/class-settings-testimonials-widget.php:330
|
290 |
msgid "Author"
|
291 |
msgstr ""
|
292 |
|
293 |
+
#: lib/class-settings-testimonials-widget.php:331 testimonials-widget.php:450
|
294 |
msgid "Date"
|
295 |
msgstr ""
|
296 |
|
297 |
+
#: lib/class-settings-testimonials-widget.php:332
|
298 |
msgid "Menu Order"
|
299 |
msgstr ""
|
300 |
|
301 |
+
#: lib/class-settings-testimonials-widget.php:333 testimonials-widget.php:440
|
302 |
msgid "Source"
|
303 |
msgstr ""
|
304 |
|
305 |
+
#: lib/class-settings-testimonials-widget.php:334
|
306 |
msgid "No order"
|
307 |
msgstr ""
|
308 |
|
309 |
+
#: lib/class-settings-testimonials-widget.php:342
|
310 |
msgid "ORDER BY meta_key"
|
311 |
msgstr ""
|
312 |
|
313 |
+
#: lib/class-settings-testimonials-widget.php:343
|
314 |
msgid ""
|
315 |
"Used when \"Random Order\" is disabled and sorting by a testimonials meta "
|
316 |
"key is needed. Overrides ORDER BY"
|
317 |
msgstr ""
|
318 |
|
319 |
+
#: lib/class-settings-testimonials-widget.php:346
|
320 |
msgid "None"
|
321 |
msgstr ""
|
322 |
|
323 |
+
#: lib/class-settings-testimonials-widget.php:347 testimonials-widget.php:442
|
324 |
+
#: testimonials-widget.php:1416
|
325 |
msgid "Title"
|
326 |
msgstr ""
|
327 |
|
328 |
+
#: lib/class-settings-testimonials-widget.php:348 testimonials-widget.php:444
|
329 |
+
#: testimonials-widget.php:1428
|
330 |
msgid "Email"
|
331 |
msgstr ""
|
332 |
|
333 |
+
#: lib/class-settings-testimonials-widget.php:349 testimonials-widget.php:443
|
334 |
+
#: testimonials-widget.php:1422
|
335 |
msgid "Location"
|
336 |
msgstr ""
|
337 |
|
338 |
+
#: lib/class-settings-testimonials-widget.php:350 testimonials-widget.php:445
|
339 |
+
#: testimonials-widget.php:1434
|
340 |
msgid "Company"
|
341 |
msgstr ""
|
342 |
|
343 |
+
#: lib/class-settings-testimonials-widget.php:351 testimonials-widget.php:446
|
344 |
+
#: testimonials-widget.php:1440
|
345 |
msgid "URL"
|
346 |
msgstr ""
|
347 |
|
348 |
+
#: lib/class-settings-testimonials-widget.php:358
|
349 |
msgid "ORDER BY Order"
|
350 |
msgstr ""
|
351 |
|
352 |
+
#: lib/class-settings-testimonials-widget.php:361
|
353 |
msgid "Descending"
|
354 |
msgstr ""
|
355 |
|
356 |
+
#: lib/class-settings-testimonials-widget.php:362
|
357 |
msgid "Ascending"
|
358 |
msgstr ""
|
359 |
|
360 |
+
#: lib/class-settings-testimonials-widget.php:376
|
361 |
msgid "Debug Mode?"
|
362 |
msgstr ""
|
363 |
|
364 |
+
#: lib/class-settings-testimonials-widget.php:377
|
365 |
msgid "Not implemented yet"
|
366 |
msgstr ""
|
367 |
|
368 |
+
#: lib/class-settings-testimonials-widget.php:385
|
369 |
msgid "Allow Comments?"
|
370 |
msgstr ""
|
371 |
|
372 |
+
#: lib/class-settings-testimonials-widget.php:386
|
373 |
msgid ""
|
374 |
"Only affects the Testimonials Widget post edit page. Your theme controls the "
|
375 |
"front-end view."
|
376 |
msgstr ""
|
377 |
|
378 |
+
#: lib/class-settings-testimonials-widget.php:391
|
379 |
msgid ""
|
380 |
"URL slug-name for <a href=\"%1s\">testimonials archive</a> page. After "
|
381 |
"changing, you must click \"Save Changes\" on <a href=\"%2s\">Permalink "
|
382 |
"Settings</a> to update them."
|
383 |
msgstr ""
|
384 |
|
385 |
+
#: lib/class-settings-testimonials-widget.php:398
|
386 |
msgid "Archive Page URL"
|
387 |
msgstr ""
|
388 |
|
389 |
+
#: lib/class-settings-testimonials-widget.php:405
|
390 |
msgid ""
|
391 |
"URL slug-name for testimonial view pages. After changing, you must click "
|
392 |
"\"Save Changes\" on <a href=\"%1s\">Permalink Settings</a> to update them."
|
393 |
msgstr ""
|
394 |
|
395 |
+
#: lib/class-settings-testimonials-widget.php:409
|
396 |
msgid "Testimonial Page URL"
|
397 |
msgstr ""
|
398 |
|
399 |
+
#: lib/class-settings-testimonials-widget.php:419
|
400 |
msgid "Compatiblity Options"
|
401 |
msgstr ""
|
402 |
|
403 |
+
#: lib/class-settings-testimonials-widget.php:425
|
404 |
msgid "Remove `.hentry` CSS?"
|
405 |
msgstr ""
|
406 |
|
407 |
+
#: lib/class-settings-testimonials-widget.php:426
|
408 |
msgid ""
|
409 |
"Pre 2.6.4. Some themes use class `.hentry` in a manner that breaks "
|
410 |
"Testimonials Widgets CSS"
|
411 |
msgstr ""
|
412 |
|
413 |
+
#: lib/class-settings-testimonials-widget.php:436
|
414 |
msgid "Use `<q>` tag?"
|
415 |
msgstr ""
|
416 |
|
417 |
+
#: lib/class-settings-testimonials-widget.php:437
|
418 |
msgid "Pre 2.11.0. Not HTML5 compliant"
|
419 |
msgstr ""
|
420 |
|
421 |
+
#: lib/class-settings-testimonials-widget.php:447
|
422 |
+
msgid "Remove Plugin Data on Deletion?"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
423 |
msgstr ""
|
424 |
|
425 |
+
#: lib/class-settings-testimonials-widget.php:450
|
426 |
+
msgid ""
|
427 |
+
"Delete all Testimonials Widget data and options from database on plugin "
|
428 |
+
"deletion"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
msgstr ""
|
430 |
|
431 |
+
#: lib/class-settings-testimonials-widget.php:460
|
432 |
+
msgid "Import/Export Settings"
|
433 |
msgstr ""
|
434 |
|
435 |
+
#: lib/class-settings-testimonials-widget.php:462
|
436 |
+
msgid ""
|
437 |
+
"These are your current settings in a text format. Copy the textarea contents "
|
438 |
+
"to make a backup of your settings. You can paste new settings here to "
|
439 |
+
"overwrite your current configuration."
|
440 |
msgstr ""
|
441 |
|
442 |
+
#: lib/class-settings-testimonials-widget.php:469
|
443 |
+
msgid "Reset to Defaults?"
|
444 |
msgstr ""
|
445 |
|
446 |
+
#: lib/class-settings-testimonials-widget.php:472
|
447 |
+
msgid "Check this box to reset options to their defaults"
|
448 |
msgstr ""
|
449 |
|
450 |
+
#: lib/class-settings-testimonials-widget.php:538
|
451 |
+
#: lib/class-settings-testimonials-widget.php:575
|
452 |
msgid "Testimonials Widget Settings"
|
453 |
msgstr ""
|
454 |
|
455 |
+
#: lib/class-settings-testimonials-widget.php:538 testimonials-widget.php:65
|
456 |
msgid "Settings"
|
457 |
msgstr ""
|
458 |
|
459 |
+
#: lib/class-settings-testimonials-widget.php:594
|
460 |
msgid "Save Changes"
|
461 |
msgstr ""
|
462 |
|
463 |
+
#: lib/class-settings-testimonials-widget.php:605
|
464 |
msgid "Copyright ©%1$s %2$s."
|
465 |
msgstr ""
|
466 |
|
467 |
+
#: lib/class-settings-testimonials-widget.php:970
|
468 |
msgid "Required"
|
469 |
msgstr ""
|
470 |
|
471 |
+
#: lib/class-testimonials-widget-widget.php:26
|
472 |
msgid "Display testimonials with multiple selection and display options"
|
473 |
msgstr ""
|
474 |
|
475 |
+
#. #-#-#-#-# testimonials-widget.pot (Testimonials Widget 2.12.0) #-#-#-#-#
|
476 |
#. Plugin Name of the plugin/theme
|
477 |
+
#: lib/class-testimonials-widget-widget.php:37
|
478 |
msgid "Testimonials Widget"
|
479 |
msgstr ""
|
480 |
|
481 |
+
#: lib/class-testimonials-widget-widget.php:160
|
482 |
msgid "CSS Class"
|
483 |
msgstr ""
|
484 |
|
485 |
+
#: lib/class-testimonials-widget-widget.php:161
|
486 |
msgid "This widget's unique CSS class for styling"
|
487 |
msgstr ""
|
488 |
|
489 |
+
#: lib/class-testimonials-widget-widget.php:205
|
490 |
msgid "Expand/Collapse"
|
491 |
msgstr ""
|
492 |
|
493 |
+
#: testimonials-widget.php:184
|
494 |
msgid "Deleting Testimonials Widget plugin will remove all data and settings."
|
495 |
msgstr ""
|
496 |
|
497 |
+
#: testimonials-widget.php:265
|
498 |
+
msgid ""
|
499 |
+
"Testimonials Widget has updated CSS naming and HTML5 layout options. Please "
|
500 |
+
"<a href=\"%s\">read the FAQ</a> to make fixes if your testimonials display "
|
501 |
+
"is funky"
|
502 |
+
msgstr ""
|
503 |
+
|
504 |
+
#: testimonials-widget.php:439
|
505 |
msgid "Image"
|
506 |
msgstr ""
|
507 |
|
508 |
+
#: testimonials-widget.php:441
|
509 |
msgid "Shortcodes"
|
510 |
msgstr ""
|
511 |
|
512 |
+
#: testimonials-widget.php:447
|
513 |
msgid "Published by"
|
514 |
msgstr ""
|
515 |
|
516 |
+
#: testimonials-widget.php:448
|
517 |
msgid "Category"
|
518 |
msgstr ""
|
519 |
|
520 |
+
#: testimonials-widget.php:449
|
521 |
msgid "Tags"
|
522 |
msgstr ""
|
523 |
|
524 |
+
#: testimonials-widget.php:461
|
525 |
msgid "Add New"
|
526 |
msgstr ""
|
527 |
|
528 |
+
#: testimonials-widget.php:462 testimonials-widget.php:465
|
529 |
msgid "Add New Testimonial"
|
530 |
msgstr ""
|
531 |
|
532 |
+
#: testimonials-widget.php:463
|
533 |
msgid "Edit Testimonial"
|
534 |
msgstr ""
|
535 |
|
536 |
+
#: testimonials-widget.php:466 testimonials-widget.php:731
|
537 |
msgid "No testimonials found"
|
538 |
msgstr ""
|
539 |
|
540 |
+
#: testimonials-widget.php:467
|
541 |
msgid "No testimonials found in Trash"
|
542 |
msgstr ""
|
543 |
|
544 |
+
#: testimonials-widget.php:469
|
545 |
msgid "Search Testimonials"
|
546 |
msgstr ""
|
547 |
|
548 |
+
#: testimonials-widget.php:470
|
549 |
msgid "Testimonial"
|
550 |
msgstr ""
|
551 |
|
552 |
+
#: testimonials-widget.php:471
|
553 |
msgid "View Testimonial"
|
554 |
msgstr ""
|
555 |
|
556 |
+
#: testimonials-widget.php:849
|
557 |
msgid "…"
|
558 |
msgstr ""
|
559 |
|
560 |
+
#: testimonials-widget.php:1174
|
561 |
msgid "«"
|
562 |
msgstr ""
|
563 |
|
564 |
+
#: testimonials-widget.php:1183
|
565 |
msgid "»"
|
566 |
msgstr ""
|
567 |
|
568 |
+
#: testimonials-widget.php:1452
|
569 |
msgid "Testimonial Data"
|
570 |
msgstr ""
|
571 |
|
572 |
+
#: testimonials-widget.php:1477
|
573 |
msgid "Enter title here"
|
574 |
msgstr ""
|
575 |
|
576 |
+
#: testimonials-widget.php:1478
|
577 |
msgid "Enter testimonial source here"
|
578 |
msgstr ""
|
579 |
|
580 |
+
#: testimonials-widget.php:1503
|
581 |
msgid "Testimonial updated. <a href=\"%s\">View testimonial</a>"
|
582 |
msgstr ""
|
583 |
|
584 |
+
#: testimonials-widget.php:1504
|
585 |
msgid "Custom field updated."
|
586 |
msgstr ""
|
587 |
|
588 |
+
#: testimonials-widget.php:1505
|
589 |
msgid "Custom field deleted."
|
590 |
msgstr ""
|
591 |
|
592 |
+
#: testimonials-widget.php:1506
|
593 |
msgid "Testimonial updated."
|
594 |
msgstr ""
|
595 |
|
596 |
#. translators: %s: date and time of the revision
|
597 |
+
#: testimonials-widget.php:1508
|
598 |
msgid "Testimonial restored to revision from %s"
|
599 |
msgstr ""
|
600 |
|
601 |
+
#: testimonials-widget.php:1509
|
602 |
msgid "Testimonial published. <a href=\"%s\">View testimonial</a>"
|
603 |
msgstr ""
|
604 |
|
605 |
+
#: testimonials-widget.php:1510
|
606 |
msgid "Testimonial saved."
|
607 |
msgstr ""
|
608 |
|
609 |
+
#: testimonials-widget.php:1511
|
610 |
msgid ""
|
611 |
"Testimonial submitted. <a target=\"_blank\" href=\"%s\">Preview testimonial</"
|
612 |
"a>"
|
613 |
msgstr ""
|
614 |
|
615 |
+
#: testimonials-widget.php:1512
|
616 |
msgid ""
|
617 |
"Testimonial scheduled for: <strong>%1$s</strong>. <a target=\"_blank\" href="
|
618 |
"\"%2$s\">Preview testimonial</a>"
|
619 |
msgstr ""
|
620 |
|
621 |
+
#: testimonials-widget.php:1513
|
622 |
msgid ""
|
623 |
"Testimonial draft updated. <a target=\"_blank\" href=\"%s\">Preview "
|
624 |
"testimonial</a>"
|
lib/class-redrokk-metabox-class.php
ADDED
@@ -0,0 +1,1433 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*
|
5 |
+
* @Author Anonymous
|
6 |
+
* @link http://www.redrokk.com
|
7 |
+
* @Package Wordpress
|
8 |
+
* @SubPackage RedRokk Library
|
9 |
+
*
|
10 |
+
* @version 2.0
|
11 |
+
*/
|
12 |
+
|
13 |
+
//security
|
14 |
+
defined( 'ABSPATH' ) or die( 'You\'re not supposed to be here.' );
|
15 |
+
|
16 |
+
/**
|
17 |
+
*
|
18 |
+
*
|
19 |
+
* @author Anonymous
|
20 |
+
* @example
|
21 |
+
* $gallery = redrokk_metabox_class::getInstance('gallery');
|
22 |
+
*/
|
23 |
+
if ( !class_exists( 'redrokk_metabox_class' ) ):
|
24 |
+
class redrokk_metabox_class {
|
25 |
+
/**
|
26 |
+
* HTML 'id' attribute of the edit screen section
|
27 |
+
*
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
var $_id;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Save the form fields here that will be displayed to the user
|
34 |
+
*
|
35 |
+
* @var array
|
36 |
+
*/
|
37 |
+
var $_fields;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Title of the edit screen section, visible to user
|
41 |
+
* Default: None
|
42 |
+
*
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
var $title;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Function that prints out the HTML for the edit screen section. Pass
|
49 |
+
* function name as a string. Within a class, you can instead pass an
|
50 |
+
* array to call one of the class's methods. See the second example under
|
51 |
+
* Example below.
|
52 |
+
* Default: None
|
53 |
+
*
|
54 |
+
* @var callback
|
55 |
+
*/
|
56 |
+
var $callback = null;
|
57 |
+
|
58 |
+
/**
|
59 |
+
* The part of the page where the edit screen section should be shown
|
60 |
+
* ('normal', 'advanced', or 'side'). (Note that 'side' doesn't exist before 2.7)
|
61 |
+
* Default: 'advanced'
|
62 |
+
*
|
63 |
+
* @var string
|
64 |
+
*/
|
65 |
+
var $context = 'normal';
|
66 |
+
|
67 |
+
/**
|
68 |
+
* The priority within the context where the boxes should show
|
69 |
+
* ('high', 'core', 'default' or 'low')
|
70 |
+
* Default: 'default'
|
71 |
+
*
|
72 |
+
* @var string
|
73 |
+
*/
|
74 |
+
var $priority = 'default';
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Arguments to pass into your callback function. The callback will receive the
|
78 |
+
* $post object and whatever parameters are passed through this variable.
|
79 |
+
* Default: null
|
80 |
+
*
|
81 |
+
* @var array
|
82 |
+
*/
|
83 |
+
var $callback_args;
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Prebuilt metaboxes can be activated by using this type
|
87 |
+
* Default: default
|
88 |
+
*
|
89 |
+
* (options:)
|
90 |
+
* default
|
91 |
+
* images
|
92 |
+
*
|
93 |
+
* @var string
|
94 |
+
*/
|
95 |
+
var $_type;
|
96 |
+
|
97 |
+
/**
|
98 |
+
*
|
99 |
+
*
|
100 |
+
* @var unknown_type
|
101 |
+
*/
|
102 |
+
var $_category_name;
|
103 |
+
|
104 |
+
/**
|
105 |
+
* The type of Write screen on which to show the edit screen section
|
106 |
+
* ('post', 'page', 'link', or 'custom_post_type' where custom_post_type
|
107 |
+
* is the custom post type slug)
|
108 |
+
* Default: None
|
109 |
+
*
|
110 |
+
* @var array
|
111 |
+
*/
|
112 |
+
var $_object_types = array();
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Whether or not to make the fields available as wp-options
|
116 |
+
*
|
117 |
+
* @var bool
|
118 |
+
*/
|
119 |
+
var $_isAdminPage = false;
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Constructor.
|
123 |
+
*
|
124 |
+
*/
|
125 |
+
function __construct( $options = array() ) {
|
126 |
+
//initializing
|
127 |
+
$this->setProperties( $options );
|
128 |
+
$this->setOptionHooks();
|
129 |
+
|
130 |
+
if ( !$this->callback ) {
|
131 |
+
$this->callback = array( &$this, 'show' );
|
132 |
+
}
|
133 |
+
if ( !$this->title ) {
|
134 |
+
$this->title = ucfirst( $this->_id );
|
135 |
+
}
|
136 |
+
|
137 |
+
//registering this metabox
|
138 |
+
add_action( 'add_meta_boxes', array( &$this, '_register' ) );
|
139 |
+
|
140 |
+
// backwards compatible (before WP 3.0)
|
141 |
+
// add_action( 'admin_init', array($this, '_register'), 1 );
|
142 |
+
|
143 |
+
add_action( 'save_post', array( &$this, '_save' ) );
|
144 |
+
add_filter( 'wp_redirect', array( &$this, '_redirectIntervention' ), 40, 1 );
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Method properly inturprets the given parameter and sets it accordingly
|
150 |
+
*
|
151 |
+
* @param string|object $value
|
152 |
+
*/
|
153 |
+
function setObjectTypes( $value ) {
|
154 |
+
if ( is_a( $value, 'redrokk_post_class' ) ) {
|
155 |
+
$value = $value->_post_type;
|
156 |
+
}
|
157 |
+
if ( is_a( $value, 'redrokk_admin_class' ) ) {
|
158 |
+
$value = $value->id;
|
159 |
+
$this->_isAdminPage = $value;
|
160 |
+
}
|
161 |
+
if ( is_array( $value ) ) {
|
162 |
+
foreach ( $value as $v )
|
163 |
+
$this->_object_types[] = $v;
|
164 |
+
return $this;
|
165 |
+
}
|
166 |
+
|
167 |
+
$this->_object_types[] = $value;
|
168 |
+
return $this;
|
169 |
+
}
|
170 |
+
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Method is designed to return the currently visible post type
|
174 |
+
*/
|
175 |
+
function getCurrentPostType() {
|
176 |
+
$post_type = false;
|
177 |
+
if ( isset( $_REQUEST['post_type'] ) ) {
|
178 |
+
$post_type = $_REQUEST['post_type'];
|
179 |
+
}
|
180 |
+
elseif ( isset( $_REQUEST['post'] ) ) {
|
181 |
+
$post = get_post( $_REQUEST['post'] );
|
182 |
+
$post_type = $post->post_type;
|
183 |
+
}
|
184 |
+
elseif ( isset( $_REQUEST['page'] ) ) {
|
185 |
+
$post_type = $_REQUEST['page'];
|
186 |
+
}
|
187 |
+
|
188 |
+
return $post_type;
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Method properly prepares the metabox type by binding the necessary hooks
|
194 |
+
*
|
195 |
+
* @param mixed $value
|
196 |
+
*/
|
197 |
+
function settype( $value = 'default' ) {
|
198 |
+
$this->_type = $value;
|
199 |
+
|
200 |
+
switch ( $this->_type ) {
|
201 |
+
default:
|
202 |
+
case 'default':
|
203 |
+
add_action( 'metabox-show-'.$this->_id, array( &$this, '_renderForm' ), 20, 1 );
|
204 |
+
add_action( 'metabox-save-'.$this->_id, array( &$this, 'saveAsPostMeta' ), 10, 2 );
|
205 |
+
break;
|
206 |
+
case 'image':
|
207 |
+
case 'images':
|
208 |
+
$this->_fields = array(
|
209 |
+
array(
|
210 |
+
'name' => 'New Image',
|
211 |
+
'type' => 'title',
|
212 |
+
),
|
213 |
+
array(
|
214 |
+
'name' => 'Image Title',
|
215 |
+
'id' => $this->_id.'_post_title',
|
216 |
+
'type' => 'text',
|
217 |
+
),
|
218 |
+
array(
|
219 |
+
'name' => 'Description',
|
220 |
+
'id' => $this->_id.'_post_content',
|
221 |
+
'type' => 'textarea',
|
222 |
+
),
|
223 |
+
array(
|
224 |
+
'name' => 'Image File',
|
225 |
+
'id' => $this->_id.'_image',
|
226 |
+
'type' => 'image',
|
227 |
+
),
|
228 |
+
array(
|
229 |
+
'name' => 'Save Image',
|
230 |
+
'type' => 'submit',
|
231 |
+
),
|
232 |
+
);
|
233 |
+
add_action( 'metabox-show-'.$this->_id, array( &$this, '_renderListImageAttachments' ), 20, 1 );
|
234 |
+
add_action( 'metabox-show-'.$this->_id, array( &$this, '_renderForm' ), 20, 1 );
|
235 |
+
add_action( 'metabox-save-'.$this->_id, array( &$this, 'saveAsAttachment' ), 1, 2 );
|
236 |
+
break;
|
237 |
+
case 'video':
|
238 |
+
case 'videos':
|
239 |
+
$this->_fields = array(
|
240 |
+
array(
|
241 |
+
'name' => 'New Video',
|
242 |
+
'type' => 'title',
|
243 |
+
),
|
244 |
+
array(
|
245 |
+
'name' => 'Video Title',
|
246 |
+
'id' => $this->_id.'_post_title',
|
247 |
+
'type' => 'text',
|
248 |
+
),
|
249 |
+
array(
|
250 |
+
'name' => 'Description',
|
251 |
+
'id' => $this->_id.'_post_content',
|
252 |
+
'type' => 'textarea',
|
253 |
+
),
|
254 |
+
array(
|
255 |
+
'name' => 'Video File',
|
256 |
+
'id' => $this->_id.'_image',
|
257 |
+
'type' => 'image',
|
258 |
+
),
|
259 |
+
array(
|
260 |
+
'name' => 'Video Link',
|
261 |
+
'id' => $this->_id.'_link',
|
262 |
+
'type' => 'text',
|
263 |
+
),
|
264 |
+
array(
|
265 |
+
'name' => '_videocat',
|
266 |
+
'id' => $this->_id.'_videocat',
|
267 |
+
'default'=>$this->getCategory(),
|
268 |
+
'type' => 'hidden',
|
269 |
+
),
|
270 |
+
array(
|
271 |
+
'name' => '_metaid',
|
272 |
+
'id' => $this->_id.'_metaid',
|
273 |
+
'type' => 'hidden',
|
274 |
+
),
|
275 |
+
array(
|
276 |
+
'name' => 'Save Video',
|
277 |
+
'type' => 'submit',
|
278 |
+
),
|
279 |
+
);
|
280 |
+
add_action( 'metabox-show-'.$this->_id, array( &$this, '_renderListAttachments' ), 20, 1 );
|
281 |
+
add_action( 'metabox-show-'.$this->_id, array( &$this, '_renderListVideoAttachments' ), 20, 1 );
|
282 |
+
add_action( 'metabox-show-'.$this->_id, array( &$this, '_renderForm' ), 20, 1 );
|
283 |
+
add_action( 'metabox-save-'.$this->_id, array( &$this, 'saveAsPostMeta' ), 1, 2 );
|
284 |
+
break;
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Returns the category to use
|
291 |
+
*/
|
292 |
+
function getCategory() {
|
293 |
+
return isset( $this->_category_name )
|
294 |
+
? $this->_category_name
|
295 |
+
: '_videocat';
|
296 |
+
}
|
297 |
+
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Method will save the posted content as an image attachment
|
301 |
+
*
|
302 |
+
*/
|
303 |
+
function saveAsAttachment( $source, $post_id ) {
|
304 |
+
if ( empty( $_FILES ) || !isset( $_REQUEST[$this->_id.'files'] ) ) return $source;
|
305 |
+
|
306 |
+
// initializing
|
307 |
+
$property = $_REQUEST[$this->_id.'files'];
|
308 |
+
$post_data = array();
|
309 |
+
|
310 |
+
if ( isset( $source[$this->_id.'_post_title'] ) && $source[$this->_id.'_post_title'] ) {
|
311 |
+
$post_data['post_title'] = $source[$this->_id.'_post_title'];
|
312 |
+
}
|
313 |
+
|
314 |
+
if ( isset( $source[$this->_id.'_post_content'] ) && $source[$this->_id.'_post_content'] ) {
|
315 |
+
$post_data['post_content'] = $source[$this->_id.'_post_content'];
|
316 |
+
}
|
317 |
+
|
318 |
+
$id = media_handle_upload( $property, $post_id, $post_data );
|
319 |
+
$source[$property] = $id;
|
320 |
+
|
321 |
+
$type = 'post';
|
322 |
+
if ( $this->getCurrentPostType() ) {
|
323 |
+
$type = $this->getCurrentPostType();
|
324 |
+
}
|
325 |
+
|
326 |
+
//saving the attachment ID to the taxonomy
|
327 |
+
if ( !in_array( $type, get_post_types( array( 'public' => false ) ) ) ) {
|
328 |
+
$old = get_metadata( $type, $post_id, $property, true );
|
329 |
+
if ( $id && $id != $old ) {
|
330 |
+
wp_delete_attachment( $old, true );
|
331 |
+
update_metadata( $type, $post_id, $property, $id );
|
332 |
+
}
|
333 |
+
}
|
334 |
+
|
335 |
+
foreach ( (array)$source as $property => $new ) {
|
336 |
+
//skip everything but the specially prefixed
|
337 |
+
if ( strpos( $property, $this->_id ) !== 0 ) continue;
|
338 |
+
if ( in_array( $property, array(
|
339 |
+
$this->_id.'_post_title',
|
340 |
+
$this->_id.'_post_content',
|
341 |
+
) ) ) continue;
|
342 |
+
|
343 |
+
$old = get_metadata( $type, $id, $property, true );
|
344 |
+
if ( $new && $new != $old ) {
|
345 |
+
update_metadata( $type, $id, $property, $new );
|
346 |
+
}
|
347 |
+
elseif ( !$new ) {
|
348 |
+
delete_metadata( $type, $id, $property, $old );
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
return $source;
|
353 |
+
}
|
354 |
+
|
355 |
+
|
356 |
+
/**
|
357 |
+
* Method saves the data provided as post meta values
|
358 |
+
*
|
359 |
+
* @param array $source
|
360 |
+
* @param integer $post_id
|
361 |
+
*/
|
362 |
+
function saveAsPostMeta( $source, $post_id ) {
|
363 |
+
$type = 'post';
|
364 |
+
if ( !$this->getCurrentPostType() ) {
|
365 |
+
$type = $this->_table;
|
366 |
+
}
|
367 |
+
|
368 |
+
//save as a file
|
369 |
+
//if there's no FILES then we save as a meta
|
370 |
+
$source = $this->saveAsAttachment( $source, $post_id );
|
371 |
+
|
372 |
+
//get the ID of this meta set
|
373 |
+
$id = false;
|
374 |
+
if ( isset( $source[$this->_id.'_metaid'] ) && $source[$this->_id.'_metaid'] ) {
|
375 |
+
$id = $source[$this->_id.'_metaid'];
|
376 |
+
}
|
377 |
+
|
378 |
+
// if this is a built in metabox
|
379 |
+
if ( $this->_type != 'default'
|
380 |
+
&& ( !isset( $source[$this->_id.'_image'] ) || !$source[$this->_id.'_image'] ) )
|
381 |
+
return false;
|
382 |
+
|
383 |
+
// Saving only the specially prefixed items
|
384 |
+
foreach ( (array)$source as $property => $new ) {
|
385 |
+
//skip everything but the specially prefixed
|
386 |
+
if ( strpos( $property, $this->_id ) !== 0 ) continue;
|
387 |
+
|
388 |
+
//each meta set has it's own ID
|
389 |
+
$property = str_replace( $this->_id, $this->_category_name.'_'.$id, $property );
|
390 |
+
|
391 |
+
$old = get_metadata( $type, $post_id, $property, true );
|
392 |
+
if ( $new && $new != $old ) {
|
393 |
+
update_metadata( $type, $post_id, $property, $new );
|
394 |
+
}
|
395 |
+
elseif ( !$new ) {
|
396 |
+
delete_metadata( $type, $post_id, $property, $old );
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
// maybe there's a last id
|
401 |
+
if ( !$id ) {
|
402 |
+
if ( !$id = get_metadata( $type, $post_id, '_metaidlast', true ) ) {
|
403 |
+
$id = 0;
|
404 |
+
}
|
405 |
+
$id++;
|
406 |
+
update_metadata( $type, $post_id, '_metaidlast', $id );
|
407 |
+
}
|
408 |
+
|
409 |
+
// saving all of the standard items
|
410 |
+
foreach ( (array)$source as $property => $new ) {
|
411 |
+
//skip special properties that are prefixed with the id
|
412 |
+
if ( strpos( $property, $this->_id ) === 0 ) continue;
|
413 |
+
|
414 |
+
$old = get_metadata( $type, $post_id, $property, true );
|
415 |
+
update_metadata( $type, $post_id, $property, $new );
|
416 |
+
|
417 |
+
// if ($new && $new != $old) {
|
418 |
+
// update_metadata($type, $post_id, $property, $new);
|
419 |
+
// }
|
420 |
+
// elseif (!$new) {
|
421 |
+
// delete_metadata($type, $post_id, $property, $old);
|
422 |
+
// }
|
423 |
+
|
424 |
+
}
|
425 |
+
|
426 |
+
return true;
|
427 |
+
}
|
428 |
+
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Do something with the data entered
|
432 |
+
*
|
433 |
+
* @param integer $post_id
|
434 |
+
*/
|
435 |
+
function _save( $post_id ) {
|
436 |
+
//initializing
|
437 |
+
$post = get_post( $post_id );
|
438 |
+
|
439 |
+
// verify if this is an auto save routine.
|
440 |
+
// If it is our form has not been submitted, so we dont want to do anything
|
441 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
442 |
+
return;
|
443 |
+
|
444 |
+
// verify this came from the our screen and with proper authorization,
|
445 |
+
// because save_post can be triggered at other times
|
446 |
+
if ( !isset( $_REQUEST[ get_class().$this->_id ] ) )
|
447 |
+
return;
|
448 |
+
|
449 |
+
if ( !wp_verify_nonce( $_REQUEST[ get_class().$this->_id ], plugin_basename( __FILE__ ) ) )
|
450 |
+
return;
|
451 |
+
|
452 |
+
// this metabox is to be displayed for a certain object type only
|
453 |
+
if ( !in_array( $post->post_type, $this->_object_types ) )
|
454 |
+
return;
|
455 |
+
|
456 |
+
// Check permissions
|
457 |
+
if ( 'page' == $post->post_type ) {
|
458 |
+
if ( !current_user_can( 'edit_page', $post->ID ) )
|
459 |
+
return;
|
460 |
+
}
|
461 |
+
else {
|
462 |
+
if ( !current_user_can( 'edit_post', $post->ID ) )
|
463 |
+
return;
|
464 |
+
}
|
465 |
+
|
466 |
+
//saving the request data
|
467 |
+
if ( !$this->_type ) $this->setType();
|
468 |
+
do_action( 'metabox-save-'.$this->_id, $this->getRequestPostMetas(), $post->ID, $this );
|
469 |
+
return true;
|
470 |
+
}
|
471 |
+
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Method returns the post meta
|
475 |
+
*
|
476 |
+
*/
|
477 |
+
function getRequestPostMetas() {
|
478 |
+
$ignores = array( 'post_title', 'post_name', 'post_content', 'post_excerpt', 'post',
|
479 |
+
'post_status', 'post_type', 'post_author', 'ping_status', 'post_parent', 'message',
|
480 |
+
'post_category', 'comment_status', 'menu_order', 'to_ping', 'pinged', 'post_password',
|
481 |
+
'guid', 'post_content_filtered', 'import_id', 'post_date', 'post_date_gmt', 'tags_input',
|
482 |
+
'action' );
|
483 |
+
|
484 |
+
$fields = array();
|
485 |
+
foreach ( (array)$this->_fields as $field ) {
|
486 |
+
if ( !array_key_exists( 'id', $field ) ) continue;
|
487 |
+
$fields[] = $field['id'];
|
488 |
+
}
|
489 |
+
|
490 |
+
$requests = $_REQUEST;
|
491 |
+
foreach ( (array)$requests as $k => $request ) {
|
492 |
+
if ( ( !empty( $fields ) && !in_array( $k, $fields ) )
|
493 |
+
|| ( in_array( $k, $ignores ) || strpos( $k, 'nounce' ) !== false ) ) {
|
494 |
+
unset( $requests[$k] );
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
return apply_filters( 'metabox-requests-'.$this->_id, $requests );
|
499 |
+
}
|
500 |
+
|
501 |
+
|
502 |
+
/**
|
503 |
+
* Display the inner contents of the metabox
|
504 |
+
*
|
505 |
+
* @param object $post
|
506 |
+
*/
|
507 |
+
function show( $post ) {
|
508 |
+
// Use nonce for verification
|
509 |
+
wp_nonce_field( plugin_basename( __FILE__ ), get_class().$this->_id );
|
510 |
+
do_action( 'metabox-show-'.$this->_id, $this->_fields, $this );
|
511 |
+
}
|
512 |
+
|
513 |
+
|
514 |
+
/**
|
515 |
+
* Method displays a list of attached images
|
516 |
+
*
|
517 |
+
*/
|
518 |
+
function _renderListImageAttachments() {
|
519 |
+
global $post, $current_screen;
|
520 |
+
$images = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image" );
|
521 |
+
|
522 |
+
// no images to render
|
523 |
+
if ( empty( $images ) ) {
|
524 |
+
?><p>No images have been saved.</p><?php
|
525 |
+
|
526 |
+
// rendering the images
|
527 |
+
} else {
|
528 |
+
|
529 |
+
?>
|
530 |
+
<table class="wp-list-table form-table widefat" style="border:none;">
|
531 |
+
<?php foreach ( (array)$images as $post_id => $image ): ?>
|
532 |
+
<?php $image_attributes = wp_get_attachment_image_src( $image->ID, 'thumbnail' ); ?>
|
533 |
+
<tbody id="the-list">
|
534 |
+
<tr>
|
535 |
+
<th scope="row" style="width: 140px">
|
536 |
+
<div style="padding:10px;background:whiteSmoke;">
|
537 |
+
<img src="<?php echo wp_get_attachment_thumb_url( $image->ID ); ?>" /></div>
|
538 |
+
</th>
|
539 |
+
<td>
|
540 |
+
<b><?php echo $image->post_title; ?></b>
|
541 |
+
<p><?php echo get_the_content( $image->ID ); ?></p>
|
542 |
+
|
543 |
+
<div class="row-actions">
|
544 |
+
<span class="inline">
|
545 |
+
<a href="<?php echo wp_nonce_url(
|
546 |
+
"media.php?attachment_id=$image->ID"
|
547 |
+
."&action=edit&_redirect="
|
548 |
+
.urlencode( $this->_currentPageURL() )
|
549 |
+
); ?>">
|
550 |
+
Edit</a> |
|
551 |
+
</span>
|
552 |
+
<span class="trash">
|
553 |
+
<a class="submitdelete"
|
554 |
+
onclick="return showNotice.warn();"
|
555 |
+
href="<?php echo wp_nonce_url(
|
556 |
+
"post.php?action=delete&_redirect="
|
557 |
+
.urlencode( $this->_currentPageURL() )
|
558 |
+
."&post=$image->ID",
|
559 |
+
'delete-attachment_' . $image->ID ); ?>">
|
560 |
+
Delete Permanently</a> |
|
561 |
+
</span>
|
562 |
+
<span class="inline">
|
563 |
+
<a target="_blank"
|
564 |
+
href="<?php echo get_attachment_link( $image->ID ); ?>">
|
565 |
+
View</a>
|
566 |
+
</span>
|
567 |
+
</div>
|
568 |
+
</td>
|
569 |
+
</tr>
|
570 |
+
</tbody>
|
571 |
+
<?php endforeach; ?>
|
572 |
+
</table>
|
573 |
+
<?php
|
574 |
+
}
|
575 |
+
return;
|
576 |
+
}
|
577 |
+
|
578 |
+
|
579 |
+
/**
|
580 |
+
* Return a clean list of meta listings created by this system
|
581 |
+
*
|
582 |
+
* @param string $category
|
583 |
+
* $param object $post
|
584 |
+
*/
|
585 |
+
public static function getMetaListings( $category, $post = null ) {
|
586 |
+
// initializing
|
587 |
+
if ( $post === NULL ) {
|
588 |
+
global $post;
|
589 |
+
}
|
590 |
+
$custom = get_post_custom( $post->ID );
|
591 |
+
$return = array();
|
592 |
+
|
593 |
+
//looping all values to build our return array
|
594 |
+
foreach ( (array)$custom as $property => $value ) {
|
595 |
+
$parts = explode( '_', $property );
|
596 |
+
if ( !isset( $parts[0] ) || !isset( $parts[1] ) || !isset( $parts[2] ) ) continue;
|
597 |
+
if ( $parts[0] != $category ) continue;
|
598 |
+
|
599 |
+
$pro = str_replace( $parts[0].'_'.$parts[1].'_', '', $property );
|
600 |
+
$return[$parts[1]][$pro] = $value;
|
601 |
+
}
|
602 |
+
|
603 |
+
return $return;
|
604 |
+
}
|
605 |
+
|
606 |
+
|
607 |
+
/**
|
608 |
+
* Function removes a specific category meta
|
609 |
+
*
|
610 |
+
* @param string $category
|
611 |
+
* $param string $meta_id
|
612 |
+
* $param object $post
|
613 |
+
*/
|
614 |
+
public static function deleteMetaListing( $category, $meta_id, $post = null ) {
|
615 |
+
// initializing
|
616 |
+
if ( $post === NULL ) {
|
617 |
+
global $post;
|
618 |
+
}
|
619 |
+
$listings = redrokk_metabox_class::getMetaListings( $category, $post );
|
620 |
+
if ( !isset( $listings[$meta_id] ) ) return false;
|
621 |
+
|
622 |
+
$type = 'post';
|
623 |
+
|
624 |
+
foreach ( (array)$listings[$meta_id] as $property => $value ) {
|
625 |
+
$pro = $category.'_'.$meta_id.'_'.$property;
|
626 |
+
delete_metadata( $type, $post->ID, $pro, $value[0] );
|
627 |
+
}
|
628 |
+
return true;
|
629 |
+
}
|
630 |
+
|
631 |
+
|
632 |
+
/**
|
633 |
+
* Method displays a list of meta attachments
|
634 |
+
*
|
635 |
+
*/
|
636 |
+
function _renderListAttachments() {
|
637 |
+
global $post;
|
638 |
+
|
639 |
+
//delete action prior to pulling new listings
|
640 |
+
if ( isset( $_REQUEST['redrokkdelete'] ) && $_REQUEST['redrokkdelete'] ) {
|
641 |
+
redrokk_metabox_class::deleteMetaListing( $this->_category_name, $_REQUEST['redrokkdelete'], $post );
|
642 |
+
}
|
643 |
+
|
644 |
+
//pull new listings
|
645 |
+
$metaListings = redrokk_metabox_class::getMetaListings( $this->_category_name, $post );
|
646 |
+
|
647 |
+
if ( !empty( $metaListings ) ) {
|
648 |
+
?>
|
649 |
+
<table class="wp-list-table form-table widefat" style="border:none;">
|
650 |
+
<tbody id="the-list">
|
651 |
+
<?php foreach ( (array)$metaListings as $meta_id => $video ): ?>
|
652 |
+
<?php $video = apply_filters( 'redrokk_metabox_class::_renderListAttachments', $video, $meta_id );?>
|
653 |
+
|
654 |
+
<tr id="<?php echo $this->_category_name; ?>_<?php echo $meta_id; ?>">
|
655 |
+
<th scope="row" style="width: 140px">
|
656 |
+
<div style="padding:10px;background:whiteSmoke;">
|
657 |
+
<?php if ( isset( $video['link'] ) ) echo apply_filters( 'the_content', $video['link'][0] ); ?>
|
658 |
+
</div>
|
659 |
+
</th>
|
660 |
+
<td>
|
661 |
+
<b><?php if ( isset( $video['post_title'] ) ) echo $video['post_title'][0]; ?></b>
|
662 |
+
<p><?php if ( isset( $video['post_content'] ) ) echo $video['post_content'][0]; ?></p>
|
663 |
+
|
664 |
+
<div class="row-actions">
|
665 |
+
<span class="inline">
|
666 |
+
<a href="#" id="edit_<?php echo $this->_category_name; ?>_<?php echo $meta_id; ?>">
|
667 |
+
Edit</a> |
|
668 |
+
</span>
|
669 |
+
<span class="trash">
|
670 |
+
<a class="submitdelete"
|
671 |
+
onclick="return showNotice.warn();"
|
672 |
+
href="<?php echo site_url( "wp-admin/post.php?post={$post->ID}"
|
673 |
+
."&action=edit"
|
674 |
+
."&redrokkdelete=$meta_id"
|
675 |
+
); ?>">
|
676 |
+
Delete Permanently</a>
|
677 |
+
</span>
|
678 |
+
</div>
|
679 |
+
<script>
|
680 |
+
jQuery('#edit_<?php echo $this->_category_name; ?>_<?php echo $meta_id; ?>').click(function(){
|
681 |
+
var data = {
|
682 |
+
<?php
|
683 |
+
$data = array();
|
684 |
+
|
685 |
+
//making sure all fields will be cleared
|
686 |
+
foreach ( (array)$this->_fields as $field ) {
|
687 |
+
if ( !isset( $field['id'] ) || !isset( $field['type'] ) ) continue;
|
688 |
+
if ( !in_array( $field['type'], array( 'text', 'file', 'image', 'textarea', 'hidden' ) ) )
|
689 |
+
continue;
|
690 |
+
|
691 |
+
$id = str_replace( $this->_id.'_', '', $field['id'] );
|
692 |
+
$data[$id] = "'$id':''";
|
693 |
+
}
|
694 |
+
|
695 |
+
//adding our values to the array
|
696 |
+
foreach ( (array)$video as $vp => $vv ) {
|
697 |
+
if ( isset( $vv[0] ) ) $vv = $vv[0];
|
698 |
+
$data[$vp] = "'$vp':'$vv'";
|
699 |
+
}
|
700 |
+
|
701 |
+
//adding the meta ID to the array
|
702 |
+
$data[$id] = "'metaid':'$meta_id'";
|
703 |
+
|
704 |
+
echo implode( ',', $data );
|
705 |
+
?>
|
706 |
+
};
|
707 |
+
|
708 |
+
jQuery.each(data, function(key, value){
|
709 |
+
jQuery('#<?php echo $this->_id; ?>_'+key).val( value );
|
710 |
+
});
|
711 |
+
return false;
|
712 |
+
});
|
713 |
+
</script>
|
714 |
+
</td>
|
715 |
+
<?php do_action( 'redrokk_metabox_class::_renderListAttachments::rows', $video, $meta_id, $this ); ?>
|
716 |
+
</tr>
|
717 |
+
<?php endforeach; ?>
|
718 |
+
</tbody>
|
719 |
+
</table>
|
720 |
+
<?php
|
721 |
+
}
|
722 |
+
|
723 |
+
}
|
724 |
+
|
725 |
+
|
726 |
+
/**
|
727 |
+
* Method displays a list of attached videos
|
728 |
+
*
|
729 |
+
*/
|
730 |
+
function _renderListVideoAttachments() {
|
731 |
+
global $post;
|
732 |
+
|
733 |
+
//pull new listings
|
734 |
+
$videos = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=video/mp4" );
|
735 |
+
|
736 |
+
// no images to render
|
737 |
+
if ( !empty( $videos ) ) {
|
738 |
+
?>
|
739 |
+
<table class="wp-list-table form-table widefat" style="border:none;">
|
740 |
+
<tbody id="the-list">
|
741 |
+
<?php foreach ( (array)$videos as $post_id => $video ): ?>
|
742 |
+
<?php $image_attributes = wp_get_attachment_link( $video->ID ); ?>
|
743 |
+
<tr>
|
744 |
+
<th scope="row" style="width: 140px">
|
745 |
+
<div style="padding:10px;background:whiteSmoke;">
|
746 |
+
<?php echo $image_attributes; ?>
|
747 |
+
</div>
|
748 |
+
</th>
|
749 |
+
<td>
|
750 |
+
<b><?php echo $video->post_title; ?></b>
|
751 |
+
<p><?php echo get_the_content( $video->ID ); ?></p>
|
752 |
+
|
753 |
+
<div class="row-actions">
|
754 |
+
<span class="inline">
|
755 |
+
<a href="<?php echo wp_nonce_url(
|
756 |
+
"media.php?attachment_id=$meta_id"
|
757 |
+
."&action=edit&_redirect="
|
758 |
+
.urlencode( $this->_currentPageURL() )
|
759 |
+
); ?>">
|
760 |
+
Edit</a> |
|
761 |
+
</span>
|
762 |
+
<span class="trash">
|
763 |
+
<a class="submitdelete"
|
764 |
+
onclick="return showNotice.warn();"
|
765 |
+
href="<?php echo wp_nonce_url(
|
766 |
+
"post.php?action=delete&_redirect="
|
767 |
+
.urlencode( $this->_currentPageURL() )
|
768 |
+
."&post=$video->ID",
|
769 |
+
'delete-attachment_' . $video->ID ); ?>">
|
770 |
+
Delete Permanently</a>
|
771 |
+
</span>
|
772 |
+
</div>
|
773 |
+
</td>
|
774 |
+
</tr>
|
775 |
+
<?php endforeach; ?>
|
776 |
+
</tbody>
|
777 |
+
</table>
|
778 |
+
<?php
|
779 |
+
}
|
780 |
+
}
|
781 |
+
|
782 |
+
|
783 |
+
/**
|
784 |
+
* Method renders the form from any source
|
785 |
+
*
|
786 |
+
* @param array $fields
|
787 |
+
*/
|
788 |
+
function _renderForm( $fields = array() ) {
|
789 |
+
//initializing
|
790 |
+
global $post;
|
791 |
+
$defaults = array(
|
792 |
+
'name' => '',
|
793 |
+
'desc' => '',
|
794 |
+
'id' => '',
|
795 |
+
'type' => 'text',
|
796 |
+
'options' => array(),
|
797 |
+
'default' => '',
|
798 |
+
'value' => '',
|
799 |
+
'class' => '',
|
800 |
+
'multiple' => '',
|
801 |
+
'args' => array(
|
802 |
+
'hide_empty' => 0,
|
803 |
+
'name' => 'element_name',
|
804 |
+
'hierarchical' => true
|
805 |
+
),
|
806 |
+
'attributes' => ''
|
807 |
+
);
|
808 |
+
|
809 |
+
// no fields to render
|
810 |
+
if ( empty( $fields ) ) {
|
811 |
+
?>
|
812 |
+
<p>No form fields have been defined. Use <pre>
|
813 |
+
$metabox->set('_fields', array(
|
814 |
+
array(
|
815 |
+
'name' => 'Title',
|
816 |
+
'type' => 'title',
|
817 |
+
),
|
818 |
+
array(
|
819 |
+
'name' => 'Title',
|
820 |
+
'desc' => '',
|
821 |
+
'id' => 'title',
|
822 |
+
'type' => 'text',
|
823 |
+
'std' => ''
|
824 |
+
),
|
825 |
+
array(
|
826 |
+
'name' => 'image',
|
827 |
+
'desc' => '',
|
828 |
+
'id' => 'imagefile',
|
829 |
+
'type' => 'image',
|
830 |
+
'std' => ''
|
831 |
+
),
|
832 |
+
array(
|
833 |
+
'name' => 'Textarea',
|
834 |
+
'desc' => 'Enter big text here',
|
835 |
+
'id' => 'textarea_id',
|
836 |
+
'type' => 'textarea',
|
837 |
+
'std' => 'Default value 2'
|
838 |
+
),
|
839 |
+
array(
|
840 |
+
'name' => 'Select box',
|
841 |
+
'id' => 'select_id',
|
842 |
+
'type' => 'select',
|
843 |
+
'options'=> array(
|
844 |
+
'value1' => 'Value 1',
|
845 |
+
'value2' => 'Value 2',
|
846 |
+
'value3' => 'Value 3',
|
847 |
+
'value4' => 'Value 4',
|
848 |
+
)
|
849 |
+
),
|
850 |
+
array(
|
851 |
+
'name' => 'Radio',
|
852 |
+
'id' => 'radio_id',
|
853 |
+
'type' => 'radio',
|
854 |
+
'value' => 'test',
|
855 |
+
'desc' => 'Check this box if you want its value saved',
|
856 |
+
),
|
857 |
+
array(
|
858 |
+
'name' => '',
|
859 |
+
'id' => 'radio_id',
|
860 |
+
'type' => 'radio',
|
861 |
+
'value' => 'test2',
|
862 |
+
'desc' => 'Check this box if you want its value saved',
|
863 |
+
),
|
864 |
+
array(
|
865 |
+
'name' => 'Checkbox',
|
866 |
+
'id' => 'checkbox_id',
|
867 |
+
'type' => 'checkbox',
|
868 |
+
'desc' => 'Check this box if you want its value saved',
|
869 |
+
),
|
870 |
+
));</pre>
|
871 |
+
</p>
|
872 |
+
<?php
|
873 |
+
|
874 |
+
// rendering the fields
|
875 |
+
} else {
|
876 |
+
?>
|
877 |
+
<table class="form-table">
|
878 |
+
<?php
|
879 |
+
// do_action("{$this->_class}_before");
|
880 |
+
$custom = get_post_custom( $this->_id );
|
881 |
+
|
882 |
+
foreach ( (array)$fields as $field ):
|
883 |
+
$field = wp_parse_args( $field, $defaults );
|
884 |
+
$field['args'] = wp_parse_args( $field['args'], $defaults['args'] );
|
885 |
+
|
886 |
+
extract( $field );
|
887 |
+
$field['args']['name'] = $element_name = $id;
|
888 |
+
|
889 |
+
// grabbing the meta value
|
890 |
+
if ( array_key_exists( $id, $custom ) ) {
|
891 |
+
if ( isset( $custom[$id][0] ) )
|
892 |
+
$meta = esc_attr( $custom[$id][0] );
|
893 |
+
else
|
894 |
+
$meta = esc_attr( $custom[$id] );
|
895 |
+
} else {
|
896 |
+
$meta = $default;
|
897 |
+
}
|
898 |
+
|
899 |
+
$id = sanitize_title( $id );
|
900 |
+
|
901 |
+
if ( array_key_exists( 'deleteattachment', $_GET )
|
902 |
+
&& $id == $_GET['fileproperty']
|
903 |
+
&& $meta == $_GET['deleteattachment'] ) {
|
904 |
+
wp_delete_attachment( $_GET['deleteattachment'], $force_delete = true );
|
905 |
+
update_post_meta( $post->ID, $id, '' );
|
906 |
+
}
|
907 |
+
?>
|
908 |
+
<?php switch ( $type ) { default: ?>
|
909 |
+
<?php if ( is_callable( $type ) && function_exists( $type ) ) : ?>
|
910 |
+
<tr>
|
911 |
+
<th scope="row" style="width: 140px">
|
912 |
+
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
913 |
+
</th>
|
914 |
+
<td>
|
915 |
+
<?php call_user_func( $type, $args ); ?>
|
916 |
+
<span class="description"><?php echo $desc; ?></span>
|
917 |
+
</td>
|
918 |
+
</tr>
|
919 |
+
<?php break; endif; ?>
|
920 |
+
<?php case 'text': ?>
|
921 |
+
<tr>
|
922 |
+
<th scope="row" style="width: 140px">
|
923 |
+
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
924 |
+
</th>
|
925 |
+
<td>
|
926 |
+
<input <?php echo $attributes ?>
|
927 |
+
id="<?php echo $id; ?>"
|
928 |
+
value="<?php echo $meta; ?>"
|
929 |
+
type="<?php echo $type; ?>"
|
930 |
+
name="<?php echo $id; ?>"
|
931 |
+
class="text large-text <?php echo $class; ?>" />
|
932 |
+
<span class="description"><?php echo $desc; ?></span>
|
933 |
+
</td>
|
934 |
+
</tr>
|
935 |
+
<?php break; ?>
|
936 |
+
<?php case 'submit': ?>
|
937 |
+
<?php case 'button': ?>
|
938 |
+
<tr>
|
939 |
+
<td colspan="2">
|
940 |
+
<input <?php echo $attributes ?>
|
941 |
+
id="<?php echo $id; ?>"
|
942 |
+
value="<?php echo $name; ?>"
|
943 |
+
type="submit"
|
944 |
+
name="submit"
|
945 |
+
class="button-primary <?php echo $class; ?>" />
|
946 |
+
<span class="description"><?php echo $desc; ?></span>
|
947 |
+
</td>
|
948 |
+
</tr>
|
949 |
+
<?php break; ?>
|
950 |
+
<?php case 'file': ?>
|
951 |
+
<?php case 'image': ?>
|
952 |
+
<tr>
|
953 |
+
<th scope="row" style="width: 140px">
|
954 |
+
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
955 |
+
</th>
|
956 |
+
<td>
|
957 |
+
<?php if ( $meta && wp_get_attachment_url( $meta ) ): ?>
|
958 |
+
<?php echo wp_get_attachment_image( $meta ); ?>
|
959 |
+
<span><a href="<?php echo add_query_arg( 'fileproperty', $id, add_query_arg( 'deleteattachment', $meta, $this->_currentPageURL() ) ); ?>">Delete Image</a></span>
|
960 |
+
<?php else: ?>
|
961 |
+
<input type="hidden" name="<?php echo $this->_id; ?>files" value="<?php echo $id; ?>" />
|
962 |
+
<!-- first hidden input forces this item to be submitted when it is not checked -->
|
963 |
+
<input <?php echo $attributes ?>
|
964 |
+
id="<?php echo $id; ?>"
|
965 |
+
type="file"
|
966 |
+
name="<?php echo $id; ?>"
|
967 |
+
onChange="jQuery(this).closest('form').attr('enctype', 'multipart/form-data');"
|
968 |
+
class="<?php echo $class; ?>" />
|
969 |
+
<?php endif; ?>
|
970 |
+
<span class="description"><?php echo $desc; ?></span>
|
971 |
+
</td>
|
972 |
+
</tr>
|
973 |
+
<?php break; ?>
|
974 |
+
<?php case 'title': ?>
|
975 |
+
<tr>
|
976 |
+
<th colspan="2" scope="row">
|
977 |
+
<h3 <?php echo $attributes ?> style="border: 1px solid #ddd;
|
978 |
+
padding: 10px;
|
979 |
+
background: #eee;
|
980 |
+
border-radius: 2px;
|
981 |
+
color: #666;
|
982 |
+
margin: 0;"><?php echo $name; ?>
|
983 |
+
</h3>
|
984 |
+
</th>
|
985 |
+
</tr>
|
986 |
+
<?php break; ?>
|
987 |
+
<?php case 'checkbox': ?>
|
988 |
+
<tr>
|
989 |
+
<th scope="row" style="width: 140px">
|
990 |
+
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
991 |
+
</th>
|
992 |
+
<td>
|
993 |
+
<input type="hidden" name="<?php echo $id; ?>" value="" />
|
994 |
+
<!-- first hidden input forces this item to be submitted when it is not checked -->
|
995 |
+
|
996 |
+
<?php foreach ( (array)$options as $_value => $_name ): ?>
|
997 |
+
<input value="<?php echo $_value; ?>" type="checkbox" <?php echo $attributes ?>
|
998 |
+
name="<?php echo $element_name; ?>" id="<?php echo $id; ?>"
|
999 |
+
<?php echo $meta == $_value? 'checked="checked"' :''; ?>
|
1000 |
+
class="<?php echo $class; ?>" />
|
1001 |
+
<?php echo $_name; ?>
|
1002 |
+
<?php endforeach; ?>
|
1003 |
+
<span class="description"><?php echo $desc; ?></span>
|
1004 |
+
</td>
|
1005 |
+
</tr>
|
1006 |
+
<?php break; ?>
|
1007 |
+
<?php case 'radio': ?>
|
1008 |
+
<tr>
|
1009 |
+
<th scope="row" style="width: 140px">
|
1010 |
+
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
1011 |
+
</th>
|
1012 |
+
<td>
|
1013 |
+
<?php foreach ( (array)$options as $_value => $_name ): ?>
|
1014 |
+
<input name="<?php echo $element_name; ?>" id="<?php echo $id; ?>"
|
1015 |
+
value="<?php echo $_value; ?>" type="<?php echo $type; ?>"
|
1016 |
+
<?php echo $meta == $_value?'checked="checked"' :''; ?>
|
1017 |
+
<?php echo $attributes ?> class="<?php echo $class; ?>" />
|
1018 |
+
<?php echo $_name; ?>
|
1019 |
+
<?php endforeach; ?>
|
1020 |
+
<span class="description"><?php echo $desc; ?></span>
|
1021 |
+
</td>
|
1022 |
+
</tr>
|
1023 |
+
<?php break; ?>
|
1024 |
+
<?php case 'textarea': ?>
|
1025 |
+
<tr>
|
1026 |
+
<th scope="row" style="width: 140px">
|
1027 |
+
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
1028 |
+
</th>
|
1029 |
+
<td>
|
1030 |
+
<textarea <?php echo $attributes ?>
|
1031 |
+
id="<?php echo $id; ?>"
|
1032 |
+
name="<?php echo $id; ?>"
|
1033 |
+
class="large-text <?php echo $class; ?>"
|
1034 |
+
><?php echo $meta; ?></textarea>
|
1035 |
+
<span class="description"><?php echo $desc; ?></span>
|
1036 |
+
</td>
|
1037 |
+
</tr>
|
1038 |
+
<?php break; ?>
|
1039 |
+
<?php case 'wpeditor': ?>
|
1040 |
+
<tr>
|
1041 |
+
<th scope="row" style="width: 140px">
|
1042 |
+
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
1043 |
+
</th>
|
1044 |
+
<td>
|
1045 |
+
<?php wp_editor( $meta, $id, $settings = array() ); ?>
|
1046 |
+
<span class="description"><?php echo $desc; ?></span>
|
1047 |
+
</td>
|
1048 |
+
</tr>
|
1049 |
+
<?php break; ?>
|
1050 |
+
<?php case 'select_capabilities': ?>
|
1051 |
+
<?php $options = $type=='select_capabilities' ?$this->get_options_capabilities()+$options :$options; ?>
|
1052 |
+
|
1053 |
+
<?php case 'select_roles': ?>
|
1054 |
+
<?php $options = $type=='select_roles' ?$this->get_options_roles()+$options :$options; ?>
|
1055 |
+
|
1056 |
+
<?php case 'select_menu': ?>
|
1057 |
+
<?php $options = $type=='select_menu' ?$this->get_options_menus()+$options :$options; ?>
|
1058 |
+
|
1059 |
+
<?php case 'select_pages': ?>
|
1060 |
+
<?php $options = $type=='select_pages' ?$this->get_options_pages()+$options :$options; ?>
|
1061 |
+
|
1062 |
+
<?php case 'select_users': ?>
|
1063 |
+
<?php $options = $type=='select_users' ?$this->get_options_users()+$options :$options; ?>
|
1064 |
+
|
1065 |
+
<?php case 'select_categories': ?>
|
1066 |
+
<?php case 'select': ?>
|
1067 |
+
<tr>
|
1068 |
+
<th scope="row" style="width: 140px">
|
1069 |
+
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
1070 |
+
</th>
|
1071 |
+
<td>
|
1072 |
+
<?php if ( $type == 'select_categories' ): ?>
|
1073 |
+
<?php wp_dropdown_categories( $args ); ?>
|
1074 |
+
|
1075 |
+
<?php else: ?>
|
1076 |
+
|
1077 |
+
<select <?php echo $attributes ?>
|
1078 |
+
id="<?php echo $id; ?>"
|
1079 |
+
name="<?php echo $id; ?>"
|
1080 |
+
class="<?php echo $class; ?>"
|
1081 |
+
<?php echo $multiple ?"MULTIPLE SIZE='$multiple'" :''; ?>
|
1082 |
+
><?php foreach ( (array)$options as $_value => $_name ): ?>
|
1083 |
+
|
1084 |
+
<option
|
1085 |
+
value="<?php echo $_value; ?>"
|
1086 |
+
<?php echo $meta == $_value ?' selected="selected"' :''; ?>
|
1087 |
+
><?php echo $_name; ?></option>
|
1088 |
+
|
1089 |
+
<?php endforeach; ?></select>
|
1090 |
+
<?php endif; ?>
|
1091 |
+
<span class="description"><?php echo $desc; ?></span>
|
1092 |
+
</td>
|
1093 |
+
</tr>
|
1094 |
+
<?php break; ?>
|
1095 |
+
<?php case 'hidden': ?>
|
1096 |
+
<tr>
|
1097 |
+
<td colspan="2">
|
1098 |
+
<input <?php echo $attributes ?>
|
1099 |
+
id="<?php echo $id; ?>"
|
1100 |
+
value="<?php echo $meta ?$meta :$default; ?>"
|
1101 |
+
type="<?php echo $type; ?>"
|
1102 |
+
name="<?php echo $id; ?>"
|
1103 |
+
style="visibility:hidden;" />
|
1104 |
+
</td>
|
1105 |
+
</tr>
|
1106 |
+
<?php break; ?>
|
1107 |
+
<?php case 'custom': ?>
|
1108 |
+
<tr>
|
1109 |
+
<td colspan="2">
|
1110 |
+
<?php echo $desc.$default; ?>
|
1111 |
+
</td>
|
1112 |
+
</tr>
|
1113 |
+
<?php } ?>
|
1114 |
+
<?php endforeach; ?>
|
1115 |
+
</table>
|
1116 |
+
<?php
|
1117 |
+
}
|
1118 |
+
return $this;
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
|
1122 |
+
/**
|
1123 |
+
* Returns an options list of menus
|
1124 |
+
*/
|
1125 |
+
function get_options_pages() {
|
1126 |
+
// initializing
|
1127 |
+
$options = array( '0'=>' -- ' );
|
1128 |
+
$pages = get_pages( array( 'post_type' => 'page', 'post_status' => 'publish' ) );
|
1129 |
+
|
1130 |
+
foreach ( $pages as $page ) {
|
1131 |
+
$options[$page->ID] = $page->post_title;
|
1132 |
+
}
|
1133 |
+
|
1134 |
+
return $options;
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
|
1138 |
+
/**
|
1139 |
+
* Returns an options list of menus
|
1140 |
+
*/
|
1141 |
+
function get_options_menus() {
|
1142 |
+
// initializing
|
1143 |
+
$options = array( '0'=>' -- ' );
|
1144 |
+
$menus = get_terms( 'nav_menu', array(
|
1145 |
+
'hide_empty' => 0
|
1146 |
+
) );
|
1147 |
+
|
1148 |
+
foreach ( $menus as $menu ) {
|
1149 |
+
$options[$menu->slug] = $menu->name;
|
1150 |
+
}
|
1151 |
+
|
1152 |
+
return $options;
|
1153 |
+
}
|
1154 |
+
|
1155 |
+
|
1156 |
+
/**
|
1157 |
+
* Returns an options list of users
|
1158 |
+
*/
|
1159 |
+
function get_options_users() {
|
1160 |
+
// initializing
|
1161 |
+
global $wpdb;
|
1162 |
+
|
1163 |
+
$options = array( '0'=>' -- ' );
|
1164 |
+
$query = $wpdb->prepare( "SELECT $wpdb->users.ID, $wpdb->users.display_name FROM $wpdb->users" );
|
1165 |
+
$results = $wpdb->get_results( $query );
|
1166 |
+
|
1167 |
+
foreach ( (array)$results as $result ) {
|
1168 |
+
$options[$result->ID] = $result->display_name;
|
1169 |
+
}
|
1170 |
+
|
1171 |
+
return $options;
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
|
1175 |
+
/**
|
1176 |
+
* Returns an options list of capabilities
|
1177 |
+
*/
|
1178 |
+
function get_options_capabilities() {
|
1179 |
+
// initializing
|
1180 |
+
global $wpdb;
|
1181 |
+
|
1182 |
+
$options = array();
|
1183 |
+
$roles = get_option( $wpdb->prefix . 'user_roles' );
|
1184 |
+
|
1185 |
+
foreach ( (array)$roles as $role ) {
|
1186 |
+
if ( !isset( $role['capabilities'] ) ) continue;
|
1187 |
+
foreach ( (array)$role['capabilities'] as $cap => $v ) {
|
1188 |
+
$options[$role['name']."::$cap"] = $role['name']."::$cap";
|
1189 |
+
}
|
1190 |
+
}
|
1191 |
+
|
1192 |
+
return $options;
|
1193 |
+
}
|
1194 |
+
|
1195 |
+
|
1196 |
+
/**
|
1197 |
+
* Returns an options list of roles
|
1198 |
+
*/
|
1199 |
+
function get_options_roles() {
|
1200 |
+
// initializing
|
1201 |
+
global $wpdb;
|
1202 |
+
|
1203 |
+
$options = array(
|
1204 |
+
'read' => 'Public'
|
1205 |
+
);
|
1206 |
+
$roles = get_option( $wpdb->prefix . 'user_roles' );
|
1207 |
+
|
1208 |
+
foreach ( (array)$roles as $role ) {
|
1209 |
+
$options[strtolower( $role['name'] )] = $role['name'];
|
1210 |
+
}
|
1211 |
+
|
1212 |
+
return $options;
|
1213 |
+
}
|
1214 |
+
|
1215 |
+
|
1216 |
+
/**
|
1217 |
+
* Adds a box to the main column on the Post and Page edit screens
|
1218 |
+
*
|
1219 |
+
*/
|
1220 |
+
function _register() {
|
1221 |
+
// this metabox is to be displayed for a certain object type only
|
1222 |
+
if ( !empty( $this->_object_types ) && !in_array( $this->getCurrentPostType(), $this->_object_types ) )
|
1223 |
+
return;
|
1224 |
+
|
1225 |
+
if ( !$this->callback_args ) {
|
1226 |
+
$this->callback_args = $this;
|
1227 |
+
}
|
1228 |
+
|
1229 |
+
// if the user has not already set the type of this metabox,
|
1230 |
+
// then we need to do that now
|
1231 |
+
if ( !$this->_type ) {
|
1232 |
+
$this->setType();
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
add_meta_box(
|
1236 |
+
$this->_id,
|
1237 |
+
$this->title,
|
1238 |
+
$this->callback,
|
1239 |
+
$this->getCurrentPostType(),
|
1240 |
+
$this->context,
|
1241 |
+
$this->priority,
|
1242 |
+
$this->callback_args
|
1243 |
+
);
|
1244 |
+
}
|
1245 |
+
|
1246 |
+
|
1247 |
+
/**
|
1248 |
+
* Method set's the hooks for the options creted by this metabox
|
1249 |
+
*
|
1250 |
+
*/
|
1251 |
+
function setOptionHooks() {
|
1252 |
+
foreach ( (array)$this->_fields as $field ) {
|
1253 |
+
if ( !isset( $field['id'] ) ) continue;
|
1254 |
+
|
1255 |
+
//creating the callback for the admin page
|
1256 |
+
$function = create_function( '$default', '
|
1257 |
+
return redrokk_admin_class::getInstance("'.$this->_isAdminPage.'")
|
1258 |
+
->getOption("'.$field['id'].'", $default, true);
|
1259 |
+
' );
|
1260 |
+
add_filter( "pre_option_{$field['id']}", $function, 20, 2 );
|
1261 |
+
}
|
1262 |
+
}
|
1263 |
+
|
1264 |
+
|
1265 |
+
/**
|
1266 |
+
* Method redirects the user if we have added a request redirect
|
1267 |
+
* in the url
|
1268 |
+
*
|
1269 |
+
* @param string $location
|
1270 |
+
*/
|
1271 |
+
function _redirectIntervention( $location ) {
|
1272 |
+
if ( isset( $_GET['_redirect'] ) ) {
|
1273 |
+
$location = urldecode( $_GET['_redirect'] );
|
1274 |
+
}
|
1275 |
+
return $location;
|
1276 |
+
}
|
1277 |
+
|
1278 |
+
|
1279 |
+
/**
|
1280 |
+
* Get the current page url
|
1281 |
+
*/
|
1282 |
+
function _currentPageURL() {
|
1283 |
+
$pageURL = 'http';
|
1284 |
+
if ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) {$pageURL .= "s";}
|
1285 |
+
$pageURL .= "://";
|
1286 |
+
if ( $_SERVER["SERVER_PORT"] != "80" ) {
|
1287 |
+
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
1288 |
+
} else {
|
1289 |
+
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
1290 |
+
}
|
1291 |
+
return $pageURL;
|
1292 |
+
}
|
1293 |
+
|
1294 |
+
|
1295 |
+
/**
|
1296 |
+
* Method to bind an associative array or object to the JTable instance.This
|
1297 |
+
* method only binds properties that are publicly accessible and optionally
|
1298 |
+
* takes an array of properties to ignore when binding.
|
1299 |
+
*
|
1300 |
+
* @param mixed $src An associative array or object to bind to the JTable instance.
|
1301 |
+
* @param mixed $ignore An optional array or space separated list of properties to ignore while binding.
|
1302 |
+
*
|
1303 |
+
* @return boolean True on success.
|
1304 |
+
*
|
1305 |
+
* @link http://docs.joomla.org/JTable/bind
|
1306 |
+
* @since 11.1
|
1307 |
+
*/
|
1308 |
+
public function bind( $src, $ignore = array() ) {
|
1309 |
+
// If the source value is not an array or object return false.
|
1310 |
+
if ( !is_object( $src ) && !is_array( $src ) ) {
|
1311 |
+
trigger_error( 'Bind failed as the provided source is not an array.' );
|
1312 |
+
return false;
|
1313 |
+
}
|
1314 |
+
|
1315 |
+
// If the source value is an object, get its accessible properties.
|
1316 |
+
if ( is_object( $src ) ) {
|
1317 |
+
$src = get_object_vars( $src );
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
// If the ignore value is a string, explode it over spaces.
|
1321 |
+
if ( !is_array( $ignore ) ) {
|
1322 |
+
$ignore = explode( ' ', $ignore );
|
1323 |
+
}
|
1324 |
+
|
1325 |
+
// Bind the source value, excluding the ignored fields.
|
1326 |
+
foreach ( $this->getProperties() as $k => $v ) {
|
1327 |
+
// Only process fields not in the ignore array.
|
1328 |
+
if ( !in_array( $k, $ignore ) ) {
|
1329 |
+
if ( isset( $src[$k] ) ) {
|
1330 |
+
$this->$k = $src[$k];
|
1331 |
+
}
|
1332 |
+
}
|
1333 |
+
}
|
1334 |
+
|
1335 |
+
return true;
|
1336 |
+
}
|
1337 |
+
|
1338 |
+
|
1339 |
+
/**
|
1340 |
+
* Set the object properties based on a named array/hash.
|
1341 |
+
*
|
1342 |
+
* @param mixed $properties Either an associative array or another object.
|
1343 |
+
*
|
1344 |
+
* @return boolean
|
1345 |
+
*
|
1346 |
+
* @since 11.1
|
1347 |
+
*
|
1348 |
+
* @see set()
|
1349 |
+
*/
|
1350 |
+
public function setProperties( $properties ) {
|
1351 |
+
if ( is_array( $properties ) || is_object( $properties ) ) {
|
1352 |
+
foreach ( (array) $properties as $k => $v ) {
|
1353 |
+
// Use the set function which might be overridden.
|
1354 |
+
$this->set( $k, $v );
|
1355 |
+
}
|
1356 |
+
return true;
|
1357 |
+
}
|
1358 |
+
|
1359 |
+
return false;
|
1360 |
+
}
|
1361 |
+
|
1362 |
+
|
1363 |
+
/**
|
1364 |
+
* Modifies a property of the object, creating it if it does not already exist.
|
1365 |
+
*
|
1366 |
+
* @param string $property The name of the property.
|
1367 |
+
* @param mixed $value The value of the property to set.
|
1368 |
+
*
|
1369 |
+
* @return mixed Previous value of the property.
|
1370 |
+
*
|
1371 |
+
* @since 11.1
|
1372 |
+
*/
|
1373 |
+
public function set( $property, $value = null ) {
|
1374 |
+
$_property = 'set'.str_replace( ' ', '', ucwords( str_replace( '_', ' ', $property ) ) );
|
1375 |
+
if ( method_exists( $this, $_property ) ) {
|
1376 |
+
return $this->$_property( $value );
|
1377 |
+
}
|
1378 |
+
|
1379 |
+
$previous = isset( $this->$property ) ? $this->$property : null;
|
1380 |
+
$this->$property = $value;
|
1381 |
+
return $previous;
|
1382 |
+
}
|
1383 |
+
|
1384 |
+
|
1385 |
+
/**
|
1386 |
+
* Returns an associative array of object properties.
|
1387 |
+
*
|
1388 |
+
* @param boolean $public If true, returns only the public properties.
|
1389 |
+
*
|
1390 |
+
* @return array
|
1391 |
+
*
|
1392 |
+
* @see get()
|
1393 |
+
*/
|
1394 |
+
public function getProperties( $public = true ) {
|
1395 |
+
$vars = get_object_vars( $this );
|
1396 |
+
if ( $public ) {
|
1397 |
+
foreach ( $vars as $key => $value ) {
|
1398 |
+
if ( '_' == substr( $key, 0, 1 ) ) {
|
1399 |
+
unset( $vars[$key] );
|
1400 |
+
}
|
1401 |
+
}
|
1402 |
+
}
|
1403 |
+
|
1404 |
+
return $vars;
|
1405 |
+
}
|
1406 |
+
|
1407 |
+
|
1408 |
+
/**
|
1409 |
+
* contains the current instance of this class
|
1410 |
+
*
|
1411 |
+
* @var object
|
1412 |
+
*/
|
1413 |
+
static $_instances = null;
|
1414 |
+
|
1415 |
+
/**
|
1416 |
+
* Method is called when we need to instantiate this class
|
1417 |
+
*
|
1418 |
+
* @param array $options
|
1419 |
+
*/
|
1420 |
+
public static function getInstance( $_id, $options = array() ) {
|
1421 |
+
if ( !isset( self::$_instances[$_id] ) ) {
|
1422 |
+
$options['_id'] = $_id;
|
1423 |
+
$class = get_class();
|
1424 |
+
self::$_instances[$_id] = new $class( $options );
|
1425 |
+
}
|
1426 |
+
return self::$_instances[$_id];
|
1427 |
+
}
|
1428 |
+
|
1429 |
+
|
1430 |
+
}
|
1431 |
+
|
1432 |
+
|
1433 |
+
endif;
|
lib/class-settings-testimonials-widget.php
ADDED
@@ -0,0 +1,1091 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Copyright 2013 Michael Cannon (email: mc@aihr.us)
|
4 |
+
|
5 |
+
This program is free software; you can redistribute it and/or modify
|
6 |
+
it under the terms of the GNU General Public License, version 2, as
|
7 |
+
published by the Free Software Foundation.
|
8 |
+
|
9 |
+
This program is distributed in the hope that it will be useful,
|
10 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
+
GNU General Public License for more details.
|
13 |
+
|
14 |
+
You should have received a copy of the GNU General Public License
|
15 |
+
along with this program; if not, write to the Free Software
|
16 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Testimonials Widget settings class
|
21 |
+
*
|
22 |
+
* Based upon http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
|
23 |
+
*/
|
24 |
+
class Testimonials_Widget_Settings {
|
25 |
+
const ID = 'testimonialswidget_settings';
|
26 |
+
|
27 |
+
public static $default = array(
|
28 |
+
'backwards' => array(
|
29 |
+
'version' => '', // below this version number, use std
|
30 |
+
'std' => '',
|
31 |
+
),
|
32 |
+
'choices' => array(), // key => value
|
33 |
+
'class' => '',
|
34 |
+
'desc' => '',
|
35 |
+
'id' => 'default_field',
|
36 |
+
'section' => 'general',
|
37 |
+
'std' => '', // default key or value
|
38 |
+
'title' => '',
|
39 |
+
'type' => 'text', // textarea, checkbox, radio, select, hidden, heading, password, expand_begin, expand_end
|
40 |
+
'validate' => '', // required, term, slug, slugs, ids, order, single paramater PHP functions
|
41 |
+
'widget' => 1, // show in widget options, 0 off
|
42 |
+
);
|
43 |
+
public static $defaults = array();
|
44 |
+
public static $sections = array();
|
45 |
+
public static $settings = array();
|
46 |
+
public static $version = null;
|
47 |
+
|
48 |
+
|
49 |
+
public function __construct() {
|
50 |
+
add_action( 'admin_init', array( &$this, 'admin_init' ) );
|
51 |
+
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
52 |
+
add_action( 'init', array( &$this, 'init' ) );
|
53 |
+
load_plugin_textdomain( 'testimonials-widget', false, '/testimonials-widget/languages/' );
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
public function init() {
|
58 |
+
self::sections();
|
59 |
+
self::settings();
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
public static function sections() {
|
64 |
+
self::$sections['general'] = __( 'General', 'testimonials-widget' );
|
65 |
+
self::$sections['selection'] = __( 'Selection', 'testimonials-widget' );
|
66 |
+
self::$sections['ordering'] = __( 'Ordering', 'testimonials-widget' );
|
67 |
+
self::$sections['widget'] = __( 'Widget', 'testimonials-widget' );
|
68 |
+
// self::$sections['testing'] = __( 'Testing', 'testimonials-widget' );
|
69 |
+
self::$sections['post_type'] = __( 'Post Type', 'testimonials-widget' );
|
70 |
+
self::$sections['reset'] = __( 'Compatibility & Reset', 'testimonials-widget' );
|
71 |
+
self::$sections['about'] = __( 'About Testimonials Widget', 'testimonials-widget' );
|
72 |
+
|
73 |
+
self::$sections = apply_filters( 'testimonials_widget_sections', self::$sections );
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
/**
|
78 |
+
*
|
79 |
+
*
|
80 |
+
* @SuppressWarnings(PHPMD.Superglobals)
|
81 |
+
*/
|
82 |
+
public static function settings() {
|
83 |
+
// Widget
|
84 |
+
self::$settings['title'] = array(
|
85 |
+
'section' => 'widget',
|
86 |
+
'title' => __( 'Widget Title', 'testimonials-widget' ),
|
87 |
+
'std' => __( 'Testimonials', 'testimonials-widget' ),
|
88 |
+
'validate' => 'wp_kses_post',
|
89 |
+
);
|
90 |
+
|
91 |
+
self::$settings['title_link'] = array(
|
92 |
+
'section' => 'widget',
|
93 |
+
'title' => __( 'Title Link', 'testimonials-widget' ),
|
94 |
+
'desc' => __( 'URL or Post ID to link widget title to. Ex: 123 or http://example.com', 'testimonials-widget' ),
|
95 |
+
'validate' => 'wp_kses_data',
|
96 |
+
);
|
97 |
+
|
98 |
+
self::$settings['char_limit'] = array(
|
99 |
+
'section' => 'widget',
|
100 |
+
'title' => __( 'Character Limit', 'testimonials-widget' ),
|
101 |
+
'desc' => __( 'Number of characters to limit non-single testimonial views to', 'testimonials-widget' ),
|
102 |
+
'validate' => 'absint',
|
103 |
+
);
|
104 |
+
|
105 |
+
self::$settings['height'] = array(
|
106 |
+
'section' => 'widget',
|
107 |
+
'title' => __( 'Height', 'testimonials-widget' ),
|
108 |
+
'desc' => __( 'Testimonials height, in pixels. Overrides minimum and maximum height', 'testimonials-widget' ),
|
109 |
+
'validate' => 'min1',
|
110 |
+
);
|
111 |
+
|
112 |
+
self::$settings['refresh_interval'] = array(
|
113 |
+
'section' => 'widget',
|
114 |
+
'title' => __( 'Rotation Speed', 'testimonials-widget' ),
|
115 |
+
'desc' => __( 'Number of seconds between testimonial rotations or 0 for no rotation at all refresh', 'testimonials-widget' ),
|
116 |
+
'std' => 5,
|
117 |
+
'validate' => 'absint',
|
118 |
+
);
|
119 |
+
|
120 |
+
self::$settings['widget_expand_begin'] = array(
|
121 |
+
'section' => 'widget',
|
122 |
+
'desc' => __( 'Additional Widget Options', 'testimonials-widget' ),
|
123 |
+
'type' => 'expand_begin',
|
124 |
+
);
|
125 |
+
|
126 |
+
self::$settings['keep_whitespace'] = array(
|
127 |
+
'section' => 'widget',
|
128 |
+
'title' => __( 'Keep Whitespace?', 'testimonials-widget' ),
|
129 |
+
'desc' => __( 'Keeps testimonials looking as entered than sans auto-formatting', 'testimonials-widget' ),
|
130 |
+
'type' => 'checkbox',
|
131 |
+
);
|
132 |
+
|
133 |
+
self::$settings['min_height'] = array(
|
134 |
+
'section' => 'widget',
|
135 |
+
'title' => __( 'Minimum Height', 'testimonials-widget' ),
|
136 |
+
'desc' => __( 'Set for minimum display height, in pixels', 'testimonials-widget' ),
|
137 |
+
'validate' => 'min1',
|
138 |
+
);
|
139 |
+
|
140 |
+
self::$settings['max_height'] = array(
|
141 |
+
'section' => 'widget',
|
142 |
+
'title' => __( 'Maximum Height', 'testimonials-widget' ),
|
143 |
+
'desc' => __( 'Set for maximum display height, in pixels', 'testimonials-widget' ),
|
144 |
+
'validate' => 'min1',
|
145 |
+
);
|
146 |
+
|
147 |
+
self::$settings['bottom_text'] = array(
|
148 |
+
'section' => 'widget',
|
149 |
+
'title' => __( 'Testimonial Bottom Text', 'testimonials-widget' ),
|
150 |
+
'desc' => __( 'Custom text or HTML for bottom of testimonials', 'testimonials-widget' ),
|
151 |
+
'type' => 'textarea',
|
152 |
+
'validate' => 'wp_kses_post',
|
153 |
+
);
|
154 |
+
|
155 |
+
self::$settings['widget_expand_end'] = array(
|
156 |
+
'section' => 'widget',
|
157 |
+
'type' => 'expand_end',
|
158 |
+
);
|
159 |
+
|
160 |
+
// General
|
161 |
+
self::$settings['general_expand_begin'] = array(
|
162 |
+
'desc' => __( 'General Options', 'testimonials-widget' ),
|
163 |
+
'type' => 'expand_begin',
|
164 |
+
);
|
165 |
+
|
166 |
+
self::$settings['disable_quotes'] = array(
|
167 |
+
'title' => __( 'Hide built-in quotes?', 'testimonials-widget' ),
|
168 |
+
'desc' => __( 'Remove open and close quote span tags surrounding testimonial content', 'testimonials-widget' ),
|
169 |
+
'type' => 'checkbox',
|
170 |
+
);
|
171 |
+
|
172 |
+
self::$settings['hide_not_found'] = array(
|
173 |
+
'title' => __( 'Hide "Testimonials Not Found"?', 'testimonials-widget' ),
|
174 |
+
'type' => 'checkbox',
|
175 |
+
);
|
176 |
+
|
177 |
+
self::$settings['hide_gravatar'] = array(
|
178 |
+
'title' => __( 'Hide Gravatar Image?', 'testimonials-widget' ),
|
179 |
+
'type' => 'checkbox',
|
180 |
+
);
|
181 |
+
|
182 |
+
self::$settings['hide_image'] = array(
|
183 |
+
'title' => __( 'Hide Image?', 'testimonials-widget' ),
|
184 |
+
'type' => 'checkbox',
|
185 |
+
);
|
186 |
+
|
187 |
+
self::$settings['hide_image_single'] = array(
|
188 |
+
'title' => __( 'Hide Image in Single View?', 'testimonials-widget' ),
|
189 |
+
'type' => 'checkbox',
|
190 |
+
'widget' => 0,
|
191 |
+
);
|
192 |
+
|
193 |
+
self::$settings['hide_content'] = array(
|
194 |
+
'title' => __( 'Hide Testimonial Content?', 'testimonials-widget' ),
|
195 |
+
'type' => 'checkbox',
|
196 |
+
);
|
197 |
+
|
198 |
+
self::$settings['hide_source'] = array(
|
199 |
+
'title' => __( 'Hide Author/Source?', 'testimonials-widget' ),
|
200 |
+
'type' => 'checkbox',
|
201 |
+
'desc' => __( 'Don\'t display "Post Title" in cite', 'testimonials-widget' ),
|
202 |
+
);
|
203 |
+
|
204 |
+
self::$settings['hide_email'] = array(
|
205 |
+
'title' => __( 'Hide Email?', 'testimonials-widget' ),
|
206 |
+
'type' => 'checkbox',
|
207 |
+
'std' => 1,
|
208 |
+
);
|
209 |
+
|
210 |
+
self::$settings['hide_title'] = array(
|
211 |
+
'title' => __( 'Hide Title?', 'testimonials-widget' ),
|
212 |
+
'type' => 'checkbox',
|
213 |
+
);
|
214 |
+
|
215 |
+
self::$settings['hide_location'] = array(
|
216 |
+
'title' => __( 'Hide Location?', 'testimonials-widget' ),
|
217 |
+
'type' => 'checkbox',
|
218 |
+
);
|
219 |
+
|
220 |
+
self::$settings['hide_company'] = array(
|
221 |
+
'title' => __( 'Hide Company?', 'testimonials-widget' ),
|
222 |
+
'type' => 'checkbox',
|
223 |
+
);
|
224 |
+
|
225 |
+
self::$settings['hide_url'] = array(
|
226 |
+
'title' => __( 'Hide URL?', 'testimonials-widget' ),
|
227 |
+
'type' => 'checkbox',
|
228 |
+
);
|
229 |
+
|
230 |
+
self::$settings['target'] = array(
|
231 |
+
'title' => __( 'URL Target', 'testimonials-widget' ),
|
232 |
+
'desc' => __( 'Add target to all URLs; leave blank if none', 'testimonials-widget' ),
|
233 |
+
'validate' => 'term',
|
234 |
+
);
|
235 |
+
|
236 |
+
self::$settings['paging'] = array(
|
237 |
+
'title' => __( 'Enable Paging?', 'testimonials-widget' ),
|
238 |
+
'desc' => __( 'For `[testimonialswidget_list]`', 'testimonials-widget' ),
|
239 |
+
'type' => 'select',
|
240 |
+
'choices' => array(
|
241 |
+
'' => __( 'Disable', 'testimonials-widget' ),
|
242 |
+
1 => __( 'Enable', 'testimonials-widget' ),
|
243 |
+
'before' => __( 'Before testimonials', 'testimonials-widget' ),
|
244 |
+
'after' => __( 'After testimonials', 'testimonials-widget' ),
|
245 |
+
),
|
246 |
+
'std' => 1,
|
247 |
+
'widget' => 0,
|
248 |
+
);
|
249 |
+
|
250 |
+
self::$settings['general_expand_end'] = array(
|
251 |
+
'type' => 'expand_end',
|
252 |
+
);
|
253 |
+
|
254 |
+
// Selection
|
255 |
+
self::$settings['selection_expand_begin'] = array(
|
256 |
+
'section' => 'selection',
|
257 |
+
'desc' => __( 'Selection Options', 'testimonials-widget' ),
|
258 |
+
'type' => 'expand_begin',
|
259 |
+
);
|
260 |
+
|
261 |
+
self::$settings['category'] = array(
|
262 |
+
'section' => 'selection',
|
263 |
+
'title' => __( 'Category Filter', 'testimonials-widget' ),
|
264 |
+
'desc' => __( 'Comma separated category slug-names. Ex: category-a, another-category', 'testimonials-widget' ),
|
265 |
+
'validate' => 'slugs',
|
266 |
+
);
|
267 |
+
|
268 |
+
self::$settings['tags'] = array(
|
269 |
+
'section' => 'selection',
|
270 |
+
'title' => __( 'Tags Filter', 'testimonials-widget' ),
|
271 |
+
'desc' => __( 'Comma separated tag slug-names. Ex: tag-a, another-tag', 'testimonials-widget' ),
|
272 |
+
'validate' => 'slugs',
|
273 |
+
);
|
274 |
+
|
275 |
+
self::$settings['tags_all'] = array(
|
276 |
+
'section' => 'selection',
|
277 |
+
'title' => __( 'Require All Tags?', 'testimonials-widget' ),
|
278 |
+
'desc' => __( 'Select only testimonials with all of the given tags', 'testimonials-widget' ),
|
279 |
+
'type' => 'checkbox',
|
280 |
+
);
|
281 |
+
|
282 |
+
self::$settings['ids'] = array(
|
283 |
+
'section' => 'selection',
|
284 |
+
'title' => __( 'Include IDs Filter', 'testimonials-widget' ),
|
285 |
+
'desc' => __( 'Comma separated testimonial IDs. Ex: 3,1,2', 'testimonials-widget' ),
|
286 |
+
'validate' => 'ids',
|
287 |
+
);
|
288 |
+
|
289 |
+
self::$settings['exclude'] = array(
|
290 |
+
'section' => 'selection',
|
291 |
+
'title' => __( 'Exclude IDs Filter', 'testimonials-widget' ),
|
292 |
+
'desc' => __( 'Comma separated testimonial IDs. Ex: 3,1,2', 'testimonials-widget' ),
|
293 |
+
'validate' => 'ids',
|
294 |
+
);
|
295 |
+
|
296 |
+
self::$settings['limit'] = array(
|
297 |
+
'section' => 'selection',
|
298 |
+
'title' => __( 'Limit', 'testimonials-widget' ),
|
299 |
+
'desc' => __( 'Number of testimonials to select per instance', 'testimonials-widget' ),
|
300 |
+
'std' => 10,
|
301 |
+
'validate' => 'nozero',
|
302 |
+
);
|
303 |
+
|
304 |
+
self::$settings['selection_expand_end'] = array(
|
305 |
+
'section' => 'selection',
|
306 |
+
'type' => 'expand_end',
|
307 |
+
);
|
308 |
+
|
309 |
+
// Ordering
|
310 |
+
self::$settings['ordering_expand_begin'] = array(
|
311 |
+
'section' => 'ordering',
|
312 |
+
'desc' => __( 'Ordering Options', 'testimonials-widget' ),
|
313 |
+
'type' => 'expand_begin',
|
314 |
+
);
|
315 |
+
|
316 |
+
self::$settings['random'] = array(
|
317 |
+
'section' => 'ordering',
|
318 |
+
'title' => __( 'Random Order?', 'testimonials-widget' ),
|
319 |
+
'desc' => __( 'If checked, ignores ORDER BY, ORDER BY meta_key, and ORDER BY Order. Widgets are random by default automatically', 'testimonials-widget' ),
|
320 |
+
'type' => 'checkbox',
|
321 |
+
);
|
322 |
+
|
323 |
+
self::$settings['orderby'] = array(
|
324 |
+
'section' => 'ordering',
|
325 |
+
'title' => __( 'ORDER BY', 'testimonials-widget' ),
|
326 |
+
'desc' => __( 'Used when "Random Order" is disabled', 'testimonials-widget' ),
|
327 |
+
'type' => 'select',
|
328 |
+
'choices' => array(
|
329 |
+
'ID' => __( 'Testimonial ID', 'testimonials-widget' ),
|
330 |
+
'author' => __( 'Author', 'testimonials-widget' ),
|
331 |
+
'date' => __( 'Date', 'testimonials-widget' ),
|
332 |
+
'menu_order' => __( 'Menu Order', 'testimonials-widget' ),
|
333 |
+
'title' => __( 'Source', 'testimonials-widget' ),
|
334 |
+
'none' => __( 'No order', 'testimonials-widget' ),
|
335 |
+
),
|
336 |
+
'std' => 'ID',
|
337 |
+
'validate' => 'term',
|
338 |
+
);
|
339 |
+
|
340 |
+
self::$settings['meta_key'] = array(
|
341 |
+
'section' => 'ordering',
|
342 |
+
'title' => __( 'ORDER BY meta_key', 'testimonials-widget' ),
|
343 |
+
'desc' => __( 'Used when "Random Order" is disabled and sorting by a testimonials meta key is needed. Overrides ORDER BY', 'testimonials-widget' ),
|
344 |
+
'type' => 'select',
|
345 |
+
'choices' => array(
|
346 |
+
'' => __( 'None', 'testimonials-widget' ),
|
347 |
+
'testimonials-widget-title' => __( 'Title', 'testimonials-widget' ),
|
348 |
+
'testimonials-widget-email' => __( 'Email', 'testimonials-widget' ),
|
349 |
+
'testimonials-widget-location' => __( 'Location', 'testimonials-widget' ),
|
350 |
+
'testimonials-widget-company' => __( 'Company', 'testimonials-widget' ),
|
351 |
+
'testimonials-widget-url' => __( 'URL', 'testimonials-widget' ),
|
352 |
+
),
|
353 |
+
'validate' => 'slug',
|
354 |
+
);
|
355 |
+
|
356 |
+
self::$settings['order'] = array(
|
357 |
+
'section' => 'ordering',
|
358 |
+
'title' => __( 'ORDER BY Order', 'testimonials-widget' ),
|
359 |
+
'type' => 'select',
|
360 |
+
'choices' => array(
|
361 |
+
'DESC' => __( 'Descending', 'testimonials-widget' ),
|
362 |
+
'ASC' => __( 'Ascending', 'testimonials-widget' ),
|
363 |
+
),
|
364 |
+
'std' => 'DESC',
|
365 |
+
'validate' => 'order',
|
366 |
+
);
|
367 |
+
|
368 |
+
self::$settings['ordering_expand_end'] = array(
|
369 |
+
'section' => 'ordering',
|
370 |
+
'type' => 'expand_end',
|
371 |
+
);
|
372 |
+
|
373 |
+
// Debug
|
374 |
+
self::$settings['debug_mode'] = array(
|
375 |
+
'section' => 'testing',
|
376 |
+
'title' => __( 'Debug Mode?', 'testimonials-widget' ),
|
377 |
+
'desc' => __( 'Not implemented yet', 'testimonials-widget' ),
|
378 |
+
'type' => 'checkbox',
|
379 |
+
'widget' => 0,
|
380 |
+
);
|
381 |
+
|
382 |
+
// Post Type
|
383 |
+
self::$settings['allow_comments'] = array(
|
384 |
+
'section' => 'post_type',
|
385 |
+
'title' => __( 'Allow Comments?', 'testimonials-widget' ),
|
386 |
+
'desc' => __( 'Only affects the Testimonials Widget post edit page. Your theme controls the front-end view.', 'testimonials-widget' ),
|
387 |
+
'type' => 'checkbox',
|
388 |
+
'widget' => 0,
|
389 |
+
);
|
390 |
+
|
391 |
+
$desc = __( 'URL slug-name for <a href="%1s">testimonials archive</a> page. After changing, you must click "Save Changes" on <a href="%2s">Permalink Settings</a> to update them.', 'testimonials-widget' );
|
392 |
+
$has_archive = tw_get_option( 'has_archive', '' );
|
393 |
+
$site_url = site_url( '/' . $has_archive );
|
394 |
+
$url = admin_url( 'options-permalink.php' );
|
395 |
+
|
396 |
+
self::$settings['has_archive'] = array(
|
397 |
+
'section' => 'post_type',
|
398 |
+
'title' => __( 'Archive Page URL', 'testimonials-widget' ),
|
399 |
+
'desc' => sprintf( $desc, $site_url, $url ),
|
400 |
+
'std' => 'testimonials-archive',
|
401 |
+
'validate' => 'sanitize_title',
|
402 |
+
'widget' => 0,
|
403 |
+
);
|
404 |
+
|
405 |
+
$desc = __( 'URL slug-name for testimonial view pages. After changing, you must click "Save Changes" on <a href="%1s">Permalink Settings</a> to update them.', 'testimonials-widget' );
|
406 |
+
|
407 |
+
self::$settings['rewrite_slug'] = array(
|
408 |
+
'section' => 'post_type',
|
409 |
+
'title' => __( 'Testimonial Page URL', 'testimonials-widget' ),
|
410 |
+
'desc' => sprintf( $desc, $url ),
|
411 |
+
'std' => 'testimonial',
|
412 |
+
'validate' => 'sanitize_title',
|
413 |
+
'widget' => 0,
|
414 |
+
);
|
415 |
+
|
416 |
+
// Reset
|
417 |
+
self::$settings['reset_expand_begin'] = array(
|
418 |
+
'section' => 'reset',
|
419 |
+
'desc' => __( 'Compatiblity Options', 'testimonials-widget' ),
|
420 |
+
'type' => 'expand_begin',
|
421 |
+
);
|
422 |
+
|
423 |
+
self::$settings['remove_hentry'] = array(
|
424 |
+
'section' => 'reset',
|
425 |
+
'title' => __( 'Remove `.hentry` CSS?', 'testimonials-widget' ),
|
426 |
+
'desc' => __( 'Pre 2.6.4. Some themes use class `.hentry` in a manner that breaks Testimonials Widgets CSS', 'testimonials-widget' ),
|
427 |
+
'type' => 'checkbox',
|
428 |
+
'backwards' => array(
|
429 |
+
'version' => '2.6.4',
|
430 |
+
'std' => 1,
|
431 |
+
),
|
432 |
+
);
|
433 |
+
|
434 |
+
self::$settings['use_quote_tag'] = array(
|
435 |
+
'section' => 'reset',
|
436 |
+
'title' => __( 'Use `<q>` tag?', 'testimonials-widget' ),
|
437 |
+
'desc' => __( 'Pre 2.11.0. Not HTML5 compliant', 'testimonials-widget' ),
|
438 |
+
'type' => 'checkbox',
|
439 |
+
'backwards' => array(
|
440 |
+
'version' => '2.11.0',
|
441 |
+
'std' => 1,
|
442 |
+
),
|
443 |
+
);
|
444 |
+
|
445 |
+
self::$settings['delete_data'] = array(
|
446 |
+
'section' => 'reset',
|
447 |
+
'title' => __( 'Remove Plugin Data on Deletion?', 'testimonials-widget' ),
|
448 |
+
'type' => 'checkbox',
|
449 |
+
'class' => 'warning', // Custom class for CSS
|
450 |
+
'desc' => __( 'Delete all Testimonials Widget data and options from database on plugin deletion', 'testimonials-widget' ),
|
451 |
+
'widget' => 0,
|
452 |
+
);
|
453 |
+
|
454 |
+
$options = tw_get_options();
|
455 |
+
$serialized_options = serialize( $options );
|
456 |
+
$_SESSION['importexport'] = $serialized_options;
|
457 |
+
|
458 |
+
self::$settings['importexport'] = array(
|
459 |
+
'section' => 'reset',
|
460 |
+
'title' => __( 'Import/Export Settings', 'testimonials-widget' ),
|
461 |
+
'type' => 'textarea',
|
462 |
+
'desc' => __( 'These are your current settings in a text format. Copy the textarea contents to make a backup of your settings. You can paste new settings here to overwrite your current configuration.', 'testimonials-widget' ),
|
463 |
+
'std' => $serialized_options,
|
464 |
+
'widget' => 0,
|
465 |
+
);
|
466 |
+
|
467 |
+
self::$settings['reset_defaults'] = array(
|
468 |
+
'section' => 'reset',
|
469 |
+
'title' => __( 'Reset to Defaults?', 'testimonials-widget' ),
|
470 |
+
'type' => 'checkbox',
|
471 |
+
'class' => 'warning', // Custom class for CSS
|
472 |
+
'desc' => __( 'Check this box to reset options to their defaults', 'testimonials-widget' ),
|
473 |
+
'widget' => 0,
|
474 |
+
);
|
475 |
+
|
476 |
+
self::$settings['reset_expand_end'] = array(
|
477 |
+
'section' => 'reset',
|
478 |
+
'type' => 'expand_end',
|
479 |
+
);
|
480 |
+
|
481 |
+
self::$settings = apply_filters( 'testimonials_widget_settings', self::$settings );
|
482 |
+
|
483 |
+
foreach ( self::$settings as $id => $parts ) {
|
484 |
+
self::$settings[ $id ] = wp_parse_args( $parts, self::$default );
|
485 |
+
}
|
486 |
+
}
|
487 |
+
|
488 |
+
|
489 |
+
public static function get_defaults( $mode = null ) {
|
490 |
+
if ( empty( self::$defaults ) )
|
491 |
+
self::settings();
|
492 |
+
|
493 |
+
$do_backwards = false;
|
494 |
+
if ( 'backwards' == $mode ) {
|
495 |
+
$old_version = tw_get_option( 'version' );
|
496 |
+
if ( ! empty( $old_version ) )
|
497 |
+
$do_backwards = true;
|
498 |
+
}
|
499 |
+
|
500 |
+
foreach ( self::$settings as $id => $parts ) {
|
501 |
+
$std = isset( $parts['std'] ) ? $parts['std'] : '';
|
502 |
+
if ( $do_backwards ) {
|
503 |
+
$version = ! empty( $parts['backwards']['version'] ) ? $parts['backwards']['version'] : false;
|
504 |
+
if ( ! empty( $version ) ) {
|
505 |
+
if ( $old_version < $version )
|
506 |
+
$std = $parts['backwards']['std'];
|
507 |
+
}
|
508 |
+
}
|
509 |
+
|
510 |
+
self::$defaults[ $id ] = $std;
|
511 |
+
}
|
512 |
+
|
513 |
+
return self::$defaults;
|
514 |
+
}
|
515 |
+
|
516 |
+
|
517 |
+
public static function get_settings() {
|
518 |
+
if ( empty( self::$settings ) )
|
519 |
+
self::settings();
|
520 |
+
|
521 |
+
return self::$settings;
|
522 |
+
}
|
523 |
+
|
524 |
+
|
525 |
+
public function admin_init() {
|
526 |
+
$version = tw_get_option( 'version' );
|
527 |
+
self::$version = Testimonials_Widget::VERSION;
|
528 |
+
self::$version = apply_filters( 'testimonials_widget_version', self::$version );
|
529 |
+
|
530 |
+
if ( $version != self::$version )
|
531 |
+
$this->initialize_settings();
|
532 |
+
|
533 |
+
$this->register_settings();
|
534 |
+
}
|
535 |
+
|
536 |
+
|
537 |
+
public function admin_menu() {
|
538 |
+
$admin_page = add_submenu_page( 'edit.php?post_type=' . Testimonials_Widget::PT, __( 'Testimonials Widget Settings', 'testimonials-widget' ), __( 'Settings', 'testimonials-widget' ), 'manage_options', self::ID, array( 'Testimonials_Widget_Settings', 'display_page' ) );
|
539 |
+
|
540 |
+
add_action( 'admin_print_scripts-' . $admin_page, array( &$this, 'scripts' ) );
|
541 |
+
add_action( 'admin_print_styles-' . $admin_page, array( &$this, 'styles' ) );
|
542 |
+
}
|
543 |
+
|
544 |
+
|
545 |
+
/**
|
546 |
+
*
|
547 |
+
*
|
548 |
+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
|
549 |
+
*/
|
550 |
+
public function create_setting( $args = array() ) {
|
551 |
+
extract( $args );
|
552 |
+
|
553 |
+
if ( preg_match( '#(_expand_begin|_expand_end)#', $id ) )
|
554 |
+
return;
|
555 |
+
|
556 |
+
$field_args = array(
|
557 |
+
'type' => $type,
|
558 |
+
'id' => $id,
|
559 |
+
'desc' => $desc,
|
560 |
+
'std' => $std,
|
561 |
+
'choices' => $choices,
|
562 |
+
'label_for' => $id,
|
563 |
+
'class' => $class,
|
564 |
+
);
|
565 |
+
|
566 |
+
self::$defaults[$id] = $std;
|
567 |
+
|
568 |
+
add_settings_field( $id, $title, array( &$this, 'display_setting' ), self::ID, $section, $field_args );
|
569 |
+
}
|
570 |
+
|
571 |
+
|
572 |
+
public static function display_page() {
|
573 |
+
echo '<div class="wrap">
|
574 |
+
<div class="icon32" id="icon-options-general"></div>
|
575 |
+
<h2>' . __( 'Testimonials Widget Settings', 'testimonials-widget' ) . '</h2>';
|
576 |
+
|
577 |
+
echo '<form action="options.php" method="post">';
|
578 |
+
|
579 |
+
settings_fields( self::ID );
|
580 |
+
|
581 |
+
echo '<div class="ui-tabs">
|
582 |
+
<ul class="ui-tabs-nav">';
|
583 |
+
|
584 |
+
foreach ( self::$sections as $section_slug => $section )
|
585 |
+
echo '<li><a href="#' . $section_slug . '">' . $section . '</a></li>';
|
586 |
+
|
587 |
+
echo '</ul>';
|
588 |
+
|
589 |
+
do_settings_sections( self::ID );
|
590 |
+
|
591 |
+
echo '</div>';
|
592 |
+
|
593 |
+
echo '
|
594 |
+
<p class="submit"><input name="Submit" type="submit" class="button-primary" value="' . __( 'Save Changes', 'testimonials-widget' ) . '" /></p>
|
595 |
+
</form>
|
596 |
+
';
|
597 |
+
|
598 |
+
echo '
|
599 |
+
<p>When ready, <a href="'.get_admin_url().'edit.php?post_type=testimonials-widget">view</a>
|
600 |
+
or <a href="'.get_admin_url().'post-new.php?post_type=testimonials-widget">add</a> testimonials.</p>
|
601 |
+
|
602 |
+
<p>If you like this plugin, <a href="http://aihr.us/about-aihrus/donate/" title="Donate for Good Karma">please donate</a> or <a href="http://aihr.us/testimonials-widget-premium/" title="purchase Testimonials Widget Premium">purchase Testimonials Widget Premium</a> to help fund further development and <a href="http://wordpress.org/support/plugin/testimonials-widget" title="Support forums">support</a>.</p>
|
603 |
+
';
|
604 |
+
|
605 |
+
$text = __( 'Copyright ©%1$s %2$s.', 'testimonials-widget' );
|
606 |
+
$link = '<a href="http://aihr.us">Aihrus</a>';
|
607 |
+
$copyright = '<div class="copyright">' . sprintf( $text, date( 'Y' ), $link ) . '</div>';
|
608 |
+
echo $copyright;
|
609 |
+
|
610 |
+
self::section_scripts();
|
611 |
+
|
612 |
+
echo '</div>';
|
613 |
+
}
|
614 |
+
|
615 |
+
|
616 |
+
public static function section_scripts() {
|
617 |
+
echo '<script type="text/javascript">
|
618 |
+
jQuery(document).ready(function($) {
|
619 |
+
var sections = [];';
|
620 |
+
|
621 |
+
foreach ( self::$sections as $section_slug => $section )
|
622 |
+
echo "sections['$section'] = '$section_slug';";
|
623 |
+
|
624 |
+
echo 'var wrapped = $(".wrap h3").wrap("<div class=\"ui-tabs-panel\">");
|
625 |
+
wrapped.each(function() {
|
626 |
+
$(this).parent().append($(this).parent().nextUntil("div.ui-tabs-panel"));
|
627 |
+
});
|
628 |
+
$(".ui-tabs-panel").each(function(index) {
|
629 |
+
$(this).attr("id", sections[$(this).children("h3").text()]);
|
630 |
+
if (index > 0)
|
631 |
+
$(this).addClass("ui-tabs-hide");
|
632 |
+
});
|
633 |
+
$(".ui-tabs").tabs({
|
634 |
+
fx: { opacity: "toggle", duration: "fast" }
|
635 |
+
});
|
636 |
+
|
637 |
+
$("input[type=text], textarea").each(function() {
|
638 |
+
if ($(this).val() == $(this).attr("placeholder") || $(this).val() == "")
|
639 |
+
$(this).css("color", "#999");
|
640 |
+
});
|
641 |
+
|
642 |
+
$("input[type=text], textarea").focus(function() {
|
643 |
+
if ($(this).val() == $(this).attr("placeholder") || $(this).val() == "") {
|
644 |
+
$(this).val("");
|
645 |
+
$(this).css("color", "#000");
|
646 |
+
}
|
647 |
+
}).blur(function() {
|
648 |
+
if ($(this).val() == "" || $(this).val() == $(this).attr("placeholder")) {
|
649 |
+
$(this).val($(this).attr("placeholder"));
|
650 |
+
$(this).css("color", "#999");
|
651 |
+
}
|
652 |
+
});
|
653 |
+
|
654 |
+
$(".wrap h3, .wrap table").show();
|
655 |
+
|
656 |
+
// This will make the "warning" checkbox class really stand out when checked.
|
657 |
+
// I use it here for the Reset checkbox.
|
658 |
+
$(".warning").change(function() {
|
659 |
+
if ($(this).is(":checked"))
|
660 |
+
$(this).parent().css("background", "#c00").css("color", "#fff").css("fontWeight", "bold");
|
661 |
+
else
|
662 |
+
$(this).parent().css("background", "none").css("color", "inherit").css("fontWeight", "normal");
|
663 |
+
});
|
664 |
+
|
665 |
+
// Browser compatibility
|
666 |
+
if ($.browser.mozilla)
|
667 |
+
$("form").attr("autocomplete", "off");
|
668 |
+
});
|
669 |
+
</script>';
|
670 |
+
}
|
671 |
+
|
672 |
+
|
673 |
+
public function display_section() {
|
674 |
+
// code
|
675 |
+
}
|
676 |
+
|
677 |
+
|
678 |
+
public function display_about_section() {
|
679 |
+
|
680 |
+
echo <<<EOD
|
681 |
+
<div style="width: 70%;">
|
682 |
+
<p><img class="alignright size-medium" title="Michael in Red Square, Moscow, Russia" src="/wp-content/plugins/testimonials-widget/media/michael-cannon-red-square-300x2251.jpg" alt="Michael in Red Square, Moscow, Russia" width="300" height="225" /><a href="http://wordpress.org/extend/plugins/testimonials-widget/">Testimonials Widget</a> is by <a href="http://aihr.us/about-aihrus/michael-cannon-resume/">Michael Cannon</a>. He's <a title="Lot's of stuff about Peichi Liu…" href="http://peimic.com/t/peichi-liu/">Peichi’s</a> smiling man, an adventurous <a title="Water rat" href="http://www.chinesehoroscope.org/chinese_zodiac/rat/" target="_blank">water-rat</a>, <a title="Axelerant – Open Source. Engineered." href="http://axelerant.com/who-we-are">chief people officer</a>, <a title="Aihrus – website support made easy since 1999" href="http://aihr.us/about-aihrus/">chief technology officer</a>, <a title="Road biker, cyclist, biking; whatever you call, I love to ride" href="http://peimic.com/c/biking/">cyclist</a>, <a title="Michael's poetic like literary ramblings" href="http://peimic.com/t/poetry/">poet</a>, <a title="World Wide Opportunities on Organic Farms" href="http://peimic.com/t/WWOOF/">WWOOF’er</a> and <a title="My traveled to country list, is more than my age." href="http://peimic.com/c/travel/">world traveler</a>.</p>
|
683 |
+
</div>
|
684 |
+
EOD;
|
685 |
+
|
686 |
+
}
|
687 |
+
|
688 |
+
|
689 |
+
public static function display_setting( $args = array(), $do_echo = true, $input = null ) {
|
690 |
+
$content = '';
|
691 |
+
|
692 |
+
extract( $args );
|
693 |
+
|
694 |
+
if ( is_null( $input ) ) {
|
695 |
+
$options = get_option( self::ID );
|
696 |
+
} else {
|
697 |
+
$options = array();
|
698 |
+
$options[$id] = $input;
|
699 |
+
}
|
700 |
+
|
701 |
+
if ( ! isset( $options[$id] ) && $type != 'checkbox' ) {
|
702 |
+
$options[$id] = $std;
|
703 |
+
} elseif ( ! isset( $options[$id] ) ) {
|
704 |
+
$options[$id] = 0;
|
705 |
+
}
|
706 |
+
|
707 |
+
$field_class = '';
|
708 |
+
if ( ! empty( $class ) ) {
|
709 |
+
$field_class = ' ' . $class;
|
710 |
+
}
|
711 |
+
|
712 |
+
switch ( $type ) {
|
713 |
+
case 'checkbox':
|
714 |
+
$content .= '<input class="checkbox' . $field_class . '" type="checkbox" id="' . $id . '" name="' . self::ID . '[' . $id . ']" value="1" ' . checked( $options[$id], 1, false ) . ' /> ';
|
715 |
+
|
716 |
+
if ( ! empty( $desc ) )
|
717 |
+
$content .= '<label for="' . $id . '"><span class="description">' . $desc . '</span></label>';
|
718 |
+
|
719 |
+
break;
|
720 |
+
|
721 |
+
case 'file':
|
722 |
+
$content .= '<input class="regular-text' . $field_class . '" type="file" id="' . $id . '" name="' . self::ID . '[' . $id . ']" />';
|
723 |
+
|
724 |
+
if ( ! empty( $desc ) )
|
725 |
+
$content .= '<br /><span class="description">' . $desc . '</span>';
|
726 |
+
|
727 |
+
break;
|
728 |
+
|
729 |
+
case 'heading':
|
730 |
+
$content .= '</td></tr><tr valign="top"><td colspan="2"><h4>' . $desc . '</h4>';
|
731 |
+
break;
|
732 |
+
|
733 |
+
case 'hidden':
|
734 |
+
$content .= '<input type="hidden" id="' . $id . '" name="' . self::ID . '[' . $id . ']" value="' . esc_attr( $options[$id] ) . '" />';
|
735 |
+
|
736 |
+
break;
|
737 |
+
|
738 |
+
case 'password':
|
739 |
+
$content .= '<input class="regular-text' . $field_class . '" type="password" id="' . $id . '" name="' . self::ID . '[' . $id . ']" value="' . esc_attr( $options[$id] ) . '" />';
|
740 |
+
|
741 |
+
if ( ! empty( $desc ) )
|
742 |
+
$content .= '<br /><span class="description">' . $desc . '</span>';
|
743 |
+
|
744 |
+
break;
|
745 |
+
|
746 |
+
case 'radio':
|
747 |
+
$i = 1;
|
748 |
+
$count_choices = count( $choices );
|
749 |
+
foreach ( $choices as $value => $label ) {
|
750 |
+
$content .= '<input class="radio' . $field_class . '" type="radio" name="' . self::ID . '[' . $id . ']" id="' . $id . $i . '" value="' . esc_attr( $value ) . '" ' . checked( $options[$id], $value, false ) . '> <label for="' . $id . $i . '">' . $label . '</label>';
|
751 |
+
|
752 |
+
if ( $i < $count_choices )
|
753 |
+
$content .= '<br />';
|
754 |
+
|
755 |
+
$i++;
|
756 |
+
}
|
757 |
+
|
758 |
+
if ( ! empty( $desc ) )
|
759 |
+
$content .= '<br /><span class="description">' . $desc . '</span>';
|
760 |
+
|
761 |
+
break;
|
762 |
+
|
763 |
+
case 'readonly':
|
764 |
+
$content .= '<input class="regular-text' . $field_class . '" type="text" id="' . $id . '" name="' . self::ID . '[' . $id . ']" value="' . esc_attr( $options[$id] ) . '" readonly="readonly" />';
|
765 |
+
|
766 |
+
if ( ! empty( $desc ) )
|
767 |
+
$content .= '<br /><span class="description">' . $desc . '</span>';
|
768 |
+
|
769 |
+
break;
|
770 |
+
|
771 |
+
case 'select':
|
772 |
+
$content .= '<select class="select' . $field_class . '" name="' . self::ID . '[' . $id . ']">';
|
773 |
+
|
774 |
+
foreach ( $choices as $value => $label )
|
775 |
+
$content .= '<option value="' . esc_attr( $value ) . '"' . selected( $options[$id], $value, false ) . '>' . $label . '</option>';
|
776 |
+
|
777 |
+
$content .= '</select>';
|
778 |
+
|
779 |
+
if ( ! empty( $desc ) )
|
780 |
+
$content .= '<br /><span class="description">' . $desc . '</span>';
|
781 |
+
|
782 |
+
break;
|
783 |
+
|
784 |
+
case 'text':
|
785 |
+
$content .= '<input class="regular-text' . $field_class . '" type="text" id="' . $id . '" name="' . self::ID . '[' . $id . ']" placeholder="' . $std . '" value="' . esc_attr( $options[$id] ) . '" />';
|
786 |
+
|
787 |
+
if ( ! empty( $desc ) )
|
788 |
+
$content .= '<br /><span class="description">' . $desc . '</span>';
|
789 |
+
|
790 |
+
break;
|
791 |
+
|
792 |
+
case 'textarea':
|
793 |
+
$content .= '<textarea class="' . $field_class . '" id="' . $id . '" name="' . self::ID . '[' . $id . ']" placeholder="' . $std . '" rows="5" cols="30">' . wp_htmledit_pre( $options[$id] ) . '</textarea>';
|
794 |
+
|
795 |
+
if ( ! empty( $desc ) )
|
796 |
+
$content .= '<br /><span class="description">' . $desc . '</span>';
|
797 |
+
|
798 |
+
break;
|
799 |
+
|
800 |
+
default:
|
801 |
+
break;
|
802 |
+
}
|
803 |
+
|
804 |
+
if ( $do_echo ) {
|
805 |
+
echo $content;
|
806 |
+
} else {
|
807 |
+
return $content;
|
808 |
+
}
|
809 |
+
}
|
810 |
+
|
811 |
+
|
812 |
+
public function initialize_settings() {
|
813 |
+
$defaults = self::get_defaults( 'backwards' );
|
814 |
+
$current = get_option( self::ID );
|
815 |
+
$current = wp_parse_args( $current, $defaults );
|
816 |
+
$current['admin_notices'] = true;
|
817 |
+
$current['version'] = self::$version;
|
818 |
+
|
819 |
+
update_option( self::ID, $current );
|
820 |
+
}
|
821 |
+
|
822 |
+
|
823 |
+
public function register_settings() {
|
824 |
+
register_setting( self::ID, self::ID, array( &$this, 'validate_settings' ) );
|
825 |
+
|
826 |
+
foreach ( self::$sections as $slug => $title ) {
|
827 |
+
if ( $slug == 'about' )
|
828 |
+
add_settings_section( $slug, $title, array( &$this, 'display_about_section' ), self::ID );
|
829 |
+
else
|
830 |
+
add_settings_section( $slug, $title, array( &$this, 'display_section' ), self::ID );
|
831 |
+
}
|
832 |
+
|
833 |
+
foreach ( self::$settings as $id => $setting ) {
|
834 |
+
$setting['id'] = $id;
|
835 |
+
$this->create_setting( $setting );
|
836 |
+
}
|
837 |
+
}
|
838 |
+
|
839 |
+
|
840 |
+
public function scripts() {
|
841 |
+
wp_print_scripts( 'jquery-ui-tabs' );
|
842 |
+
}
|
843 |
+
|
844 |
+
|
845 |
+
public function styles() {
|
846 |
+
wp_register_style( __CLASS__ . '-admin', plugins_url( 'settings.css', __FILE__ ) );
|
847 |
+
wp_enqueue_style( __CLASS__ . '-admin' );
|
848 |
+
}
|
849 |
+
|
850 |
+
|
851 |
+
/**
|
852 |
+
*
|
853 |
+
*
|
854 |
+
* @SuppressWarnings(PHPMD.Superglobals)
|
855 |
+
*/
|
856 |
+
public static function validate_settings( $input, $options = null, $do_errors = false ) {
|
857 |
+
$errors = array();
|
858 |
+
|
859 |
+
if ( is_null( $options ) ) {
|
860 |
+
$options = self::get_settings();
|
861 |
+
$defaults = self::get_defaults();
|
862 |
+
|
863 |
+
if ( ! empty( $input['reset_defaults'] ) ) {
|
864 |
+
foreach ( $defaults as $id => $std ) {
|
865 |
+
$input[$id] = $std;
|
866 |
+
}
|
867 |
+
|
868 |
+
unset( $input['reset_defaults'] );
|
869 |
+
}
|
870 |
+
|
871 |
+
if ( ! empty( $input['importexport'] ) && $_SESSION['importexport'] != $input['importexport'] ) {
|
872 |
+
$importexport = $input['importexport'];
|
873 |
+
$unserialized = unserialize( $importexport );
|
874 |
+
foreach ( $unserialized as $id => $std ) {
|
875 |
+
$input[$id] = $std;
|
876 |
+
}
|
877 |
+
}
|
878 |
+
}
|
879 |
+
|
880 |
+
foreach ( $options as $id => $parts ) {
|
881 |
+
$default = $parts['std'];
|
882 |
+
$type = $parts['type'];
|
883 |
+
$validations = ! empty( $parts['validate'] ) ? $parts['validate'] : array();
|
884 |
+
if ( ! empty( $validations ) )
|
885 |
+
$validations = explode( ',', $validations );
|
886 |
+
|
887 |
+
if ( ! isset( $input[ $id ] ) ) {
|
888 |
+
if ( 'checkbox' != $type ) {
|
889 |
+
$input[ $id ] = $default;
|
890 |
+
} else {
|
891 |
+
$input[ $id ] = 0;
|
892 |
+
}
|
893 |
+
}
|
894 |
+
|
895 |
+
if ( $default == $input[ $id ] && ! in_array( 'required', $validations ) )
|
896 |
+
continue;
|
897 |
+
|
898 |
+
if ( 'checkbox' == $type ) {
|
899 |
+
if ( self::is_true( $input[ $id ] ) )
|
900 |
+
$input[ $id ] = 1;
|
901 |
+
else
|
902 |
+
$input[ $id ] = 0;
|
903 |
+
} elseif ( in_array( $type, array( 'radio', 'select' ) ) ) {
|
904 |
+
// single choices only
|
905 |
+
$keys = array_keys( $parts['choices'] );
|
906 |
+
|
907 |
+
if ( ! in_array( $input[ $id ], $keys ) ) {
|
908 |
+
if ( self::is_true( $input[ $id ] ) )
|
909 |
+
$input[ $id ] = 1;
|
910 |
+
else
|
911 |
+
$input[ $id ] = 0;
|
912 |
+
}
|
913 |
+
}
|
914 |
+
|
915 |
+
if ( ! empty( $validations ) ) {
|
916 |
+
foreach ( $validations as $validate )
|
917 |
+
self::validators( $validate, $id, $input, $default, $errors );
|
918 |
+
}
|
919 |
+
}
|
920 |
+
|
921 |
+
$input['version'] = self::$version;
|
922 |
+
$input = apply_filters( 'testimonials_widget_validate_settings', $input, $errors );
|
923 |
+
unset( $input['importexport'] );
|
924 |
+
|
925 |
+
if ( empty( $do_errors ) ) {
|
926 |
+
$validated = $input;
|
927 |
+
} else {
|
928 |
+
$validated = array(
|
929 |
+
'input' => $input,
|
930 |
+
'errors' => $errors,
|
931 |
+
);
|
932 |
+
}
|
933 |
+
|
934 |
+
return $validated;
|
935 |
+
}
|
936 |
+
|
937 |
+
|
938 |
+
public static function validators( $validate, $id, &$input, $default, &$errors ) {
|
939 |
+
switch ( $validate ) {
|
940 |
+
case 'absint':
|
941 |
+
case 'intval':
|
942 |
+
if ( '' != $input[ $id ] )
|
943 |
+
$input[ $id ] = $validate( $input[ $id ] );
|
944 |
+
else
|
945 |
+
$input[ $id ] = $default;
|
946 |
+
break;
|
947 |
+
|
948 |
+
case 'ids':
|
949 |
+
$input[ $id ] = self::validate_ids( $input[ $id ], $default );
|
950 |
+
break;
|
951 |
+
|
952 |
+
case 'min1':
|
953 |
+
$input[ $id ] = intval( $input[ $id ] );
|
954 |
+
if ( 0 >= $input[ $id ] )
|
955 |
+
$input[ $id ] = $default;
|
956 |
+
break;
|
957 |
+
|
958 |
+
case 'nozero':
|
959 |
+
$input[ $id ] = intval( $input[ $id ] );
|
960 |
+
if ( 0 === $input[ $id ] )
|
961 |
+
$input[ $id ] = $default;
|
962 |
+
break;
|
963 |
+
|
964 |
+
case 'order':
|
965 |
+
$input[ $id ] = self::validate_order( $input[ $id ], $default );
|
966 |
+
break;
|
967 |
+
|
968 |
+
case 'required':
|
969 |
+
if ( empty( $input[ $id ] ) ) {
|
970 |
+
$errors[ $id ] = __( 'Required', 'testimonials-widget' );
|
971 |
+
}
|
972 |
+
break;
|
973 |
+
|
974 |
+
case 'slug':
|
975 |
+
$input[ $id ] = self::validate_slug( $input[ $id ], $default );
|
976 |
+
break;
|
977 |
+
|
978 |
+
case 'slugs':
|
979 |
+
$input[ $id ] = self::validate_slugs( $input[ $id ], $default );
|
980 |
+
break;
|
981 |
+
|
982 |
+
case 'term':
|
983 |
+
$input[ $id ] = self::validate_term( $input[ $id ], $default );
|
984 |
+
break;
|
985 |
+
|
986 |
+
default:
|
987 |
+
$input[ $id ] = $validate( $input[ $id ] );
|
988 |
+
break;
|
989 |
+
}
|
990 |
+
}
|
991 |
+
|
992 |
+
|
993 |
+
public static function validate_ids( $input, $default ) {
|
994 |
+
if ( preg_match( '#^\d+(,\s?\d+)*$#', $input['exclude'] ) )
|
995 |
+
return preg_replace( '#\s#', '', $input );
|
996 |
+
|
997 |
+
return $default;
|
998 |
+
}
|
999 |
+
|
1000 |
+
|
1001 |
+
public static function validate_order( $input, $default ) {
|
1002 |
+
if ( preg_match( '#^desc|asc$#i', $input ) )
|
1003 |
+
return $input;
|
1004 |
+
|
1005 |
+
return $default;
|
1006 |
+
}
|
1007 |
+
|
1008 |
+
|
1009 |
+
public static function validate_slugs( $input, $default ) {
|
1010 |
+
if ( preg_match( '#^[\w-]+(,\s?[\w-]+)*$#', $input ) )
|
1011 |
+
return preg_replace( '#\s#', '', $input );
|
1012 |
+
|
1013 |
+
return $default;
|
1014 |
+
}
|
1015 |
+
|
1016 |
+
|
1017 |
+
public static function validate_slug( $input, $default ) {
|
1018 |
+
if ( preg_match( '#^[\w-]+$#', $input ) )
|
1019 |
+
return $input;
|
1020 |
+
|
1021 |
+
return $default;
|
1022 |
+
}
|
1023 |
+
|
1024 |
+
|
1025 |
+
public static function validate_term( $input, $default ) {
|
1026 |
+
if ( preg_match( '#^\w+$#', $input ) )
|
1027 |
+
return $input;
|
1028 |
+
|
1029 |
+
return $default;
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
|
1033 |
+
/**
|
1034 |
+
* allows for true, 'true', 1, 'yes' to be true
|
1035 |
+
*/
|
1036 |
+
public static function is_true( $value = null, $return_boolean = true ) {
|
1037 |
+
if ( true === $value || 'true' == strtolower( $value ) || 1 == $value || 'yes' == strtolower( $value ) ) {
|
1038 |
+
if ( $return_boolean )
|
1039 |
+
return true;
|
1040 |
+
else
|
1041 |
+
return 1;
|
1042 |
+
} else {
|
1043 |
+
if ( $return_boolean )
|
1044 |
+
return false;
|
1045 |
+
else
|
1046 |
+
return 0;
|
1047 |
+
}
|
1048 |
+
}
|
1049 |
+
|
1050 |
+
|
1051 |
+
}
|
1052 |
+
|
1053 |
+
|
1054 |
+
$Testimonials_Widget_Settings = new Testimonials_Widget_Settings();
|
1055 |
+
|
1056 |
+
|
1057 |
+
function tw_get_options() {
|
1058 |
+
$options = get_option( Testimonials_Widget_Settings::ID );
|
1059 |
+
|
1060 |
+
if ( false === $options ) {
|
1061 |
+
$options = Testimonials_Widget_Settings::get_defaults();
|
1062 |
+
update_option( Testimonials_Widget_Settings::ID, $options );
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
return $options;
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
|
1069 |
+
function tw_get_option( $option, $default = null ) {
|
1070 |
+
$options = get_option( Testimonials_Widget_Settings::ID, null );
|
1071 |
+
|
1072 |
+
if ( isset( $options[$option] ) )
|
1073 |
+
return $options[$option];
|
1074 |
+
else
|
1075 |
+
return $default;
|
1076 |
+
}
|
1077 |
+
|
1078 |
+
|
1079 |
+
function tw_set_option( $option, $value = null ) {
|
1080 |
+
$options = get_option( Testimonials_Widget_Settings::ID );
|
1081 |
+
|
1082 |
+
if ( ! is_array( $options ) ) {
|
1083 |
+
$options = array();
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
$options[$option] = $value;
|
1087 |
+
update_option( Testimonials_Widget_Settings::ID, $options );
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
|
1091 |
+
?>
|
lib/class-testimonials-widget-widget.php
ADDED
@@ -0,0 +1,304 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Copyright 2013 Michael Cannon (email: mc@aihr.us)
|
4 |
+
|
5 |
+
This program is free software; you can redistribute it and/or modify
|
6 |
+
it under the terms of the GNU General Public License, version 2, as
|
7 |
+
published by the Free Software Foundation.
|
8 |
+
|
9 |
+
This program is distributed in the hope that it will be useful,
|
10 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
+
GNU General Public License for more details.
|
13 |
+
|
14 |
+
You should have received a copy of the GNU General Public License
|
15 |
+
along with this program; if not, write to the Free Software
|
16 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
+
*/
|
18 |
+
|
19 |
+
class Testimonials_Widget_Widget extends WP_Widget {
|
20 |
+
const ID = 'testimonials_widget';
|
21 |
+
|
22 |
+
public function __construct() {
|
23 |
+
// Widget settings
|
24 |
+
$widget_ops = array(
|
25 |
+
'classname' => 'Testimonials_Widget_Widget',
|
26 |
+
'description' => __( 'Display testimonials with multiple selection and display options', 'testimonials-widget' )
|
27 |
+
);
|
28 |
+
|
29 |
+
// Widget control settings
|
30 |
+
$control_ops = array(
|
31 |
+
'id_base' => self::ID,
|
32 |
+
);
|
33 |
+
|
34 |
+
// Create the widget
|
35 |
+
$this->WP_Widget(
|
36 |
+
self::ID,
|
37 |
+
__( 'Testimonials Widget', 'testimonials-widget' ),
|
38 |
+
$widget_ops,
|
39 |
+
$control_ops
|
40 |
+
);
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
public function get_testimonials_css() {
|
45 |
+
Testimonials_Widget::get_testimonials_css();
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
public function get_testimonials_scripts() {
|
50 |
+
Testimonials_Widget::get_testimonials_scripts();
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
public function widget( $args, $instance ) {
|
55 |
+
global $before_widget, $before_title, $after_title, $after_widget;
|
56 |
+
|
57 |
+
$args = wp_parse_args( $args, Testimonials_Widget::get_defaults() );
|
58 |
+
extract( $args );
|
59 |
+
|
60 |
+
// Our variables from the widget settings
|
61 |
+
$title = apply_filters( 'widget_title', $instance['title'], null );
|
62 |
+
|
63 |
+
$testimonials = Testimonials_Widget::testimonialswidget_widget( $instance, $this->number );
|
64 |
+
|
65 |
+
// Before widget (defined by themes)
|
66 |
+
echo $before_widget;
|
67 |
+
|
68 |
+
// Display the widget title if one was input (before and after defined by themes)
|
69 |
+
if ( ! empty( $title ) ) {
|
70 |
+
if ( ! empty( $instance['title_link'] ) ) {
|
71 |
+
// revise title with title_link link creation
|
72 |
+
$title_link = $instance['title_link'];
|
73 |
+
|
74 |
+
if ( preg_match( '#^\d+$#', $title_link ) ) {
|
75 |
+
$new_title = '<a href="';
|
76 |
+
$new_title .= get_permalink( $title_link );
|
77 |
+
$new_title .= '" title="';
|
78 |
+
$new_title .= get_the_title( $title_link );
|
79 |
+
$new_title .= '">';
|
80 |
+
$new_title .= $title;
|
81 |
+
$new_title .= '</a>';
|
82 |
+
|
83 |
+
$title = $new_title;
|
84 |
+
} else {
|
85 |
+
$do_http = true;
|
86 |
+
|
87 |
+
if ( 0 === strpos( $title_link, '/' ) )
|
88 |
+
$do_http = false;
|
89 |
+
|
90 |
+
if ( $do_http && 0 === preg_match( '#https?://#', $title_link ) ) {
|
91 |
+
$title_link = 'http://' . $title_link;
|
92 |
+
}
|
93 |
+
|
94 |
+
$new_title = '<a href="';
|
95 |
+
$new_title .= $title_link;
|
96 |
+
$new_title .= '" title="';
|
97 |
+
$new_title .= $title;
|
98 |
+
$new_title .= '"';
|
99 |
+
|
100 |
+
$new_title .= '>';
|
101 |
+
$new_title .= $title;
|
102 |
+
$new_title .= '</a>';
|
103 |
+
|
104 |
+
$title = $new_title;
|
105 |
+
|
106 |
+
if ( ! empty( $instance['target'] ) )
|
107 |
+
$title = links_add_target( $title, $instance['target'] );
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
echo $before_title . $title . $after_title;
|
112 |
+
}
|
113 |
+
|
114 |
+
// Display Widget
|
115 |
+
echo $testimonials;
|
116 |
+
|
117 |
+
// After widget (defined by themes)
|
118 |
+
echo $after_widget;
|
119 |
+
}
|
120 |
+
|
121 |
+
|
122 |
+
/**
|
123 |
+
*
|
124 |
+
*
|
125 |
+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
126 |
+
*/
|
127 |
+
public function update( $new_instance, $old_instance ) {
|
128 |
+
$instance = Testimonials_Widget_Settings::validate_settings( $new_instance );
|
129 |
+
|
130 |
+
return $instance;
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
public function form( $instance ) {
|
135 |
+
$defaults = Testimonials_Widget::get_defaults();
|
136 |
+
$do_number = true;
|
137 |
+
|
138 |
+
if ( empty( $instance ) ) {
|
139 |
+
$do_number = false;
|
140 |
+
|
141 |
+
if ( empty( $defaults['char_limit'] ) )
|
142 |
+
$defaults['char_limit'] = 500;
|
143 |
+
|
144 |
+
if ( empty( $defaults['random'] ) )
|
145 |
+
$defaults['random'] = 1;
|
146 |
+
|
147 |
+
$instance = array();
|
148 |
+
}
|
149 |
+
|
150 |
+
$instance = wp_parse_args( $instance, $defaults );
|
151 |
+
$form_parts = Testimonials_Widget_Settings::get_settings();
|
152 |
+
|
153 |
+
if ( $do_number ) {
|
154 |
+
$number = $this->number;
|
155 |
+
$std = ' .' . Testimonials_Widget::ID . $number;
|
156 |
+
|
157 |
+
$form_parts['css_class'] = array(
|
158 |
+
'section' => 'widget',
|
159 |
+
'type' => 'readonly',
|
160 |
+
'title' => __( 'CSS Class', 'testimonials-widget' ),
|
161 |
+
'desc' => __( 'This widget\'s unique CSS class for styling', 'testimonials-widget' ),
|
162 |
+
'std' => $std,
|
163 |
+
'widget' => 1,
|
164 |
+
);
|
165 |
+
}
|
166 |
+
|
167 |
+
$form_parts = self::widget_options( $form_parts );
|
168 |
+
|
169 |
+
foreach ( $form_parts as $key => $part ) {
|
170 |
+
$part[ 'id' ] = $key;
|
171 |
+
$this->display_setting( $part, $instance );
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
|
176 |
+
public static function widget_options( $options ) {
|
177 |
+
foreach ( $options as $id => $parts ) {
|
178 |
+
// remove non-widget parts
|
179 |
+
if ( empty( $parts['widget'] ) )
|
180 |
+
unset( $options[ $id ] );
|
181 |
+
}
|
182 |
+
|
183 |
+
$options = apply_filters( 'testimonials_widget_widget_options', $options );
|
184 |
+
|
185 |
+
return $options;
|
186 |
+
}
|
187 |
+
|
188 |
+
|
189 |
+
public function display_setting( $args = array(), $options ) {
|
190 |
+
extract( $args );
|
191 |
+
|
192 |
+
$do_return = false;
|
193 |
+
switch ( $type ) {
|
194 |
+
case 'heading':
|
195 |
+
if ( ! empty( $desc ) )
|
196 |
+
echo '<h3>' . $desc . '</h3>';
|
197 |
+
|
198 |
+
$do_return = true;
|
199 |
+
break;
|
200 |
+
|
201 |
+
case 'expand_begin':
|
202 |
+
if ( ! empty( $desc ) )
|
203 |
+
echo '<h3>' . $desc . '</h3>';
|
204 |
+
|
205 |
+
echo '<a id="' . $this->get_field_id( $id ) . '" style="cursor:pointer;" onclick="jQuery( \'div#' . $this->get_field_id( $id ) . '\' ) . slideToggle();">' . __( 'Expand/Collapse', 'testimonials-widget' ) . ' »</a>';
|
206 |
+
echo '<div id="' . $this->get_field_id( $id ) . '" style="display:none">';
|
207 |
+
|
208 |
+
$do_return = true;
|
209 |
+
break;
|
210 |
+
|
211 |
+
case 'expand_end':
|
212 |
+
echo '</div>';
|
213 |
+
|
214 |
+
$do_return = true;
|
215 |
+
break;
|
216 |
+
|
217 |
+
default:
|
218 |
+
break;
|
219 |
+
}
|
220 |
+
|
221 |
+
if ( $do_return )
|
222 |
+
return;
|
223 |
+
|
224 |
+
if ( ! isset( $options[$id] ) && $type != 'checkbox' )
|
225 |
+
$options[$id] = $std;
|
226 |
+
elseif ( ! isset( $options[$id] ) )
|
227 |
+
$options[$id] = 0;
|
228 |
+
|
229 |
+
$field_class = '';
|
230 |
+
if ( ! empty( $class ) )
|
231 |
+
$field_class = ' ' . $class;
|
232 |
+
|
233 |
+
echo '<p>';
|
234 |
+
|
235 |
+
switch ( $type ) {
|
236 |
+
case 'checkbox':
|
237 |
+
echo '<input class="checkbox' . $field_class . '" type="checkbox" id="' . $this->get_field_id( $id ) . '" name="' . $this->get_field_name( $id ) . '" value="1" ' . checked( $options[$id], 1, false ) . ' /> ';
|
238 |
+
|
239 |
+
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
240 |
+
break;
|
241 |
+
|
242 |
+
case 'select':
|
243 |
+
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
244 |
+
echo '<select id="' . $this->get_field_id( $id ) . '"class="select' . $field_class . '" name="' . $this->get_field_name( $id ) . '">';
|
245 |
+
|
246 |
+
foreach ( $choices as $value => $label )
|
247 |
+
echo '<option value="' . esc_attr( $value ) . '"' . selected( $options[$id], $value, false ) . '>' . $label . '</option>';
|
248 |
+
|
249 |
+
echo '</select>';
|
250 |
+
break;
|
251 |
+
|
252 |
+
case 'radio':
|
253 |
+
$i = 0;
|
254 |
+
$count_options = count( $options ) - 1;
|
255 |
+
|
256 |
+
foreach ( $choices as $value => $label ) {
|
257 |
+
echo '<input class="radio' . $field_class . '" type="radio" name="' . $this->get_field_name( $id ) . '" id="' . $this->get_field_name( $id . $i ) . '" value="' . esc_attr( $value ) . '" ' . checked( $options[$id], $value, false ) . '> <label for="' . $this->get_field_name( $id . $i ) . '">' . $label . '</label>';
|
258 |
+
if ( $i < $count_options )
|
259 |
+
echo '<br />';
|
260 |
+
$i++;
|
261 |
+
}
|
262 |
+
|
263 |
+
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
264 |
+
break;
|
265 |
+
|
266 |
+
case 'textarea':
|
267 |
+
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
268 |
+
|
269 |
+
echo '<textarea class="widefat' . $field_class . '" id="' . $this->get_field_id( $id ) . '" name="' . $this->get_field_name( $id ) . '" placeholder="' . $std . '" rows="5" cols="30">' . wp_htmledit_pre( $options[$id] ) . '</textarea>';
|
270 |
+
break;
|
271 |
+
|
272 |
+
case 'password':
|
273 |
+
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
274 |
+
|
275 |
+
echo '<input class="widefat' . $field_class . '" type="password" id="' . $this->get_field_id( $id ) . '" name="' . $this->get_field_name( $id ) . '" value="' . esc_attr( $options[$id] ) . '" />';
|
276 |
+
break;
|
277 |
+
|
278 |
+
case 'readonly':
|
279 |
+
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
280 |
+
|
281 |
+
echo '<input class="widefat' . $field_class . '" type="text" id="' . $this->get_field_id( $id ) . '" name="' . $this->get_field_name( $id ) . '" value="' . esc_attr( $options[$id] ) . '" readonly="readonly" />';
|
282 |
+
break;
|
283 |
+
|
284 |
+
case 'text':
|
285 |
+
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
286 |
+
|
287 |
+
echo '<input class="widefat' . $field_class . '" type="text" id="' . $this->get_field_id( $id ) . '" name="' . $this->get_field_name( $id ) . '" placeholder="' . $std . '" value="' . esc_attr( $options[$id] ) . '" />';
|
288 |
+
break;
|
289 |
+
|
290 |
+
default:
|
291 |
+
break;
|
292 |
+
}
|
293 |
+
|
294 |
+
if ( ! empty( $desc ) )
|
295 |
+
echo '<br /><span class="setting-description"><small>' . $desc . '</small></span>';
|
296 |
+
|
297 |
+
echo '</p>';
|
298 |
+
}
|
299 |
+
|
300 |
+
|
301 |
+
}
|
302 |
+
|
303 |
+
|
304 |
+
?>
|
lib/metabox.class.php
DELETED
@@ -1,1458 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @Author Anonymous
|
4 |
-
* @link http://www.redrokk.com
|
5 |
-
* @Package Wordpress
|
6 |
-
* @SubPackage RedRokk Library
|
7 |
-
*
|
8 |
-
* @version 2.0
|
9 |
-
*/
|
10 |
-
|
11 |
-
//security
|
12 |
-
defined('ABSPATH') or die('You\'re not supposed to be here.');
|
13 |
-
|
14 |
-
/**
|
15 |
-
*
|
16 |
-
*
|
17 |
-
* @author Anonymous
|
18 |
-
* @example
|
19 |
-
|
20 |
-
$gallery = redrokk_metabox_class::getInstance('gallery');
|
21 |
-
|
22 |
-
*/
|
23 |
-
if (!class_exists('redrokk_metabox_class')):
|
24 |
-
class redrokk_metabox_class
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* HTML 'id' attribute of the edit screen section
|
28 |
-
*
|
29 |
-
* @var string
|
30 |
-
*/
|
31 |
-
var $_id;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Save the form fields here that will be displayed to the user
|
35 |
-
*
|
36 |
-
* @var array
|
37 |
-
*/
|
38 |
-
var $_fields;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Title of the edit screen section, visible to user
|
42 |
-
* Default: None
|
43 |
-
*
|
44 |
-
* @var string
|
45 |
-
*/
|
46 |
-
var $title;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Function that prints out the HTML for the edit screen section. Pass
|
50 |
-
* function name as a string. Within a class, you can instead pass an
|
51 |
-
* array to call one of the class's methods. See the second example under
|
52 |
-
* Example below.
|
53 |
-
* Default: None
|
54 |
-
*
|
55 |
-
* @var callback
|
56 |
-
*/
|
57 |
-
var $callback = null;
|
58 |
-
|
59 |
-
/**
|
60 |
-
* The part of the page where the edit screen section should be shown
|
61 |
-
* ('normal', 'advanced', or 'side'). (Note that 'side' doesn't exist before 2.7)
|
62 |
-
* Default: 'advanced'
|
63 |
-
*
|
64 |
-
* @var string
|
65 |
-
*/
|
66 |
-
var $context = 'normal';
|
67 |
-
|
68 |
-
/**
|
69 |
-
* The priority within the context where the boxes should show
|
70 |
-
* ('high', 'core', 'default' or 'low')
|
71 |
-
* Default: 'default'
|
72 |
-
*
|
73 |
-
* @var string
|
74 |
-
*/
|
75 |
-
var $priority = 'default';
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Arguments to pass into your callback function. The callback will receive the
|
79 |
-
* $post object and whatever parameters are passed through this variable.
|
80 |
-
* Default: null
|
81 |
-
*
|
82 |
-
* @var array
|
83 |
-
*/
|
84 |
-
var $callback_args;
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Prebuilt metaboxes can be activated by using this type
|
88 |
-
* Default: default
|
89 |
-
*
|
90 |
-
* (options:)
|
91 |
-
* default
|
92 |
-
* images
|
93 |
-
*
|
94 |
-
* @var string
|
95 |
-
*/
|
96 |
-
var $_type;
|
97 |
-
|
98 |
-
/**
|
99 |
-
*
|
100 |
-
* @var unknown_type
|
101 |
-
*/
|
102 |
-
var $_category_name;
|
103 |
-
|
104 |
-
/**
|
105 |
-
* The type of Write screen on which to show the edit screen section
|
106 |
-
* ('post', 'page', 'link', or 'custom_post_type' where custom_post_type
|
107 |
-
* is the custom post type slug)
|
108 |
-
* Default: None
|
109 |
-
*
|
110 |
-
* @var array
|
111 |
-
*/
|
112 |
-
var $_object_types = array();
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Whether or not to make the fields available as wp-options
|
116 |
-
*
|
117 |
-
* @var bool
|
118 |
-
*/
|
119 |
-
var $_isAdminPage = false;
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Constructor.
|
123 |
-
*
|
124 |
-
*/
|
125 |
-
function __construct( $options = array() )
|
126 |
-
{
|
127 |
-
//initializing
|
128 |
-
$this->setProperties($options);
|
129 |
-
$this->setOptionHooks();
|
130 |
-
|
131 |
-
if (!$this->callback) {
|
132 |
-
$this->callback = array(&$this, 'show');
|
133 |
-
}
|
134 |
-
if (!$this->title) {
|
135 |
-
$this->title = ucfirst($this->_id);
|
136 |
-
}
|
137 |
-
|
138 |
-
//registering this metabox
|
139 |
-
add_action( 'add_meta_boxes', array(&$this, '_register') );
|
140 |
-
|
141 |
-
// backwards compatible (before WP 3.0)
|
142 |
-
// add_action( 'admin_init', array($this, '_register'), 1 );
|
143 |
-
|
144 |
-
add_action( 'save_post', array(&$this, '_save') );
|
145 |
-
add_filter( 'wp_redirect', array(&$this, '_redirectIntervention'), 40, 1 );
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Method properly inturprets the given parameter and sets it accordingly
|
150 |
-
*
|
151 |
-
* @param string|object $value
|
152 |
-
*/
|
153 |
-
function setObjectTypes( $value )
|
154 |
-
{
|
155 |
-
if (is_a($value, 'redrokk_post_class')) {
|
156 |
-
$value = $value->_post_type;
|
157 |
-
}
|
158 |
-
if (is_a($value, 'redrokk_admin_class')) {
|
159 |
-
$value = $value->id;
|
160 |
-
$this->_isAdminPage = $value;
|
161 |
-
}
|
162 |
-
if (is_array($value)) {
|
163 |
-
foreach($value as $v)
|
164 |
-
$this->_object_types[] = $v;
|
165 |
-
return $this;
|
166 |
-
}
|
167 |
-
|
168 |
-
$this->_object_types[] = $value;
|
169 |
-
return $this;
|
170 |
-
}
|
171 |
-
|
172 |
-
/**
|
173 |
-
* Method is designed to return the currently visible post type
|
174 |
-
*/
|
175 |
-
function getCurrentPostType()
|
176 |
-
{
|
177 |
-
$post_type = false;
|
178 |
-
if (isset($_REQUEST['post_type'])) {
|
179 |
-
$post_type = $_REQUEST['post_type'];
|
180 |
-
}
|
181 |
-
elseif (isset($_REQUEST['post'])) {
|
182 |
-
$post = get_post($_REQUEST['post']);
|
183 |
-
$post_type = $post->post_type;
|
184 |
-
}
|
185 |
-
elseif (isset($_REQUEST['page'])) {
|
186 |
-
$post_type = $_REQUEST['page'];
|
187 |
-
}
|
188 |
-
|
189 |
-
return $post_type;
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* Method properly prepares the metabox type by binding the necessary hooks
|
194 |
-
*
|
195 |
-
* @param mixed $value
|
196 |
-
*/
|
197 |
-
function setType( $value = 'default' )
|
198 |
-
{
|
199 |
-
$this->_type = $value;
|
200 |
-
|
201 |
-
switch ($this->_type)
|
202 |
-
{
|
203 |
-
default:
|
204 |
-
case 'default':
|
205 |
-
add_action('metabox-show-'.$this->_id, array(&$this, '_renderForm'), 20, 1 );
|
206 |
-
add_action('metabox-save-'.$this->_id, array(&$this, 'saveAsPostMeta'), 10, 2);
|
207 |
-
break;
|
208 |
-
case 'image':
|
209 |
-
case 'images':
|
210 |
-
$this->_fields = array(
|
211 |
-
array(
|
212 |
-
'name' => 'New Image',
|
213 |
-
'type' => 'title',
|
214 |
-
),
|
215 |
-
array(
|
216 |
-
'name' => 'Image Title',
|
217 |
-
'id' => $this->_id.'_post_title',
|
218 |
-
'type' => 'text',
|
219 |
-
),
|
220 |
-
array(
|
221 |
-
'name' => 'Description',
|
222 |
-
'id' => $this->_id.'_post_content',
|
223 |
-
'type' => 'textarea',
|
224 |
-
),
|
225 |
-
array(
|
226 |
-
'name' => 'Image File',
|
227 |
-
'id' => $this->_id.'_image',
|
228 |
-
'type' => 'image',
|
229 |
-
),
|
230 |
-
array(
|
231 |
-
'name' => 'Save Image',
|
232 |
-
'type' => 'submit',
|
233 |
-
),
|
234 |
-
);
|
235 |
-
add_action('metabox-show-'.$this->_id, array(&$this, '_renderListImageAttachments'), 20, 1 );
|
236 |
-
add_action('metabox-show-'.$this->_id, array(&$this, '_renderForm'), 20, 1 );
|
237 |
-
add_action('metabox-save-'.$this->_id, array(&$this, 'saveAsAttachment'), 1, 2);
|
238 |
-
break;
|
239 |
-
case 'video':
|
240 |
-
case 'videos':
|
241 |
-
$this->_fields = array(
|
242 |
-
array(
|
243 |
-
'name' => 'New Video',
|
244 |
-
'type' => 'title',
|
245 |
-
),
|
246 |
-
array(
|
247 |
-
'name' => 'Video Title',
|
248 |
-
'id' => $this->_id.'_post_title',
|
249 |
-
'type' => 'text',
|
250 |
-
),
|
251 |
-
array(
|
252 |
-
'name' => 'Description',
|
253 |
-
'id' => $this->_id.'_post_content',
|
254 |
-
'type' => 'textarea',
|
255 |
-
),
|
256 |
-
array(
|
257 |
-
'name' => 'Video File',
|
258 |
-
'id' => $this->_id.'_image',
|
259 |
-
'type' => 'image',
|
260 |
-
),
|
261 |
-
array(
|
262 |
-
'name' => 'Video Link',
|
263 |
-
'id' => $this->_id.'_link',
|
264 |
-
'type' => 'text',
|
265 |
-
),
|
266 |
-
array(
|
267 |
-
'name' => '_videocat',
|
268 |
-
'id' => $this->_id.'_videocat',
|
269 |
-
'default'=>$this->getCategory(),
|
270 |
-
'type' => 'hidden',
|
271 |
-
),
|
272 |
-
array(
|
273 |
-
'name' => '_metaid',
|
274 |
-
'id' => $this->_id.'_metaid',
|
275 |
-
'type' => 'hidden',
|
276 |
-
),
|
277 |
-
array(
|
278 |
-
'name' => 'Save Video',
|
279 |
-
'type' => 'submit',
|
280 |
-
),
|
281 |
-
);
|
282 |
-
add_action('metabox-show-'.$this->_id, array(&$this, '_renderListAttachments'), 20, 1 );
|
283 |
-
add_action('metabox-show-'.$this->_id, array(&$this, '_renderListVideoAttachments'), 20, 1 );
|
284 |
-
add_action('metabox-show-'.$this->_id, array(&$this, '_renderForm'), 20, 1 );
|
285 |
-
add_action('metabox-save-'.$this->_id, array(&$this, 'saveAsPostMeta'), 1, 2);
|
286 |
-
break;
|
287 |
-
}
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Returns the category to use
|
292 |
-
*/
|
293 |
-
function getCategory()
|
294 |
-
{
|
295 |
-
return isset($this->_category_name)
|
296 |
-
? $this->_category_name
|
297 |
-
: '_videocat';
|
298 |
-
}
|
299 |
-
|
300 |
-
/**
|
301 |
-
* Method will save the posted content as an image attachment
|
302 |
-
*
|
303 |
-
*/
|
304 |
-
function saveAsAttachment( $source, $post_id )
|
305 |
-
{
|
306 |
-
if (empty($_FILES) || !isset($_REQUEST[$this->_id.'files'])) return $source;
|
307 |
-
|
308 |
-
// initializing
|
309 |
-
$property = $_REQUEST[$this->_id.'files'];
|
310 |
-
$post_data = array();
|
311 |
-
|
312 |
-
if (isset($source[$this->_id.'_post_title']) && $source[$this->_id.'_post_title']) {
|
313 |
-
$post_data['post_title'] = $source[$this->_id.'_post_title'];
|
314 |
-
}
|
315 |
-
|
316 |
-
if (isset($source[$this->_id.'_post_content']) && $source[$this->_id.'_post_content']) {
|
317 |
-
$post_data['post_content'] = $source[$this->_id.'_post_content'];
|
318 |
-
}
|
319 |
-
|
320 |
-
$id = media_handle_upload($property, $post_id, $post_data);
|
321 |
-
$source[$property] = $id;
|
322 |
-
|
323 |
-
$type = 'post';
|
324 |
-
if ($this->getCurrentPostType()) {
|
325 |
-
$type = $this->getCurrentPostType();
|
326 |
-
}
|
327 |
-
|
328 |
-
//saving the attachment ID to the taxonomy
|
329 |
-
if (!in_array($type, get_post_types(array('public' => false)))) {
|
330 |
-
$old = get_metadata($type, $post_id, $property, true);
|
331 |
-
if ($id && $id != $old) {
|
332 |
-
wp_delete_attachment( $old, true );
|
333 |
-
update_metadata($type, $post_id, $property, $id);
|
334 |
-
}
|
335 |
-
}
|
336 |
-
|
337 |
-
foreach ((array)$source as $property => $new)
|
338 |
-
{
|
339 |
-
//skip everything but the specially prefixed
|
340 |
-
if (strpos($property, $this->_id) !== 0) continue;
|
341 |
-
if (in_array($property, array(
|
342 |
-
$this->_id.'_post_title',
|
343 |
-
$this->_id.'_post_content',
|
344 |
-
))) continue;
|
345 |
-
|
346 |
-
$old = get_metadata($type, $id, $property, true);
|
347 |
-
if ($new && $new != $old) {
|
348 |
-
update_metadata($type, $id, $property, $new);
|
349 |
-
}
|
350 |
-
elseif (!$new) {
|
351 |
-
delete_metadata($type, $id, $property, $old);
|
352 |
-
}
|
353 |
-
}
|
354 |
-
|
355 |
-
return $source;
|
356 |
-
}
|
357 |
-
|
358 |
-
/**
|
359 |
-
* Method saves the data provided as post meta values
|
360 |
-
*
|
361 |
-
* @param array $source
|
362 |
-
* @param integer $post_id
|
363 |
-
*/
|
364 |
-
function saveAsPostMeta( $source, $post_id )
|
365 |
-
{
|
366 |
-
$type = 'post';
|
367 |
-
if (!$this->getCurrentPostType()) {
|
368 |
-
$type = $this->_table;
|
369 |
-
}
|
370 |
-
|
371 |
-
//save as a file
|
372 |
-
//if there's no FILES then we save as a meta
|
373 |
-
$source = $this->saveAsAttachment( $source, $post_id );
|
374 |
-
|
375 |
-
//get the ID of this meta set
|
376 |
-
$id = false;
|
377 |
-
if (isset($source[$this->_id.'_metaid']) && $source[$this->_id.'_metaid']) {
|
378 |
-
$id = $source[$this->_id.'_metaid'];
|
379 |
-
}
|
380 |
-
|
381 |
-
// if this is a built in metabox
|
382 |
-
if ($this->_type != 'default'
|
383 |
-
&& (!isset($source[$this->_id.'_image']) || !$source[$this->_id.'_image']))
|
384 |
-
return false;
|
385 |
-
|
386 |
-
// Saving only the specially prefixed items
|
387 |
-
foreach ((array)$source as $property => $new)
|
388 |
-
{
|
389 |
-
//skip everything but the specially prefixed
|
390 |
-
if (strpos($property, $this->_id) !== 0) continue;
|
391 |
-
|
392 |
-
//each meta set has it's own ID
|
393 |
-
$property = str_replace($this->_id, $this->_category_name.'_'.$id, $property);
|
394 |
-
|
395 |
-
$old = get_metadata($type, $post_id, $property, true);
|
396 |
-
if ($new && $new != $old) {
|
397 |
-
update_metadata($type, $post_id, $property, $new);
|
398 |
-
}
|
399 |
-
elseif (!$new) {
|
400 |
-
delete_metadata($type, $post_id, $property, $old);
|
401 |
-
}
|
402 |
-
}
|
403 |
-
|
404 |
-
// maybe there's a last id
|
405 |
-
if (!$id) {
|
406 |
-
if (!$id = get_metadata($type, $post_id, '_metaidlast', true)) {
|
407 |
-
$id = 0;
|
408 |
-
}
|
409 |
-
$id++;
|
410 |
-
update_metadata($type, $post_id, '_metaidlast', $id);
|
411 |
-
}
|
412 |
-
|
413 |
-
// saving all of the standard items
|
414 |
-
foreach ((array)$source as $property => $new)
|
415 |
-
{
|
416 |
-
//skip special properties that are prefixed with the id
|
417 |
-
if (strpos($property, $this->_id) === 0) continue;
|
418 |
-
|
419 |
-
$old = get_metadata($type, $post_id, $property, true);
|
420 |
-
update_metadata($type, $post_id, $property, $new);
|
421 |
-
|
422 |
-
// if ($new && $new != $old) {
|
423 |
-
// update_metadata($type, $post_id, $property, $new);
|
424 |
-
// }
|
425 |
-
// elseif (!$new) {
|
426 |
-
// delete_metadata($type, $post_id, $property, $old);
|
427 |
-
// }
|
428 |
-
|
429 |
-
}
|
430 |
-
|
431 |
-
return true;
|
432 |
-
}
|
433 |
-
|
434 |
-
/**
|
435 |
-
* Do something with the data entered
|
436 |
-
*
|
437 |
-
* @param integer $post_id
|
438 |
-
*/
|
439 |
-
function _save( $post_id )
|
440 |
-
{
|
441 |
-
//initializing
|
442 |
-
$post = get_post($post_id);
|
443 |
-
|
444 |
-
// verify if this is an auto save routine.
|
445 |
-
// If it is our form has not been submitted, so we dont want to do anything
|
446 |
-
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
447 |
-
return;
|
448 |
-
|
449 |
-
// verify this came from the our screen and with proper authorization,
|
450 |
-
// because save_post can be triggered at other times
|
451 |
-
if ( !isset($_REQUEST[ get_class().$this->_id ]) )
|
452 |
-
return;
|
453 |
-
|
454 |
-
if ( !wp_verify_nonce( $_REQUEST[ get_class().$this->_id ], plugin_basename( __FILE__ ) ) )
|
455 |
-
return;
|
456 |
-
|
457 |
-
// this metabox is to be displayed for a certain object type only
|
458 |
-
if ( !in_array($post->post_type, $this->_object_types) )
|
459 |
-
return;
|
460 |
-
|
461 |
-
// Check permissions
|
462 |
-
if ( 'page' == $post->post_type )
|
463 |
-
{
|
464 |
-
if ( !current_user_can( 'edit_page', $post->ID ) )
|
465 |
-
return;
|
466 |
-
}
|
467 |
-
else
|
468 |
-
{
|
469 |
-
if ( !current_user_can( 'edit_post', $post->ID ) )
|
470 |
-
return;
|
471 |
-
}
|
472 |
-
|
473 |
-
//saving the request data
|
474 |
-
if (!$this->_type) $this->setType();
|
475 |
-
do_action('metabox-save-'.$this->_id, $this->getRequestPostMetas(), $post->ID, $this );
|
476 |
-
return true;
|
477 |
-
}
|
478 |
-
|
479 |
-
/**
|
480 |
-
* Method returns the post meta
|
481 |
-
*
|
482 |
-
*/
|
483 |
-
function getRequestPostMetas()
|
484 |
-
{
|
485 |
-
$ignores = array('post_title', 'post_name', 'post_content', 'post_excerpt', 'post',
|
486 |
-
'post_status', 'post_type', 'post_author', 'ping_status', 'post_parent', 'message',
|
487 |
-
'post_category', 'comment_status', 'menu_order', 'to_ping', 'pinged', 'post_password',
|
488 |
-
'guid', 'post_content_filtered', 'import_id', 'post_date', 'post_date_gmt', 'tags_input',
|
489 |
-
'action');
|
490 |
-
|
491 |
-
$fields = array();
|
492 |
-
foreach ((array)$this->_fields as $field) {
|
493 |
-
if (!array_key_exists('id', $field)) continue;
|
494 |
-
$fields[] = $field['id'];
|
495 |
-
}
|
496 |
-
|
497 |
-
$requests = $_REQUEST;
|
498 |
-
foreach ((array)$requests as $k => $request)
|
499 |
-
{
|
500 |
-
if ((!empty($fields) && !in_array($k, $fields))
|
501 |
-
|| (in_array($k, $ignores) || strpos($k, 'nounce') !== false))
|
502 |
-
{
|
503 |
-
unset($requests[$k]);
|
504 |
-
}
|
505 |
-
}
|
506 |
-
|
507 |
-
return apply_filters('metabox-requests-'.$this->_id, $requests);
|
508 |
-
}
|
509 |
-
|
510 |
-
/**
|
511 |
-
* Display the inner contents of the metabox
|
512 |
-
*
|
513 |
-
* @param object $post
|
514 |
-
*/
|
515 |
-
function show( $post )
|
516 |
-
{
|
517 |
-
// Use nonce for verification
|
518 |
-
wp_nonce_field( plugin_basename( __FILE__ ), get_class().$this->_id );
|
519 |
-
do_action('metabox-show-'.$this->_id, $this->_fields, $this);
|
520 |
-
}
|
521 |
-
|
522 |
-
/**
|
523 |
-
* Method displays a list of attached images
|
524 |
-
*
|
525 |
-
*/
|
526 |
-
function _renderListImageAttachments()
|
527 |
-
{
|
528 |
-
global $post, $current_screen;
|
529 |
-
$images = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image" );
|
530 |
-
|
531 |
-
// no images to render
|
532 |
-
if (empty($images)) {
|
533 |
-
?><p>No images have been saved.</p><?php
|
534 |
-
|
535 |
-
// rendering the images
|
536 |
-
} else {
|
537 |
-
|
538 |
-
?>
|
539 |
-
<table class="wp-list-table form-table widefat" style="border:none;">
|
540 |
-
<?php foreach ((array)$images as $post_id => $image): ?>
|
541 |
-
<?php $image_attributes = wp_get_attachment_image_src( $image->ID, 'thumbnail' ); ?>
|
542 |
-
<tbody id="the-list">
|
543 |
-
<tr>
|
544 |
-
<th scope="row" style="width: 140px">
|
545 |
-
<div style="padding:10px;background:whiteSmoke;">
|
546 |
-
<img src="<?php echo wp_get_attachment_thumb_url( $image->ID ); ?>" /></div>
|
547 |
-
</th>
|
548 |
-
<td>
|
549 |
-
<b><?php echo $image->post_title; ?></b>
|
550 |
-
<p><?php echo get_the_content($image->ID); ?></p>
|
551 |
-
|
552 |
-
<div class="row-actions">
|
553 |
-
<span class="inline">
|
554 |
-
<a href="<?php echo wp_nonce_url(
|
555 |
-
"media.php?attachment_id=$image->ID"
|
556 |
-
."&action=edit&_redirect="
|
557 |
-
.urlencode( $this->_currentPageURL() )
|
558 |
-
); ?>">
|
559 |
-
Edit</a> |
|
560 |
-
</span>
|
561 |
-
<span class="trash">
|
562 |
-
<a class="submitdelete"
|
563 |
-
onclick="return showNotice.warn();"
|
564 |
-
href="<?php echo wp_nonce_url(
|
565 |
-
"post.php?action=delete&_redirect="
|
566 |
-
.urlencode( $this->_currentPageURL() )
|
567 |
-
."&post=$image->ID",
|
568 |
-
'delete-attachment_' . $image->ID ); ?>">
|
569 |
-
Delete Permanently</a> |
|
570 |
-
</span>
|
571 |
-
<span class="inline">
|
572 |
-
<a target="_blank"
|
573 |
-
href="<?php echo get_attachment_link($image->ID); ?>">
|
574 |
-
View</a>
|
575 |
-
</span>
|
576 |
-
</div>
|
577 |
-
</td>
|
578 |
-
</tr>
|
579 |
-
</tbody>
|
580 |
-
<?php endforeach; ?>
|
581 |
-
</table>
|
582 |
-
<?php
|
583 |
-
}
|
584 |
-
return;
|
585 |
-
}
|
586 |
-
|
587 |
-
/**
|
588 |
-
* Return a clean list of meta listings created by this system
|
589 |
-
*
|
590 |
-
* @param string $category
|
591 |
-
* $param object $post
|
592 |
-
*/
|
593 |
-
public static function getMetaListings( $category, $post = null )
|
594 |
-
{
|
595 |
-
// initializing
|
596 |
-
if ($post === NULL) {
|
597 |
-
global $post;
|
598 |
-
}
|
599 |
-
$custom = get_post_custom($post->ID);
|
600 |
-
$return = array();
|
601 |
-
|
602 |
-
//looping all values to build our return array
|
603 |
-
foreach((array)$custom as $property => $value)
|
604 |
-
{
|
605 |
-
$parts = explode('_',$property);
|
606 |
-
if (!isset($parts[0]) || !isset($parts[1]) || !isset($parts[2])) continue;
|
607 |
-
if ($parts[0] != $category) continue;
|
608 |
-
|
609 |
-
$pro = str_replace($parts[0].'_'.$parts[1].'_', '', $property);
|
610 |
-
$return[$parts[1]][$pro] = $value;
|
611 |
-
}
|
612 |
-
|
613 |
-
return $return;
|
614 |
-
}
|
615 |
-
|
616 |
-
/**
|
617 |
-
* Function removes a specific category meta
|
618 |
-
*
|
619 |
-
* @param string $category
|
620 |
-
* $param string $meta_id
|
621 |
-
* $param object $post
|
622 |
-
*/
|
623 |
-
public static function deleteMetaListing( $category, $meta_id, $post = null )
|
624 |
-
{
|
625 |
-
// initializing
|
626 |
-
if ($post === NULL) {
|
627 |
-
global $post;
|
628 |
-
}
|
629 |
-
$listings = redrokk_metabox_class::getMetaListings( $category, $post );
|
630 |
-
if (!isset($listings[$meta_id])) return false;
|
631 |
-
|
632 |
-
$type = 'post';
|
633 |
-
|
634 |
-
foreach((array)$listings[$meta_id] as $property => $value) {
|
635 |
-
$pro = $category.'_'.$meta_id.'_'.$property;
|
636 |
-
delete_metadata($type, $post->ID, $pro, $value[0]);
|
637 |
-
}
|
638 |
-
return true;
|
639 |
-
}
|
640 |
-
|
641 |
-
/**
|
642 |
-
* Method displays a list of meta attachments
|
643 |
-
*
|
644 |
-
*/
|
645 |
-
function _renderListAttachments()
|
646 |
-
{
|
647 |
-
global $post;
|
648 |
-
|
649 |
-
//delete action prior to pulling new listings
|
650 |
-
if (isset($_REQUEST['redrokkdelete']) && $_REQUEST['redrokkdelete']) {
|
651 |
-
redrokk_metabox_class::deleteMetaListing($this->_category_name, $_REQUEST['redrokkdelete'], $post);
|
652 |
-
}
|
653 |
-
|
654 |
-
//pull new listings
|
655 |
-
$metaListings = redrokk_metabox_class::getMetaListings($this->_category_name, $post);
|
656 |
-
|
657 |
-
if (!empty($metaListings)) {
|
658 |
-
?>
|
659 |
-
<table class="wp-list-table form-table widefat" style="border:none;">
|
660 |
-
<tbody id="the-list">
|
661 |
-
<?php foreach ((array)$metaListings as $meta_id => $video): ?>
|
662 |
-
<?php $video = apply_filters('redrokk_metabox_class::_renderListAttachments', $video, $meta_id);?>
|
663 |
-
|
664 |
-
<tr id="<?php echo $this->_category_name; ?>_<?php echo $meta_id; ?>">
|
665 |
-
<th scope="row" style="width: 140px">
|
666 |
-
<div style="padding:10px;background:whiteSmoke;">
|
667 |
-
<?php if(isset($video['link'])) echo apply_filters('the_content', $video['link'][0]); ?>
|
668 |
-
</div>
|
669 |
-
</th>
|
670 |
-
<td>
|
671 |
-
<b><?php if(isset($video['post_title'])) echo $video['post_title'][0]; ?></b>
|
672 |
-
<p><?php if(isset($video['post_content'])) echo $video['post_content'][0]; ?></p>
|
673 |
-
|
674 |
-
<div class="row-actions">
|
675 |
-
<span class="inline">
|
676 |
-
<a href="#" id="edit_<?php echo $this->_category_name; ?>_<?php echo $meta_id; ?>">
|
677 |
-
Edit</a> |
|
678 |
-
</span>
|
679 |
-
<span class="trash">
|
680 |
-
<a class="submitdelete"
|
681 |
-
onclick="return showNotice.warn();"
|
682 |
-
href="<?php echo site_url( "wp-admin/post.php?post={$post->ID}"
|
683 |
-
."&action=edit"
|
684 |
-
."&redrokkdelete=$meta_id"
|
685 |
-
); ?>">
|
686 |
-
Delete Permanently</a>
|
687 |
-
</span>
|
688 |
-
</div>
|
689 |
-
<script>
|
690 |
-
jQuery('#edit_<?php echo $this->_category_name; ?>_<?php echo $meta_id; ?>').click(function(){
|
691 |
-
var data = {
|
692 |
-
<?php
|
693 |
-
$data = array();
|
694 |
-
|
695 |
-
//making sure all fields will be cleared
|
696 |
-
foreach ((array)$this->_fields as $field) {
|
697 |
-
if (!isset($field['id']) || !isset($field['type'])) continue;
|
698 |
-
if (!in_array($field['type'], array('text','file','image','textarea','hidden')))
|
699 |
-
continue;
|
700 |
-
|
701 |
-
$id = str_replace($this->_id.'_', '', $field['id']);
|
702 |
-
$data[$id] = "'$id':''";
|
703 |
-
}
|
704 |
-
|
705 |
-
//adding our values to the array
|
706 |
-
foreach((array)$video as $vp => $vv)
|
707 |
-
{
|
708 |
-
if (isset($vv[0])) $vv = $vv[0];
|
709 |
-
$data[$vp] = "'$vp':'$vv'";
|
710 |
-
}
|
711 |
-
|
712 |
-
//adding the meta ID to the array
|
713 |
-
$data[$id] = "'metaid':'$meta_id'";
|
714 |
-
|
715 |
-
echo implode(',',$data);
|
716 |
-
?>
|
717 |
-
};
|
718 |
-
|
719 |
-
jQuery.each(data, function(key, value){
|
720 |
-
jQuery('#<?php echo $this->_id; ?>_'+key).val( value );
|
721 |
-
});
|
722 |
-
return false;
|
723 |
-
});
|
724 |
-
</script>
|
725 |
-
</td>
|
726 |
-
<?php do_action('redrokk_metabox_class::_renderListAttachments::rows', $video, $meta_id, $this); ?>
|
727 |
-
</tr>
|
728 |
-
<?php endforeach; ?>
|
729 |
-
</tbody>
|
730 |
-
</table>
|
731 |
-
<?php
|
732 |
-
}
|
733 |
-
|
734 |
-
}
|
735 |
-
|
736 |
-
/**
|
737 |
-
* Method displays a list of attached videos
|
738 |
-
*
|
739 |
-
*/
|
740 |
-
function _renderListVideoAttachments()
|
741 |
-
{
|
742 |
-
global $post;
|
743 |
-
|
744 |
-
//pull new listings
|
745 |
-
$videos = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=video/mp4" );
|
746 |
-
|
747 |
-
// no images to render
|
748 |
-
if (!empty($videos)) {
|
749 |
-
?>
|
750 |
-
<table class="wp-list-table form-table widefat" style="border:none;">
|
751 |
-
<tbody id="the-list">
|
752 |
-
<?php foreach ((array)$videos as $post_id => $video): ?>
|
753 |
-
<?php $image_attributes = wp_get_attachment_link( $video->ID ); ?>
|
754 |
-
<tr>
|
755 |
-
<th scope="row" style="width: 140px">
|
756 |
-
<div style="padding:10px;background:whiteSmoke;">
|
757 |
-
<?php echo $image_attributes; ?>
|
758 |
-
</div>
|
759 |
-
</th>
|
760 |
-
<td>
|
761 |
-
<b><?php echo $video->post_title; ?></b>
|
762 |
-
<p><?php echo get_the_content($video->ID); ?></p>
|
763 |
-
|
764 |
-
<div class="row-actions">
|
765 |
-
<span class="inline">
|
766 |
-
<a href="<?php echo wp_nonce_url(
|
767 |
-
"media.php?attachment_id=$meta_id"
|
768 |
-
."&action=edit&_redirect="
|
769 |
-
.urlencode( $this->_currentPageURL() )
|
770 |
-
); ?>">
|
771 |
-
Edit</a> |
|
772 |
-
</span>
|
773 |
-
<span class="trash">
|
774 |
-
<a class="submitdelete"
|
775 |
-
onclick="return showNotice.warn();"
|
776 |
-
href="<?php echo wp_nonce_url(
|
777 |
-
"post.php?action=delete&_redirect="
|
778 |
-
.urlencode( $this->_currentPageURL() )
|
779 |
-
."&post=$video->ID",
|
780 |
-
'delete-attachment_' . $video->ID ); ?>">
|
781 |
-
Delete Permanently</a>
|
782 |
-
</span>
|
783 |
-
</div>
|
784 |
-
</td>
|
785 |
-
</tr>
|
786 |
-
<?php endforeach; ?>
|
787 |
-
</tbody>
|
788 |
-
</table>
|
789 |
-
<?php
|
790 |
-
}
|
791 |
-
}
|
792 |
-
|
793 |
-
/**
|
794 |
-
* Method renders the form from any source
|
795 |
-
*
|
796 |
-
* @param array $fields
|
797 |
-
*/
|
798 |
-
function _renderForm( $fields = array() )
|
799 |
-
{
|
800 |
-
//initializing
|
801 |
-
global $post;
|
802 |
-
$defaults = array(
|
803 |
-
'name' => '',
|
804 |
-
'desc' => '',
|
805 |
-
'id' => '',
|
806 |
-
'type' => 'text',
|
807 |
-
'options' => array(),
|
808 |
-
'default' => '',
|
809 |
-
'value' => '',
|
810 |
-
'class' => '',
|
811 |
-
'multiple' => '',
|
812 |
-
'args' => array(
|
813 |
-
'hide_empty' => 0,
|
814 |
-
'name' => 'element_name',
|
815 |
-
'hierarchical' => true
|
816 |
-
),
|
817 |
-
'attributes' => ''
|
818 |
-
);
|
819 |
-
|
820 |
-
// no fields to render
|
821 |
-
if (empty($fields)) {
|
822 |
-
?>
|
823 |
-
<p>No form fields have been defined. Use <pre>
|
824 |
-
$metabox->set('_fields', array(
|
825 |
-
array(
|
826 |
-
'name' => 'Title',
|
827 |
-
'type' => 'title',
|
828 |
-
),
|
829 |
-
array(
|
830 |
-
'name' => 'Title',
|
831 |
-
'desc' => '',
|
832 |
-
'id' => 'title',
|
833 |
-
'type' => 'text',
|
834 |
-
'std' => ''
|
835 |
-
),
|
836 |
-
array(
|
837 |
-
'name' => 'image',
|
838 |
-
'desc' => '',
|
839 |
-
'id' => 'imagefile',
|
840 |
-
'type' => 'image',
|
841 |
-
'std' => ''
|
842 |
-
),
|
843 |
-
array(
|
844 |
-
'name' => 'Textarea',
|
845 |
-
'desc' => 'Enter big text here',
|
846 |
-
'id' => 'textarea_id',
|
847 |
-
'type' => 'textarea',
|
848 |
-
'std' => 'Default value 2'
|
849 |
-
),
|
850 |
-
array(
|
851 |
-
'name' => 'Select box',
|
852 |
-
'id' => 'select_id',
|
853 |
-
'type' => 'select',
|
854 |
-
'options'=> array(
|
855 |
-
'value1' => 'Value 1',
|
856 |
-
'value2' => 'Value 2',
|
857 |
-
'value3' => 'Value 3',
|
858 |
-
'value4' => 'Value 4',
|
859 |
-
)
|
860 |
-
),
|
861 |
-
array(
|
862 |
-
'name' => 'Radio',
|
863 |
-
'id' => 'radio_id',
|
864 |
-
'type' => 'radio',
|
865 |
-
'value' => 'test',
|
866 |
-
'desc' => 'Check this box if you want its value saved',
|
867 |
-
),
|
868 |
-
array(
|
869 |
-
'name' => '',
|
870 |
-
'id' => 'radio_id',
|
871 |
-
'type' => 'radio',
|
872 |
-
'value' => 'test2',
|
873 |
-
'desc' => 'Check this box if you want its value saved',
|
874 |
-
),
|
875 |
-
array(
|
876 |
-
'name' => 'Checkbox',
|
877 |
-
'id' => 'checkbox_id',
|
878 |
-
'type' => 'checkbox',
|
879 |
-
'desc' => 'Check this box if you want its value saved',
|
880 |
-
),
|
881 |
-
));</pre>
|
882 |
-
</p>
|
883 |
-
<?php
|
884 |
-
|
885 |
-
// rendering the fields
|
886 |
-
} else {
|
887 |
-
?>
|
888 |
-
<table class="form-table">
|
889 |
-
<?php
|
890 |
-
// do_action("{$this->_class}_before");
|
891 |
-
$custom = get_post_custom($this->_id);
|
892 |
-
|
893 |
-
foreach ((array)$fields as $field):
|
894 |
-
$field = wp_parse_args($field, $defaults);
|
895 |
-
$field['args'] = wp_parse_args($field['args'], $defaults['args']);
|
896 |
-
|
897 |
-
extract($field);
|
898 |
-
$field['args']['name'] = $element_name = $id;
|
899 |
-
|
900 |
-
// grabbing the meta value
|
901 |
-
if (array_key_exists($id, $custom)) {
|
902 |
-
if (isset($custom[$id][0]))
|
903 |
-
$meta = esc_attr( $custom[$id][0] );
|
904 |
-
else
|
905 |
-
$meta = esc_attr( $custom[$id] );
|
906 |
-
} else {
|
907 |
-
$meta = $default;
|
908 |
-
}
|
909 |
-
|
910 |
-
$id = sanitize_title($id);
|
911 |
-
|
912 |
-
if (array_key_exists('deleteattachment', $_GET)
|
913 |
-
&& $id == $_GET['fileproperty']
|
914 |
-
&& $meta == $_GET['deleteattachment'])
|
915 |
-
{
|
916 |
-
wp_delete_attachment( $_GET['deleteattachment'], $force_delete = true );
|
917 |
-
update_post_meta($post->ID, $id, '');
|
918 |
-
}
|
919 |
-
?>
|
920 |
-
<?php switch ($type){ default: ?>
|
921 |
-
<?php if (is_callable($type) && function_exists($type)) : ?>
|
922 |
-
<tr>
|
923 |
-
<th scope="row" style="width: 140px">
|
924 |
-
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
925 |
-
</th>
|
926 |
-
<td>
|
927 |
-
<?php call_user_func($type, $args); ?>
|
928 |
-
<span class="description"><?php echo $desc; ?></span>
|
929 |
-
</td>
|
930 |
-
</tr>
|
931 |
-
<?php break; endif; ?>
|
932 |
-
<?php case 'text': ?>
|
933 |
-
<tr>
|
934 |
-
<th scope="row" style="width: 140px">
|
935 |
-
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
936 |
-
</th>
|
937 |
-
<td>
|
938 |
-
<input <?php echo $attributes ?>
|
939 |
-
id="<?php echo $id; ?>"
|
940 |
-
value="<?php echo $meta; ?>"
|
941 |
-
type="<?php echo $type; ?>"
|
942 |
-
name="<?php echo $id; ?>"
|
943 |
-
class="text large-text <?php echo $class; ?>" />
|
944 |
-
<span class="description"><?php echo $desc; ?></span>
|
945 |
-
</td>
|
946 |
-
</tr>
|
947 |
-
<?php break; ?>
|
948 |
-
<?php case 'submit': ?>
|
949 |
-
<?php case 'button': ?>
|
950 |
-
<tr>
|
951 |
-
<td colspan="2">
|
952 |
-
<input <?php echo $attributes ?>
|
953 |
-
id="<?php echo $id; ?>"
|
954 |
-
value="<?php echo $name; ?>"
|
955 |
-
type="submit"
|
956 |
-
name="submit"
|
957 |
-
class="button-primary <?php echo $class; ?>" />
|
958 |
-
<span class="description"><?php echo $desc; ?></span>
|
959 |
-
</td>
|
960 |
-
</tr>
|
961 |
-
<?php break; ?>
|
962 |
-
<?php case 'file': ?>
|
963 |
-
<?php case 'image': ?>
|
964 |
-
<tr>
|
965 |
-
<th scope="row" style="width: 140px">
|
966 |
-
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
967 |
-
</th>
|
968 |
-
<td>
|
969 |
-
<?php if ($meta && wp_get_attachment_url( $meta )): ?>
|
970 |
-
<?php echo wp_get_attachment_image( $meta ); ?>
|
971 |
-
<span><a href="<?php echo add_query_arg('fileproperty', $id, add_query_arg('deleteattachment', $meta, $this->_currentPageURL())); ?>">Delete Image</a></span>
|
972 |
-
<?php else: ?>
|
973 |
-
<input type="hidden" name="<?php echo $this->_id; ?>files" value="<?php echo $id; ?>" />
|
974 |
-
<!-- first hidden input forces this item to be submitted when it is not checked -->
|
975 |
-
<input <?php echo $attributes ?>
|
976 |
-
id="<?php echo $id; ?>"
|
977 |
-
type="file"
|
978 |
-
name="<?php echo $id; ?>"
|
979 |
-
onChange="jQuery(this).closest('form').attr('enctype', 'multipart/form-data');"
|
980 |
-
class="<?php echo $class; ?>" />
|
981 |
-
<?php endif; ?>
|
982 |
-
<span class="description"><?php echo $desc; ?></span>
|
983 |
-
</td>
|
984 |
-
</tr>
|
985 |
-
<?php break; ?>
|
986 |
-
<?php case 'title': ?>
|
987 |
-
<tr>
|
988 |
-
<th colspan="2" scope="row">
|
989 |
-
<h3 <?php echo $attributes ?> style="border: 1px solid #ddd;
|
990 |
-
padding: 10px;
|
991 |
-
background: #eee;
|
992 |
-
border-radius: 2px;
|
993 |
-
color: #666;
|
994 |
-
margin: 0;"><?php echo $name; ?>
|
995 |
-
</h3>
|
996 |
-
</th>
|
997 |
-
</tr>
|
998 |
-
<?php break; ?>
|
999 |
-
<?php case 'checkbox': ?>
|
1000 |
-
<tr>
|
1001 |
-
<th scope="row" style="width: 140px">
|
1002 |
-
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
1003 |
-
</th>
|
1004 |
-
<td>
|
1005 |
-
<input type="hidden" name="<?php echo $id; ?>" value="" />
|
1006 |
-
<!-- first hidden input forces this item to be submitted when it is not checked -->
|
1007 |
-
|
1008 |
-
<?php foreach ((array)$options as $_value => $_name): ?>
|
1009 |
-
<input value="<?php echo $_value; ?>" type="checkbox" <?php echo $attributes ?>
|
1010 |
-
name="<?php echo $element_name; ?>" id="<?php echo $id; ?>"
|
1011 |
-
<?php echo $meta == $_value? 'checked="checked"' :''; ?>
|
1012 |
-
class="<?php echo $class; ?>" />
|
1013 |
-
<?php echo $_name; ?>
|
1014 |
-
<?php endforeach; ?>
|
1015 |
-
<span class="description"><?php echo $desc; ?></span>
|
1016 |
-
</td>
|
1017 |
-
</tr>
|
1018 |
-
<?php break; ?>
|
1019 |
-
<?php case 'radio': ?>
|
1020 |
-
<tr>
|
1021 |
-
<th scope="row" style="width: 140px">
|
1022 |
-
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
1023 |
-
</th>
|
1024 |
-
<td>
|
1025 |
-
<?php foreach ((array)$options as $_value => $_name): ?>
|
1026 |
-
<input name="<?php echo $element_name; ?>" id="<?php echo $id; ?>"
|
1027 |
-
value="<?php echo $_value; ?>" type="<?php echo $type; ?>"
|
1028 |
-
<?php echo $meta == $_value?'checked="checked"' :''; ?>
|
1029 |
-
<?php echo $attributes ?> class="<?php echo $class; ?>" />
|
1030 |
-
<?php echo $_name; ?>
|
1031 |
-
<?php endforeach; ?>
|
1032 |
-
<span class="description"><?php echo $desc; ?></span>
|
1033 |
-
</td>
|
1034 |
-
</tr>
|
1035 |
-
<?php break; ?>
|
1036 |
-
<?php case 'textarea': ?>
|
1037 |
-
<tr>
|
1038 |
-
<th scope="row" style="width: 140px">
|
1039 |
-
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
1040 |
-
</th>
|
1041 |
-
<td>
|
1042 |
-
<textarea <?php echo $attributes ?>
|
1043 |
-
id="<?php echo $id; ?>"
|
1044 |
-
name="<?php echo $id; ?>"
|
1045 |
-
class="large-text <?php echo $class; ?>"
|
1046 |
-
><?php echo $meta; ?></textarea>
|
1047 |
-
<span class="description"><?php echo $desc; ?></span>
|
1048 |
-
</td>
|
1049 |
-
</tr>
|
1050 |
-
<?php break; ?>
|
1051 |
-
<?php case 'wpeditor': ?>
|
1052 |
-
<tr>
|
1053 |
-
<th scope="row" style="width: 140px">
|
1054 |
-
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
1055 |
-
</th>
|
1056 |
-
<td>
|
1057 |
-
<?php wp_editor( $meta, $id, $settings = array() ); ?>
|
1058 |
-
<span class="description"><?php echo $desc; ?></span>
|
1059 |
-
</td>
|
1060 |
-
</tr>
|
1061 |
-
<?php break; ?>
|
1062 |
-
<?php case 'select_capabilities': ?>
|
1063 |
-
<?php $options = $type=='select_capabilities' ?$this->get_options_capabilities()+$options :$options; ?>
|
1064 |
-
|
1065 |
-
<?php case 'select_roles': ?>
|
1066 |
-
<?php $options = $type=='select_roles' ?$this->get_options_roles()+$options :$options; ?>
|
1067 |
-
|
1068 |
-
<?php case 'select_menu': ?>
|
1069 |
-
<?php $options = $type=='select_menu' ?$this->get_options_menus()+$options :$options; ?>
|
1070 |
-
|
1071 |
-
<?php case 'select_pages': ?>
|
1072 |
-
<?php $options = $type=='select_pages' ?$this->get_options_pages()+$options :$options; ?>
|
1073 |
-
|
1074 |
-
<?php case 'select_users': ?>
|
1075 |
-
<?php $options = $type=='select_users' ?$this->get_options_users()+$options :$options; ?>
|
1076 |
-
|
1077 |
-
<?php case 'select_categories': ?>
|
1078 |
-
<?php case 'select': ?>
|
1079 |
-
<tr>
|
1080 |
-
<th scope="row" style="width: 140px">
|
1081 |
-
<label for="<?php echo $id; ?>"><?php echo $name; ?></label>
|
1082 |
-
</th>
|
1083 |
-
<td>
|
1084 |
-
<?php if ($type == 'select_categories'): ?>
|
1085 |
-
<?php wp_dropdown_categories($args); ?>
|
1086 |
-
|
1087 |
-
<?php else: ?>
|
1088 |
-
|
1089 |
-
<select <?php echo $attributes ?>
|
1090 |
-
id="<?php echo $id; ?>"
|
1091 |
-
name="<?php echo $id; ?>"
|
1092 |
-
class="<?php echo $class; ?>"
|
1093 |
-
<?php echo $multiple ?"MULTIPLE SIZE='$multiple'" :''; ?>
|
1094 |
-
><?php foreach ((array)$options as $_value => $_name): ?>
|
1095 |
-
|
1096 |
-
<option
|
1097 |
-
value="<?php echo $_value; ?>"
|
1098 |
-
<?php echo $meta == $_value ?' selected="selected"' :''; ?>
|
1099 |
-
><?php echo $_name; ?></option>
|
1100 |
-
|
1101 |
-
<?php endforeach; ?></select>
|
1102 |
-
<?php endif; ?>
|
1103 |
-
<span class="description"><?php echo $desc; ?></span>
|
1104 |
-
</td>
|
1105 |
-
</tr>
|
1106 |
-
<?php break; ?>
|
1107 |
-
<?php case 'hidden': ?>
|
1108 |
-
<tr>
|
1109 |
-
<td colspan="2">
|
1110 |
-
<input <?php echo $attributes ?>
|
1111 |
-
id="<?php echo $id; ?>"
|
1112 |
-
value="<?php echo $meta ?$meta :$default; ?>"
|
1113 |
-
type="<?php echo $type; ?>"
|
1114 |
-
name="<?php echo $id; ?>"
|
1115 |
-
style="visibility:hidden;" />
|
1116 |
-
</td>
|
1117 |
-
</tr>
|
1118 |
-
<?php break; ?>
|
1119 |
-
<?php case 'custom': ?>
|
1120 |
-
<tr>
|
1121 |
-
<td colspan="2">
|
1122 |
-
<?php echo $desc.$default; ?>
|
1123 |
-
</td>
|
1124 |
-
</tr>
|
1125 |
-
<?php } ?>
|
1126 |
-
<?php endforeach; ?>
|
1127 |
-
</table>
|
1128 |
-
<?php
|
1129 |
-
}
|
1130 |
-
return $this;
|
1131 |
-
}
|
1132 |
-
|
1133 |
-
/**
|
1134 |
-
* Returns an options list of menus
|
1135 |
-
*/
|
1136 |
-
function get_options_pages()
|
1137 |
-
{
|
1138 |
-
// initializing
|
1139 |
-
$options = array('0'=>' -- ');
|
1140 |
-
$pages = get_pages(array('post_type' => 'page', 'post_status' => 'publish'));
|
1141 |
-
|
1142 |
-
foreach($pages as $page) {
|
1143 |
-
$options[$page->ID] = $page->post_title;
|
1144 |
-
}
|
1145 |
-
|
1146 |
-
return $options;
|
1147 |
-
}
|
1148 |
-
|
1149 |
-
/**
|
1150 |
-
* Returns an options list of menus
|
1151 |
-
*/
|
1152 |
-
function get_options_menus()
|
1153 |
-
{
|
1154 |
-
// initializing
|
1155 |
-
$options = array('0'=>' -- ');
|
1156 |
-
$menus = get_terms('nav_menu', array(
|
1157 |
-
'hide_empty' => 0
|
1158 |
-
));
|
1159 |
-
|
1160 |
-
foreach($menus as $menu) {
|
1161 |
-
$options[$menu->slug] = $menu->name;
|
1162 |
-
}
|
1163 |
-
|
1164 |
-
return $options;
|
1165 |
-
}
|
1166 |
-
|
1167 |
-
/**
|
1168 |
-
* Returns an options list of users
|
1169 |
-
*/
|
1170 |
-
function get_options_users()
|
1171 |
-
{
|
1172 |
-
// initializing
|
1173 |
-
global $wpdb;
|
1174 |
-
|
1175 |
-
$options = array('0'=>' -- ');
|
1176 |
-
$query = $wpdb->prepare("SELECT $wpdb->users.ID, $wpdb->users.display_name FROM $wpdb->users");
|
1177 |
-
$results = $wpdb->get_results( $query );
|
1178 |
-
|
1179 |
-
foreach ((array)$results as $result)
|
1180 |
-
{
|
1181 |
-
$options[$result->ID] = $result->display_name;
|
1182 |
-
}
|
1183 |
-
|
1184 |
-
return $options;
|
1185 |
-
}
|
1186 |
-
|
1187 |
-
/**
|
1188 |
-
* Returns an options list of capabilities
|
1189 |
-
*/
|
1190 |
-
function get_options_capabilities()
|
1191 |
-
{
|
1192 |
-
// initializing
|
1193 |
-
global $wpdb;
|
1194 |
-
|
1195 |
-
$options = array();
|
1196 |
-
$roles = get_option($wpdb->prefix . 'user_roles');
|
1197 |
-
|
1198 |
-
foreach ((array)$roles as $role)
|
1199 |
-
{
|
1200 |
-
if(!isset($role['capabilities'])) continue;
|
1201 |
-
foreach ((array)$role['capabilities'] as $cap => $v)
|
1202 |
-
{
|
1203 |
-
$options[$role['name']."::$cap"] = $role['name']."::$cap";
|
1204 |
-
}
|
1205 |
-
}
|
1206 |
-
|
1207 |
-
return $options;
|
1208 |
-
}
|
1209 |
-
|
1210 |
-
/**
|
1211 |
-
* Returns an options list of roles
|
1212 |
-
*/
|
1213 |
-
function get_options_roles()
|
1214 |
-
{
|
1215 |
-
// initializing
|
1216 |
-
global $wpdb;
|
1217 |
-
|
1218 |
-
$options = array(
|
1219 |
-
'read' => 'Public'
|
1220 |
-
);
|
1221 |
-
$roles = get_option($wpdb->prefix . 'user_roles');
|
1222 |
-
|
1223 |
-
foreach ((array)$roles as $role)
|
1224 |
-
{
|
1225 |
-
$options[strtolower($role['name'])] = $role['name'];
|
1226 |
-
}
|
1227 |
-
|
1228 |
-
return $options;
|
1229 |
-
}
|
1230 |
-
|
1231 |
-
/**
|
1232 |
-
* Adds a box to the main column on the Post and Page edit screens
|
1233 |
-
*
|
1234 |
-
*/
|
1235 |
-
function _register()
|
1236 |
-
{
|
1237 |
-
// this metabox is to be displayed for a certain object type only
|
1238 |
-
if (!empty($this->_object_types) && !in_array($this->getCurrentPostType(), $this->_object_types) )
|
1239 |
-
return;
|
1240 |
-
|
1241 |
-
if (!$this->callback_args) {
|
1242 |
-
$this->callback_args = $this;
|
1243 |
-
}
|
1244 |
-
|
1245 |
-
// if the user has not already set the type of this metabox,
|
1246 |
-
// then we need to do that now
|
1247 |
-
if (!$this->_type) {
|
1248 |
-
$this->setType();
|
1249 |
-
}
|
1250 |
-
|
1251 |
-
add_meta_box(
|
1252 |
-
$this->_id,
|
1253 |
-
$this->title,
|
1254 |
-
$this->callback,
|
1255 |
-
$this->getCurrentPostType(),
|
1256 |
-
$this->context,
|
1257 |
-
$this->priority,
|
1258 |
-
$this->callback_args
|
1259 |
-
);
|
1260 |
-
}
|
1261 |
-
|
1262 |
-
/**
|
1263 |
-
* Method set's the hooks for the options creted by this metabox
|
1264 |
-
*
|
1265 |
-
*/
|
1266 |
-
function setOptionHooks()
|
1267 |
-
{
|
1268 |
-
foreach ((array)$this->_fields as $field)
|
1269 |
-
{
|
1270 |
-
if (!isset($field['id'])) continue;
|
1271 |
-
|
1272 |
-
//creating the callback for the admin page
|
1273 |
-
$function = create_function('$default','
|
1274 |
-
return redrokk_admin_class::getInstance("'.$this->_isAdminPage.'")
|
1275 |
-
->getOption("'.$field['id'].'", $default, true);
|
1276 |
-
');
|
1277 |
-
add_filter("pre_option_{$field['id']}", $function, 20, 2);
|
1278 |
-
}
|
1279 |
-
}
|
1280 |
-
|
1281 |
-
/**
|
1282 |
-
* Method redirects the user if we have added a request redirect
|
1283 |
-
* in the url
|
1284 |
-
*
|
1285 |
-
* @param string $location
|
1286 |
-
*/
|
1287 |
-
function _redirectIntervention( $location )
|
1288 |
-
{
|
1289 |
-
if (isset($_GET['_redirect'])) {
|
1290 |
-
$location = urldecode($_GET['_redirect']);
|
1291 |
-
}
|
1292 |
-
return $location;
|
1293 |
-
}
|
1294 |
-
|
1295 |
-
/**
|
1296 |
-
* Get the current page url
|
1297 |
-
*/
|
1298 |
-
function _currentPageURL()
|
1299 |
-
{
|
1300 |
-
$pageURL = 'http';
|
1301 |
-
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
|
1302 |
-
$pageURL .= "://";
|
1303 |
-
if ($_SERVER["SERVER_PORT"] != "80") {
|
1304 |
-
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
1305 |
-
} else {
|
1306 |
-
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
1307 |
-
}
|
1308 |
-
return $pageURL;
|
1309 |
-
}
|
1310 |
-
|
1311 |
-
/**
|
1312 |
-
* Method to bind an associative array or object to the JTable instance.This
|
1313 |
-
* method only binds properties that are publicly accessible and optionally
|
1314 |
-
* takes an array of properties to ignore when binding.
|
1315 |
-
*
|
1316 |
-
* @param mixed $src An associative array or object to bind to the JTable instance.
|
1317 |
-
* @param mixed $ignore An optional array or space separated list of properties to ignore while binding.
|
1318 |
-
*
|
1319 |
-
* @return boolean True on success.
|
1320 |
-
*
|
1321 |
-
* @link http://docs.joomla.org/JTable/bind
|
1322 |
-
* @since 11.1
|
1323 |
-
*/
|
1324 |
-
public function bind($src, $ignore = array())
|
1325 |
-
{
|
1326 |
-
// If the source value is not an array or object return false.
|
1327 |
-
if (!is_object($src) && !is_array($src))
|
1328 |
-
{
|
1329 |
-
trigger_error('Bind failed as the provided source is not an array.');
|
1330 |
-
return false;
|
1331 |
-
}
|
1332 |
-
|
1333 |
-
// If the source value is an object, get its accessible properties.
|
1334 |
-
if (is_object($src))
|
1335 |
-
{
|
1336 |
-
$src = get_object_vars($src);
|
1337 |
-
}
|
1338 |
-
|
1339 |
-
// If the ignore value is a string, explode it over spaces.
|
1340 |
-
if (!is_array($ignore))
|
1341 |
-
{
|
1342 |
-
$ignore = explode(' ', $ignore);
|
1343 |
-
}
|
1344 |
-
|
1345 |
-
// Bind the source value, excluding the ignored fields.
|
1346 |
-
foreach ($this->getProperties() as $k => $v)
|
1347 |
-
{
|
1348 |
-
// Only process fields not in the ignore array.
|
1349 |
-
if (!in_array($k, $ignore))
|
1350 |
-
{
|
1351 |
-
if (isset($src[$k]))
|
1352 |
-
{
|
1353 |
-
$this->$k = $src[$k];
|
1354 |
-
}
|
1355 |
-
}
|
1356 |
-
}
|
1357 |
-
|
1358 |
-
return true;
|
1359 |
-
}
|
1360 |
-
|
1361 |
-
/**
|
1362 |
-
* Set the object properties based on a named array/hash.
|
1363 |
-
*
|
1364 |
-
* @param mixed $properties Either an associative array or another object.
|
1365 |
-
*
|
1366 |
-
* @return boolean
|
1367 |
-
*
|
1368 |
-
* @since 11.1
|
1369 |
-
*
|
1370 |
-
* @see set()
|
1371 |
-
*/
|
1372 |
-
public function setProperties($properties)
|
1373 |
-
{
|
1374 |
-
if (is_array($properties) || is_object($properties))
|
1375 |
-
{
|
1376 |
-
foreach ((array) $properties as $k => $v)
|
1377 |
-
{
|
1378 |
-
// Use the set function which might be overridden.
|
1379 |
-
$this->set($k, $v);
|
1380 |
-
}
|
1381 |
-
return true;
|
1382 |
-
}
|
1383 |
-
|
1384 |
-
return false;
|
1385 |
-
}
|
1386 |
-
|
1387 |
-
/**
|
1388 |
-
* Modifies a property of the object, creating it if it does not already exist.
|
1389 |
-
*
|
1390 |
-
* @param string $property The name of the property.
|
1391 |
-
* @param mixed $value The value of the property to set.
|
1392 |
-
*
|
1393 |
-
* @return mixed Previous value of the property.
|
1394 |
-
*
|
1395 |
-
* @since 11.1
|
1396 |
-
*/
|
1397 |
-
public function set($property, $value = null)
|
1398 |
-
{
|
1399 |
-
$_property = 'set'.str_replace(' ', '', ucwords(str_replace('_', ' ', $property)));
|
1400 |
-
if (method_exists($this, $_property)) {
|
1401 |
-
return $this->$_property($value);
|
1402 |
-
}
|
1403 |
-
|
1404 |
-
$previous = isset($this->$property) ? $this->$property : null;
|
1405 |
-
$this->$property = $value;
|
1406 |
-
return $previous;
|
1407 |
-
}
|
1408 |
-
|
1409 |
-
/**
|
1410 |
-
* Returns an associative array of object properties.
|
1411 |
-
*
|
1412 |
-
* @param boolean $public If true, returns only the public properties.
|
1413 |
-
*
|
1414 |
-
* @return array
|
1415 |
-
*
|
1416 |
-
* @see get()
|
1417 |
-
*/
|
1418 |
-
public function getProperties($public = true)
|
1419 |
-
{
|
1420 |
-
$vars = get_object_vars($this);
|
1421 |
-
if ($public)
|
1422 |
-
{
|
1423 |
-
foreach ($vars as $key => $value)
|
1424 |
-
{
|
1425 |
-
if ('_' == substr($key, 0, 1))
|
1426 |
-
{
|
1427 |
-
unset($vars[$key]);
|
1428 |
-
}
|
1429 |
-
}
|
1430 |
-
}
|
1431 |
-
|
1432 |
-
return $vars;
|
1433 |
-
}
|
1434 |
-
|
1435 |
-
/**
|
1436 |
-
*
|
1437 |
-
* contains the current instance of this class
|
1438 |
-
* @var object
|
1439 |
-
*/
|
1440 |
-
static $_instances = null;
|
1441 |
-
|
1442 |
-
/**
|
1443 |
-
* Method is called when we need to instantiate this class
|
1444 |
-
*
|
1445 |
-
* @param array $options
|
1446 |
-
*/
|
1447 |
-
public static function getInstance( $_id, $options = array() )
|
1448 |
-
{
|
1449 |
-
if (!isset(self::$_instances[$_id]))
|
1450 |
-
{
|
1451 |
-
$options['_id'] = $_id;
|
1452 |
-
$class = get_class();
|
1453 |
-
self::$_instances[$_id] = new $class($options);
|
1454 |
-
}
|
1455 |
-
return self::$_instances[$_id];
|
1456 |
-
}
|
1457 |
-
}
|
1458 |
-
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/settings.testimonials-widget.php
DELETED
@@ -1,1070 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Testimonials Widget settings class
|
5 |
-
*
|
6 |
-
* Based upon http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
|
7 |
-
*/
|
8 |
-
class Testimonials_Widget_Settings {
|
9 |
-
const id = 'testimonialswidget_settings';
|
10 |
-
|
11 |
-
public static $default = array(
|
12 |
-
'backwards' => array(
|
13 |
-
'version' => '', // below this version number, use std
|
14 |
-
'std' => ''
|
15 |
-
),
|
16 |
-
'choices' => array(), // key => value
|
17 |
-
'class' => '',
|
18 |
-
'desc' => '',
|
19 |
-
'id' => 'default_field',
|
20 |
-
'section' => 'general',
|
21 |
-
'std' => '', // default key or value
|
22 |
-
'title' => '',
|
23 |
-
'type' => 'text', // textarea, checkbox, radio, select, hidden, heading, password, expand_begin, expand_end
|
24 |
-
'validate' => '', // required, term, slug, slugs, ids, order, single paramater PHP functions
|
25 |
-
'widget' => 1, // show in widget options, 0 off
|
26 |
-
);
|
27 |
-
public static $defaults = array();
|
28 |
-
public static $sections = array();
|
29 |
-
public static $settings = array();
|
30 |
-
public static $version = null;
|
31 |
-
|
32 |
-
|
33 |
-
public function __construct() {
|
34 |
-
add_action( 'admin_init', array( &$this, 'admin_init' ) );
|
35 |
-
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
36 |
-
add_action( 'init', array( &$this, 'init' ) );
|
37 |
-
load_plugin_textdomain( 'testimonials-widget', false, '/testimonials-widget/languages/' );
|
38 |
-
}
|
39 |
-
|
40 |
-
|
41 |
-
public function init() {
|
42 |
-
self::sections();
|
43 |
-
self::settings();
|
44 |
-
}
|
45 |
-
|
46 |
-
|
47 |
-
public static function sections() {
|
48 |
-
self::$sections['general'] = __( 'General', 'testimonials-widget' );
|
49 |
-
self::$sections['selection'] = __( 'Selection', 'testimonials-widget' );
|
50 |
-
self::$sections['ordering'] = __( 'Ordering', 'testimonials-widget' );
|
51 |
-
self::$sections['widget'] = __( 'Widget', 'testimonials-widget' );
|
52 |
-
// self::$sections['testing'] = __( 'Testing', 'testimonials-widget' );
|
53 |
-
self::$sections['post_type'] = __( 'Post Type', 'testimonials-widget' );
|
54 |
-
self::$sections['reset'] = __( 'Compatibility & Reset', 'testimonials-widget' );
|
55 |
-
self::$sections['about'] = __( 'About Testimonials Widget', 'testimonials-widget' );
|
56 |
-
|
57 |
-
self::$sections = apply_filters( 'testimonials_widget_sections', self::$sections );
|
58 |
-
}
|
59 |
-
|
60 |
-
|
61 |
-
public static function settings() {
|
62 |
-
// Widget
|
63 |
-
self::$settings['title'] = array(
|
64 |
-
'section' => 'widget',
|
65 |
-
'title' => __( 'Widget Title', 'testimonials-widget' ),
|
66 |
-
'std' => __( 'Testimonials', 'testimonials-widget' ),
|
67 |
-
'validate' => 'wp_kses_post',
|
68 |
-
);
|
69 |
-
|
70 |
-
self::$settings['title_link'] = array(
|
71 |
-
'section' => 'widget',
|
72 |
-
'title' => __( 'Title Link', 'testimonials-widget' ),
|
73 |
-
'desc' => __( 'URL or Post ID to link widget title to. Ex: 123 or http://example.com', 'testimonials-widget' ),
|
74 |
-
'validate' => 'wp_kses_data',
|
75 |
-
);
|
76 |
-
|
77 |
-
self::$settings['char_limit'] = array(
|
78 |
-
'section' => 'widget',
|
79 |
-
'title' => __( 'Character Limit', 'testimonials-widget' ),
|
80 |
-
'desc' => __( 'Number of characters to limit non-single testimonial views to', 'testimonials-widget' ),
|
81 |
-
'validate' => 'absint',
|
82 |
-
);
|
83 |
-
|
84 |
-
self::$settings['height'] = array(
|
85 |
-
'section' => 'widget',
|
86 |
-
'title' => __( 'Height', 'testimonials-widget' ),
|
87 |
-
'desc' => __( 'Testimonials height, in pixels. Overrides minimum and maximum height', 'testimonials-widget' ),
|
88 |
-
'validate' => 'min1',
|
89 |
-
);
|
90 |
-
|
91 |
-
self::$settings['refresh_interval'] = array(
|
92 |
-
'section' => 'widget',
|
93 |
-
'title' => __( 'Rotation Speed', 'testimonials-widget' ),
|
94 |
-
'desc' => __( 'Number of seconds between testimonial rotations or 0 for no rotation at all refresh', 'testimonials-widget' ),
|
95 |
-
'std' => 5,
|
96 |
-
'validate' => 'absint',
|
97 |
-
);
|
98 |
-
|
99 |
-
self::$settings['widget_expand_begin'] = array(
|
100 |
-
'section' => 'widget',
|
101 |
-
'desc' => __( 'Additional Widget Options', 'testimonials-widget' ),
|
102 |
-
'type' => 'expand_begin',
|
103 |
-
);
|
104 |
-
|
105 |
-
self::$settings['keep_whitespace'] = array(
|
106 |
-
'section' => 'widget',
|
107 |
-
'title' => __( 'Keep Whitespace?', 'testimonials-widget' ),
|
108 |
-
'desc' => __( 'Keeps testimonials looking as entered than sans auto-formatting', 'testimonials-widget' ),
|
109 |
-
'type' => 'checkbox',
|
110 |
-
);
|
111 |
-
|
112 |
-
self::$settings['min_height'] = array(
|
113 |
-
'section' => 'widget',
|
114 |
-
'title' => __( 'Minimum Height', 'testimonials-widget' ),
|
115 |
-
'desc' => __( 'Set for minimum display height, in pixels', 'testimonials-widget' ),
|
116 |
-
'validate' => 'min1',
|
117 |
-
);
|
118 |
-
|
119 |
-
self::$settings['max_height'] = array(
|
120 |
-
'section' => 'widget',
|
121 |
-
'title' => __( 'Maximum Height', 'testimonials-widget' ),
|
122 |
-
'desc' => __( 'Set for maximum display height, in pixels', 'testimonials-widget' ),
|
123 |
-
'validate' => 'min1',
|
124 |
-
);
|
125 |
-
|
126 |
-
self::$settings['bottom_text'] = array(
|
127 |
-
'section' => 'widget',
|
128 |
-
'title' => __( 'Testimonial Bottom Text', 'testimonials-widget' ),
|
129 |
-
'desc' => __( 'Custom text or HTML for bottom of testimonials', 'testimonials-widget' ),
|
130 |
-
'type' => 'textarea',
|
131 |
-
'validate' => 'wp_kses_post',
|
132 |
-
);
|
133 |
-
|
134 |
-
self::$settings['widget_expand_end'] = array(
|
135 |
-
'section' => 'widget',
|
136 |
-
'type' => 'expand_end',
|
137 |
-
);
|
138 |
-
|
139 |
-
// General
|
140 |
-
self::$settings['general_expand_begin'] = array(
|
141 |
-
'desc' => __( 'General Options', 'testimonials-widget' ),
|
142 |
-
'type' => 'expand_begin',
|
143 |
-
);
|
144 |
-
|
145 |
-
self::$settings['disable_quotes'] = array(
|
146 |
-
'title' => __( 'Hide built-in quotes?', 'testimonials-widget' ),
|
147 |
-
'desc' => __( 'Remove open and close quote span tags surrounding testimonial content', 'testimonials-widget' ),
|
148 |
-
'type' => 'checkbox',
|
149 |
-
);
|
150 |
-
|
151 |
-
self::$settings['hide_not_found'] = array(
|
152 |
-
'title' => __( 'Hide "Testimonials Not Found"?', 'testimonials-widget' ),
|
153 |
-
'type' => 'checkbox',
|
154 |
-
);
|
155 |
-
|
156 |
-
self::$settings['hide_gravatar'] = array(
|
157 |
-
'title' => __( 'Hide Gravatar Image?', 'testimonials-widget' ),
|
158 |
-
'type' => 'checkbox',
|
159 |
-
);
|
160 |
-
|
161 |
-
self::$settings['hide_image'] = array(
|
162 |
-
'title' => __( 'Hide Image?', 'testimonials-widget' ),
|
163 |
-
'type' => 'checkbox',
|
164 |
-
);
|
165 |
-
|
166 |
-
self::$settings['hide_image_single'] = array(
|
167 |
-
'title' => __( 'Hide Image in Single View?', 'testimonials-widget' ),
|
168 |
-
'type' => 'checkbox',
|
169 |
-
'widget' => 0,
|
170 |
-
);
|
171 |
-
|
172 |
-
self::$settings['hide_content'] = array(
|
173 |
-
'title' => __( 'Hide Testimonial Content?', 'testimonials-widget' ),
|
174 |
-
'type' => 'checkbox',
|
175 |
-
);
|
176 |
-
|
177 |
-
self::$settings['hide_source'] = array(
|
178 |
-
'title' => __( 'Hide Author/Source?', 'testimonials-widget' ),
|
179 |
-
'type' => 'checkbox',
|
180 |
-
'desc' => __( 'Don\'t display "Post Title" in cite', 'testimonials-widget' ),
|
181 |
-
);
|
182 |
-
|
183 |
-
self::$settings['hide_email'] = array(
|
184 |
-
'title' => __( 'Hide Email?', 'testimonials-widget' ),
|
185 |
-
'type' => 'checkbox',
|
186 |
-
'std' => 1,
|
187 |
-
);
|
188 |
-
|
189 |
-
self::$settings['hide_title'] = array(
|
190 |
-
'title' => __( 'Hide Title?', 'testimonials-widget' ),
|
191 |
-
'type' => 'checkbox',
|
192 |
-
);
|
193 |
-
|
194 |
-
self::$settings['hide_location'] = array(
|
195 |
-
'title' => __( 'Hide Location?', 'testimonials-widget' ),
|
196 |
-
'type' => 'checkbox',
|
197 |
-
);
|
198 |
-
|
199 |
-
self::$settings['hide_company'] = array(
|
200 |
-
'title' => __( 'Hide Company?', 'testimonials-widget' ),
|
201 |
-
'type' => 'checkbox',
|
202 |
-
);
|
203 |
-
|
204 |
-
self::$settings['hide_url'] = array(
|
205 |
-
'title' => __( 'Hide URL?', 'testimonials-widget' ),
|
206 |
-
'type' => 'checkbox',
|
207 |
-
);
|
208 |
-
|
209 |
-
self::$settings['target'] = array(
|
210 |
-
'title' => __( 'URL Target', 'testimonials-widget' ),
|
211 |
-
'desc' => __( 'Adds target to all URLs; leave blank if none', 'testimonials-widget' ),
|
212 |
-
'validate' => 'term',
|
213 |
-
);
|
214 |
-
|
215 |
-
self::$settings['paging'] = array(
|
216 |
-
'title' => __( 'Enable Paging?', 'testimonials-widget' ),
|
217 |
-
'desc' => __( 'For `[testimonialswidget_list]`', 'testimonials-widget' ),
|
218 |
-
'type' => 'select',
|
219 |
-
'choices' => array(
|
220 |
-
'' => __( 'Disable', 'testimonials-widget' ),
|
221 |
-
1 => __( 'Enable', 'testimonials-widget' ),
|
222 |
-
'before' => __( 'Before testimonials', 'testimonials-widget' ),
|
223 |
-
'after' => __( 'After testimonials', 'testimonials-widget' ),
|
224 |
-
),
|
225 |
-
'std' => 1,
|
226 |
-
'widget' => 0,
|
227 |
-
);
|
228 |
-
|
229 |
-
self::$settings['general_expand_end'] = array(
|
230 |
-
'type' => 'expand_end',
|
231 |
-
);
|
232 |
-
|
233 |
-
// Selection
|
234 |
-
self::$settings['selection_expand_begin'] = array(
|
235 |
-
'section' => 'selection',
|
236 |
-
'desc' => __( 'Selection Options', 'testimonials-widget' ),
|
237 |
-
'type' => 'expand_begin',
|
238 |
-
);
|
239 |
-
|
240 |
-
self::$settings['category'] = array(
|
241 |
-
'section' => 'selection',
|
242 |
-
'title' => __( 'Category Filter', 'testimonials-widget' ),
|
243 |
-
'desc' => __( 'Comma separated category slug-names. Ex: category-a, another-category', 'testimonials-widget' ),
|
244 |
-
'validate' => 'slugs',
|
245 |
-
);
|
246 |
-
|
247 |
-
self::$settings['tags'] = array(
|
248 |
-
'section' => 'selection',
|
249 |
-
'title' => __( 'Tags Filter', 'testimonials-widget' ),
|
250 |
-
'desc' => __( 'Comma separated tag slug-names. Ex: tag-a, another-tag', 'testimonials-widget' ),
|
251 |
-
'validate' => 'slugs',
|
252 |
-
);
|
253 |
-
|
254 |
-
self::$settings['tags_all'] = array(
|
255 |
-
'section' => 'selection',
|
256 |
-
'title' => __( 'Require All Tags?', 'testimonials-widget' ),
|
257 |
-
'desc' => __( 'Select only testimonials with all of the given tags', 'testimonials-widget' ),
|
258 |
-
'type' => 'checkbox',
|
259 |
-
);
|
260 |
-
|
261 |
-
self::$settings['ids'] = array(
|
262 |
-
'section' => 'selection',
|
263 |
-
'title' => __( 'Include IDs Filter', 'testimonials-widget' ),
|
264 |
-
'desc' => __( 'Comma separated testimonial IDs. Ex: 3,1,2', 'testimonials-widget' ),
|
265 |
-
'validate' => 'ids',
|
266 |
-
);
|
267 |
-
|
268 |
-
self::$settings['exclude'] = array(
|
269 |
-
'section' => 'selection',
|
270 |
-
'title' => __( 'Exclude IDs Filter', 'testimonials-widget' ),
|
271 |
-
'desc' => __( 'Comma separated testimonial IDs. Ex: 3,1,2', 'testimonials-widget' ),
|
272 |
-
'validate' => 'ids',
|
273 |
-
);
|
274 |
-
|
275 |
-
self::$settings['limit'] = array(
|
276 |
-
'section' => 'selection',
|
277 |
-
'title' => __( 'Limit', 'testimonials-widget' ),
|
278 |
-
'desc' => __( 'Number of testimonials to select per instance', 'testimonials-widget' ),
|
279 |
-
'std' => 10,
|
280 |
-
'validate' => 'nozero',
|
281 |
-
);
|
282 |
-
|
283 |
-
self::$settings['selection_expand_end'] = array(
|
284 |
-
'section' => 'selection',
|
285 |
-
'type' => 'expand_end',
|
286 |
-
);
|
287 |
-
|
288 |
-
// Ordering
|
289 |
-
self::$settings['ordering_expand_begin'] = array(
|
290 |
-
'section' => 'ordering',
|
291 |
-
'desc' => __( 'Ordering Options', 'testimonials-widget' ),
|
292 |
-
'type' => 'expand_begin',
|
293 |
-
);
|
294 |
-
|
295 |
-
self::$settings['random'] = array(
|
296 |
-
'section' => 'ordering',
|
297 |
-
'title' => __( 'Random Order?', 'testimonials-widget' ),
|
298 |
-
'desc' => __( 'If checked, ignores ORDER BY, ORDER BY meta_key, and ORDER BY Order. Widgets are random by default automatically', 'testimonials-widget' ),
|
299 |
-
'type' => 'checkbox',
|
300 |
-
);
|
301 |
-
|
302 |
-
self::$settings['orderby'] = array(
|
303 |
-
'section' => 'ordering',
|
304 |
-
'title' => __( 'ORDER BY', 'testimonials-widget' ),
|
305 |
-
'desc' => __( 'Used when "Random Order" is disabled', 'testimonials-widget' ),
|
306 |
-
'type' => 'select',
|
307 |
-
'choices' => array(
|
308 |
-
'ID' => __( 'Testimonial ID', 'testimonials-widget' ),
|
309 |
-
'author' => __( 'Author', 'testimonials-widget' ),
|
310 |
-
'date' => __( 'Date', 'testimonials-widget' ),
|
311 |
-
'menu_order' => __( 'Menu Order', 'testimonials-widget' ),
|
312 |
-
'title' => __( 'Source', 'testimonials-widget' ),
|
313 |
-
'none' => __( 'No order', 'testimonials-widget' ),
|
314 |
-
),
|
315 |
-
'std' => 'ID',
|
316 |
-
'validate' => 'term',
|
317 |
-
);
|
318 |
-
|
319 |
-
self::$settings['meta_key'] = array(
|
320 |
-
'section' => 'ordering',
|
321 |
-
'title' => __( 'ORDER BY meta_key', 'testimonials-widget' ),
|
322 |
-
'desc' => __( 'Used when "Random Order" is disabled and sorting by a testimonials meta key is needed. Overrides ORDER BY', 'testimonials-widget' ),
|
323 |
-
'type' => 'select',
|
324 |
-
'choices' => array(
|
325 |
-
'' => __( 'None', 'testimonials-widget' ),
|
326 |
-
'testimonials-widget-title' => __( 'Title', 'testimonials-widget' ),
|
327 |
-
'testimonials-widget-email' => __( 'Email', 'testimonials-widget' ),
|
328 |
-
'testimonials-widget-location' => __( 'Location', 'testimonials-widget' ),
|
329 |
-
'testimonials-widget-company' => __( 'Company', 'testimonials-widget' ),
|
330 |
-
'testimonials-widget-url' => __( 'URL', 'testimonials-widget' ),
|
331 |
-
),
|
332 |
-
'validate' => 'slug',
|
333 |
-
);
|
334 |
-
|
335 |
-
self::$settings['order'] = array(
|
336 |
-
'section' => 'ordering',
|
337 |
-
'title' => __( 'ORDER BY Order', 'testimonials-widget' ),
|
338 |
-
'type' => 'select',
|
339 |
-
'choices' => array(
|
340 |
-
'DESC' => __( 'Descending', 'testimonials-widget' ),
|
341 |
-
'ASC' => __( 'Ascending', 'testimonials-widget' ),
|
342 |
-
),
|
343 |
-
'std' => 'DESC',
|
344 |
-
'validate' => 'order',
|
345 |
-
);
|
346 |
-
|
347 |
-
self::$settings['ordering_expand_end'] = array(
|
348 |
-
'section' => 'ordering',
|
349 |
-
'type' => 'expand_end',
|
350 |
-
);
|
351 |
-
|
352 |
-
// Debug
|
353 |
-
self::$settings['debug_mode'] = array(
|
354 |
-
'section' => 'testing',
|
355 |
-
'title' => __( 'Debug Mode?', 'testimonials-widget' ),
|
356 |
-
'desc' => __( 'Not implemented yet', 'testimonials-widget' ),
|
357 |
-
'type' => 'checkbox',
|
358 |
-
'widget' => 0,
|
359 |
-
);
|
360 |
-
|
361 |
-
// Post Type
|
362 |
-
self::$settings['allow_comments'] = array(
|
363 |
-
'section' => 'post_type',
|
364 |
-
'title' => __( 'Allow Comments?', 'testimonials-widget' ),
|
365 |
-
'desc' => __( 'Only affects the Testimonials Widget post edit page. Your theme controls the front-end view.', 'testimonials-widget' ),
|
366 |
-
'type' => 'checkbox',
|
367 |
-
'widget' => 0,
|
368 |
-
);
|
369 |
-
|
370 |
-
$desc = __( 'URL slug-name for <a href="%1s">testimonials archive</a> page. After changing, you must click "Save Changes" on <a href="%2s">Permalink Settings</a> to update them.', 'testimonials-widget' );
|
371 |
-
$has_archive = tw_get_option( 'has_archive', '' );
|
372 |
-
$site_url = site_url( '/' . $has_archive );
|
373 |
-
$url = admin_url( 'options-permalink.php' );
|
374 |
-
self::$settings['has_archive'] = array(
|
375 |
-
'section' => 'post_type',
|
376 |
-
'title' => __( 'Archive Page URL', 'testimonials-widget' ),
|
377 |
-
'desc' => sprintf( $desc, $site_url, $url ),
|
378 |
-
'std' => 'testimonials-archive',
|
379 |
-
'validate' => 'sanitize_title',
|
380 |
-
'widget' => 0,
|
381 |
-
);
|
382 |
-
|
383 |
-
$desc = __( 'URL slug-name for testimonial view pages. After changing, you must click "Save Changes" on <a href="%1s">Permalink Settings</a> to update them.', 'testimonials-widget' );
|
384 |
-
self::$settings['rewrite_slug'] = array(
|
385 |
-
'section' => 'post_type',
|
386 |
-
'title' => __( 'Testimonial Page URL', 'testimonials-widget' ),
|
387 |
-
'desc' => sprintf( $desc, $url ),
|
388 |
-
'std' => 'testimonial',
|
389 |
-
'validate' => 'sanitize_title',
|
390 |
-
'widget' => 0,
|
391 |
-
);
|
392 |
-
|
393 |
-
// Reset
|
394 |
-
self::$settings['reset_expand_begin'] = array(
|
395 |
-
'section' => 'reset',
|
396 |
-
'desc' => __( 'Compatiblity Options', 'testimonials-widget' ),
|
397 |
-
'type' => 'expand_begin',
|
398 |
-
);
|
399 |
-
|
400 |
-
self::$settings['remove_hentry'] = array(
|
401 |
-
'section' => 'reset',
|
402 |
-
'title' => __( 'Remove `.hentry` CSS?', 'testimonials-widget' ),
|
403 |
-
'desc' => __( 'Pre 2.6.4. Some themes use class `.hentry` in a manner that breaks Testimonials Widgets CSS', 'testimonials-widget' ),
|
404 |
-
'type' => 'checkbox',
|
405 |
-
'backwards' => array(
|
406 |
-
'version' => '2.6.4',
|
407 |
-
'std' => 1
|
408 |
-
),
|
409 |
-
);
|
410 |
-
|
411 |
-
self::$settings['use_quote_tag'] = array(
|
412 |
-
'section' => 'reset',
|
413 |
-
'title' => __( 'Use `<q>` tag?', 'testimonials-widget' ),
|
414 |
-
'desc' => __( 'Pre 2.11.0. Not HTML5 compliant', 'testimonials-widget' ),
|
415 |
-
'type' => 'checkbox',
|
416 |
-
'backwards' => array(
|
417 |
-
'version' => '2.11.0',
|
418 |
-
'std' => 1
|
419 |
-
),
|
420 |
-
);
|
421 |
-
|
422 |
-
self::$settings['reset_defaults'] = array(
|
423 |
-
'section' => 'reset',
|
424 |
-
'title' => __( 'Reset to Defaults?', 'testimonials-widget' ),
|
425 |
-
'type' => 'checkbox',
|
426 |
-
'class' => 'warning', // Custom class for CSS
|
427 |
-
'desc' => __( 'Check this box to reset options to their defaults', 'testimonials-widget' ),
|
428 |
-
'widget' => 0,
|
429 |
-
);
|
430 |
-
|
431 |
-
self::$settings['reset_expand_end'] = array(
|
432 |
-
'section' => 'reset',
|
433 |
-
'type' => 'expand_end',
|
434 |
-
);
|
435 |
-
|
436 |
-
// Reference
|
437 |
-
if ( false ) {
|
438 |
-
self::$settings['example_text'] = array(
|
439 |
-
'title' => __( 'Example Text Input', 'testimonials-widget' ),
|
440 |
-
'desc' => __( 'This is a description for the text input.', 'testimonials-widget' ),
|
441 |
-
'std' => 'Default value',
|
442 |
-
);
|
443 |
-
|
444 |
-
self::$settings['example_textarea'] = array(
|
445 |
-
'title' => __( 'Example Textarea Input', 'testimonials-widget' ),
|
446 |
-
'desc' => __( 'This is a description for the textarea input.', 'testimonials-widget' ),
|
447 |
-
'std' => 'Default value',
|
448 |
-
'type' => 'textarea',
|
449 |
-
);
|
450 |
-
|
451 |
-
self::$settings['example_checkbox'] = array(
|
452 |
-
'title' => __( 'Example Checkbox', 'testimonials-widget' ),
|
453 |
-
'desc' => __( 'This is a description for the checkbox.', 'testimonials-widget' ),
|
454 |
-
'type' => 'checkbox',
|
455 |
-
'std' => 1 // Set to 1 to be checked by default, 0 to be unchecked by default.
|
456 |
-
);
|
457 |
-
|
458 |
-
self::$settings['example_heading'] = array(
|
459 |
-
'title' => '', // Not used for headings.
|
460 |
-
'desc' => 'Example Heading',
|
461 |
-
'type' => 'heading'
|
462 |
-
);
|
463 |
-
|
464 |
-
self::$settings['example_radio'] = array(
|
465 |
-
'title' => __( 'Example Radio', 'testimonials-widget' ),
|
466 |
-
'desc' => __( 'This is a description for the radio buttons.', 'testimonials-widget' ),
|
467 |
-
'type' => 'radio',
|
468 |
-
'choices' => array(
|
469 |
-
'choice1' => 'Choice 1',
|
470 |
-
'choice2' => 'Choice 2',
|
471 |
-
'choice3' => 'Choice 3'
|
472 |
-
)
|
473 |
-
);
|
474 |
-
|
475 |
-
self::$settings['example_select'] = array(
|
476 |
-
'title' => __( 'Example Select', 'testimonials-widget' ),
|
477 |
-
'desc' => __( 'This is a description for the drop-down.', 'testimonials-widget' ),
|
478 |
-
'type' => 'select',
|
479 |
-
'choices' => array(
|
480 |
-
'choice1' => 'Other Choice 1',
|
481 |
-
'choice2' => 'Other Choice 2',
|
482 |
-
'choice3' => 'Other Choice 3'
|
483 |
-
)
|
484 |
-
);
|
485 |
-
}
|
486 |
-
|
487 |
-
self::$settings = apply_filters( 'testimonials_widget_settings', self::$settings );
|
488 |
-
|
489 |
-
foreach ( self::$settings as $id => $parts ) {
|
490 |
-
self::$settings[ $id ] = wp_parse_args( $parts, self::$default );
|
491 |
-
}
|
492 |
-
}
|
493 |
-
|
494 |
-
|
495 |
-
public static function get_defaults( $mode = null ) {
|
496 |
-
if ( empty( self::$defaults ) )
|
497 |
-
self::settings();
|
498 |
-
|
499 |
-
$do_backwards = false;
|
500 |
-
if ( 'backwards' == $mode ) {
|
501 |
-
$old_version = tw_get_option( 'version' );
|
502 |
-
if ( ! empty( $old_version ) )
|
503 |
-
$do_backwards = true;
|
504 |
-
}
|
505 |
-
|
506 |
-
foreach ( self::$settings as $id => $parts ) {
|
507 |
-
$std = isset( $parts['std'] ) ? $parts['std'] : '';
|
508 |
-
if ( $do_backwards ) {
|
509 |
-
$version = ! empty( $parts['backwards']['version'] ) ? $parts['backwards']['version'] : false;
|
510 |
-
if ( ! empty( $version ) ) {
|
511 |
-
if ( $old_version < $version )
|
512 |
-
$std = $parts['backwards']['std'];
|
513 |
-
}
|
514 |
-
}
|
515 |
-
|
516 |
-
self::$defaults[ $id ] = $std;
|
517 |
-
}
|
518 |
-
|
519 |
-
return self::$defaults;
|
520 |
-
}
|
521 |
-
|
522 |
-
|
523 |
-
public static function get_settings() {
|
524 |
-
if ( empty( self::$settings ) )
|
525 |
-
self::settings();
|
526 |
-
|
527 |
-
return self::$settings;
|
528 |
-
}
|
529 |
-
|
530 |
-
|
531 |
-
public function admin_init() {
|
532 |
-
$version = tw_get_option( 'version' );
|
533 |
-
self::$version = Testimonials_Widget::version;
|
534 |
-
self::$version = apply_filters( 'testimonials_widget_version', self::$version );
|
535 |
-
|
536 |
-
if ( $version != self::$version )
|
537 |
-
$this->initialize_settings();
|
538 |
-
|
539 |
-
$this->register_settings();
|
540 |
-
}
|
541 |
-
|
542 |
-
|
543 |
-
public function admin_menu() {
|
544 |
-
$admin_page = add_submenu_page( 'edit.php?post_type=' . Testimonials_Widget::pt, __( 'Testimonials Widget Settings', 'testimonials-widget' ), __( 'Settings', 'testimonials-widget' ), 'manage_options', self::id, array( 'Testimonials_Widget_Settings', 'display_page' ) );
|
545 |
-
|
546 |
-
add_action( 'admin_print_scripts-' . $admin_page, array( &$this, 'scripts' ) );
|
547 |
-
add_action( 'admin_print_styles-' . $admin_page, array( &$this, 'styles' ) );
|
548 |
-
}
|
549 |
-
|
550 |
-
|
551 |
-
public function create_setting( $args = array() ) {
|
552 |
-
extract( $args );
|
553 |
-
|
554 |
-
if ( preg_match( '#(_expand_begin|_expand_end)#', $id ) )
|
555 |
-
return;
|
556 |
-
|
557 |
-
$field_args = array(
|
558 |
-
'type' => $type,
|
559 |
-
'id' => $id,
|
560 |
-
'desc' => $desc,
|
561 |
-
'std' => $std,
|
562 |
-
'choices' => $choices,
|
563 |
-
'label_for' => $id,
|
564 |
-
'class' => $class
|
565 |
-
);
|
566 |
-
|
567 |
-
self::$defaults[$id] = $std;
|
568 |
-
|
569 |
-
add_settings_field( $id, $title, array( &$this, 'display_setting' ), self::id, $section, $field_args );
|
570 |
-
}
|
571 |
-
|
572 |
-
|
573 |
-
public static function display_page() {
|
574 |
-
echo '<div class="wrap">
|
575 |
-
<div class="icon32" id="icon-options-general"></div>
|
576 |
-
<h2>' . __( 'Testimonials Widget Settings', 'testimonials-widget' ) . '</h2>';
|
577 |
-
|
578 |
-
echo '<form action="options.php" method="post">';
|
579 |
-
|
580 |
-
settings_fields( self::id );
|
581 |
-
|
582 |
-
echo '<div class="ui-tabs">
|
583 |
-
<ul class="ui-tabs-nav">';
|
584 |
-
|
585 |
-
foreach ( self::$sections as $section_slug => $section )
|
586 |
-
echo '<li><a href="#' . $section_slug . '">' . $section . '</a></li>';
|
587 |
-
|
588 |
-
echo '</ul>';
|
589 |
-
|
590 |
-
do_settings_sections( self::id );
|
591 |
-
|
592 |
-
echo '</div>';
|
593 |
-
|
594 |
-
echo '
|
595 |
-
<p class="submit"><input name="Submit" type="submit" class="button-primary" value="' . __( 'Save Changes', 'testimonials-widget' ) . '" /></p>
|
596 |
-
</form>
|
597 |
-
';
|
598 |
-
|
599 |
-
echo '
|
600 |
-
<p>When ready, <a href="'.get_admin_url().'edit.php?post_type=testimonials-widget">view</a>
|
601 |
-
or <a href="'.get_admin_url().'post-new.php?post_type=testimonials-widget">add</a> testimonials.</p>
|
602 |
-
|
603 |
-
<p>If you like this plugin, <a href="http://aihr.us/about-aihrus/donate/" title="Donate for Good Karma">please donate</a> or <a href="http://aihr.us/testimonials-widget-premium/" title="purchase Testimonials Widget Premium">purchase Testimonials Widget Premium</a> to help fund further development and <a href="http://wordpress.org/support/plugin/testimonials-widget" title="Support forums">support</a>.</p>
|
604 |
-
';
|
605 |
-
|
606 |
-
$text = __( 'Copyright ©%1$s %2$s.', 'testimonials-widget' );
|
607 |
-
$link = '<a href="http://aihr.us">Aihrus</a>';
|
608 |
-
$copyright = '<div class="copyright">' . sprintf( $text, date( 'Y' ), $link ) . '</div>';
|
609 |
-
echo $copyright;
|
610 |
-
|
611 |
-
self::section_scripts();
|
612 |
-
|
613 |
-
echo '</div>';
|
614 |
-
}
|
615 |
-
|
616 |
-
|
617 |
-
public static function section_scripts() {
|
618 |
-
echo '<script type="text/javascript">
|
619 |
-
jQuery(document).ready(function($) {
|
620 |
-
var sections = [];';
|
621 |
-
|
622 |
-
foreach ( self::$sections as $section_slug => $section )
|
623 |
-
echo "sections['$section'] = '$section_slug';";
|
624 |
-
|
625 |
-
echo 'var wrapped = $(".wrap h3").wrap("<div class=\"ui-tabs-panel\">");
|
626 |
-
wrapped.each(function() {
|
627 |
-
$(this).parent().append($(this).parent().nextUntil("div.ui-tabs-panel"));
|
628 |
-
});
|
629 |
-
$(".ui-tabs-panel").each(function(index) {
|
630 |
-
$(this).attr("id", sections[$(this).children("h3").text()]);
|
631 |
-
if (index > 0)
|
632 |
-
$(this).addClass("ui-tabs-hide");
|
633 |
-
});
|
634 |
-
$(".ui-tabs").tabs({
|
635 |
-
fx: { opacity: "toggle", duration: "fast" }
|
636 |
-
});
|
637 |
-
|
638 |
-
$("input[type=text], textarea").each(function() {
|
639 |
-
if ($(this).val() == $(this).attr("placeholder") || $(this).val() == "")
|
640 |
-
$(this).css("color", "#999");
|
641 |
-
});
|
642 |
-
|
643 |
-
$("input[type=text], textarea").focus(function() {
|
644 |
-
if ($(this).val() == $(this).attr("placeholder") || $(this).val() == "") {
|
645 |
-
$(this).val("");
|
646 |
-
$(this).css("color", "#000");
|
647 |
-
}
|
648 |
-
}).blur(function() {
|
649 |
-
if ($(this).val() == "" || $(this).val() == $(this).attr("placeholder")) {
|
650 |
-
$(this).val($(this).attr("placeholder"));
|
651 |
-
$(this).css("color", "#999");
|
652 |
-
}
|
653 |
-
});
|
654 |
-
|
655 |
-
$(".wrap h3, .wrap table").show();
|
656 |
-
|
657 |
-
// This will make the "warning" checkbox class really stand out when checked.
|
658 |
-
// I use it here for the Reset checkbox.
|
659 |
-
$(".warning").change(function() {
|
660 |
-
if ($(this).is(":checked"))
|
661 |
-
$(this).parent().css("background", "#c00").css("color", "#fff").css("fontWeight", "bold");
|
662 |
-
else
|
663 |
-
$(this).parent().css("background", "none").css("color", "inherit").css("fontWeight", "normal");
|
664 |
-
});
|
665 |
-
|
666 |
-
// Browser compatibility
|
667 |
-
if ($.browser.mozilla)
|
668 |
-
$("form").attr("autocomplete", "off");
|
669 |
-
});
|
670 |
-
</script>';
|
671 |
-
}
|
672 |
-
|
673 |
-
|
674 |
-
public function display_section() {
|
675 |
-
// code
|
676 |
-
}
|
677 |
-
|
678 |
-
|
679 |
-
public function display_about_section() {
|
680 |
-
|
681 |
-
echo <<<EOD
|
682 |
-
<div style="width: 70%;">
|
683 |
-
<p><img class="alignright size-medium" title="Michael in Red Square, Moscow, Russia" src="/wp-content/plugins/testimonials-widget/media/michael-cannon-red-square-300x2251.jpg" alt="Michael in Red Square, Moscow, Russia" width="300" height="225" /><a href="http://wordpress.org/extend/plugins/testimonials-widget/">Testimonials Widget</a> is by <a href="http://aihr.us/about-aihrus/michael-cannon-resume/">Michael Cannon</a>. He's <a title="Lot's of stuff about Peichi Liu…" href="http://peimic.com/t/peichi-liu/">Peichi’s</a> smiling man, an adventurous <a title="Water rat" href="http://www.chinesehoroscope.org/chinese_zodiac/rat/" target="_blank">water-rat</a>, <a title="Axelerant – Open Source. Engineered." href="http://axelerant.com/who-we-are">chief people officer</a>, <a title="Aihrus – website support made easy since 1999" href="http://aihr.us/about-aihrus/">chief technology officer</a>, <a title="Road biker, cyclist, biking; whatever you call, I love to ride" href="http://peimic.com/c/biking/">cyclist</a>, <a title="Michael's poetic like literary ramblings" href="http://peimic.com/t/poetry/">poet</a>, <a title="World Wide Opportunities on Organic Farms" href="http://peimic.com/t/WWOOF/">WWOOF’er</a> and <a title="My traveled to country list, is more than my age." href="http://peimic.com/c/travel/">world traveler</a>.</p>
|
684 |
-
</div>
|
685 |
-
EOD;
|
686 |
-
|
687 |
-
}
|
688 |
-
|
689 |
-
|
690 |
-
public static function display_setting( $args = array(), $do_echo = true, $input = null ) {
|
691 |
-
$content = '';
|
692 |
-
|
693 |
-
extract( $args );
|
694 |
-
|
695 |
-
if ( is_null( $input ) ) {
|
696 |
-
$options = get_option( self::id );
|
697 |
-
} else {
|
698 |
-
$options = array();
|
699 |
-
$options[$id] = $input;
|
700 |
-
}
|
701 |
-
|
702 |
-
if ( ! isset( $options[$id] ) && $type != 'checkbox' ) {
|
703 |
-
$options[$id] = $std;
|
704 |
-
} elseif ( ! isset( $options[$id] ) ) {
|
705 |
-
$options[$id] = 0;
|
706 |
-
}
|
707 |
-
|
708 |
-
$field_class = '';
|
709 |
-
if ( ! empty( $class ) )
|
710 |
-
$field_class = ' ' . $class;
|
711 |
-
|
712 |
-
switch ( $type ) {
|
713 |
-
|
714 |
-
case 'checkbox':
|
715 |
-
$content .= '<input class="checkbox' . $field_class . '" type="checkbox" id="' . $id . '" name="' . self::id . '[' . $id . ']" value="1" ' . checked( $options[$id], 1, false ) . ' /> ';
|
716 |
-
|
717 |
-
if ( ! empty( $desc ) )
|
718 |
-
$content .= '<label for="' . $id . '"><span class="description">' . $desc . '</span></label>';
|
719 |
-
|
720 |
-
break;
|
721 |
-
|
722 |
-
case 'file':
|
723 |
-
$content .= '<input class="regular-text' . $field_class . '" type="file" id="' . $id . '" name="' . self::id . '[' . $id . ']" />';
|
724 |
-
|
725 |
-
if ( ! empty( $desc ) )
|
726 |
-
$content .= '<br /><span class="description">' . $desc . '</span>';
|
727 |
-
|
728 |
-
break;
|
729 |
-
|
730 |
-
case 'heading':
|
731 |
-
$content .= '</td></tr><tr valign="top"><td colspan="2"><h4>' . $desc . '</h4>';
|
732 |
-
break;
|
733 |
-
|
734 |
-
case 'hidden':
|
735 |
-
$content .= '<input type="hidden" id="' . $id . '" name="' . self::id . '[' . $id . ']" value="' . esc_attr( $options[$id] ) . '" />';
|
736 |
-
|
737 |
-
break;
|
738 |
-
|
739 |
-
case 'password':
|
740 |
-
$content .= '<input class="regular-text' . $field_class . '" type="password" id="' . $id . '" name="' . self::id . '[' . $id . ']" value="' . esc_attr( $options[$id] ) . '" />';
|
741 |
-
|
742 |
-
if ( ! empty( $desc ) )
|
743 |
-
$content .= '<br /><span class="description">' . $desc . '</span>';
|
744 |
-
|
745 |
-
break;
|
746 |
-
|
747 |
-
case 'radio':
|
748 |
-
$i = 1;
|
749 |
-
$count_choices = count( $choices );
|
750 |
-
foreach ( $choices as $value => $label ) {
|
751 |
-
$content .= '<input class="radio' . $field_class . '" type="radio" name="' . self::id . '[' . $id . ']" id="' . $id . $i . '" value="' . esc_attr( $value ) . '" ' . checked( $options[$id], $value, false ) . '> <label for="' . $id . $i . '">' . $label . '</label>';
|
752 |
-
|
753 |
-
if ( $i < $count_choices )
|
754 |
-
$content .= '<br />';
|
755 |
-
|
756 |
-
$i++;
|
757 |
-
}
|
758 |
-
|
759 |
-
if ( ! empty( $desc ) )
|
760 |
-
$content .= '<br /><span class="description">' . $desc . '</span>';
|
761 |
-
|
762 |
-
break;
|
763 |
-
|
764 |
-
case 'readonly':
|
765 |
-
$content .= '<input class="regular-text' . $field_class . '" type="text" id="' . $id . '" name="' . self::id . '[' . $id . ']" value="' . esc_attr( $options[$id] ) . '" readonly="readonly" />';
|
766 |
-
|
767 |
-
if ( ! empty( $desc ) )
|
768 |
-
$content .= '<br /><span class="description">' . $desc . '</span>';
|
769 |
-
|
770 |
-
break;
|
771 |
-
|
772 |
-
case 'select':
|
773 |
-
$content .= '<select class="select' . $field_class . '" name="' . self::id . '[' . $id . ']">';
|
774 |
-
|
775 |
-
foreach ( $choices as $value => $label )
|
776 |
-
$content .= '<option value="' . esc_attr( $value ) . '"' . selected( $options[$id], $value, false ) . '>' . $label . '</option>';
|
777 |
-
|
778 |
-
$content .= '</select>';
|
779 |
-
|
780 |
-
if ( ! empty( $desc ) )
|
781 |
-
$content .= '<br /><span class="description">' . $desc . '</span>';
|
782 |
-
|
783 |
-
break;
|
784 |
-
|
785 |
-
case 'text':
|
786 |
-
$content .= '<input class="regular-text' . $field_class . '" type="text" id="' . $id . '" name="' . self::id . '[' . $id . ']" placeholder="' . $std . '" value="' . esc_attr( $options[$id] ) . '" />';
|
787 |
-
|
788 |
-
if ( ! empty( $desc ) )
|
789 |
-
$content .= '<br /><span class="description">' . $desc . '</span>';
|
790 |
-
|
791 |
-
break;
|
792 |
-
|
793 |
-
case 'textarea':
|
794 |
-
$content .= '<textarea class="' . $field_class . '" id="' . $id . '" name="' . self::id . '[' . $id . ']" placeholder="' . $std . '" rows="5" cols="30">' . wp_htmledit_pre( $options[$id] ) . '</textarea>';
|
795 |
-
|
796 |
-
if ( ! empty( $desc ) )
|
797 |
-
$content .= '<br /><span class="description">' . $desc . '</span>';
|
798 |
-
|
799 |
-
break;
|
800 |
-
|
801 |
-
default:
|
802 |
-
break;
|
803 |
-
}
|
804 |
-
|
805 |
-
if ( $do_echo ) {
|
806 |
-
echo $content;
|
807 |
-
} else {
|
808 |
-
return $content;
|
809 |
-
}
|
810 |
-
}
|
811 |
-
|
812 |
-
|
813 |
-
public function initialize_settings() {
|
814 |
-
$defaults = self::get_defaults( 'backwards' );
|
815 |
-
$current = get_option( self::id );
|
816 |
-
$current = wp_parse_args( $current, $defaults );
|
817 |
-
$current['version'] = self::$version;
|
818 |
-
|
819 |
-
update_option( self::id, $current );
|
820 |
-
}
|
821 |
-
|
822 |
-
|
823 |
-
public function register_settings() {
|
824 |
-
register_setting( self::id, self::id, array ( &$this, 'validate_settings' ) );
|
825 |
-
|
826 |
-
foreach ( self::$sections as $slug => $title ) {
|
827 |
-
if ( $slug == 'about' )
|
828 |
-
add_settings_section( $slug, $title, array( &$this, 'display_about_section' ), self::id );
|
829 |
-
else
|
830 |
-
add_settings_section( $slug, $title, array( &$this, 'display_section' ), self::id );
|
831 |
-
}
|
832 |
-
|
833 |
-
foreach ( self::$settings as $id => $setting ) {
|
834 |
-
$setting['id'] = $id;
|
835 |
-
$this->create_setting( $setting );
|
836 |
-
}
|
837 |
-
}
|
838 |
-
|
839 |
-
|
840 |
-
public function scripts() {
|
841 |
-
wp_print_scripts( 'jquery-ui-tabs' );
|
842 |
-
}
|
843 |
-
|
844 |
-
|
845 |
-
public function styles() {
|
846 |
-
wp_register_style( __CLASS__ . '-admin', plugins_url( 'settings.css', __FILE__ ) );
|
847 |
-
wp_enqueue_style( __CLASS__ . '-admin' );
|
848 |
-
}
|
849 |
-
|
850 |
-
|
851 |
-
public static function validate_settings( $input, $options = null, $do_errors = false ) {
|
852 |
-
$errors = array();
|
853 |
-
|
854 |
-
if ( is_null( $options ) ) {
|
855 |
-
$options = self::get_settings();
|
856 |
-
$defaults = self::get_defaults();
|
857 |
-
|
858 |
-
if ( ! empty( $input['reset_defaults'] ) ) {
|
859 |
-
foreach ( $defaults as $id => $std ) {
|
860 |
-
$input[$id] = $std;
|
861 |
-
}
|
862 |
-
|
863 |
-
unset( $input['reset_defaults'] );
|
864 |
-
}
|
865 |
-
}
|
866 |
-
|
867 |
-
foreach( $options as $id => $parts ) {
|
868 |
-
$default = $parts['std'];
|
869 |
-
$type = $parts['type'];
|
870 |
-
$validations = ! empty( $parts['validate'] ) ? $parts['validate'] : array();
|
871 |
-
if ( ! empty( $validations ) )
|
872 |
-
$validations = explode( ',', $validations );
|
873 |
-
|
874 |
-
if ( ! isset( $input[ $id ] ) ) {
|
875 |
-
if ( 'checkbox' != $type ) {
|
876 |
-
$input[ $id ] = $default;
|
877 |
-
} else {
|
878 |
-
$input[ $id ] = 0;
|
879 |
-
}
|
880 |
-
}
|
881 |
-
|
882 |
-
if ( $default == $input[ $id ] && ! in_array( 'required', $validations ) )
|
883 |
-
continue;
|
884 |
-
|
885 |
-
if ( 'checkbox' == $type ) {
|
886 |
-
// is_true allows for true, 'true', 1, 'yes' to be true
|
887 |
-
if ( self::is_true( $input[ $id ] ) )
|
888 |
-
$input[ $id ] = 1;
|
889 |
-
else
|
890 |
-
$input[ $id ] = 0;
|
891 |
-
} elseif ( in_array( $type, array( 'radio', 'select' ) ) ) {
|
892 |
-
// single choices only
|
893 |
-
$keys = array_keys( $parts['choices'] );
|
894 |
-
|
895 |
-
if ( ! in_array( $input[ $id ], $keys ) ) {
|
896 |
-
if ( self::is_true( $input[ $id ] ) )
|
897 |
-
$input[ $id ] = 1;
|
898 |
-
else
|
899 |
-
$input[ $id ] = 0;
|
900 |
-
}
|
901 |
-
}
|
902 |
-
|
903 |
-
if ( ! empty( $validations ) ) {
|
904 |
-
foreach ( $validations as $validate ) {
|
905 |
-
switch( $validate ) {
|
906 |
-
case 'absint':
|
907 |
-
case 'intval':
|
908 |
-
if ( '' != $input[ $id ] )
|
909 |
-
$input[ $id ] = $validate( $input[ $id ] );
|
910 |
-
else
|
911 |
-
$input[ $id ] = $default;
|
912 |
-
break;
|
913 |
-
|
914 |
-
case 'ids':
|
915 |
-
$input[ $id ] = self::validate_ids( $input[ $id ], $default );
|
916 |
-
break;
|
917 |
-
|
918 |
-
case 'min1':
|
919 |
-
$input[ $id ] = intval( $input[ $id ] );
|
920 |
-
if ( 0 >= $input[ $id ] )
|
921 |
-
$input[ $id ] = $default;
|
922 |
-
break;
|
923 |
-
|
924 |
-
case 'nozero':
|
925 |
-
$input[ $id ] = intval( $input[ $id ] );
|
926 |
-
if ( 0 === $input[ $id ] )
|
927 |
-
$input[ $id ] = $default;
|
928 |
-
break;
|
929 |
-
|
930 |
-
case 'order':
|
931 |
-
$input[ $id ] = self::validate_order( $input[ $id ], $default );
|
932 |
-
break;
|
933 |
-
|
934 |
-
case 'required':
|
935 |
-
if ( empty( $input[ $id ] ) ) {
|
936 |
-
$errors[ $id ] = __( 'Required', 'testimonials-widget' );
|
937 |
-
break 2;
|
938 |
-
}
|
939 |
-
break;
|
940 |
-
|
941 |
-
case 'slug':
|
942 |
-
$input[ $id ] = self::validate_slug( $input[ $id ], $default );
|
943 |
-
break;
|
944 |
-
|
945 |
-
case 'slugs':
|
946 |
-
$input[ $id ] = self::validate_slugs( $input[ $id ], $default );
|
947 |
-
break;
|
948 |
-
|
949 |
-
case 'term':
|
950 |
-
$input[ $id ] = self::validate_term( $input[ $id ], $default );
|
951 |
-
break;
|
952 |
-
|
953 |
-
default:
|
954 |
-
$input[ $id ] = $validate( $input[ $id ] );
|
955 |
-
break;
|
956 |
-
}
|
957 |
-
}
|
958 |
-
}
|
959 |
-
}
|
960 |
-
|
961 |
-
$input['version'] = self::$version;
|
962 |
-
|
963 |
-
$input = apply_filters( 'testimonials_widget_validate_settings', $input, $errors );
|
964 |
-
|
965 |
-
if ( empty( $do_errors ) ) {
|
966 |
-
$validated = $input;
|
967 |
-
} else {
|
968 |
-
$validated = array(
|
969 |
-
'input' => $input,
|
970 |
-
'errors' => $errors,
|
971 |
-
);
|
972 |
-
}
|
973 |
-
|
974 |
-
return $validated;
|
975 |
-
}
|
976 |
-
|
977 |
-
|
978 |
-
public static function validate_ids( $input, $default ) {
|
979 |
-
if ( preg_match( '#^\d+(,\s?\d+)*$#', $input['exclude'] ) )
|
980 |
-
return preg_replace( "#\s#", '', $input );
|
981 |
-
|
982 |
-
return $default;
|
983 |
-
}
|
984 |
-
|
985 |
-
|
986 |
-
public static function validate_order( $input, $default ) {
|
987 |
-
if ( preg_match( '#^desc|asc$#i', $input ) )
|
988 |
-
return $input;
|
989 |
-
|
990 |
-
return $default;
|
991 |
-
}
|
992 |
-
|
993 |
-
|
994 |
-
public static function validate_slugs( $input, $default ) {
|
995 |
-
if ( preg_match( '#^[\w-]+(,\s?[\w-]+)*$#', $input ) )
|
996 |
-
return preg_replace( "#\s#", '', $input );
|
997 |
-
|
998 |
-
return $default;
|
999 |
-
}
|
1000 |
-
|
1001 |
-
|
1002 |
-
public static function validate_slug( $input, $default ) {
|
1003 |
-
if ( preg_match( '#^[\w-]+$#', $input ) )
|
1004 |
-
return $input;
|
1005 |
-
|
1006 |
-
return $default;
|
1007 |
-
}
|
1008 |
-
|
1009 |
-
|
1010 |
-
public static function validate_term( $input, $default ) {
|
1011 |
-
if ( preg_match( '#^\w+$#', $input ) )
|
1012 |
-
return $input;
|
1013 |
-
|
1014 |
-
return $default;
|
1015 |
-
}
|
1016 |
-
|
1017 |
-
|
1018 |
-
public static function is_true( $value = null, $return_boolean = true ) {
|
1019 |
-
if ( true === $value || 'true' == strtolower( $value ) || 1 == $value || 'yes' == strtolower( $value ) ) {
|
1020 |
-
if ( $return_boolean )
|
1021 |
-
return true;
|
1022 |
-
else
|
1023 |
-
return 1;
|
1024 |
-
} else {
|
1025 |
-
if ( $return_boolean )
|
1026 |
-
return false;
|
1027 |
-
else
|
1028 |
-
return 0;
|
1029 |
-
}
|
1030 |
-
}
|
1031 |
-
}
|
1032 |
-
|
1033 |
-
|
1034 |
-
$Testimonials_Widget_Settings = new Testimonials_Widget_Settings();
|
1035 |
-
|
1036 |
-
|
1037 |
-
function tw_get_options() {
|
1038 |
-
$options = get_option( Testimonials_Widget_Settings::id );
|
1039 |
-
|
1040 |
-
if ( false === $options ) {
|
1041 |
-
$options = Testimonials_Widget_Settings::get_defaults();
|
1042 |
-
update_option( Testimonials_Widget_Settings::id, $options );
|
1043 |
-
}
|
1044 |
-
|
1045 |
-
return $options;
|
1046 |
-
}
|
1047 |
-
|
1048 |
-
|
1049 |
-
function tw_get_option( $option, $default = null ) {
|
1050 |
-
$options = get_option( Testimonials_Widget_Settings::id, null );
|
1051 |
-
|
1052 |
-
if ( isset( $options[$option] ) )
|
1053 |
-
return $options[$option];
|
1054 |
-
else
|
1055 |
-
return $default;
|
1056 |
-
}
|
1057 |
-
|
1058 |
-
|
1059 |
-
function tw_set_option( $option, $value = null ) {
|
1060 |
-
$options = get_option( Testimonials_Widget_Settings::id );
|
1061 |
-
|
1062 |
-
if ( ! is_array( $options ) ) {
|
1063 |
-
$options = array();
|
1064 |
-
}
|
1065 |
-
|
1066 |
-
$options[$option] = $value;
|
1067 |
-
update_option( Testimonials_Widget_Settings::id, $options );
|
1068 |
-
}
|
1069 |
-
|
1070 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/testimonials-widget-widget.php
DELETED
@@ -1,273 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Testimonials_Widget_Widget extends WP_Widget {
|
4 |
-
public function Testimonials_Widget_Widget() {
|
5 |
-
// Widget settings
|
6 |
-
$widget_ops = array(
|
7 |
-
'classname' => 'Testimonials_Widget_Widget',
|
8 |
-
'description' => __( 'Display testimonials with multiple selection and display options', 'testimonials-widget' )
|
9 |
-
);
|
10 |
-
|
11 |
-
// Widget control settings
|
12 |
-
$control_ops = array(
|
13 |
-
'id_base' => 'testimonials_widget',
|
14 |
-
);
|
15 |
-
|
16 |
-
// Create the widget
|
17 |
-
$this->WP_Widget(
|
18 |
-
'testimonials_widget',
|
19 |
-
__( 'Testimonials Widget', 'testimonials-widget' ),
|
20 |
-
$widget_ops,
|
21 |
-
$control_ops
|
22 |
-
);
|
23 |
-
}
|
24 |
-
|
25 |
-
|
26 |
-
public function get_testimonials_css() {
|
27 |
-
Testimonials_Widget::get_testimonials_css();
|
28 |
-
}
|
29 |
-
|
30 |
-
|
31 |
-
public function get_testimonials_scripts() {
|
32 |
-
Testimonials_Widget::get_testimonials_scripts();
|
33 |
-
}
|
34 |
-
|
35 |
-
|
36 |
-
public function widget( $args, $instance ) {
|
37 |
-
global $before_widget, $before_title, $after_title, $after_widget;
|
38 |
-
|
39 |
-
$args = wp_parse_args( $args, Testimonials_Widget::get_defaults() );
|
40 |
-
extract( $args );
|
41 |
-
|
42 |
-
// Our variables from the widget settings
|
43 |
-
$title = apply_filters( 'widget_title', $instance['title'], null );
|
44 |
-
|
45 |
-
$testimonials = Testimonials_Widget::testimonialswidget_widget( $instance, $this->number );
|
46 |
-
|
47 |
-
// Before widget (defined by themes)
|
48 |
-
echo $before_widget;
|
49 |
-
|
50 |
-
// Display the widget title if one was input (before and after defined by themes)
|
51 |
-
if ( ! empty( $title ) ) {
|
52 |
-
if ( ! empty( $instance['title_link'] ) ) {
|
53 |
-
// revise title with title_link link creation
|
54 |
-
$title_link = $instance['title_link'];
|
55 |
-
|
56 |
-
if ( preg_match( '#^\d+$#', $title_link ) ) {
|
57 |
-
$new_title = '<a href="';
|
58 |
-
$new_title .= get_permalink( $title_link );
|
59 |
-
$new_title .= '" title="';
|
60 |
-
$new_title .= get_the_title( $title_link );
|
61 |
-
$new_title .= '">';
|
62 |
-
$new_title .= $title;
|
63 |
-
$new_title .= '</a>';
|
64 |
-
|
65 |
-
$title = $new_title;
|
66 |
-
} else {
|
67 |
-
$do_http = true;
|
68 |
-
|
69 |
-
if ( 0 === strpos( $title_link, '/' ) )
|
70 |
-
$do_http = false;
|
71 |
-
|
72 |
-
if ( $do_http && 0 === preg_match( "#https?://#", $title_link ) ) {
|
73 |
-
$title_link = 'http://' . $title_link;
|
74 |
-
}
|
75 |
-
|
76 |
-
$new_title = '<a href="';
|
77 |
-
$new_title .= $title_link;
|
78 |
-
$new_title .= '" title="';
|
79 |
-
$new_title .= $title;
|
80 |
-
$new_title .= '"';
|
81 |
-
|
82 |
-
$new_title .= '>';
|
83 |
-
$new_title .= $title;
|
84 |
-
$new_title .= '</a>';
|
85 |
-
|
86 |
-
$title = $new_title;
|
87 |
-
|
88 |
-
if ( ! empty( $instance['target'] ) )
|
89 |
-
$title = links_add_target( $title, $instance['target'] );
|
90 |
-
}
|
91 |
-
}
|
92 |
-
|
93 |
-
echo $before_title . $title . $after_title;
|
94 |
-
}
|
95 |
-
|
96 |
-
// Display Widget
|
97 |
-
echo $testimonials;
|
98 |
-
|
99 |
-
// After widget (defined by themes)
|
100 |
-
echo $after_widget;
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
public function update( $new_instance, $old_instance ) {
|
105 |
-
$instance = Testimonials_Widget_Settings::validate_settings( $new_instance );
|
106 |
-
|
107 |
-
return $instance;
|
108 |
-
}
|
109 |
-
|
110 |
-
public function form( $instance ) {
|
111 |
-
$defaults = Testimonials_Widget::get_defaults();
|
112 |
-
$do_number = true;
|
113 |
-
|
114 |
-
if ( empty( $instance ) ) {
|
115 |
-
$do_number = false;
|
116 |
-
|
117 |
-
if ( empty( $defaults['char_limit'] ) )
|
118 |
-
$defaults['char_limit'] = 500;
|
119 |
-
|
120 |
-
if ( empty( $defaults['random'] ) )
|
121 |
-
$defaults['random'] = 1;
|
122 |
-
|
123 |
-
$instance = array();
|
124 |
-
}
|
125 |
-
|
126 |
-
$instance = wp_parse_args( $instance, $defaults );
|
127 |
-
$form_parts = Testimonials_Widget_Settings::get_settings();
|
128 |
-
|
129 |
-
if ( $do_number ) {
|
130 |
-
$number = $this->number;
|
131 |
-
$std = ' .' . Testimonials_Widget::id . $number;
|
132 |
-
$form_parts['css_class'] = array(
|
133 |
-
'section' => 'widget',
|
134 |
-
'type' => 'readonly',
|
135 |
-
'title' => __( 'CSS Class', 'testimonials-widget' ),
|
136 |
-
'desc' => __( 'This widget\'s unique CSS class for styling', 'testimonials-widget' ),
|
137 |
-
'std' => $std,
|
138 |
-
);
|
139 |
-
}
|
140 |
-
|
141 |
-
// remove non-widget parts
|
142 |
-
$form_parts = self::widget_options( $form_parts );
|
143 |
-
|
144 |
-
foreach ( $form_parts as $key => $part ) {
|
145 |
-
$part[ 'id' ] = $key;
|
146 |
-
$this->display_setting( $part, $instance );
|
147 |
-
}
|
148 |
-
}
|
149 |
-
|
150 |
-
|
151 |
-
public function widget_options( $options ) {
|
152 |
-
$settings = Testimonials_Widget_Settings::get_settings();
|
153 |
-
foreach ( $settings as $id => $parts ) {
|
154 |
-
if ( empty( $parts['widget'] ) )
|
155 |
-
unset( $options[ $id ] );
|
156 |
-
}
|
157 |
-
|
158 |
-
return $options;
|
159 |
-
}
|
160 |
-
|
161 |
-
|
162 |
-
public function display_setting( $args = array(), $options ) {
|
163 |
-
extract( $args );
|
164 |
-
|
165 |
-
$do_return = false;
|
166 |
-
switch ( $type ) {
|
167 |
-
case 'heading':
|
168 |
-
if ( ! empty( $desc ) )
|
169 |
-
echo '<h3>' . $desc . '</h3>';
|
170 |
-
|
171 |
-
$do_return = true;
|
172 |
-
break;
|
173 |
-
|
174 |
-
case 'expand_begin':
|
175 |
-
if ( ! empty( $desc ) )
|
176 |
-
echo '<h3>' . $desc . '</h3>';
|
177 |
-
|
178 |
-
echo '<a id="' . $this->get_field_id( $id ) . '" style="cursor:pointer;" onclick="jQuery( \'div#' . $this->get_field_id( $id ) . '\' ) . slideToggle();">' . __( 'Expand/Collapse', 'testimonials-widget' ) . ' »</a>';
|
179 |
-
echo '<div id="' . $this->get_field_id( $id ) . '" style="display:none">';
|
180 |
-
|
181 |
-
$do_return = true;
|
182 |
-
break;
|
183 |
-
|
184 |
-
case 'expand_end':
|
185 |
-
echo '</div>';
|
186 |
-
|
187 |
-
$do_return = true;
|
188 |
-
break;
|
189 |
-
|
190 |
-
default:
|
191 |
-
break;
|
192 |
-
}
|
193 |
-
|
194 |
-
if ( $do_return )
|
195 |
-
return;
|
196 |
-
|
197 |
-
if ( ! isset( $options[$id] ) && $type != 'checkbox' )
|
198 |
-
$options[$id] = $std;
|
199 |
-
elseif ( ! isset( $options[$id] ) )
|
200 |
-
$options[$id] = 0;
|
201 |
-
|
202 |
-
$field_class = '';
|
203 |
-
if ( ! empty( $class ) )
|
204 |
-
$field_class = ' ' . $class;
|
205 |
-
|
206 |
-
echo '<p>';
|
207 |
-
|
208 |
-
switch ( $type ) {
|
209 |
-
case 'checkbox':
|
210 |
-
echo '<input class="checkbox' . $field_class . '" type="checkbox" id="' . $this->get_field_id( $id ) . '" name="' . $this->get_field_name( $id ) . '" value="1" ' . checked( $options[$id], 1, false ) . ' /> ';
|
211 |
-
|
212 |
-
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
213 |
-
break;
|
214 |
-
|
215 |
-
case 'select':
|
216 |
-
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
217 |
-
echo '<select id="' . $this->get_field_id( $id ) . '"class="select' . $field_class . '" name="' . $this->get_field_name( $id ) . '">';
|
218 |
-
|
219 |
-
foreach ( $choices as $value => $label )
|
220 |
-
echo '<option value="' . esc_attr( $value ) . '"' . selected( $options[$id], $value, false ) . '>' . $label . '</option>';
|
221 |
-
|
222 |
-
echo '</select>';
|
223 |
-
break;
|
224 |
-
|
225 |
-
case 'radio':
|
226 |
-
$i = 0;
|
227 |
-
$count_options = count( $options ) - 1;
|
228 |
-
foreach ( $choices as $value => $label ) {
|
229 |
-
echo '<input class="radio' . $field_class . '" type="radio" name="' . $this->get_field_name( $id ) . '" id="' . $this->get_field_name( $id . $i ) . '" value="' . esc_attr( $value ) . '" ' . checked( $options[$id], $value, false ) . '> <label for="' . $this->get_field_name( $id . $i ) . '">' . $label . '</label>';
|
230 |
-
if ( $i < $count_options )
|
231 |
-
echo '<br />';
|
232 |
-
$i++;
|
233 |
-
}
|
234 |
-
|
235 |
-
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
236 |
-
break;
|
237 |
-
|
238 |
-
case 'textarea':
|
239 |
-
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
240 |
-
|
241 |
-
echo '<textarea class="widefat' . $field_class . '" id="' . $this->get_field_id( $id ) . '" name="' . $this->get_field_name( $id ) . '" placeholder="' . $std . '" rows="5" cols="30">' . wp_htmledit_pre( $options[$id] ) . '</textarea>';
|
242 |
-
break;
|
243 |
-
|
244 |
-
case 'password':
|
245 |
-
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
246 |
-
|
247 |
-
echo '<input class="widefat' . $field_class . '" type="password" id="' . $this->get_field_id( $id ) . '" name="' . $this->get_field_name( $id ) . '" value="' . esc_attr( $options[$id] ) . '" />';
|
248 |
-
break;
|
249 |
-
|
250 |
-
case 'readonly':
|
251 |
-
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
252 |
-
|
253 |
-
echo '<input class="widefat' . $field_class . '" type="text" id="' . $this->get_field_id( $id ) . '" name="' . $this->get_field_name( $id ) . '" value="' . esc_attr( $options[$id] ) . '" readonly="readonly" />';
|
254 |
-
break;
|
255 |
-
|
256 |
-
case 'text':
|
257 |
-
echo '<label for="' . $this->get_field_id( $id ) . '">' . $title . '</label>';
|
258 |
-
|
259 |
-
echo '<input class="widefat' . $field_class . '" type="text" id="' . $this->get_field_id( $id ) . '" name="' . $this->get_field_name( $id ) . '" placeholder="' . $std . '" value="' . esc_attr( $options[$id] ) . '" />';
|
260 |
-
break;
|
261 |
-
|
262 |
-
default:
|
263 |
-
break;
|
264 |
-
}
|
265 |
-
|
266 |
-
if ( ! empty( $desc ) )
|
267 |
-
echo '<br /><span class="setting-description"><small>' . $desc . '</small></span>';
|
268 |
-
|
269 |
-
echo '</p>';
|
270 |
-
}
|
271 |
-
}
|
272 |
-
|
273 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
phpcs.ruleset.xml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<ruleset name="Aihrus">
|
3 |
+
<description>
|
4 |
+
Custom phpcs rules to check for Aihrus' WordPress projects
|
5 |
+
</description>
|
6 |
+
|
7 |
+
<exclude-pattern>lib/class-redrokk-metabox-class.php</exclude-pattern>
|
8 |
+
|
9 |
+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
|
10 |
+
|
11 |
+
<rule ref="Generic">
|
12 |
+
<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed" />
|
13 |
+
<exclude name="Generic.Files.EndFileNewline.NotFound" />
|
14 |
+
<exclude name="Generic.Files.EndFileNoNewline.Found" />
|
15 |
+
<exclude name="Generic.Files.LineLength.MaxExceeded" />
|
16 |
+
<exclude name="Generic.Formatting.NoSpaceAfterCast.SpaceFound" />
|
17 |
+
<exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman.BraceOnSameLine" />
|
18 |
+
<exclude name="Generic.Metrics.CyclomaticComplexity.MaxExceeded" />
|
19 |
+
<exclude name="Generic.NamingConventions.CamelCapsFunctionName.ScopeNotCamelCaps" />
|
20 |
+
<exclude name="Generic.PHP.UpperCaseConstant.Found" />
|
21 |
+
<exclude name="Generic.WhiteSpace.DisallowTabIndent.TabsUsed" />
|
22 |
+
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
|
23 |
+
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine" />
|
24 |
+
</rule>
|
25 |
+
|
26 |
+
<rule ref="WordPress">
|
27 |
+
<exclude name="WordPress.XSS.EscapeOutput" />
|
28 |
+
</rule>
|
29 |
+
</ruleset>
|
phpmd.ruleset.xml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<ruleset name="Aihrus"
|
3 |
+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
|
4 |
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
5 |
+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
6 |
+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
|
7 |
+
<description>
|
8 |
+
Custom phpmd rules to check for Aihrus' WordPress projects
|
9 |
+
</description>
|
10 |
+
|
11 |
+
<exclude-pattern>lib/class-redrokk-metabox-class.php</exclude-pattern>
|
12 |
+
|
13 |
+
<!-- @ref http://phpmd.org/documentation/creating-a-ruleset.html -->
|
14 |
+
|
15 |
+
<!--
|
16 |
+
<rule ref="rulesets/codesize.xml" />
|
17 |
+
-->
|
18 |
+
<rule ref="rulesets/controversial.xml/Superglobals" />
|
19 |
+
<rule ref="rulesets/design.xml" />
|
20 |
+
<rule ref="rulesets/naming.xml">
|
21 |
+
<exclude name="ShortVariable" />
|
22 |
+
</rule>
|
23 |
+
<rule ref="rulesets/unusedcode.xml" />
|
24 |
+
</ruleset>
|
project.ruleset.xml
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<ruleset name="WPized Project">
|
3 |
-
<description>A custom set of rules to check for a WPized WordPress project</description>
|
4 |
-
|
5 |
-
<exclude-pattern>/docroot/wp-admin/*</exclude-pattern>
|
6 |
-
<exclude-pattern>/docroot/wp-includes/*</exclude-pattern>
|
7 |
-
<exclude-pattern>/docroot/wp-*.php</exclude-pattern>
|
8 |
-
<exclude-pattern>/docroot/index.php</exclude-pattern>
|
9 |
-
<exclude-pattern>/docroot/xmlrpc.php</exclude-pattern>
|
10 |
-
<exclude-pattern>/docroot/wp-content/plugins/*</exclude-pattern>
|
11 |
-
|
12 |
-
<rule ref="Squiz.PHP.CommentedOutCode"/>
|
13 |
-
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
|
14 |
-
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
|
15 |
-
<rule ref="Generic.Commenting.Todo"/>
|
16 |
-
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
|
17 |
-
|
18 |
-
<!--
|
19 |
-
We may also want to to include all the rules in a standard
|
20 |
-
-->
|
21 |
-
<rule ref="WordPress">
|
22 |
-
<!--
|
23 |
-
We may want a middle ground though. The best way to do this is add the
|
24 |
-
entire ruleset, then rule by rule, remove ones that don't suit a project. We
|
25 |
-
can do this by running `phpc ` with the '-s' flag, to see the names of the
|
26 |
-
different Sniffs, as their rules are broken. From here, we can opt to
|
27 |
-
exclude problematic sniffs like so.
|
28 |
-
-->
|
29 |
-
|
30 |
-
<exclude name="WordPress.Formatting.MultipleStatementAlignment" />
|
31 |
-
<xexclude name="WordPress.WhiteSpace.ControlStructureSpacing" />
|
32 |
-
<xexclude name="WordPress.Functions.FunctionCallSignature" />
|
33 |
-
<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed" />
|
34 |
-
</rule>
|
35 |
-
</ruleset>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Donate link: http://aihr.us/about-aihrus/donate/
|
|
5 |
Tags: client, customer, quotations, quote, quotes, random, review, quote, recommendation, reference, testimonial, testimonials, testimony, widget, wpml
|
6 |
Requires at least: 3.4
|
7 |
Tested up to: 3.6.0
|
8 |
-
Stable tag: 2.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -16,11 +16,11 @@ Testimonials Widget plugin allows you to display random or selected portfolio, q
|
|
16 |
|
17 |
Testimonials Widget plugin allows you to display random or selected portfolio, quotes, reviews, showcases, or text with images on your WordPress blog. You can insert Testimonials Widget content via shortcode, theme functions, or widgets with category and tag selections and having multiple display options such as random or specific ordering.
|
18 |
|
19 |
-
More than one Testimonials Widget instance can be displayed at a time pulls from the `testimonials-widget` custom post type. Additionally, with shortcodes and theme functions, you can display a short or long list or rotation of testimonials. Each
|
20 |
|
21 |
Widgets display content sans `wpautop` formatting. This means no forced paragraph breaks unless the content specifically contains them. You can enable `wpautop` via the "Keep whitespace?" option.
|
22 |
|
23 |
-
Through categories and tagging, you can create organizational structures based upon products, projects and services via categories and then apply tagging for further
|
24 |
|
25 |
The single testimonial view supports image, source, title, location, email, company and URL details.
|
26 |
|
@@ -32,15 +32,14 @@ The single testimonial view supports image, source, title, location, email, comp
|
|
32 |
* Filters to manipulate testimonials output
|
33 |
* Multiple paging options for testimonials listings
|
34 |
* Settings screen for site-wide option defaults
|
|
|
35 |
* Shortcodes and theme functions for listings and rotation
|
36 |
* Single testimonial view includes image, source, title, location, email, company and URL details
|
37 |
* Testimonials archive view
|
38 |
|
39 |
= Testimonials Widget Premium Plugin Features =
|
40 |
|
41 |
-
Testimonials Widget Premium plugin extends the best [Testimonials Widget](http://wordpress.org/extend/plugins/testimonials-widget/) plugin for WordPress with [caching, excerpts, filters, read more links](http://aihr.us/testimonials-widget-premium/), more selection options, and advanced capabilities like selecting posts, pages and other custom post types as testimonials. Additionally, users can add testimonials via a front-end form.
|
42 |
-
|
43 |
-
In using Testimonials Widget Premium, you'll not be sorry.
|
44 |
|
45 |
* "Read more" link column on testimonial posts admin page
|
46 |
* Alternate destinations for "Read more" links
|
@@ -62,10 +61,11 @@ In using Testimonials Widget Premium, you'll not be sorry.
|
|
62 |
* Select only testimonials with excerpts, images or of arbitrary maximum and minimum length
|
63 |
* Select post, page and other custom post types for content rotations
|
64 |
* Settings and URL based cache clearing
|
65 |
-
* Shortcodes and theme functions for testimonials count
|
66 |
* Show excerpts with list and single views
|
67 |
-
* Show unique
|
68 |
* Testimonial links listing with image, source, title, location, company, and URL fields
|
|
|
69 |
* WPML compatible
|
70 |
|
71 |
[Buy Testimonials Widget Premium](http://aihr.us/testimonials-widget-premium/) plugin for WordPress.
|
@@ -76,29 +76,29 @@ In using Testimonials Widget Premium, you'll not be sorry.
|
|
76 |
* Automatic linking of email and URL fields via source or company fields
|
77 |
* Clickable widget titles
|
78 |
* Commenting on testimonial single-view pages
|
79 |
-
* Compatible with WordPress
|
80 |
* Configuration based validation for easy extending or overriding
|
81 |
* Content truncation respects HTML tags
|
82 |
* Custom CSS in footer for HTML validation
|
83 |
* Custom text or HTML for bottom of widgets
|
84 |
* Custom widget bottom text
|
85 |
* Customizable archive and testimonial URLs
|
86 |
-
*
|
87 |
-
* Deletes
|
88 |
* Disable self-generated quotation marks
|
89 |
* Easy to configure Next and Previous page indicators
|
90 |
* Editors and admins can edit testimonial publisher
|
91 |
* Flush URLs on deactivation
|
92 |
* IE7 CSS hacks for quotes and join parts
|
93 |
* Image, email based Gravatar, category and tag enabled
|
94 |
-
* Internal version tracking for
|
95 |
* Localizable via `languages/testimonials-widget.pot`
|
96 |
* Optional commenting on testimonial single-view pages
|
97 |
* Respects meta capabilities
|
98 |
* Rotation JavaScript in footer than body
|
99 |
* Supports [WP-PageNavi](http://wordpress.org/extend/plugins/wp-pagenavi/)
|
100 |
* Testimonial content supports HTML
|
101 |
-
* Testimonial, email, and URL fields are clickable –
|
102 |
* Testimonials Widget widget displays static and rotating testimonials
|
103 |
* Testimonials output is completely customizable via filters
|
104 |
* Testimonials support styling based upon CSS classes for category, tags and post id
|
@@ -113,6 +113,10 @@ In using Testimonials Widget Premium, you'll not be sorry.
|
|
113 |
|
114 |
= Shortcode and Widget Options =
|
115 |
|
|
|
|
|
|
|
|
|
116 |
**General**
|
117 |
|
118 |
* Character Limit - Number of characters to limit testimonial views to
|
@@ -142,7 +146,7 @@ In using Testimonials Widget Premium, you'll not be sorry.
|
|
142 |
* `hide_company` - default show; hide_company=true
|
143 |
* Hide URL?
|
144 |
* `hide_url` - default show; hide_url=true
|
145 |
-
* URL Target -
|
146 |
* `target` - default none; target=_new
|
147 |
* Testimonial Bottom Text - Custom text or HTML for bottom of testimonials
|
148 |
* `bottom_text` - default none; bottom_text="`<h3><a href="http://example.com">All testimonials</a></h3>`"
|
@@ -188,7 +192,7 @@ In using Testimonials Widget Premium, you'll not be sorry.
|
|
188 |
* `title_link` - default none; title_link=123, title_link=http://example.com
|
189 |
* Keep Whitespace? - Keeps testimonials looking as entered than sans auto-formatting
|
190 |
* `keep_whitespace` - default none; keep_whitespace=true
|
191 |
-
* The citation has no whitespace
|
192 |
* Height - Testimonials height, in pixels. Overrides minimum and maximum height
|
193 |
* `height` - default none; height=300
|
194 |
* Minimum Height - Set for minimum display height, in pixels
|
@@ -208,10 +212,11 @@ In using Testimonials Widget Premium, you'll not be sorry.
|
|
208 |
|
209 |
**Compatibility & Reset**
|
210 |
|
211 |
-
* Remove `.hentry` CSS? –
|
212 |
* `remove_hentry` - default none; remove_hentry=true
|
213 |
* Use `<q>` tag? – Pre 2.11.0. Not HTML5 compliant
|
214 |
* `use_quote_tag` - default none; use_quote_tag=true
|
|
|
215 |
* Reset to Defaults? – Check this box to reset options to their defaults
|
216 |
|
217 |
= Shortcode Examples =
|
@@ -265,6 +270,7 @@ In using Testimonials Widget Premium, you'll not be sorry.
|
|
265 |
* `testimonials_widget_testimonials_js` - Alter dynamically generated JavaScript
|
266 |
* `testimonials_widget_validate_settings` - Validate settings helper
|
267 |
* `testimonials_widget_version` - Version tracking for settings
|
|
|
268 |
* `testimonials_widget_wp_pagenavi` - Configure WP-PageNavi specifically for Testimonial Widgets
|
269 |
|
270 |
= Notes =
|
@@ -296,17 +302,13 @@ A big, special thank you to [Joe Weber](https://plus.google.com/1000632712692773
|
|
296 |
|
297 |
Version 2.0.0 of Testimonials Widget is a complete rewrite based upon a composite of ideas from user feedback and grokking the plugins [Imperfect Quotes](http://www.swarmstrategies.com/imperfect-quotes/), [IvyCat Ajax Testimonials](http://wordpress.org/extend/plugins/ivycat-ajax-testimonials/), [Quotes Collection](http://srinig.com/wordpress/plugins/quotes-collection/), and [TB Testimonials](http://travisballard.com/wordpress/tb-testimonials/). Thank you to these plugin developers for their efforts that have helped inspire this rewrite.
|
298 |
|
299 |
-
A cool thanks to RedRokk Library for the [redrokk_metabox_class](https://gist.github.com/1880770). It makes configuring
|
300 |
|
301 |
Prior to version 2.0.0, this plugin was a fork of [Quotes Collection](http://srinig.com/wordpress/plugins/quotes-collection/) by [Srini G](http://wordpress.org/support/profile/SriniG) with additional contributions from [j0hnsmith](http://wordpress.org/support/profile/j0hnsmith), [ChrisCree](http://wordpress.org/support/profile/ChrisCree) and [comprock](http://wordpress.org/support/profile/comprock).
|
302 |
|
303 |
= Support =
|
304 |
|
305 |
-
|
306 |
-
|
307 |
-
If you want private or priority support, [please donate](http://aihr.us/about-aihrus/donate/) at least $ 65 USD to cover my time. Then send your [support request](http://aihr.us/contact-aihrus/).
|
308 |
-
|
309 |
-
Thank you for your understanding.
|
310 |
|
311 |
|
312 |
== Installation ==
|
@@ -326,17 +328,37 @@ Thank you for your understanding.
|
|
326 |
|
327 |
== Frequently Asked Questions ==
|
328 |
|
329 |
-
|
330 |
|
331 |
-
=
|
332 |
|
333 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
|
335 |
|
336 |
== Screenshots ==
|
337 |
|
338 |
1. Testimonials admin interface
|
339 |
-
2.
|
340 |
3. Expanded 'General Options' in Testimonials Widget options
|
341 |
4. Testimonial widget in the sidebar
|
342 |
5. [testimonialswidget_list] in post
|
@@ -351,6 +373,7 @@ Visit the [support forum](http://wordpress.org/support/plugin/testimonials-widge
|
|
351 |
14. Testimonials Widget Settings > Selection tab
|
352 |
15. Testimonials Widget Settings > Post Type tab
|
353 |
16. Testimonials Widget Settings > Widget tab
|
|
|
354 |
|
355 |
|
356 |
== Changelog ==
|
@@ -360,6 +383,18 @@ See [Changelog](http://aihr.us/testimonials-widget/changelog/)
|
|
360 |
|
361 |
== Upgrade Notice ==
|
362 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
= 2.11.3 =
|
364 |
|
365 |
* Correct filter name `testimonials_widget_next_posts_link` to `testimonials_widget_next_posts_link_text`
|
@@ -426,10 +461,3 @@ Beta testers benefit directly with latest versions, free access to Testimonials
|
|
426 |
== TODO ==
|
427 |
|
428 |
Is there something you want done? Write it up on the [support forums](http://wordpress.org/support/plugin/testimonials-widget) and then [donate](http://aihr.us/about-aihrus/donate/) or [write an awesome testimonial](http://aihr.us/about-aihrus/testimonials/add-testimonial/).
|
429 |
-
|
430 |
-
* Add http protocol to URLs on validation
|
431 |
-
* Add notice about deleting data and settings on uninstall
|
432 |
-
* BUG Non-static method Testimonials_Widget::get_testimonials_html() should not be called statically on line 546 in file /Users/michael/Sites/wp/wp-content/plugins/testimonials-widget/testimonials-widget.php
|
433 |
-
* Settings export/import
|
434 |
-
* Show changelog on update
|
435 |
-
* Update to WordPress Coding standards
|
5 |
Tags: client, customer, quotations, quote, quotes, random, review, quote, recommendation, reference, testimonial, testimonials, testimony, widget, wpml
|
6 |
Requires at least: 3.4
|
7 |
Tested up to: 3.6.0
|
8 |
+
Stable tag: 2.12.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
16 |
|
17 |
Testimonials Widget plugin allows you to display random or selected portfolio, quotes, reviews, showcases, or text with images on your WordPress blog. You can insert Testimonials Widget content via shortcode, theme functions, or widgets with category and tag selections and having multiple display options such as random or specific ordering.
|
18 |
|
19 |
+
More than one Testimonials Widget instance can be displayed at a time pulls from the `testimonials-widget` custom post type. Additionally, with shortcodes and theme functions, you can display a short or long list or rotation of testimonials. Each Testimonial Widget has its own CSS identifier for custom styling.
|
20 |
|
21 |
Widgets display content sans `wpautop` formatting. This means no forced paragraph breaks unless the content specifically contains them. You can enable `wpautop` via the "Keep whitespace?" option.
|
22 |
|
23 |
+
Through categories and tagging, you can create organizational structures based upon products, projects and services via categories and then apply tagging for further classification. As an example, you might create a Portfolio category and then use tags to identify web, magazine, media, public, enterprise niches. You can then configure the Testimonial Widget to show only Portfolio testimonials with the public and enterprise tags. In another Testimonial Widget, you can also select only Portfolio testimonials, but then allow web and media tags.
|
24 |
|
25 |
The single testimonial view supports image, source, title, location, email, company and URL details.
|
26 |
|
32 |
* Filters to manipulate testimonials output
|
33 |
* Multiple paging options for testimonials listings
|
34 |
* Settings screen for site-wide option defaults
|
35 |
+
* Settings export/import
|
36 |
* Shortcodes and theme functions for listings and rotation
|
37 |
* Single testimonial view includes image, source, title, location, email, company and URL details
|
38 |
* Testimonials archive view
|
39 |
|
40 |
= Testimonials Widget Premium Plugin Features =
|
41 |
|
42 |
+
Testimonials Widget Premium plugin extends the best [Testimonials Widget](http://wordpress.org/extend/plugins/testimonials-widget/) plugin for WordPress with [caching, excerpts, filters, read more links](http://aihr.us/testimonials-widget-premium/), more selection options, and advanced capabilities like selecting posts, pages and other custom post types as testimonials. Additionally, users can add testimonials via a front-end form shortcode or widget.
|
|
|
|
|
43 |
|
44 |
* "Read more" link column on testimonial posts admin page
|
45 |
* Alternate destinations for "Read more" links
|
61 |
* Select only testimonials with excerpts, images or of arbitrary maximum and minimum length
|
62 |
* Select post, page and other custom post types for content rotations
|
63 |
* Settings and URL based cache clearing
|
64 |
+
* Shortcodes and theme functions for testimonials count and testimonial link list
|
65 |
* Show excerpts with list and single views
|
66 |
+
* Show unique testimonials on page with multiple testimonial instances
|
67 |
* Testimonial links listing with image, source, title, location, company, and URL fields
|
68 |
+
* Shortcodes, theme functions, and widget user testimonial submission form
|
69 |
* WPML compatible
|
70 |
|
71 |
[Buy Testimonials Widget Premium](http://aihr.us/testimonials-widget-premium/) plugin for WordPress.
|
76 |
* Automatic linking of email and URL fields via source or company fields
|
77 |
* Clickable widget titles
|
78 |
* Commenting on testimonial single-view pages
|
79 |
+
* Compatible with WordPress multisite
|
80 |
* Configuration based validation for easy extending or overriding
|
81 |
* Content truncation respects HTML tags
|
82 |
* Custom CSS in footer for HTML validation
|
83 |
* Custom text or HTML for bottom of widgets
|
84 |
* Custom widget bottom text
|
85 |
* Customizable archive and testimonial URLs
|
86 |
+
* Customizable testimonial data field `testimonial_extra`
|
87 |
+
* Deletes testimonials-widget custom post type entries and settings on uninstall
|
88 |
* Disable self-generated quotation marks
|
89 |
* Easy to configure Next and Previous page indicators
|
90 |
* Editors and admins can edit testimonial publisher
|
91 |
* Flush URLs on deactivation
|
92 |
* IE7 CSS hacks for quotes and join parts
|
93 |
* Image, email based Gravatar, category and tag enabled
|
94 |
+
* Internal version tracking for compatibility checks and automatic settings update
|
95 |
* Localizable via `languages/testimonials-widget.pot`
|
96 |
* Optional commenting on testimonial single-view pages
|
97 |
* Respects meta capabilities
|
98 |
* Rotation JavaScript in footer than body
|
99 |
* Supports [WP-PageNavi](http://wordpress.org/extend/plugins/wp-pagenavi/)
|
100 |
* Testimonial content supports HTML
|
101 |
+
* Testimonial, email, and URL fields are clickable – URL requires `http://` or `https://` prefix
|
102 |
* Testimonials Widget widget displays static and rotating testimonials
|
103 |
* Testimonials output is completely customizable via filters
|
104 |
* Testimonials support styling based upon CSS classes for category, tags and post id
|
113 |
|
114 |
= Shortcode and Widget Options =
|
115 |
|
116 |
+
Please keep in mind that inheritance affects options. This means that changes made to Testimonials > Settings will not affect current widget instance options. You must change the widget instance manually. However, if you create a new widget instance, then the global settings will apply.
|
117 |
+
|
118 |
+
Further, global settings are the baseline for shortcodes. If you want to alter the shortcode appearance, then alter the shortcode options directly.
|
119 |
+
|
120 |
**General**
|
121 |
|
122 |
* Character Limit - Number of characters to limit testimonial views to
|
146 |
* `hide_company` - default show; hide_company=true
|
147 |
* Hide URL?
|
148 |
* `hide_url` - default show; hide_url=true
|
149 |
+
* URL Target - Add target to all URLs; leave blank if none
|
150 |
* `target` - default none; target=_new
|
151 |
* Testimonial Bottom Text - Custom text or HTML for bottom of testimonials
|
152 |
* `bottom_text` - default none; bottom_text="`<h3><a href="http://example.com">All testimonials</a></h3>`"
|
192 |
* `title_link` - default none; title_link=123, title_link=http://example.com
|
193 |
* Keep Whitespace? - Keeps testimonials looking as entered than sans auto-formatting
|
194 |
* `keep_whitespace` - default none; keep_whitespace=true
|
195 |
+
* The citation has no whitespace adaptations. It's straight text, except for email or URL links. The presentation is handled strictly by CSS.
|
196 |
* Height - Testimonials height, in pixels. Overrides minimum and maximum height
|
197 |
* `height` - default none; height=300
|
198 |
* Minimum Height - Set for minimum display height, in pixels
|
212 |
|
213 |
**Compatibility & Reset**
|
214 |
|
215 |
+
* Remove `.hentry` CSS? – Some themes use class `.hentry` in a manner that breaks Testimonials Widgets CSS
|
216 |
* `remove_hentry` - default none; remove_hentry=true
|
217 |
* Use `<q>` tag? – Pre 2.11.0. Not HTML5 compliant
|
218 |
* `use_quote_tag` - default none; use_quote_tag=true
|
219 |
+
* Remove Plugin Data on Deletion? - Delete all Testimonials Widget data and options from database on plugin deletion
|
220 |
* Reset to Defaults? – Check this box to reset options to their defaults
|
221 |
|
222 |
= Shortcode Examples =
|
270 |
* `testimonials_widget_testimonials_js` - Alter dynamically generated JavaScript
|
271 |
* `testimonials_widget_validate_settings` - Validate settings helper
|
272 |
* `testimonials_widget_version` - Version tracking for settings
|
273 |
+
* `testimonials_widget_widget_options` – Alters displayed widget options
|
274 |
* `testimonials_widget_wp_pagenavi` - Configure WP-PageNavi specifically for Testimonial Widgets
|
275 |
|
276 |
= Notes =
|
302 |
|
303 |
Version 2.0.0 of Testimonials Widget is a complete rewrite based upon a composite of ideas from user feedback and grokking the plugins [Imperfect Quotes](http://www.swarmstrategies.com/imperfect-quotes/), [IvyCat Ajax Testimonials](http://wordpress.org/extend/plugins/ivycat-ajax-testimonials/), [Quotes Collection](http://srinig.com/wordpress/plugins/quotes-collection/), and [TB Testimonials](http://travisballard.com/wordpress/tb-testimonials/). Thank you to these plugin developers for their efforts that have helped inspire this rewrite.
|
304 |
|
305 |
+
A cool thanks to RedRokk Library for the [redrokk_metabox_class](https://gist.github.com/1880770). It makes configuring meta boxes for your posts, pages or custom post types a snap.
|
306 |
|
307 |
Prior to version 2.0.0, this plugin was a fork of [Quotes Collection](http://srinig.com/wordpress/plugins/quotes-collection/) by [Srini G](http://wordpress.org/support/profile/SriniG) with additional contributions from [j0hnsmith](http://wordpress.org/support/profile/j0hnsmith), [ChrisCree](http://wordpress.org/support/profile/ChrisCree) and [comprock](http://wordpress.org/support/profile/comprock).
|
308 |
|
309 |
= Support =
|
310 |
|
311 |
+
Please visit the [Testimonials Widget Knowledge Base](https://aihrus.zendesk.com/categories/20104507-Testimonials-Widget) for frequently asked questions, offering ideas, or getting support.
|
|
|
|
|
|
|
|
|
312 |
|
313 |
|
314 |
== Installation ==
|
328 |
|
329 |
== Frequently Asked Questions ==
|
330 |
|
331 |
+
Please visit the [Testimonials Widget Knowledge Base](https://aihrus.zendesk.com/categories/20104507-Testimonials-Widget) for frequently asked questions, offering ideas, or getting support.
|
332 |
|
333 |
+
= Latest Major Changes =
|
334 |
|
335 |
+
* New Features
|
336 |
+
* Options
|
337 |
+
* Remove Plugin Data on Deletion? - Delete all Testimonials Widget data and options from database on plugin deletion
|
338 |
+
* Settings export/import
|
339 |
+
* CSS class names are simplified and now WordPress coding standards compliant
|
340 |
+
* For the most part, other than `testimonialswidget_testimonial` remove `testimonialswidget_` from the CSS class name in your CSS customizations.
|
341 |
+
* Ex: `.testimonialswidget_join` becomes `.join`
|
342 |
+
* Ex: `.testimonialswidget_author` becomes `.author`
|
343 |
+
* CSS and JavaScript renaming
|
344 |
+
* `bottom_text` renamed to `bottom-text`
|
345 |
+
* `close_quote` renamed to `close-quote`
|
346 |
+
* `display_none` renamed to `display-none`
|
347 |
+
* `join_location` renamed to `join-location`
|
348 |
+
* `join_title` renamed to `join-title`
|
349 |
+
* `open_quote` renamed to `open-quote`
|
350 |
+
* `testimonialswidget_testimonial` renamed to `testimonials-widget-testimonial`
|
351 |
+
* `testimonialswidget_testimonials` renamed to `testimonials-widget-testimonials`
|
352 |
+
* Testimonials are now formatted using `blockquote` than `q` for HTML5 compliance. If you need `q` tag formatting, enable it at WP Admin > Testimonials > Settings, Compatibility & Reset tab
|
353 |
+
* `cite` is now `div.credit`
|
354 |
+
* Filters
|
355 |
+
* Rename `testimonials_widget_next_posts_link` to `testimonials_widget_next_posts_link_text`
|
356 |
|
357 |
|
358 |
== Screenshots ==
|
359 |
|
360 |
1. Testimonials admin interface
|
361 |
+
2. Collapsed Testimonials Widget options
|
362 |
3. Expanded 'General Options' in Testimonials Widget options
|
363 |
4. Testimonial widget in the sidebar
|
364 |
5. [testimonialswidget_list] in post
|
373 |
14. Testimonials Widget Settings > Selection tab
|
374 |
15. Testimonials Widget Settings > Post Type tab
|
375 |
16. Testimonials Widget Settings > Widget tab
|
376 |
+
17. Testimonials Widget Settings > Compatibility & Reset tab
|
377 |
|
378 |
|
379 |
== Changelog ==
|
383 |
|
384 |
== Upgrade Notice ==
|
385 |
|
386 |
+
= 2.12.0 =
|
387 |
+
|
388 |
+
* CSS and JavaScript renaming
|
389 |
+
* `bottom_text` renamed to `bottom-text`
|
390 |
+
* `close_quote` renamed to `close-quote`
|
391 |
+
* `display_none` renamed to `display-none`
|
392 |
+
* `join_location` renamed to `join-location`
|
393 |
+
* `join_title` renamed to `join-title`
|
394 |
+
* `open_quote` renamed to `open-quote`
|
395 |
+
* `testimonialswidget_testimonial` renamed to `testimonials-widget-testimonial`
|
396 |
+
* `testimonialswidget_testimonials` renamed to `testimonials-widget-testimonials`
|
397 |
+
|
398 |
= 2.11.3 =
|
399 |
|
400 |
* Correct filter name `testimonials_widget_next_posts_link` to `testimonials_widget_next_posts_link_text`
|
461 |
== TODO ==
|
462 |
|
463 |
Is there something you want done? Write it up on the [support forums](http://wordpress.org/support/plugin/testimonials-widget) and then [donate](http://aihr.us/about-aihrus/donate/) or [write an awesome testimonial](http://aihr.us/about-aihrus/testimonials/add-testimonial/).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testimonials-widget.css
CHANGED
@@ -1,119 +1,119 @@
|
|
1 |
-
.
|
2 |
/* testimonials wrapper */
|
3 |
}
|
4 |
|
5 |
-
.
|
6 |
clear: left;
|
7 |
display: none;
|
8 |
margin: 0 0 1.4em;
|
9 |
}
|
10 |
|
11 |
-
.
|
12 |
/* active testimonials */
|
13 |
display: block;
|
14 |
}
|
15 |
|
16 |
-
.
|
17 |
/* staged testimonials */
|
18 |
display: none;
|
19 |
}
|
20 |
|
21 |
-
.
|
22 |
clear: both;
|
23 |
font-weight: 700;
|
24 |
height: 1.4em;
|
25 |
}
|
26 |
|
27 |
-
.
|
28 |
-
.
|
29 |
display: block;
|
30 |
}
|
31 |
|
32 |
-
.
|
33 |
float: left;
|
34 |
margin-bottom: .4em;
|
35 |
margin-right: .2em;
|
36 |
}
|
37 |
|
38 |
-
.widget .
|
39 |
display: block;
|
40 |
float: initial;
|
41 |
}
|
42 |
|
43 |
-
.
|
44 |
-
.
|
45 |
/* the testimonial itself */
|
46 |
quotes: none;
|
47 |
}
|
48 |
|
49 |
-
.
|
50 |
*zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '“' );
|
51 |
}
|
52 |
|
53 |
-
.
|
54 |
-
|
55 |
}
|
56 |
|
57 |
-
.
|
58 |
*zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '”' );
|
59 |
}
|
60 |
|
61 |
-
.
|
62 |
-
|
63 |
}
|
64 |
|
65 |
-
.
|
66 |
-
.
|
67 |
/* outer wrapper for source & company */
|
68 |
display: block; /* To display source and company on a new line */
|
69 |
margin-top: .2em;
|
70 |
text-align: right;
|
71 |
}
|
72 |
|
73 |
-
.widget .
|
74 |
-
.widget .
|
75 |
margin-top: .8em;
|
76 |
}
|
77 |
|
78 |
-
.widget .
|
79 |
.widget .whitespace cite,
|
80 |
-
.widget .
|
81 |
.widget .whitespace div.credit {
|
82 |
margin-top: .2em;
|
83 |
}
|
84 |
|
85 |
-
.
|
86 |
-
.
|
87 |
content: "– "
|
88 |
}
|
89 |
|
90 |
-
.
|
91 |
-
.
|
92 |
-
.
|
93 |
/* section between source and company information */
|
94 |
*zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ', ' );
|
95 |
}
|
96 |
|
97 |
-
.
|
98 |
-
.
|
99 |
-
.
|
100 |
/* join text */
|
101 |
content: ", "
|
102 |
}
|
103 |
|
104 |
-
.
|
105 |
-
.
|
106 |
-
.
|
107 |
-
.
|
108 |
-
.
|
109 |
-
.
|
110 |
/* testimonial title, company and url informaiton */
|
111 |
}
|
112 |
|
113 |
-
.
|
114 |
margin-top: .8em;
|
115 |
}
|
116 |
|
117 |
-
.
|
118 |
margin-top: 1.4em;
|
119 |
}
|
1 |
+
.testimonials-widget-testimonials {
|
2 |
/* testimonials wrapper */
|
3 |
}
|
4 |
|
5 |
+
.testimonials-widget-testimonial {
|
6 |
clear: left;
|
7 |
display: none;
|
8 |
margin: 0 0 1.4em;
|
9 |
}
|
10 |
|
11 |
+
.testimonials-widget-testimonials .active {
|
12 |
/* active testimonials */
|
13 |
display: block;
|
14 |
}
|
15 |
|
16 |
+
.testimonials-widget-testimonials .display-none {
|
17 |
/* staged testimonials */
|
18 |
display: none;
|
19 |
}
|
20 |
|
21 |
+
.testimonials-widget-testimonials .paging {
|
22 |
clear: both;
|
23 |
font-weight: 700;
|
24 |
height: 1.4em;
|
25 |
}
|
26 |
|
27 |
+
.testimonials-widget-testimonial.list,
|
28 |
+
.testimonials-widget-testimonial.single {
|
29 |
display: block;
|
30 |
}
|
31 |
|
32 |
+
.testimonials-widget-testimonial .image {
|
33 |
float: left;
|
34 |
margin-bottom: .4em;
|
35 |
margin-right: .2em;
|
36 |
}
|
37 |
|
38 |
+
.widget .testimonials-widget-testimonial .image {
|
39 |
display: block;
|
40 |
float: initial;
|
41 |
}
|
42 |
|
43 |
+
.testimonials-widget-testimonial q,
|
44 |
+
.testimonials-widget-testimonial blockquote {
|
45 |
/* the testimonial itself */
|
46 |
quotes: none;
|
47 |
}
|
48 |
|
49 |
+
.testimonials-widget-testimonial .open-quote {
|
50 |
*zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '“' );
|
51 |
}
|
52 |
|
53 |
+
.testimonials-widget-testimonial .open-quote:before {
|
54 |
+
content: '\201C';
|
55 |
}
|
56 |
|
57 |
+
.testimonials-widget-testimonial .close-quote {
|
58 |
*zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '”' );
|
59 |
}
|
60 |
|
61 |
+
.testimonials-widget-testimonial .close-quote:after {
|
62 |
+
content: '\201D';
|
63 |
}
|
64 |
|
65 |
+
.testimonials-widget-testimonial cite,
|
66 |
+
.testimonials-widget-testimonial div.credit {
|
67 |
/* outer wrapper for source & company */
|
68 |
display: block; /* To display source and company on a new line */
|
69 |
margin-top: .2em;
|
70 |
text-align: right;
|
71 |
}
|
72 |
|
73 |
+
.widget .testimonials-widget-testimonial cite,
|
74 |
+
.widget .testimonials-widget-testimonial div.credit {
|
75 |
margin-top: .8em;
|
76 |
}
|
77 |
|
78 |
+
.widget .testimonials-widget-testimonial .whitespace cite,
|
79 |
.widget .whitespace cite,
|
80 |
+
.widget .testimonials-widget-testimonial .whitespace div.credit,
|
81 |
.widget .whitespace div.credit {
|
82 |
margin-top: .2em;
|
83 |
}
|
84 |
|
85 |
+
.testimonials-widget-testimonial cite:before,
|
86 |
+
.testimonials-widget-testimonial div.credit:before {
|
87 |
content: "– "
|
88 |
}
|
89 |
|
90 |
+
.testimonials-widget-testimonial .join-title,
|
91 |
+
.testimonials-widget-testimonial .join-location,
|
92 |
+
.testimonials-widget-testimonial .join {
|
93 |
/* section between source and company information */
|
94 |
*zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ', ' );
|
95 |
}
|
96 |
|
97 |
+
.testimonials-widget-testimonial .join-title:before,
|
98 |
+
.testimonials-widget-testimonial .join-location:before,
|
99 |
+
.testimonials-widget-testimonial .join:before {
|
100 |
/* join text */
|
101 |
content: ", "
|
102 |
}
|
103 |
|
104 |
+
.testimonials-widget-testimonial .author,
|
105 |
+
.testimonials-widget-testimonial .email,
|
106 |
+
.testimonials-widget-testimonial .title,
|
107 |
+
.testimonials-widget-testimonial .location,
|
108 |
+
.testimonials-widget-testimonial .company,
|
109 |
+
.testimonials-widget-testimonial .url {
|
110 |
/* testimonial title, company and url informaiton */
|
111 |
}
|
112 |
|
113 |
+
.testimonials-widget-testimonial .extra {
|
114 |
margin-top: .8em;
|
115 |
}
|
116 |
|
117 |
+
.testimonials-widget-testimonial .bottom_text {
|
118 |
margin-top: 1.4em;
|
119 |
}
|
testimonials-widget.php
CHANGED
@@ -1,54 +1,51 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
*/
|
11 |
/**
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
You should have received a copy of the GNU General Public License
|
24 |
-
along with this program; if not, write to the Free Software
|
25 |
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*/
|
27 |
|
28 |
|
29 |
-
require_once
|
30 |
|
31 |
|
32 |
class Testimonials_Widget {
|
33 |
-
const
|
34 |
-
const
|
35 |
-
const
|
36 |
-
const
|
37 |
-
|
38 |
-
private static $base
|
39 |
-
private static $max_num_pages
|
40 |
-
private static $post_count
|
41 |
-
private static $wp_query
|
42 |
-
|
43 |
-
public static $css
|
44 |
-
public static $css_called
|
45 |
-
public static $instance_number
|
46 |
-
public static $scripts
|
47 |
-
public static $scripts_called
|
48 |
-
public static $settings_link
|
49 |
-
public static $tag_close_quote
|
50 |
-
public static $tag_open_quote
|
51 |
-
public static $widget_number
|
52 |
|
53 |
|
54 |
public function __construct() {
|
@@ -57,7 +54,7 @@ class Testimonials_Widget {
|
|
57 |
add_action( 'widgets_init', array( &$this, 'widgets_init' ) );
|
58 |
add_shortcode( 'testimonialswidget_list', array( &$this, 'testimonialswidget_list' ) );
|
59 |
add_shortcode( 'testimonialswidget_widget', array( &$this, 'testimonialswidget_widget' ) );
|
60 |
-
load_plugin_textdomain( self::
|
61 |
register_activation_hook( __FILE__, array( &$this, 'activation' ) );
|
62 |
register_deactivation_hook( __FILE__, array( &$this, 'deactivation' ) );
|
63 |
register_uninstall_hook( __FILE__, array( 'Testimonials_Widget', 'uninstall' ) );
|
@@ -65,15 +62,15 @@ class Testimonials_Widget {
|
|
65 |
|
66 |
|
67 |
public function admin_init() {
|
68 |
-
self::$settings_link
|
69 |
|
70 |
$this->add_meta_box_testimonials_widget();
|
71 |
$this->update();
|
72 |
add_action( 'gettext', array( &$this, 'gettext_testimonials' ) );
|
73 |
-
add_action( 'manage_' . self::
|
74 |
-
add_filter( 'manage_' . self::
|
75 |
add_filter( 'plugin_action_links', array( &$this, 'plugin_action_links' ), 10, 2 );
|
76 |
-
add_filter( 'plugin_row_meta', array( &$this, 'plugin_row_meta'), 10, 2 );
|
77 |
add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
|
78 |
add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts_author' ) );
|
79 |
self::support_thumbnails();
|
@@ -82,7 +79,7 @@ class Testimonials_Widget {
|
|
82 |
|
83 |
public function init() {
|
84 |
add_filter( 'the_content', array( &$this, 'get_single' ) );
|
85 |
-
self::$base
|
86 |
self::init_post_type();
|
87 |
self::styles();
|
88 |
}
|
@@ -108,18 +105,18 @@ class Testimonials_Widget {
|
|
108 |
|
109 |
|
110 |
public static function support_thumbnails() {
|
111 |
-
$feature
|
112 |
-
$feature_level
|
113 |
|
114 |
if ( true === $feature_level ) {
|
115 |
// already enabled for all post types
|
116 |
return;
|
117 |
} elseif ( false === $feature_level ) {
|
118 |
// none allowed, only enable for our own
|
119 |
-
add_theme_support( $feature, array( self::
|
120 |
} else {
|
121 |
// add our own to list of supported
|
122 |
-
$feature_level[0][]
|
123 |
add_theme_support( $feature, $feature_level[0] );
|
124 |
}
|
125 |
}
|
@@ -128,25 +125,30 @@ class Testimonials_Widget {
|
|
128 |
public function get_single( $content ) {
|
129 |
global $post;
|
130 |
|
131 |
-
if ( ! is_single() || self::
|
132 |
return $content;
|
133 |
|
134 |
-
$atts
|
135 |
-
$atts['hide_content']
|
136 |
-
$atts['ids']
|
137 |
-
$atts['type']
|
138 |
|
139 |
-
$testimonials
|
140 |
-
$testimonial
|
141 |
|
142 |
-
$details
|
143 |
-
$details
|
144 |
-
$content
|
145 |
|
146 |
return $content . $details;
|
147 |
}
|
148 |
|
149 |
|
|
|
|
|
|
|
|
|
|
|
150 |
public function activation() {
|
151 |
if ( ! current_user_can( 'activate_plugins' ) )
|
152 |
return;
|
@@ -154,14 +156,17 @@ class Testimonials_Widget {
|
|
154 |
$plugin = isset( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '';
|
155 |
check_admin_referer( "activate-plugin_{$plugin}" );
|
156 |
|
157 |
-
// fixme
|
158 |
-
// add_action( 'admin_notices', array( 'Testimonials_Widget', 'notice_uninstall' ) );
|
159 |
self::init();
|
160 |
|
161 |
flush_rewrite_rules();
|
162 |
}
|
163 |
|
164 |
|
|
|
|
|
|
|
|
|
|
|
165 |
public function deactivation() {
|
166 |
if ( ! current_user_can( 'activate_plugins' ) )
|
167 |
return;
|
@@ -174,10 +179,10 @@ class Testimonials_Widget {
|
|
174 |
|
175 |
|
176 |
function notice_uninstall() {
|
177 |
-
$content
|
178 |
-
$content
|
179 |
-
$content
|
180 |
-
$content
|
181 |
|
182 |
echo $content;
|
183 |
}
|
@@ -194,40 +199,44 @@ class Testimonials_Widget {
|
|
194 |
|
195 |
global $wpdb;
|
196 |
|
197 |
-
|
198 |
-
|
|
|
|
|
199 |
|
200 |
-
|
201 |
-
|
202 |
-
$wpdb->query( "OPTIMIZE TABLE `" . $wpdb->posts . "`" );
|
203 |
}
|
204 |
|
205 |
|
206 |
public static function delete_testimonials() {
|
207 |
global $wpdb;
|
208 |
|
209 |
-
$query
|
210 |
-
$posts
|
211 |
|
212 |
-
foreach( $posts as $post ) {
|
213 |
-
$post_id
|
214 |
self::delete_attachments( $post_id );
|
215 |
|
216 |
// dels post, meta & comments
|
217 |
// true is force delete
|
218 |
wp_delete_post( $post_id, true );
|
219 |
}
|
|
|
|
|
|
|
220 |
}
|
221 |
|
222 |
|
223 |
public static function delete_attachments( $post_id = false ) {
|
224 |
global $wpdb;
|
225 |
|
226 |
-
$post_id
|
227 |
-
$query
|
228 |
-
$attachments
|
229 |
|
230 |
-
foreach( $attachments as $attachment ) {
|
231 |
// true is force delete
|
232 |
wp_delete_attachment( $attachment->ID, true );
|
233 |
}
|
@@ -238,84 +247,105 @@ class Testimonials_Widget {
|
|
238 |
if ( $file != self::$base ) {
|
239 |
return $input;
|
240 |
}
|
241 |
-
|
242 |
-
$links
|
243 |
'<a href="http://aihr.us/about-aihrus/donate/">Donate</a>',
|
244 |
-
'<a href="http://aihr.us/testimonials-widget-premium/">Purchase Testimonials Widget Premium</a>'
|
245 |
);
|
246 |
|
247 |
-
$input
|
248 |
-
|
249 |
return $input;
|
250 |
}
|
251 |
|
252 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
public function update() {
|
254 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
|
256 |
// testimonials already migrated?
|
257 |
-
if ( true
|
258 |
-
|
|
|
259 |
|
|
|
|
|
260 |
global $wpdb;
|
261 |
|
262 |
-
$table_name
|
263 |
-
$meta_key
|
264 |
|
265 |
// check that db table exists and has entries
|
266 |
-
$query
|
267 |
|
268 |
// ignore already imported
|
269 |
-
$done_import_query
|
270 |
-
$done_import
|
271 |
|
272 |
if ( ! empty( $done_import ) ) {
|
273 |
-
$done_import
|
274 |
-
$query
|
275 |
}
|
276 |
|
277 |
-
$results
|
278 |
-
if( ! empty( $results ) ) {
|
279 |
foreach ( $results as $result ) {
|
280 |
// author can contain title and company details
|
281 |
-
$author
|
282 |
-
$company
|
283 |
|
284 |
// ex: First Last of Company!
|
285 |
-
$author
|
286 |
// now ex: First Last, Company!
|
287 |
|
288 |
// ex: First Last, Company
|
289 |
// ex: First Last, Web Development Manager, Topcon Positioning Systems, Inc.
|
290 |
// ex: First Last, Owner, Company, LLC
|
291 |
-
$author
|
292 |
-
$temp_comma
|
293 |
-
$author
|
|
|
294 |
// now ex: First Last, Owner, Company^^^ LLC
|
295 |
-
$author
|
|
|
296 |
// ex: First Last, Web Development Manager, Company^^^ Inc.
|
297 |
// it's possible to have "Michael Cannon, Senior Developer" and "Senior Developer" become the company. Okay for now
|
298 |
-
$author
|
299 |
|
300 |
if ( 1 < count( $author ) ) {
|
301 |
-
$company
|
302 |
-
$company
|
303 |
}
|
304 |
|
305 |
-
$author
|
306 |
-
$author
|
307 |
-
|
308 |
-
$post_data
|
309 |
-
'post_type'
|
310 |
-
'post_status'
|
311 |
-
'post_date'
|
312 |
-
'post_modified'
|
313 |
-
'post_title'
|
314 |
-
'post_content'
|
315 |
-
'tags_input'
|
316 |
);
|
317 |
|
318 |
-
$post_id
|
319 |
|
320 |
// track/link testimonial import to new post
|
321 |
add_post_meta( $post_id, $meta_key, $result->testimonial_id );
|
@@ -324,7 +354,7 @@ class Testimonials_Widget {
|
|
324 |
add_post_meta( $post_id, 'testimonials-widget-company', $company );
|
325 |
}
|
326 |
|
327 |
-
$source
|
328 |
if ( ! empty( $source ) ) {
|
329 |
if ( is_email( $source ) ) {
|
330 |
add_post_meta( $post_id, 'testimonials-widget-email', $source );
|
@@ -335,9 +365,9 @@ class Testimonials_Widget {
|
|
335 |
}
|
336 |
}
|
337 |
|
338 |
-
$options['migrated']
|
339 |
-
delete_option( self::
|
340 |
-
add_option( self::
|
341 |
}
|
342 |
|
343 |
|
@@ -345,7 +375,7 @@ class Testimonials_Widget {
|
|
345 |
global $user_ID;
|
346 |
|
347 |
// author's and below
|
348 |
-
if( $query->is_admin && ! empty( $query->is_main_query ) && $query->is_post_type_archive( Testimonials_Widget::
|
349 |
$query->set( 'post_author', $user_ID );
|
350 |
|
351 |
return $query;
|
@@ -353,49 +383,49 @@ class Testimonials_Widget {
|
|
353 |
|
354 |
|
355 |
public function manage_testimonialswidget_posts_custom_column( $column, $post_id ) {
|
356 |
-
$result
|
357 |
|
358 |
switch ( $column ) {
|
359 |
case 'shortcode':
|
360 |
-
$result
|
361 |
-
$result
|
362 |
-
$result
|
363 |
-
$result
|
364 |
-
$result
|
365 |
-
$result
|
366 |
-
$result
|
367 |
break;
|
368 |
|
369 |
case 'testimonials-widget-company':
|
370 |
case 'testimonials-widget-location':
|
371 |
case 'testimonials-widget-title':
|
372 |
-
$result
|
373 |
break;
|
374 |
|
375 |
case 'testimonials-widget-email':
|
376 |
case 'testimonials-widget-url':
|
377 |
-
$url
|
378 |
-
if ( ! empty( $url ) && ! is_email( $url ) && 0 === preg_match(
|
379 |
-
$url
|
380 |
}
|
381 |
|
382 |
-
$result
|
383 |
break;
|
384 |
|
385 |
case 'thumbnail':
|
386 |
-
$email
|
387 |
|
388 |
if ( has_post_thumbnail( $post_id ) ) {
|
389 |
-
$result
|
390 |
} elseif ( is_email( $email ) ) {
|
391 |
-
$result
|
392 |
} else {
|
393 |
-
$result
|
394 |
}
|
395 |
break;
|
396 |
}
|
397 |
|
398 |
-
$result
|
399 |
|
400 |
if ( $result )
|
401 |
echo $result;
|
@@ -404,23 +434,23 @@ class Testimonials_Widget {
|
|
404 |
|
405 |
public function manage_edit_testimonialswidget_columns( $columns ) {
|
406 |
// order of keys matches column ordering
|
407 |
-
$columns
|
408 |
-
'cb'
|
409 |
-
'thumbnail'
|
410 |
-
'title'
|
411 |
-
'shortcode'
|
412 |
-
'testimonials-widget-title'
|
413 |
-
'testimonials-widget-location'
|
414 |
-
'testimonials-widget-email'
|
415 |
-
'testimonials-widget-company'
|
416 |
-
'testimonials-widget-url'
|
417 |
-
'author'
|
418 |
-
'categories'
|
419 |
-
'tags'
|
420 |
-
'date'
|
421 |
);
|
422 |
|
423 |
-
$columns
|
424 |
|
425 |
return $columns;
|
426 |
}
|
@@ -428,59 +458,59 @@ class Testimonials_Widget {
|
|
428 |
|
429 |
public function init_post_type() {
|
430 |
$labels = array(
|
431 |
-
'add_new'
|
432 |
-
'add_new_item'
|
433 |
-
'edit_item'
|
434 |
-
'name'
|
435 |
-
'new_item'
|
436 |
-
'not_found'
|
437 |
-
'not_found_in_trash'
|
438 |
-
'parent_item_colon'
|
439 |
-
'search_items'
|
440 |
-
'singular_name'
|
441 |
-
'view_item'
|
442 |
);
|
443 |
-
|
444 |
-
$supports
|
445 |
'title',
|
446 |
'editor',
|
447 |
'thumbnail',
|
448 |
);
|
449 |
|
450 |
-
$allow_comments
|
451 |
if ( $allow_comments )
|
452 |
-
$supports[]
|
453 |
|
454 |
-
$has_archive
|
455 |
-
$rewrite_slug
|
456 |
|
457 |
// editor's and up
|
458 |
-
if( current_user_can( 'edit_others_posts' ) )
|
459 |
-
$supports[]
|
460 |
|
461 |
$args = array(
|
462 |
-
'label'
|
463 |
-
'capability_type'
|
464 |
-
'has_archive'
|
465 |
-
'hierarchical'
|
466 |
-
'labels'
|
467 |
-
'public'
|
468 |
-
'publicly_queryable'
|
469 |
-
'query_var'
|
470 |
-
'rewrite'
|
471 |
-
|
472 |
-
'with_front' => false
|
473 |
),
|
474 |
-
'show_in_menu'
|
475 |
-
'show_ui'
|
476 |
-
'supports'
|
477 |
-
'taxonomies'
|
478 |
'category',
|
479 |
'post_tag',
|
480 |
)
|
481 |
);
|
482 |
|
483 |
-
register_post_type( Testimonials_Widget::
|
484 |
}
|
485 |
|
486 |
|
@@ -496,25 +526,25 @@ class Testimonials_Widget {
|
|
496 |
public function testimonialswidget_list( $atts ) {
|
497 |
self::add_instance();
|
498 |
|
499 |
-
$atts
|
500 |
-
$atts
|
501 |
|
502 |
-
if ( get_query_var('paged') ) {
|
503 |
-
$atts['paged']
|
504 |
-
} elseif ( get_query_var('page') ) {
|
505 |
-
$atts['paged']
|
506 |
} else {
|
507 |
-
$atts['paged']
|
508 |
}
|
509 |
|
510 |
-
$atts['type']
|
511 |
|
512 |
-
$content
|
513 |
|
514 |
if ( false === $content ) {
|
515 |
-
$testimonials
|
516 |
-
$content
|
517 |
-
$content
|
518 |
}
|
519 |
|
520 |
return $content;
|
@@ -526,52 +556,52 @@ class Testimonials_Widget {
|
|
526 |
self::scripts();
|
527 |
|
528 |
if ( empty( $widget_number ) ) {
|
529 |
-
$widget_number
|
530 |
|
531 |
if ( empty( $atts['random'] ) )
|
532 |
-
$atts['random']
|
533 |
}
|
534 |
-
$atts
|
535 |
-
$atts
|
536 |
|
537 |
-
$atts['paging']
|
538 |
-
$atts['type']
|
539 |
-
$atts['widget_number']
|
540 |
|
541 |
-
$testimonials
|
542 |
|
543 |
-
$content
|
544 |
|
545 |
if ( false === $content ) {
|
546 |
-
$content
|
547 |
-
$content
|
548 |
}
|
549 |
|
550 |
// Generate CSS
|
551 |
-
$atts['type']
|
552 |
-
$css
|
553 |
|
554 |
if ( false === $css ) {
|
555 |
-
$css
|
556 |
-
$css
|
557 |
}
|
558 |
|
559 |
if ( ! empty( $css ) ) {
|
560 |
-
self::$css
|
561 |
add_action( 'wp_footer', array( 'Testimonials_Widget', 'get_testimonials_css' ), 20 );
|
562 |
}
|
563 |
|
564 |
// Generate JS
|
565 |
-
$atts['type']
|
566 |
-
$js
|
567 |
|
568 |
if ( false === $js ) {
|
569 |
-
$js
|
570 |
-
$js
|
571 |
}
|
572 |
|
573 |
if ( ! empty( $js ) ) {
|
574 |
-
self::$scripts
|
575 |
add_action( 'wp_footer', array( 'Testimonials_Widget', 'get_testimonials_scripts' ), 20 );
|
576 |
}
|
577 |
|
@@ -592,20 +622,20 @@ class Testimonials_Widget {
|
|
592 |
|
593 |
public static function get_testimonials_html_css( $atts, $widget_number = null ) {
|
594 |
// display attributes
|
595 |
-
$height
|
596 |
-
$max_height
|
597 |
-
$min_height
|
598 |
|
599 |
if ( $height ) {
|
600 |
-
$max_height
|
601 |
-
$min_height
|
602 |
}
|
603 |
|
604 |
-
$css
|
605 |
-
$id_base
|
606 |
|
607 |
if ( $min_height ) {
|
608 |
-
$css[]
|
609 |
<style>
|
610 |
.$id_base {
|
611 |
min-height: {$min_height}px;
|
@@ -615,7 +645,7 @@ EOF;
|
|
615 |
}
|
616 |
|
617 |
if ( $max_height ) {
|
618 |
-
$css[]
|
619 |
<style>
|
620 |
.$id_base {
|
621 |
max-height: {$max_height}px;
|
@@ -624,7 +654,7 @@ EOF;
|
|
624 |
EOF;
|
625 |
}
|
626 |
|
627 |
-
$css
|
628 |
|
629 |
return $css;
|
630 |
}
|
@@ -632,22 +662,22 @@ EOF;
|
|
632 |
|
633 |
public static function get_testimonials_html_js( $testimonials, $atts, $widget_number = null ) {
|
634 |
// display attributes
|
635 |
-
$refresh_interval
|
636 |
|
637 |
-
$id_base
|
638 |
-
$scripts
|
639 |
|
640 |
if ( $refresh_interval && 1 < count( $testimonials ) ) {
|
641 |
-
$javascript
|
642 |
<script type="text/javascript">
|
643 |
function nextTestimonial{$widget_number}() {
|
644 |
if ( ! jQuery('.{$id_base}').first().hasClass('hovered') ) {
|
645 |
var active = jQuery('.{$id_base} .active');
|
646 |
-
var next
|
647 |
active.fadeOut(1250, function(){
|
648 |
active.removeClass('active');
|
649 |
next.fadeIn(500);
|
650 |
-
next.removeClass('
|
651 |
next.addClass('active');
|
652 |
});
|
653 |
}
|
@@ -664,263 +694,282 @@ jQuery(document).ready(function(){
|
|
664 |
</script>
|
665 |
EOF;
|
666 |
|
667 |
-
$scripts[ $id_base ]
|
668 |
}
|
669 |
|
670 |
-
$scripts
|
671 |
|
672 |
return $scripts;
|
673 |
}
|
674 |
|
675 |
|
676 |
-
public function get_testimonials_html( $testimonials, $atts, $is_list = true, $widget_number = null ) {
|
677 |
// display attributes
|
678 |
-
$hide_not_found
|
679 |
-
$paging
|
680 |
-
$paging_before
|
681 |
-
$paging_after
|
682 |
-
$
|
683 |
-
$target = $atts['target'];
|
684 |
|
685 |
-
$html
|
686 |
-
$id
|
687 |
|
688 |
if ( is_null( $widget_number ) ) {
|
689 |
-
$html
|
690 |
|
691 |
if ( $is_list )
|
692 |
-
$html
|
693 |
|
694 |
-
$html
|
695 |
} else {
|
696 |
-
$id_base
|
697 |
-
$html
|
698 |
}
|
699 |
|
700 |
if ( empty( $testimonials ) && ! $hide_not_found ) {
|
701 |
-
$testimonials
|
702 |
-
array( 'testimonial_content'
|
703 |
);
|
704 |
}
|
705 |
-
|
706 |
if ( $paging || $paging_before ) {
|
707 |
-
$html
|
708 |
-
}
|
709 |
|
710 |
-
$is_first
|
711 |
|
712 |
foreach ( $testimonials as $testimonial ) {
|
713 |
-
$content
|
714 |
-
$content
|
715 |
-
$html
|
716 |
-
$is_first
|
717 |
-
}
|
718 |
|
719 |
if ( $paging || $paging_after ) {
|
720 |
-
$html
|
721 |
-
}
|
722 |
|
723 |
-
$html
|
724 |
|
725 |
if ( $target )
|
726 |
-
$html
|
727 |
|
728 |
return $html;
|
729 |
}
|
730 |
|
731 |
|
732 |
-
public function get_testimonial_html( $testimonial, $atts, $is_list = true, $is_first = false, $widget_number = null ) {
|
733 |
// display attributes
|
734 |
-
$
|
735 |
-
$
|
736 |
-
$
|
737 |
-
$
|
738 |
-
$
|
739 |
-
|
740 |
-
$
|
741 |
-
$do_image = ! $atts['hide_image'] && ! empty( $testimonial['testimonial_image'] );
|
742 |
-
$do_image_single = ! $atts['hide_image_single'];
|
743 |
-
$do_location = ! $atts['hide_location'] && ! empty( $testimonial['testimonial_location'] );
|
744 |
-
$do_source = ! $atts['hide_source'] && ! empty( $testimonial['testimonial_source'] );
|
745 |
-
$do_title = ! $atts['hide_title'] && ! empty( $testimonial['testimonial_title'] );
|
746 |
-
$do_url = ! $atts['hide_url'] && ! empty( $testimonial['testimonial_url'] );
|
747 |
-
$keep_whitespace = $atts['keep_whitespace'];
|
748 |
-
$remove_hentry = $atts['remove_hentry'];
|
749 |
-
$use_quote_tag = $atts['use_quote_tag'];
|
750 |
-
|
751 |
-
$class = 'testimonialswidget_testimonial';
|
752 |
|
753 |
if ( is_single() && empty( $widget_number ) ) {
|
754 |
-
$class
|
755 |
} elseif ( $is_list ) {
|
756 |
-
$class
|
757 |
} elseif ( $is_first ) {
|
758 |
-
$class
|
759 |
} elseif ( ! $is_first ) {
|
760 |
-
$class
|
761 |
}
|
762 |
|
763 |
if ( $keep_whitespace )
|
764 |
-
$class
|
765 |
|
766 |
-
$div_open
|
767 |
|
768 |
if ( ! empty( $testimonial['post_id'] ) )
|
769 |
-
$div_open
|
770 |
else
|
771 |
-
$div_open
|
772 |
|
773 |
-
$div_open
|
774 |
|
775 |
if ( $remove_hentry )
|
776 |
-
$div_open
|
777 |
|
778 |
-
$image
|
779 |
if ( $do_image ) {
|
780 |
-
$image
|
781 |
-
$image
|
782 |
-
$image
|
783 |
}
|
784 |
|
785 |
if ( ! $do_image_single && 'get_single' == $atts['type'] ) {
|
786 |
-
$image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
787 |
}
|
788 |
|
789 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
790 |
if ( $do_content ) {
|
791 |
-
$content
|
792 |
-
$content
|
793 |
|
794 |
if ( $char_limit ) {
|
795 |
-
$content
|
796 |
-
$content
|
797 |
}
|
798 |
|
799 |
-
$content
|
800 |
-
$content
|
801 |
|
802 |
if ( empty( $use_quote_tag ) ) {
|
803 |
-
$quote
|
804 |
-
$quote
|
805 |
-
$quote
|
806 |
} else {
|
807 |
-
$quote
|
808 |
-
$quote
|
809 |
-
$quote
|
810 |
}
|
811 |
}
|
812 |
|
813 |
-
$
|
814 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
815 |
if ( $do_source && $do_email ) {
|
816 |
-
$cite
|
817 |
-
$cite
|
818 |
-
$cite
|
819 |
-
$cite
|
820 |
-
$cite
|
821 |
} elseif ( $do_source && ! $do_company && $do_url ) {
|
822 |
-
$
|
823 |
-
|
824 |
-
$cite
|
825 |
-
$cite
|
826 |
-
$cite
|
827 |
-
$
|
|
|
828 |
} elseif ( $do_source ) {
|
829 |
-
$cite
|
830 |
-
$cite
|
831 |
-
$cite
|
832 |
} elseif ( $do_email ) {
|
833 |
-
$cite
|
834 |
-
$cite
|
835 |
-
$cite
|
836 |
}
|
837 |
|
838 |
if ( $do_title && $cite )
|
839 |
-
$cite
|
|
|
840 |
|
841 |
if ( $do_title ) {
|
842 |
-
$cite
|
843 |
-
$cite
|
844 |
-
$cite
|
845 |
}
|
846 |
|
847 |
if ( $do_location && $cite )
|
848 |
-
$cite
|
849 |
|
850 |
if ( $do_location ) {
|
851 |
-
$cite
|
852 |
-
$cite
|
853 |
-
$cite
|
854 |
}
|
855 |
|
856 |
if ( ( $do_company || ( $do_url && ! $done_url ) ) && $cite )
|
857 |
-
$cite
|
858 |
|
859 |
if ( $do_company && $do_url ) {
|
860 |
-
$cite
|
861 |
-
$cite
|
862 |
-
$cite
|
863 |
-
$cite
|
864 |
-
$cite
|
865 |
} elseif ( $do_company ) {
|
866 |
-
$cite
|
867 |
-
$cite
|
868 |
-
$cite
|
869 |
} elseif ( $do_url && ! $done_url ) {
|
870 |
-
$cite
|
871 |
-
$cite
|
872 |
-
$cite
|
873 |
}
|
874 |
|
875 |
if ( ! empty( $cite ) ) {
|
876 |
if ( empty( $use_quote_tag ) ) {
|
877 |
-
$temp
|
878 |
-
$temp
|
879 |
-
$temp
|
880 |
-
|
|
|
881 |
} else {
|
882 |
-
$cite
|
883 |
}
|
884 |
}
|
885 |
|
886 |
-
$
|
887 |
-
if ( ! empty( $testimonial['testimonial_extra'] ) ) {
|
888 |
-
$extra .= '<div class="extra">';
|
889 |
-
$extra .= $testimonial['testimonial_extra'];
|
890 |
-
$extra .= '</div>';
|
891 |
-
}
|
892 |
-
|
893 |
-
$bottom_text = '';
|
894 |
-
if ( ! empty( $atts['bottom_text'] ) ) {
|
895 |
-
$bottom_text = '<div class="bottom_text">';
|
896 |
-
$bottom_text .= $atts['bottom_text'];
|
897 |
-
$bottom_text .= '</div>';
|
898 |
-
}
|
899 |
-
|
900 |
-
$div_close = '</div>';
|
901 |
-
|
902 |
-
$html = $div_open
|
903 |
-
. $image
|
904 |
-
. $quote
|
905 |
-
. $cite
|
906 |
-
. $extra
|
907 |
-
. $bottom_text
|
908 |
-
. $div_close;
|
909 |
-
|
910 |
-
$html = apply_filters( 'testimonials_widget_get_testimonial_html', $html, $testimonial, $atts, $is_list, $is_first, $widget_number, $div_open, $image, $quote, $cite, $extra, $bottom_text, $div_close );
|
911 |
-
|
912 |
-
// not done sooner as tag_close_quote is used for Premium
|
913 |
-
if ( $disable_quotes ) {
|
914 |
-
$html = str_replace( self::$tag_open_quote, '', $html );
|
915 |
-
$html = str_replace( self::$tag_close_quote, '', $html );
|
916 |
-
}
|
917 |
-
|
918 |
-
return $html;
|
919 |
}
|
920 |
|
921 |
|
922 |
// Original PHP code as myTruncate2 by Chirp Internet: www.chirp.com.au
|
923 |
-
public static function testimonials_truncate( $string, $char_limit = false, $
|
924 |
if ( empty( $force_pad ) ) {
|
925 |
if ( empty( $char_limit ) )
|
926 |
return $string;
|
@@ -929,7 +978,7 @@ EOF;
|
|
929 |
if ( strlen( $string ) <= $char_limit )
|
930 |
return $string;
|
931 |
}
|
932 |
-
|
933 |
if ( ! empty( $char_limit ) ) {
|
934 |
return self::truncate( $string, $char_limit, $pad, $force_pad );
|
935 |
}
|
@@ -942,107 +991,118 @@ EOF;
|
|
942 |
* Truncate HTML, close opened tags. UTF-8 aware, and aware of unpaired tags
|
943 |
* (which don't need a matching closing tag)
|
944 |
*
|
945 |
-
* @param string
|
946 |
-
* @param int
|
947 |
-
* @param string
|
948 |
* @param boolean $force_indicator Suffix to use if string was truncated.
|
949 |
* @return string
|
950 |
*
|
951 |
* @ref http://pastie.org/3084080
|
952 |
*/
|
953 |
-
public static function truncate( $html, $max_length, $indicator = '…', $force_indicator = false )
|
954 |
-
{
|
955 |
$output_length = 0; // number of counted characters stored so far in $output
|
956 |
-
$position
|
957 |
-
$tag_stack
|
958 |
-
$output
|
959 |
-
$truncated
|
960 |
|
961 |
-
/**
|
|
|
962 |
* theoretically need a closing /> )
|
|
|
963 |
* @see http://www.netstrider.com/tutorials/HTMLRef/a_d.html
|
964 |
* @see http://www.w3schools.com/tags/default.asp
|
965 |
* @see http://stackoverflow.com/questions/3741896/what-do-you-call-tags-that-need-no-ending-tag
|
966 |
*/
|
967 |
-
$unpaired_tags = array(
|
968 |
-
'
|
969 |
-
'
|
970 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
971 |
|
972 |
-
$func_strcut
|
973 |
-
$func_strlen
|
974 |
|
975 |
// loop through, splitting at HTML entities or tags
|
976 |
-
while ($output_length < $max_length
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
{
|
985 |
-
$output .= $func_strcut($text, 0, $max_length - $output_length);
|
986 |
-
$truncated = true;
|
987 |
$output_length = $max_length;
|
988 |
break;
|
989 |
}
|
990 |
|
991 |
// store everything, it wasn't too long
|
992 |
-
$output
|
993 |
-
$output_length += $func_strlen($text);
|
994 |
|
995 |
-
if ($tag[0] == '&')
|
996 |
-
|
997 |
$output .= $tag;
|
998 |
$output_length++; // only counted as one character
|
999 |
-
}
|
1000 |
-
|
1001 |
-
{
|
1002 |
$tag_inner = $match[1][0];
|
1003 |
-
|
1004 |
-
{
|
|
|
1005 |
$output .= $tag;
|
1006 |
// If input tags aren't balanced, we leave the popped tag
|
1007 |
// on the stack so hopefully we're not introducing more
|
1008 |
// problems.
|
1009 |
-
|
1010 |
-
{
|
1011 |
-
array_pop($tag_stack);
|
1012 |
}
|
1013 |
-
}
|
1014 |
-
else if ($tag[$func_strlen($tag) - 2] == '/'
|
1015 |
-
|| in_array(strtolower($tag_inner),$unpaired_tags) )
|
1016 |
-
{
|
1017 |
// Self-closing or unpaired tag
|
1018 |
$output .= $tag;
|
1019 |
-
}
|
1020 |
-
|
1021 |
-
|
1022 |
-
$output .= $tag;
|
1023 |
$tag_stack[] = $tag_inner; // push tag onto the stack
|
1024 |
}
|
1025 |
}
|
1026 |
|
1027 |
// Continue after the tag we just found
|
1028 |
-
$position = $tag_position + $func_strlen($tag);
|
1029 |
}
|
1030 |
|
1031 |
-
// Print any remaining text after the last tag, if there's room
|
1032 |
-
|
1033 |
-
{
|
1034 |
-
$output .= $func_strcut($html, $position, $max_length - $output_length);
|
1035 |
}
|
1036 |
|
1037 |
-
$truncated = $func_strlen($html)
|
1038 |
|
1039 |
// add terminator if it was truncated in loop or just above here
|
1040 |
if ( $truncated || $force_indicator )
|
1041 |
$output .= $indicator;
|
1042 |
|
1043 |
// Close any open tags
|
1044 |
-
while (!empty($tag_stack))
|
1045 |
-
$output .= '</'.array_pop($tag_stack).'>';
|
1046 |
|
1047 |
return $output;
|
1048 |
}
|
@@ -1052,88 +1112,90 @@ EOF;
|
|
1052 |
if ( empty ( $content ) )
|
1053 |
return $content;
|
1054 |
|
1055 |
-
$keep_whitespace
|
1056 |
|
1057 |
-
// wrap our own quote class around the content before any formatting
|
1058 |
// happens
|
1059 |
|
1060 |
-
$temp_content
|
1061 |
-
$temp_content
|
1062 |
-
$temp_content
|
1063 |
-
|
|
|
1064 |
|
1065 |
-
$content
|
1066 |
-
$content
|
1067 |
-
$content
|
1068 |
-
$content
|
1069 |
|
1070 |
if ( is_null( $widget_number ) ) {
|
1071 |
-
$content
|
1072 |
-
$content
|
1073 |
} elseif ( $keep_whitespace ) {
|
1074 |
-
$content
|
1075 |
} else {
|
1076 |
-
$content
|
1077 |
}
|
1078 |
-
|
1079 |
-
$content
|
1080 |
-
$content
|
1081 |
-
|
1082 |
return $content;
|
1083 |
}
|
1084 |
|
1085 |
|
1086 |
-
public static function get_testimonials_paging( $
|
1087 |
-
$html
|
1088 |
|
1089 |
if ( is_home() || 1 === self::$max_num_pages ) {
|
1090 |
return $html;
|
1091 |
}
|
1092 |
|
1093 |
-
$html
|
1094 |
|
1095 |
if ( $prepend ) {
|
1096 |
-
$html
|
1097 |
} else {
|
1098 |
-
$html
|
1099 |
}
|
1100 |
|
1101 |
-
$html
|
1102 |
|
1103 |
if ( ! empty( $atts['paged'] ) ) {
|
1104 |
-
$paged
|
1105 |
} else {
|
1106 |
-
$paged
|
1107 |
}
|
1108 |
|
1109 |
if ( ! function_exists( 'wp_pagenavi' ) ) {
|
1110 |
-
$html
|
1111 |
|
1112 |
if ( 1 < $paged ) {
|
1113 |
-
$laquo
|
1114 |
-
$html
|
1115 |
}
|
1116 |
|
1117 |
-
$html
|
1118 |
|
1119 |
-
$html
|
1120 |
|
1121 |
if ( $paged != self::$max_num_pages ) {
|
1122 |
-
$raquo
|
1123 |
-
$html
|
1124 |
}
|
1125 |
|
1126 |
-
$html
|
1127 |
} else {
|
1128 |
-
$args
|
1129 |
-
'echo'
|
1130 |
-
'query'
|
1131 |
);
|
1132 |
-
$args
|
1133 |
-
|
|
|
1134 |
}
|
1135 |
|
1136 |
-
$html
|
1137 |
|
1138 |
return $html;
|
1139 |
}
|
@@ -1141,26 +1203,31 @@ EOF;
|
|
1141 |
|
1142 |
public static function get_testimonials_css() {
|
1143 |
if ( empty( self::$css_called ) ) {
|
1144 |
-
foreach( self::$css as $
|
1145 |
echo $css;
|
1146 |
}
|
1147 |
-
|
1148 |
-
self::$css_called
|
1149 |
}
|
1150 |
}
|
1151 |
|
1152 |
|
1153 |
public static function get_testimonials_scripts() {
|
1154 |
if ( empty( self::$scripts_called ) ) {
|
1155 |
-
foreach( self::$scripts as $
|
1156 |
echo $script;
|
1157 |
}
|
1158 |
-
|
1159 |
-
self::$scripts_called
|
1160 |
}
|
1161 |
}
|
1162 |
|
1163 |
|
|
|
|
|
|
|
|
|
|
|
1164 |
public static function get_query_args( $atts ) {
|
1165 |
extract( $atts );
|
1166 |
|
@@ -1169,156 +1236,157 @@ EOF;
|
|
1169 |
}
|
1170 |
|
1171 |
if ( $random ) {
|
1172 |
-
$orderby
|
1173 |
-
$order
|
1174 |
}
|
1175 |
|
1176 |
-
$args
|
1177 |
-
'orderby'
|
1178 |
-
'post_status'
|
1179 |
-
'publish',
|
1180 |
-
'private',
|
1181 |
),
|
1182 |
-
'post_type'
|
1183 |
-
'posts_per_page'
|
1184 |
);
|
1185 |
|
1186 |
if ( is_single() ) {
|
1187 |
-
$args['post_status'][]
|
1188 |
-
$args['post_status'][]
|
1189 |
}
|
1190 |
|
1191 |
if ( $paging && ! empty( $atts['paged'] ) && is_singular() ) {
|
1192 |
-
$args['paged']
|
1193 |
}
|
1194 |
|
1195 |
if ( ! $random && $meta_key ) {
|
1196 |
-
$args['meta_key']
|
1197 |
-
$args['orderby']
|
1198 |
}
|
1199 |
|
1200 |
if ( $order ) {
|
1201 |
-
$args['order']
|
1202 |
}
|
1203 |
|
1204 |
if ( $ids ) {
|
1205 |
-
$ids
|
1206 |
|
1207 |
-
$args['post__in']
|
1208 |
|
1209 |
if ( 'none' == $args['orderby'] ) {
|
1210 |
add_filter( 'posts_results', array( 'Testimonials_Widget', 'posts_results_sort_none' ), 10, 2 );
|
1211 |
}
|
1212 |
}
|
1213 |
|
|
|
1214 |
if ( $exclude ) {
|
1215 |
-
$exclude
|
1216 |
|
1217 |
-
$args['post__not_in']
|
1218 |
}
|
1219 |
|
1220 |
if ( $category ) {
|
1221 |
-
$args['category_name']
|
1222 |
}
|
1223 |
|
1224 |
if ( $tags ) {
|
1225 |
-
$tags
|
1226 |
|
1227 |
if ( $tags_all ) {
|
1228 |
-
$args['tag_slug__and']
|
1229 |
} else {
|
1230 |
-
$args['tag_slug__in']
|
1231 |
}
|
1232 |
}
|
1233 |
|
1234 |
-
$args
|
1235 |
|
1236 |
return $args;
|
1237 |
}
|
1238 |
|
1239 |
|
1240 |
public static function get_testimonials( $atts ) {
|
1241 |
-
$hide_gravatar
|
1242 |
|
1243 |
-
$args
|
1244 |
-
$args['query']
|
1245 |
|
1246 |
-
$testimonials
|
1247 |
|
1248 |
if ( false === $testimonials ) {
|
1249 |
-
$testimonials
|
1250 |
-
$testimonials
|
1251 |
}
|
1252 |
|
1253 |
if ( has_filter( 'posts_results', array( 'Testimonials_Widget', 'posts_results_sort_none' ) ) ) {
|
1254 |
remove_filter( 'posts_results', array( 'Testimonials_Widget', 'posts_results_sort_none' ) );
|
1255 |
}
|
1256 |
|
1257 |
-
self::$max_num_pages
|
1258 |
-
self::$post_count
|
1259 |
-
self::$wp_query
|
1260 |
|
1261 |
wp_reset_postdata();
|
1262 |
|
1263 |
-
$image_size
|
1264 |
-
$gravatar_size
|
|
|
|
|
1265 |
|
1266 |
-
$testimonial_data = array();
|
1267 |
-
|
1268 |
if ( empty( self::$post_count ) )
|
1269 |
return $testimonial_data;
|
1270 |
|
1271 |
-
foreach( $testimonials->posts as $row ) {
|
1272 |
-
$post_id
|
1273 |
|
1274 |
-
$email
|
1275 |
|
1276 |
if ( has_post_thumbnail( $post_id ) ) {
|
1277 |
-
$image
|
1278 |
} elseif ( ! $hide_gravatar && is_email( $email ) ) {
|
1279 |
-
$image
|
1280 |
} else {
|
1281 |
-
$image
|
1282 |
}
|
1283 |
|
1284 |
-
$url
|
1285 |
-
if ( ! empty( $url ) && 0 === preg_match(
|
1286 |
-
$url
|
1287 |
}
|
1288 |
|
1289 |
-
$data
|
1290 |
-
'post_id'
|
1291 |
-
'testimonial_company'
|
1292 |
-
'testimonial_content'
|
1293 |
-
'testimonial_email'
|
1294 |
-
'testimonial_extra'
|
1295 |
-
'testimonial_image'
|
1296 |
-
'testimonial_location'
|
1297 |
-
'testimonial_source'
|
1298 |
-
'testimonial_title'
|
1299 |
-
'testimonial_url'
|
1300 |
);
|
1301 |
|
1302 |
-
$testimonial_data[]
|
1303 |
}
|
1304 |
|
1305 |
-
$testimonial_data
|
1306 |
|
1307 |
return $testimonial_data;
|
1308 |
}
|
1309 |
|
1310 |
|
1311 |
public function posts_results_sort_none( $posts, $query ) {
|
1312 |
-
$order
|
1313 |
if ( empty( $order ) )
|
1314 |
return $posts;
|
1315 |
|
1316 |
-
$posts_none_sorted
|
1317 |
// put posts in same orders as post__in
|
1318 |
-
foreach( $order as $id ) {
|
1319 |
-
foreach( $posts as $key => $post ) {
|
1320 |
if ( $id == $post->ID ) {
|
1321 |
-
$posts_none_sorted[]
|
1322 |
unset( $posts[$key] );
|
1323 |
}
|
1324 |
}
|
@@ -1329,58 +1397,63 @@ EOF;
|
|
1329 |
|
1330 |
|
1331 |
public function widgets_init() {
|
1332 |
-
require_once 'lib/testimonials-widget-widget.php';
|
1333 |
|
1334 |
register_widget( 'Testimonials_Widget_Widget' );
|
1335 |
}
|
1336 |
|
1337 |
|
|
|
|
|
|
|
|
|
|
|
1338 |
public function add_meta_box_testimonials_widget() {
|
1339 |
-
require_once
|
1340 |
-
|
1341 |
-
$fields = array(
|
1342 |
-
array(
|
1343 |
-
'name' => __( 'Title', 'testimonials-widget' ),
|
1344 |
-
'id' => 'testimonials-widget-title',
|
1345 |
-
'type' => 'text',
|
1346 |
-
'desc' => '',
|
1347 |
-
),
|
1348 |
-
array(
|
1349 |
-
'name' => __( 'Location', 'testimonials-widget' ),
|
1350 |
-
'id' => 'testimonials-widget-location',
|
1351 |
-
'type' => 'text',
|
1352 |
-
'desc' => '',
|
1353 |
-
),
|
1354 |
-
array(
|
1355 |
-
'name' => __( 'Email', 'testimonials-widget' ),
|
1356 |
-
'id' => 'testimonials-widget-email',
|
1357 |
-
'type' => 'text',
|
1358 |
-
'desc' => '',
|
1359 |
-
),
|
1360 |
-
array(
|
1361 |
-
'name' => __( 'Company', 'testimonials-widget' ),
|
1362 |
-
'id' => 'testimonials-widget-company',
|
1363 |
-
'type' => 'text',
|
1364 |
-
'desc' => '',
|
1365 |
-
),
|
1366 |
-
array(
|
1367 |
-
'name' => __( 'URL', 'testimonials-widget' ),
|
1368 |
-
'id' => 'testimonials-widget-url',
|
1369 |
-
'type' => 'text',
|
1370 |
-
'desc' => '',
|
1371 |
-
),
|
1372 |
-
);
|
1373 |
|
1374 |
-
$fields
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1375 |
|
1376 |
-
$
|
1377 |
-
|
|
|
|
|
1378 |
array(
|
1379 |
-
'title'
|
1380 |
-
'description'
|
1381 |
-
'_object_types'
|
1382 |
-
'priority'
|
1383 |
-
'_fields'
|
1384 |
)
|
1385 |
);
|
1386 |
}
|
@@ -1391,7 +1464,7 @@ EOF;
|
|
1391 |
*
|
1392 |
* Original author: Travis Ballard http://www.travisballard.com
|
1393 |
*
|
1394 |
-
* @param string
|
1395 |
* @return string $translation
|
1396 |
*/
|
1397 |
public function gettext_testimonials( $translation ) {
|
@@ -1399,8 +1472,8 @@ EOF;
|
|
1399 |
|
1400 |
global $post;
|
1401 |
|
1402 |
-
if ( is_object( $post ) && self::
|
1403 |
-
switch( $translation ) {
|
1404 |
case __( 'Enter title here', 'testimonials-widget' ):
|
1405 |
return __( 'Enter testimonial source here', 'testimonials-widget' );
|
1406 |
break;
|
@@ -1418,23 +1491,24 @@ EOF;
|
|
1418 |
*
|
1419 |
* Original author: Travis Ballard http://www.travisballard.com
|
1420 |
*
|
1421 |
-
* @
|
|
|
1422 |
* @return mixed $m
|
1423 |
*/
|
1424 |
public function post_updated_messages( $m ) {
|
1425 |
global $post;
|
1426 |
|
1427 |
-
$m[ self::
|
1428 |
0 => '', // Unused. Messages start at index 1.
|
1429 |
1 => sprintf( __( 'Testimonial updated. <a href="%s">View testimonial</a>', 'testimonials-widget' ), esc_url( get_permalink( $post->ID ) ) ),
|
1430 |
2 => __( 'Custom field updated.', 'testimonials-widget' ),
|
1431 |
3 => __( 'Custom field deleted.', 'testimonials-widget' ),
|
1432 |
4 => __( 'Testimonial updated.', 'testimonials-widget' ),
|
1433 |
/* translators: %s: date and time of the revision */
|
1434 |
-
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Testimonial restored to revision from %s', 'testimonials-widget' ), wp_post_revision_title( (int)$_GET['revision'], false ) ) : false,
|
1435 |
6 => sprintf( __( 'Testimonial published. <a href="%s">View testimonial</a>', 'testimonials-widget' ), esc_url( get_permalink( $post->ID ) ) ),
|
1436 |
7 => __( 'Testimonial saved.', 'testimonials-widget' ),
|
1437 |
-
8 => sprintf( __( 'Testimonial submitted. <a target="_blank" href="%s">Preview testimonial</a>', 'testimonials-widget' ), esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) ),
|
1438 |
9 => sprintf( __( 'Testimonial scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview testimonial</a>', 'testimonials-widget' ), date_i18n( 'M j, Y @ G:i', strtotime( $post->post_date ) ), esc_url( get_permalink( $post->ID ) ) ),
|
1439 |
10 => sprintf( __( 'Testimonial draft updated. <a target="_blank" href="%s">Preview testimonial</a>', 'testimonials-widget' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) )
|
1440 |
);
|
@@ -1442,10 +1516,11 @@ EOF;
|
|
1442 |
return $m;
|
1443 |
}
|
1444 |
|
|
|
1445 |
}
|
1446 |
|
1447 |
|
1448 |
-
$Testimonials_Widget
|
1449 |
|
1450 |
|
1451 |
function testimonialswidget_list( $atts = array() ) {
|
@@ -1461,4 +1536,5 @@ function testimonialswidget_widget( $atts = array(), $widget_number = null ) {
|
|
1461 |
return $Testimonials_Widget->testimonialswidget_widget( $atts, $widget_number );
|
1462 |
}
|
1463 |
|
|
|
1464 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Plugin Name: Testimonials Widget
|
4 |
+
* Plugin URI: http://wordpress.org/extend/plugins/testimonials-widget/
|
5 |
+
* Description: Testimonials Widget plugin allows you to display random or selected portfolio, quotes, reviews, showcases, or text with images on your WordPress blog.
|
6 |
+
* Version: 2.12.0
|
7 |
+
* Author: Michael Cannon
|
8 |
+
* Author URI: http://aihr.us/about-aihrus/michael-cannon-resume/
|
9 |
+
* License: GPLv2 or later
|
10 |
*/
|
11 |
/**
|
12 |
+
* Copyright 2013 Michael Cannon (email: mc@aihr.us)
|
13 |
+
* This program is free software; you can redistribute it and/or modify
|
14 |
+
* it under the terms of the GNU General Public License, version 2, as
|
15 |
+
* published by the Free Software Foundation.
|
16 |
+
* This program is distributed in the hope that it will be useful,
|
17 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
+
* GNU General Public License for more details.
|
20 |
+
* You should have received a copy of the GNU General Public License
|
21 |
+
* along with this program; if not, write to the Free Software
|
22 |
+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
23 |
*/
|
24 |
|
25 |
|
26 |
+
require_once 'lib/class-settings-testimonials-widget.php';
|
27 |
|
28 |
|
29 |
class Testimonials_Widget {
|
30 |
+
const ID = 'testimonials-widget-testimonials';
|
31 |
+
const OLD_NAME = 'testimonialswidget';
|
32 |
+
const PT = 'testimonials-widget';
|
33 |
+
const VERSION = '2.12.0';
|
34 |
+
|
35 |
+
private static $base = null;
|
36 |
+
private static $max_num_pages = 0;
|
37 |
+
private static $post_count = 0;
|
38 |
+
private static $wp_query = null;
|
39 |
+
|
40 |
+
public static $css = array();
|
41 |
+
public static $css_called = false;
|
42 |
+
public static $instance_number = 0;
|
43 |
+
public static $scripts = array();
|
44 |
+
public static $scripts_called = false;
|
45 |
+
public static $settings_link = '';
|
46 |
+
public static $tag_close_quote = '<span class="close-quote"></span>';
|
47 |
+
public static $tag_open_quote = '<span class="open-quote"></span>';
|
48 |
+
public static $widget_number = 100000;
|
49 |
|
50 |
|
51 |
public function __construct() {
|
54 |
add_action( 'widgets_init', array( &$this, 'widgets_init' ) );
|
55 |
add_shortcode( 'testimonialswidget_list', array( &$this, 'testimonialswidget_list' ) );
|
56 |
add_shortcode( 'testimonialswidget_widget', array( &$this, 'testimonialswidget_widget' ) );
|
57 |
+
load_plugin_textdomain( self::PT, false, 'testimonials-widget/languages' );
|
58 |
register_activation_hook( __FILE__, array( &$this, 'activation' ) );
|
59 |
register_deactivation_hook( __FILE__, array( &$this, 'deactivation' ) );
|
60 |
register_uninstall_hook( __FILE__, array( 'Testimonials_Widget', 'uninstall' ) );
|
62 |
|
63 |
|
64 |
public function admin_init() {
|
65 |
+
self::$settings_link = '<a href="' . get_admin_url() . 'edit.php?post_type=' . Testimonials_Widget::PT . '&page=' . Testimonials_Widget_Settings::ID . '">' . __( 'Settings', 'testimonials-widget' ) . '</a>';
|
66 |
|
67 |
$this->add_meta_box_testimonials_widget();
|
68 |
$this->update();
|
69 |
add_action( 'gettext', array( &$this, 'gettext_testimonials' ) );
|
70 |
+
add_action( 'manage_' . self::PT . '_posts_custom_column', array( &$this, 'manage_testimonialswidget_posts_custom_column' ), 10, 2 );
|
71 |
+
add_filter( 'manage_' . self::PT . '_posts_columns', array( &$this, 'manage_edit_testimonialswidget_columns' ) );
|
72 |
add_filter( 'plugin_action_links', array( &$this, 'plugin_action_links' ), 10, 2 );
|
73 |
+
add_filter( 'plugin_row_meta', array( &$this, 'plugin_row_meta' ), 10, 2 );
|
74 |
add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
|
75 |
add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts_author' ) );
|
76 |
self::support_thumbnails();
|
79 |
|
80 |
public function init() {
|
81 |
add_filter( 'the_content', array( &$this, 'get_single' ) );
|
82 |
+
self::$base = plugin_basename( __FILE__ );
|
83 |
self::init_post_type();
|
84 |
self::styles();
|
85 |
}
|
105 |
|
106 |
|
107 |
public static function support_thumbnails() {
|
108 |
+
$feature = 'post-thumbnails';
|
109 |
+
$feature_level = get_theme_support( $feature );
|
110 |
|
111 |
if ( true === $feature_level ) {
|
112 |
// already enabled for all post types
|
113 |
return;
|
114 |
} elseif ( false === $feature_level ) {
|
115 |
// none allowed, only enable for our own
|
116 |
+
add_theme_support( $feature, array( self::PT ) );
|
117 |
} else {
|
118 |
// add our own to list of supported
|
119 |
+
$feature_level[0][] = self::PT;
|
120 |
add_theme_support( $feature, $feature_level[0] );
|
121 |
}
|
122 |
}
|
125 |
public function get_single( $content ) {
|
126 |
global $post;
|
127 |
|
128 |
+
if ( ! is_single() || self::PT != $post->post_type )
|
129 |
return $content;
|
130 |
|
131 |
+
$atts = self::get_defaults( true );
|
132 |
+
$atts['hide_content'] = 1;
|
133 |
+
$atts['ids'] = $post->ID;
|
134 |
+
$atts['type'] = 'get_single';
|
135 |
|
136 |
+
$testimonials = self::get_testimonials( $atts );
|
137 |
+
$testimonial = $testimonials[0];
|
138 |
|
139 |
+
$details = self::get_testimonial_html( $testimonial, $atts );
|
140 |
+
$details = apply_filters( 'testimonials_widget_testimonial_html_single', $details, $testimonial, $atts );
|
141 |
+
$content = apply_filters( 'testimonials_widget_testimonial_html_single_content', $content, $testimonial, $atts );
|
142 |
|
143 |
return $content . $details;
|
144 |
}
|
145 |
|
146 |
|
147 |
+
/**
|
148 |
+
*
|
149 |
+
*
|
150 |
+
* @SuppressWarnings(PHPMD.Superglobals)
|
151 |
+
*/
|
152 |
public function activation() {
|
153 |
if ( ! current_user_can( 'activate_plugins' ) )
|
154 |
return;
|
156 |
$plugin = isset( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '';
|
157 |
check_admin_referer( "activate-plugin_{$plugin}" );
|
158 |
|
|
|
|
|
159 |
self::init();
|
160 |
|
161 |
flush_rewrite_rules();
|
162 |
}
|
163 |
|
164 |
|
165 |
+
/**
|
166 |
+
*
|
167 |
+
*
|
168 |
+
* @SuppressWarnings(PHPMD.Superglobals)
|
169 |
+
*/
|
170 |
public function deactivation() {
|
171 |
if ( ! current_user_can( 'activate_plugins' ) )
|
172 |
return;
|
179 |
|
180 |
|
181 |
function notice_uninstall() {
|
182 |
+
$content = '';
|
183 |
+
$content .= '<div class="error"><p>';
|
184 |
+
$content .= __( 'Deleting Testimonials Widget plugin will remove all data and settings.', 'testimonials-widget' );
|
185 |
+
$content .= '</p></div>';
|
186 |
|
187 |
echo $content;
|
188 |
}
|
199 |
|
200 |
global $wpdb;
|
201 |
|
202 |
+
$delete_data = tw_get_option( 'delete_data', false );
|
203 |
+
if ( $delete_data ) {
|
204 |
+
delete_option( Testimonials_Widget_Settings::ID );
|
205 |
+
$wpdb->query( 'OPTIMIZE TABLE `' . $wpdb->options . '`' );
|
206 |
|
207 |
+
self::delete_testimonials();
|
208 |
+
}
|
|
|
209 |
}
|
210 |
|
211 |
|
212 |
public static function delete_testimonials() {
|
213 |
global $wpdb;
|
214 |
|
215 |
+
$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::PT . "'";
|
216 |
+
$posts = $wpdb->get_results( $query );
|
217 |
|
218 |
+
foreach ( $posts as $post ) {
|
219 |
+
$post_id = $post->ID;
|
220 |
self::delete_attachments( $post_id );
|
221 |
|
222 |
// dels post, meta & comments
|
223 |
// true is force delete
|
224 |
wp_delete_post( $post_id, true );
|
225 |
}
|
226 |
+
|
227 |
+
$wpdb->query( 'OPTIMIZE TABLE `' . $wpdb->postmeta . '`' );
|
228 |
+
$wpdb->query( 'OPTIMIZE TABLE `' . $wpdb->posts . '`' );
|
229 |
}
|
230 |
|
231 |
|
232 |
public static function delete_attachments( $post_id = false ) {
|
233 |
global $wpdb;
|
234 |
|
235 |
+
$post_id = $post_id ? $post_id : 0;
|
236 |
+
$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_parent = {$post_id}";
|
237 |
+
$attachments = $wpdb->get_results( $query );
|
238 |
|
239 |
+
foreach ( $attachments as $attachment ) {
|
240 |
// true is force delete
|
241 |
wp_delete_attachment( $attachment->ID, true );
|
242 |
}
|
247 |
if ( $file != self::$base ) {
|
248 |
return $input;
|
249 |
}
|
250 |
+
|
251 |
+
$links = array(
|
252 |
'<a href="http://aihr.us/about-aihrus/donate/">Donate</a>',
|
253 |
+
'<a href="http://aihr.us/testimonials-widget-premium/">Purchase Testimonials Widget Premium</a>',
|
254 |
);
|
255 |
|
256 |
+
$input = array_merge( $input, $links );
|
257 |
+
|
258 |
return $input;
|
259 |
}
|
260 |
|
261 |
|
262 |
+
public function admin_notices() {
|
263 |
+
$content = '';
|
264 |
+
$content .= '<div class="error"><p>';
|
265 |
+
$content .= sprintf( __( 'Testimonials Widget has updated CSS naming and HTML5 layout options. Please <a href="%s">read the FAQ</a> to make fixes if your testimonials display is funky', 'testimonials-widget-premium', 'testimonials-widget' ), 'http://wordpress.org/extend/plugins/testimonials-widget/faq/' );
|
266 |
+
$content .= '</p></div>';
|
267 |
+
|
268 |
+
echo $content;
|
269 |
+
}
|
270 |
+
|
271 |
+
|
272 |
public function update() {
|
273 |
+
$admin_notices = tw_get_option( 'admin_notices' );
|
274 |
+
if ( $admin_notices ) {
|
275 |
+
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
276 |
+
tw_set_option( 'admin_notices' );
|
277 |
+
}
|
278 |
+
|
279 |
+
$options = get_option( self::OLD_NAME );
|
280 |
|
281 |
// testimonials already migrated?
|
282 |
+
if ( true !== $options['migrated'] )
|
283 |
+
$this->migrate();
|
284 |
+
}
|
285 |
|
286 |
+
|
287 |
+
public function migrate() {
|
288 |
global $wpdb;
|
289 |
|
290 |
+
$table_name = $wpdb->prefix . self::OLD_NAME;
|
291 |
+
$meta_key = '_' . self::PT . ':testimonial_id';
|
292 |
|
293 |
// check that db table exists and has entries
|
294 |
+
$query = 'SELECT `testimonial_id`, `testimonial`, `author`, `source`, `tags`, `public`, `time_added`, `time_updated` FROM `' . $table_name . '`';
|
295 |
|
296 |
// ignore already imported
|
297 |
+
$done_import_query = 'SELECT meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_key = "' . $meta_key . '"';
|
298 |
+
$done_import = $wpdb->get_col( $done_import_query );
|
299 |
|
300 |
if ( ! empty( $done_import ) ) {
|
301 |
+
$done_import = array_unique( $done_import );
|
302 |
+
$query .= ' WHERE testimonial_id NOT IN ( ' . implode( ',', $done_import ) . ' )';
|
303 |
}
|
304 |
|
305 |
+
$results = $wpdb->get_results( $query );
|
306 |
+
if ( ! empty( $results ) ) {
|
307 |
foreach ( $results as $result ) {
|
308 |
// author can contain title and company details
|
309 |
+
$author = $result->author;
|
310 |
+
$company = false;
|
311 |
|
312 |
// ex: First Last of Company!
|
313 |
+
$author = str_replace( ' of ', ', ', $author );
|
314 |
// now ex: First Last, Company!
|
315 |
|
316 |
// ex: First Last, Company
|
317 |
// ex: First Last, Web Development Manager, Topcon Positioning Systems, Inc.
|
318 |
// ex: First Last, Owner, Company, LLC
|
319 |
+
$author = str_replace( ' of ', ', ', $author );
|
320 |
+
$temp_comma = '^^^';
|
321 |
+
$author = str_replace( ', LLC', $temp_comma . ' LLC', $author );
|
322 |
+
|
323 |
// now ex: First Last, Owner, Company^^^ LLC
|
324 |
+
$author = str_replace( ', Inc', $temp_comma . ' Inc', $author );
|
325 |
+
|
326 |
// ex: First Last, Web Development Manager, Company^^^ Inc.
|
327 |
// it's possible to have "Michael Cannon, Senior Developer" and "Senior Developer" become the company. Okay for now
|
328 |
+
$author = explode( ', ', $author );
|
329 |
|
330 |
if ( 1 < count( $author ) ) {
|
331 |
+
$company = array_pop( $author );
|
332 |
+
$company = str_replace( $temp_comma, ',', $company );
|
333 |
}
|
334 |
|
335 |
+
$author = implode( ', ', $author );
|
336 |
+
$author = str_replace( $temp_comma, ',', $author );
|
337 |
+
|
338 |
+
$post_data = array(
|
339 |
+
'post_type' => self::PT,
|
340 |
+
'post_status' => ( 'yes' == $result->public ) ? 'publish' : 'private',
|
341 |
+
'post_date' => $result->time_added,
|
342 |
+
'post_modified' => $result->time_updated,
|
343 |
+
'post_title' => $author,
|
344 |
+
'post_content' => $result->testimonial,
|
345 |
+
'tags_input' => $result->tags,
|
346 |
);
|
347 |
|
348 |
+
$post_id = wp_insert_post( $post_data, true );
|
349 |
|
350 |
// track/link testimonial import to new post
|
351 |
add_post_meta( $post_id, $meta_key, $result->testimonial_id );
|
354 |
add_post_meta( $post_id, 'testimonials-widget-company', $company );
|
355 |
}
|
356 |
|
357 |
+
$source = $result->source;
|
358 |
if ( ! empty( $source ) ) {
|
359 |
if ( is_email( $source ) ) {
|
360 |
add_post_meta( $post_id, 'testimonials-widget-email', $source );
|
365 |
}
|
366 |
}
|
367 |
|
368 |
+
$options['migrated'] = true;
|
369 |
+
delete_option( self::OLD_NAME );
|
370 |
+
add_option( self::OLD_NAME, $options, null, 'no' );
|
371 |
}
|
372 |
|
373 |
|
375 |
global $user_ID;
|
376 |
|
377 |
// author's and below
|
378 |
+
if ( $query->is_admin && ! empty( $query->is_main_query ) && $query->is_post_type_archive( Testimonials_Widget::PT ) && ! current_user_can( 'edit_others_posts' ) )
|
379 |
$query->set( 'post_author', $user_ID );
|
380 |
|
381 |
return $query;
|
383 |
|
384 |
|
385 |
public function manage_testimonialswidget_posts_custom_column( $column, $post_id ) {
|
386 |
+
$result = false;
|
387 |
|
388 |
switch ( $column ) {
|
389 |
case 'shortcode':
|
390 |
+
$result = '[testimonialswidget_list ids="';
|
391 |
+
$result .= $post_id;
|
392 |
+
$result .= '"]';
|
393 |
+
$result .= '<br />';
|
394 |
+
$result .= '[testimonialswidget_widget ids="';
|
395 |
+
$result .= $post_id;
|
396 |
+
$result .= '"]';
|
397 |
break;
|
398 |
|
399 |
case 'testimonials-widget-company':
|
400 |
case 'testimonials-widget-location':
|
401 |
case 'testimonials-widget-title':
|
402 |
+
$result = get_post_meta( $post_id, $column, true );
|
403 |
break;
|
404 |
|
405 |
case 'testimonials-widget-email':
|
406 |
case 'testimonials-widget-url':
|
407 |
+
$url = get_post_meta( $post_id, $column, true );
|
408 |
+
if ( ! empty( $url ) && ! is_email( $url ) && 0 === preg_match( '#https?://#', $url ) ) {
|
409 |
+
$url = 'http://' . $url;
|
410 |
}
|
411 |
|
412 |
+
$result = make_clickable( $url );
|
413 |
break;
|
414 |
|
415 |
case 'thumbnail':
|
416 |
+
$email = get_post_meta( $post_id, 'testimonials-widget-email', true );
|
417 |
|
418 |
if ( has_post_thumbnail( $post_id ) ) {
|
419 |
+
$result = get_the_post_thumbnail( $post_id, 'thumbnail' );
|
420 |
} elseif ( is_email( $email ) ) {
|
421 |
+
$result = get_avatar( $email );
|
422 |
} else {
|
423 |
+
$result = false;
|
424 |
}
|
425 |
break;
|
426 |
}
|
427 |
|
428 |
+
$result = apply_filters( 'testimonials_widget_posts_custom_column', $result, $column, $post_id );
|
429 |
|
430 |
if ( $result )
|
431 |
echo $result;
|
434 |
|
435 |
public function manage_edit_testimonialswidget_columns( $columns ) {
|
436 |
// order of keys matches column ordering
|
437 |
+
$columns = array(
|
438 |
+
'cb' => '<input type="checkbox" />',
|
439 |
+
'thumbnail' => __( 'Image', 'testimonials-widget' ),
|
440 |
+
'title' => __( 'Source', 'testimonials-widget' ),
|
441 |
+
'shortcode' => __( 'Shortcodes', 'testimonials-widget' ),
|
442 |
+
'testimonials-widget-title' => __( 'Title', 'testimonials-widget' ),
|
443 |
+
'testimonials-widget-location' => __( 'Location', 'testimonials-widget' ),
|
444 |
+
'testimonials-widget-email' => __( 'Email', 'testimonials-widget' ),
|
445 |
+
'testimonials-widget-company' => __( 'Company', 'testimonials-widget' ),
|
446 |
+
'testimonials-widget-url' => __( 'URL', 'testimonials-widget' ),
|
447 |
+
'author' => __( 'Published by', 'testimonials-widget' ),
|
448 |
+
'categories' => __( 'Category', 'testimonials-widget' ),
|
449 |
+
'tags' => __( 'Tags', 'testimonials-widget' ),
|
450 |
+
'date' => __( 'Date', 'testimonials-widget' ),
|
451 |
);
|
452 |
|
453 |
+
$columns = apply_filters( 'testimonials_widget_columns', $columns );
|
454 |
|
455 |
return $columns;
|
456 |
}
|
458 |
|
459 |
public function init_post_type() {
|
460 |
$labels = array(
|
461 |
+
'add_new' => __( 'Add New', 'testimonials-widget' ),
|
462 |
+
'add_new_item' => __( 'Add New Testimonial', 'testimonials-widget' ),
|
463 |
+
'edit_item' => __( 'Edit Testimonial', 'testimonials-widget' ),
|
464 |
+
'name' => __( 'Testimonials', 'testimonials-widget' ),
|
465 |
+
'new_item' => __( 'Add New Testimonial', 'testimonials-widget' ),
|
466 |
+
'not_found' => __( 'No testimonials found', 'testimonials-widget' ),
|
467 |
+
'not_found_in_trash' => __( 'No testimonials found in Trash', 'testimonials-widget' ),
|
468 |
+
'parent_item_colon' => null,
|
469 |
+
'search_items' => __( 'Search Testimonials', 'testimonials-widget' ),
|
470 |
+
'singular_name' => __( 'Testimonial', 'testimonials-widget' ),
|
471 |
+
'view_item' => __( 'View Testimonial', 'testimonials-widget' ),
|
472 |
);
|
473 |
+
|
474 |
+
$supports = array(
|
475 |
'title',
|
476 |
'editor',
|
477 |
'thumbnail',
|
478 |
);
|
479 |
|
480 |
+
$allow_comments = tw_get_option( 'allow_comments', false );
|
481 |
if ( $allow_comments )
|
482 |
+
$supports[] = 'comments';
|
483 |
|
484 |
+
$has_archive = tw_get_option( 'has_archive', true );
|
485 |
+
$rewrite_slug = tw_get_option( 'rewrite_slug', 'testimonial' );
|
486 |
|
487 |
// editor's and up
|
488 |
+
if ( current_user_can( 'edit_others_posts' ) )
|
489 |
+
$supports[] = 'author';
|
490 |
|
491 |
$args = array(
|
492 |
+
'label' => __( 'Testimonials', 'testimonials-widget' ),
|
493 |
+
'capability_type' => 'post',
|
494 |
+
'has_archive' => $has_archive,
|
495 |
+
'hierarchical' => false,
|
496 |
+
'labels' => $labels,
|
497 |
+
'public' => true,
|
498 |
+
'publicly_queryable' => true,
|
499 |
+
'query_var' => true,
|
500 |
+
'rewrite' => array(
|
501 |
+
'slug' => $rewrite_slug,
|
502 |
+
'with_front' => false,
|
503 |
),
|
504 |
+
'show_in_menu' => true,
|
505 |
+
'show_ui' => true,
|
506 |
+
'supports' => $supports,
|
507 |
+
'taxonomies' => array(
|
508 |
'category',
|
509 |
'post_tag',
|
510 |
)
|
511 |
);
|
512 |
|
513 |
+
register_post_type( Testimonials_Widget::PT, $args );
|
514 |
}
|
515 |
|
516 |
|
526 |
public function testimonialswidget_list( $atts ) {
|
527 |
self::add_instance();
|
528 |
|
529 |
+
$atts = wp_parse_args( $atts, self::get_defaults() );
|
530 |
+
$atts = Testimonials_Widget_Settings::validate_settings( $atts );
|
531 |
|
532 |
+
if ( get_query_var( 'paged' ) ) {
|
533 |
+
$atts['paged'] = get_query_var( 'paged' );
|
534 |
+
} elseif ( get_query_var( 'page' ) ) {
|
535 |
+
$atts['paged'] = get_query_var( 'page' );
|
536 |
} else {
|
537 |
+
$atts['paged'] = 1;
|
538 |
}
|
539 |
|
540 |
+
$atts['type'] = 'testimonialswidget_list';
|
541 |
|
542 |
+
$content = apply_filters( 'testimonials_widget_cache_get', false, $atts );
|
543 |
|
544 |
if ( false === $content ) {
|
545 |
+
$testimonials = self::get_testimonials( $atts );
|
546 |
+
$content = self::get_testimonials_html( $testimonials, $atts );
|
547 |
+
$content = apply_filters( 'testimonials_widget_cache_set', $content, $atts );
|
548 |
}
|
549 |
|
550 |
return $content;
|
556 |
self::scripts();
|
557 |
|
558 |
if ( empty( $widget_number ) ) {
|
559 |
+
$widget_number = self::$widget_number++;
|
560 |
|
561 |
if ( empty( $atts['random'] ) )
|
562 |
+
$atts['random'] = 1;
|
563 |
}
|
564 |
+
$atts = wp_parse_args( $atts, self::get_defaults() );
|
565 |
+
$atts = Testimonials_Widget_Settings::validate_settings( $atts );
|
566 |
|
567 |
+
$atts['paging'] = false;
|
568 |
+
$atts['type'] = 'testimonialswidget_widget';
|
569 |
+
$atts['widget_number'] = $widget_number;
|
570 |
|
571 |
+
$testimonials = self::get_testimonials( $atts );
|
572 |
|
573 |
+
$content = apply_filters( 'testimonials_widget_cache_get', false, $atts );
|
574 |
|
575 |
if ( false === $content ) {
|
576 |
+
$content = self::get_testimonials_html( $testimonials, $atts, false, $widget_number );
|
577 |
+
$content = apply_filters( 'testimonials_widget_cache_set', $content, $atts );
|
578 |
}
|
579 |
|
580 |
// Generate CSS
|
581 |
+
$atts['type'] = 'testimonialswidget_widget_css';
|
582 |
+
$css = apply_filters( 'testimonials_widget_cache_get', false, $atts );
|
583 |
|
584 |
if ( false === $css ) {
|
585 |
+
$css = self::get_testimonials_html_css( $atts, $widget_number );
|
586 |
+
$css = apply_filters( 'testimonials_widget_cache_set', $css, $atts );
|
587 |
}
|
588 |
|
589 |
if ( ! empty( $css ) ) {
|
590 |
+
self::$css = array_merge( $css, self::$css );
|
591 |
add_action( 'wp_footer', array( 'Testimonials_Widget', 'get_testimonials_css' ), 20 );
|
592 |
}
|
593 |
|
594 |
// Generate JS
|
595 |
+
$atts['type'] = 'testimonialswidget_widget_js';
|
596 |
+
$js = apply_filters( 'testimonials_widget_cache_get', false, $atts );
|
597 |
|
598 |
if ( false === $js ) {
|
599 |
+
$js = self::get_testimonials_html_js( $testimonials, $atts, $widget_number );
|
600 |
+
$js = apply_filters( 'testimonials_widget_cache_set', $js, $atts );
|
601 |
}
|
602 |
|
603 |
if ( ! empty( $js ) ) {
|
604 |
+
self::$scripts = array_merge( $js, self::$scripts );
|
605 |
add_action( 'wp_footer', array( 'Testimonials_Widget', 'get_testimonials_scripts' ), 20 );
|
606 |
}
|
607 |
|
622 |
|
623 |
public static function get_testimonials_html_css( $atts, $widget_number = null ) {
|
624 |
// display attributes
|
625 |
+
$height = $atts['height'];
|
626 |
+
$max_height = $atts['max_height'];
|
627 |
+
$min_height = $atts['min_height'];
|
628 |
|
629 |
if ( $height ) {
|
630 |
+
$max_height = $height;
|
631 |
+
$min_height = $height;
|
632 |
}
|
633 |
|
634 |
+
$css = array();
|
635 |
+
$id_base = self::ID . $widget_number;
|
636 |
|
637 |
if ( $min_height ) {
|
638 |
+
$css[] = <<<EOF
|
639 |
<style>
|
640 |
.$id_base {
|
641 |
min-height: {$min_height}px;
|
645 |
}
|
646 |
|
647 |
if ( $max_height ) {
|
648 |
+
$css[] = <<<EOF
|
649 |
<style>
|
650 |
.$id_base {
|
651 |
max-height: {$max_height}px;
|
654 |
EOF;
|
655 |
}
|
656 |
|
657 |
+
$css = apply_filters( 'testimonials_widget_testimonials_css', $css, $atts, $widget_number );
|
658 |
|
659 |
return $css;
|
660 |
}
|
662 |
|
663 |
public static function get_testimonials_html_js( $testimonials, $atts, $widget_number = null ) {
|
664 |
// display attributes
|
665 |
+
$refresh_interval = $atts['refresh_interval'];
|
666 |
|
667 |
+
$id_base = self::ID . $widget_number;
|
668 |
+
$scripts = array();
|
669 |
|
670 |
if ( $refresh_interval && 1 < count( $testimonials ) ) {
|
671 |
+
$javascript = <<<EOF
|
672 |
<script type="text/javascript">
|
673 |
function nextTestimonial{$widget_number}() {
|
674 |
if ( ! jQuery('.{$id_base}').first().hasClass('hovered') ) {
|
675 |
var active = jQuery('.{$id_base} .active');
|
676 |
+
var next = (jQuery('.{$id_base} .active').next().length > 0) ? jQuery('.{$id_base} .active').next() : jQuery('.{$id_base} .testimonials-widget-testimonial:first');
|
677 |
active.fadeOut(1250, function(){
|
678 |
active.removeClass('active');
|
679 |
next.fadeIn(500);
|
680 |
+
next.removeClass('display-none');
|
681 |
next.addClass('active');
|
682 |
});
|
683 |
}
|
694 |
</script>
|
695 |
EOF;
|
696 |
|
697 |
+
$scripts[ $id_base ] = $javascript;
|
698 |
}
|
699 |
|
700 |
+
$scripts = apply_filters( 'testimonials_widget_testimonials_js', $scripts, $testimonials, $atts, $widget_number );
|
701 |
|
702 |
return $scripts;
|
703 |
}
|
704 |
|
705 |
|
706 |
+
public static function get_testimonials_html( $testimonials, $atts, $is_list = true, $widget_number = null ) {
|
707 |
// display attributes
|
708 |
+
$hide_not_found = $atts['hide_not_found'];
|
709 |
+
$paging = Testimonials_Widget_Settings::is_true( $atts['paging'] );
|
710 |
+
$paging_before = ( 'before' === strtolower( $atts['paging'] ) );
|
711 |
+
$paging_after = ( 'after' === strtolower( $atts['paging'] ) );
|
712 |
+
$target = $atts['target'];
|
|
|
713 |
|
714 |
+
$html = '';
|
715 |
+
$id = self::ID;
|
716 |
|
717 |
if ( is_null( $widget_number ) ) {
|
718 |
+
$html .= '<div class="' . $id;
|
719 |
|
720 |
if ( $is_list )
|
721 |
+
$html .= ' listing';
|
722 |
|
723 |
+
$html .= '">';
|
724 |
} else {
|
725 |
+
$id_base = $id . $widget_number;
|
726 |
+
$html .= '<div class="' . $id . ' ' . $id_base . '">';
|
727 |
}
|
728 |
|
729 |
if ( empty( $testimonials ) && ! $hide_not_found ) {
|
730 |
+
$testimonials = array(
|
731 |
+
array( 'testimonial_content' => __( 'No testimonials found', 'testimonials-widget' ) ),
|
732 |
);
|
733 |
}
|
734 |
+
|
735 |
if ( $paging || $paging_before ) {
|
736 |
+
$html .= self::get_testimonials_paging( $atts );
|
737 |
+
}
|
738 |
|
739 |
+
$is_first = true;
|
740 |
|
741 |
foreach ( $testimonials as $testimonial ) {
|
742 |
+
$content = self::get_testimonial_html( $testimonial, $atts, $is_list, $is_first, $widget_number );
|
743 |
+
$content = apply_filters( 'testimonials_widget_testimonial_html', $content, $testimonial, $atts, $is_list, $is_first, $widget_number );
|
744 |
+
$html .= $content;
|
745 |
+
$is_first = false;
|
746 |
+
}
|
747 |
|
748 |
if ( $paging || $paging_after ) {
|
749 |
+
$html .= self::get_testimonials_paging( $atts, false );
|
750 |
+
}
|
751 |
|
752 |
+
$html .= '</div>';
|
753 |
|
754 |
if ( $target )
|
755 |
+
$html = links_add_target( $html, $target );
|
756 |
|
757 |
return $html;
|
758 |
}
|
759 |
|
760 |
|
761 |
+
public static function get_testimonial_html( $testimonial, $atts, $is_list = true, $is_first = false, $widget_number = null ) {
|
762 |
// display attributes
|
763 |
+
$disable_quotes = $atts['disable_quotes'];
|
764 |
+
$do_image = ! $atts['hide_image'] && ! empty( $testimonial['testimonial_image'] );
|
765 |
+
$do_image_single = ! $atts['hide_image_single'];
|
766 |
+
$keep_whitespace = $atts['keep_whitespace'];
|
767 |
+
$remove_hentry = $atts['remove_hentry'];
|
768 |
+
|
769 |
+
$class = 'testimonials-widget-testimonial';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
770 |
|
771 |
if ( is_single() && empty( $widget_number ) ) {
|
772 |
+
$class .= ' single';
|
773 |
} elseif ( $is_list ) {
|
774 |
+
$class .= ' list';
|
775 |
} elseif ( $is_first ) {
|
776 |
+
$class .= ' active';
|
777 |
} elseif ( ! $is_first ) {
|
778 |
+
$class .= ' display-none';
|
779 |
}
|
780 |
|
781 |
if ( $keep_whitespace )
|
782 |
+
$class .= ' whitespace';
|
783 |
|
784 |
+
$div_open = '<div class="';
|
785 |
|
786 |
if ( ! empty( $testimonial['post_id'] ) )
|
787 |
+
$div_open .= join( ' ', get_post_class( $class, $testimonial['post_id'] ) );
|
788 |
else
|
789 |
+
$div_open .= 'testimonials-widget type-testimonials-widget status-publish hentry ' . $class;
|
790 |
|
791 |
+
$div_open .= '">';
|
792 |
|
793 |
if ( $remove_hentry )
|
794 |
+
$div_open = str_replace( ' hentry', '', $div_open );
|
795 |
|
796 |
+
$image = '';
|
797 |
if ( $do_image ) {
|
798 |
+
$image .= '<span class="image">';
|
799 |
+
$image .= $testimonial['testimonial_image'];
|
800 |
+
$image .= '</span>';
|
801 |
}
|
802 |
|
803 |
if ( ! $do_image_single && 'get_single' == $atts['type'] ) {
|
804 |
+
$image = '';
|
805 |
+
}
|
806 |
+
|
807 |
+
$quote = self::get_quote( $testimonial, $atts, $widget_number );
|
808 |
+
$cite = self::get_cite( $testimonial, $atts );
|
809 |
+
|
810 |
+
$extra = '';
|
811 |
+
if ( ! empty( $testimonial['testimonial_extra'] ) ) {
|
812 |
+
$extra .= '<div class="extra">';
|
813 |
+
$extra .= $testimonial['testimonial_extra'];
|
814 |
+
$extra .= '</div>';
|
815 |
}
|
816 |
|
817 |
+
$bottom_text = '';
|
818 |
+
|
819 |
+
if ( ! empty( $atts['bottom_text'] ) ) {
|
820 |
+
$bottom_text = '<div class="bottom_text">';
|
821 |
+
$bottom_text .= $atts['bottom_text'];
|
822 |
+
$bottom_text .= '</div>';
|
823 |
+
}
|
824 |
+
|
825 |
+
$div_close = '</div>';
|
826 |
+
|
827 |
+
$html = $div_open
|
828 |
+
. $image
|
829 |
+
. $quote
|
830 |
+
. $cite
|
831 |
+
. $extra
|
832 |
+
. $bottom_text
|
833 |
+
. $div_close;
|
834 |
+
|
835 |
+
$html = apply_filters( 'testimonials_widget_get_testimonial_html', $html, $testimonial, $atts, $is_list, $is_first, $widget_number, $div_open, $image, $quote, $cite, $extra, $bottom_text, $div_close );
|
836 |
+
|
837 |
+
// not done sooner as tag_close_quote is used for Premium
|
838 |
+
if ( $disable_quotes ) {
|
839 |
+
$html = str_replace( self::$tag_open_quote, '', $html );
|
840 |
+
$html = str_replace( self::$tag_close_quote, '', $html );
|
841 |
+
}
|
842 |
+
|
843 |
+
return $html;
|
844 |
+
}
|
845 |
+
|
846 |
+
|
847 |
+
public static function get_quote( $testimonial, $atts, $widget_number ) {
|
848 |
+
$char_limit = $atts['char_limit'];
|
849 |
+
$content_more = apply_filters( 'testimonials_widget_content_more', __( '…', 'testimonials-widget' ) );
|
850 |
+
$content_more .= self::$tag_close_quote;
|
851 |
+
$do_content = ! $atts['hide_content'] && ! empty( $testimonial['testimonial_content'] );
|
852 |
+
$use_quote_tag = $atts['use_quote_tag'];
|
853 |
+
|
854 |
+
$quote = '';
|
855 |
if ( $do_content ) {
|
856 |
+
$content = $testimonial['testimonial_content'];
|
857 |
+
$content = self::format_content( $content, $widget_number, $atts );
|
858 |
|
859 |
if ( $char_limit ) {
|
860 |
+
$content = self::testimonials_truncate( $content, $char_limit, $content_more );
|
861 |
+
$content = force_balance_tags( $content );
|
862 |
}
|
863 |
|
864 |
+
$content = apply_filters( 'testimonials_widget_content', $content, $widget_number, $testimonial, $atts );
|
865 |
+
$content = make_clickable( $content );
|
866 |
|
867 |
if ( empty( $use_quote_tag ) ) {
|
868 |
+
$quote = '<blockquote>';
|
869 |
+
$quote .= $content;
|
870 |
+
$quote .= '</blockquote>';
|
871 |
} else {
|
872 |
+
$quote = '<q>';
|
873 |
+
$quote .= $content;
|
874 |
+
$quote .= '</q>';
|
875 |
}
|
876 |
}
|
877 |
|
878 |
+
return $quote;
|
879 |
+
}
|
880 |
+
|
881 |
+
|
882 |
+
public static function get_cite( $testimonial, $atts ) {
|
883 |
+
$do_company = ! $atts['hide_company'] && ! empty( $testimonial['testimonial_company'] );
|
884 |
+
$do_email = ! $atts['hide_email'] && ! empty( $testimonial['testimonial_email'] ) && is_email( $testimonial['testimonial_email'] );
|
885 |
+
$do_location = ! $atts['hide_location'] && ! empty( $testimonial['testimonial_location'] );
|
886 |
+
$do_source = ! $atts['hide_source'] && ! empty( $testimonial['testimonial_source'] );
|
887 |
+
$do_title = ! $atts['hide_title'] && ! empty( $testimonial['testimonial_title'] );
|
888 |
+
$do_url = ! $atts['hide_url'] && ! empty( $testimonial['testimonial_url'] );
|
889 |
+
$use_quote_tag = $atts['use_quote_tag'];
|
890 |
+
|
891 |
+
$cite = '';
|
892 |
+
$done_url = false;
|
893 |
if ( $do_source && $do_email ) {
|
894 |
+
$cite .= '<span class="author">';
|
895 |
+
$cite .= '<a href="mailto:' . $testimonial['testimonial_email'] . '">';
|
896 |
+
$cite .= $testimonial['testimonial_source'];
|
897 |
+
$cite .= '</a>';
|
898 |
+
$cite .= '</span>';
|
899 |
} elseif ( $do_source && ! $do_company && $do_url ) {
|
900 |
+
$done_url = true;
|
901 |
+
|
902 |
+
$cite .= '<span class="author">';
|
903 |
+
$cite .= '<a href="' . $testimonial['testimonial_url'] . '" rel="nofollow">';
|
904 |
+
$cite .= $testimonial['testimonial_source'];
|
905 |
+
$cite .= '</a>';
|
906 |
+
$cite .= '</span>';
|
907 |
} elseif ( $do_source ) {
|
908 |
+
$cite .= '<span class="author">';
|
909 |
+
$cite .= $testimonial['testimonial_source'];
|
910 |
+
$cite .= '</span>';
|
911 |
} elseif ( $do_email ) {
|
912 |
+
$cite .= '<span class="email">';
|
913 |
+
$cite .= make_clickable( $testimonial['testimonial_email'] );
|
914 |
+
$cite .= '</span>';
|
915 |
}
|
916 |
|
917 |
if ( $do_title && $cite )
|
918 |
+
$cite .= '<span class="join-title"></span>';
|
919 |
+
|
920 |
|
921 |
if ( $do_title ) {
|
922 |
+
$cite .= '<span class="title">';
|
923 |
+
$cite .= $testimonial['testimonial_title'];
|
924 |
+
$cite .= '</span>';
|
925 |
}
|
926 |
|
927 |
if ( $do_location && $cite )
|
928 |
+
$cite .= '<span class="join-location"></span>';
|
929 |
|
930 |
if ( $do_location ) {
|
931 |
+
$cite .= '<span class="location">';
|
932 |
+
$cite .= $testimonial['testimonial_location'];
|
933 |
+
$cite .= '</span>';
|
934 |
}
|
935 |
|
936 |
if ( ( $do_company || ( $do_url && ! $done_url ) ) && $cite )
|
937 |
+
$cite .= '<span class="join"></span>';
|
938 |
|
939 |
if ( $do_company && $do_url ) {
|
940 |
+
$cite .= '<span class="company">';
|
941 |
+
$cite .= '<a href="' . $testimonial['testimonial_url'] . '" rel="nofollow">';
|
942 |
+
$cite .= $testimonial['testimonial_company'];
|
943 |
+
$cite .= '</a>';
|
944 |
+
$cite .= '</span>';
|
945 |
} elseif ( $do_company ) {
|
946 |
+
$cite .= '<span class="company">';
|
947 |
+
$cite .= $testimonial['testimonial_company'];
|
948 |
+
$cite .= '</span>';
|
949 |
} elseif ( $do_url && ! $done_url ) {
|
950 |
+
$cite .= '<span class="url">';
|
951 |
+
$cite .= make_clickable( $testimonial['testimonial_url'] );
|
952 |
+
$cite .= '</span>';
|
953 |
}
|
954 |
|
955 |
if ( ! empty( $cite ) ) {
|
956 |
if ( empty( $use_quote_tag ) ) {
|
957 |
+
$temp = '<div class="credit">';
|
958 |
+
$temp .= $cite;
|
959 |
+
$temp .= '</div>';
|
960 |
+
|
961 |
+
$cite = $temp;
|
962 |
} else {
|
963 |
+
$cite = '<cite>' . $cite . '</cite>';
|
964 |
}
|
965 |
}
|
966 |
|
967 |
+
return $cite;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
968 |
}
|
969 |
|
970 |
|
971 |
// Original PHP code as myTruncate2 by Chirp Internet: www.chirp.com.au
|
972 |
+
public static function testimonials_truncate( $string, $char_limit = false, $pad = '…', $force_pad = false ) {
|
973 |
if ( empty( $force_pad ) ) {
|
974 |
if ( empty( $char_limit ) )
|
975 |
return $string;
|
978 |
if ( strlen( $string ) <= $char_limit )
|
979 |
return $string;
|
980 |
}
|
981 |
+
|
982 |
if ( ! empty( $char_limit ) ) {
|
983 |
return self::truncate( $string, $char_limit, $pad, $force_pad );
|
984 |
}
|
991 |
* Truncate HTML, close opened tags. UTF-8 aware, and aware of unpaired tags
|
992 |
* (which don't need a matching closing tag)
|
993 |
*
|
994 |
+
* @param string $html
|
995 |
+
* @param int $max_length Maximum length of the characters of the string
|
996 |
+
* @param string $indicator Suffix to use if string was truncated.
|
997 |
* @param boolean $force_indicator Suffix to use if string was truncated.
|
998 |
* @return string
|
999 |
*
|
1000 |
* @ref http://pastie.org/3084080
|
1001 |
*/
|
1002 |
+
public static function truncate( $html, $max_length, $indicator = '…', $force_indicator = false ) {
|
|
|
1003 |
$output_length = 0; // number of counted characters stored so far in $output
|
1004 |
+
$position = 0; // character offset within input string after last tag/entity
|
1005 |
+
$tag_stack = array(); // stack of tags we've encountered but not closed
|
1006 |
+
$output = '';
|
1007 |
+
$truncated = false;
|
1008 |
|
1009 |
+
/**
|
1010 |
+
* these tags don't have matching closing elements, in HTML (in XHTML they
|
1011 |
* theoretically need a closing /> )
|
1012 |
+
*
|
1013 |
* @see http://www.netstrider.com/tutorials/HTMLRef/a_d.html
|
1014 |
* @see http://www.w3schools.com/tags/default.asp
|
1015 |
* @see http://stackoverflow.com/questions/3741896/what-do-you-call-tags-that-need-no-ending-tag
|
1016 |
*/
|
1017 |
+
$unpaired_tags = array(
|
1018 |
+
'doctype',
|
1019 |
+
'!doctype',
|
1020 |
+
'area',
|
1021 |
+
'base',
|
1022 |
+
'basefont',
|
1023 |
+
'bgsound',
|
1024 |
+
'br',
|
1025 |
+
'col',
|
1026 |
+
'embed',
|
1027 |
+
'frame',
|
1028 |
+
'hr',
|
1029 |
+
'img',
|
1030 |
+
'input',
|
1031 |
+
'link',
|
1032 |
+
'meta',
|
1033 |
+
'param',
|
1034 |
+
'sound',
|
1035 |
+
'spacer',
|
1036 |
+
'wbr',
|
1037 |
+
);
|
1038 |
|
1039 |
+
$func_strcut = function_exists( 'mb_strcut' ) ? 'mb_strcut' : 'substr';
|
1040 |
+
$func_strlen = function_exists( 'mb_strlen' ) ? 'mb_strlen' : 'strlen';
|
1041 |
|
1042 |
// loop through, splitting at HTML entities or tags
|
1043 |
+
while ( $output_length < $max_length && preg_match( '{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;}', $html, $match, PREG_OFFSET_CAPTURE, $position ) ) {
|
1044 |
+
list( $tag, $tag_position ) = $match[0];
|
1045 |
+
|
1046 |
+
// get text leading up to the tag, and store it – up to max_length
|
1047 |
+
$text = $func_strcut( $html, $position, $tag_position - $position );
|
1048 |
+
if ( $output_length + $func_strlen( $text ) > $max_length ) {
|
1049 |
+
$output .= $func_strcut( $text, 0, $max_length - $output_length );
|
1050 |
+
$truncated = true;
|
|
|
|
|
|
|
1051 |
$output_length = $max_length;
|
1052 |
break;
|
1053 |
}
|
1054 |
|
1055 |
// store everything, it wasn't too long
|
1056 |
+
$output .= $text;
|
1057 |
+
$output_length += $func_strlen( $text );
|
1058 |
|
1059 |
+
if ( $tag[0] == '&' ) {
|
1060 |
+
// Handle HTML entity by copying straight through
|
1061 |
$output .= $tag;
|
1062 |
$output_length++; // only counted as one character
|
1063 |
+
} else {
|
1064 |
+
// Handle HTML tag
|
|
|
1065 |
$tag_inner = $match[1][0];
|
1066 |
+
|
1067 |
+
if ( $tag[1] == '/' ) {
|
1068 |
+
// This is a closing tag.
|
1069 |
$output .= $tag;
|
1070 |
// If input tags aren't balanced, we leave the popped tag
|
1071 |
// on the stack so hopefully we're not introducing more
|
1072 |
// problems.
|
1073 |
+
|
1074 |
+
if ( end( $tag_stack ) == $tag_inner ) {
|
1075 |
+
array_pop( $tag_stack );
|
1076 |
}
|
1077 |
+
} elseif ( $tag[$func_strlen( $tag ) - 2] == '/' || in_array( strtolower( $tag_inner ), $unpaired_tags ) ) {
|
|
|
|
|
|
|
1078 |
// Self-closing or unpaired tag
|
1079 |
$output .= $tag;
|
1080 |
+
} else {
|
1081 |
+
// Opening tag.
|
1082 |
+
$output .= $tag;
|
|
|
1083 |
$tag_stack[] = $tag_inner; // push tag onto the stack
|
1084 |
}
|
1085 |
}
|
1086 |
|
1087 |
// Continue after the tag we just found
|
1088 |
+
$position = $tag_position + $func_strlen( $tag );
|
1089 |
}
|
1090 |
|
1091 |
+
// Print any remaining text after the last tag, if there's room
|
1092 |
+
|
1093 |
+
if ( $output_length < $max_length && $position < $func_strlen( $html ) ) {
|
1094 |
+
$output .= $func_strcut( $html, $position, $max_length - $output_length );
|
1095 |
}
|
1096 |
|
1097 |
+
$truncated = $func_strlen( $html ) - $position > $max_length - $output_length;
|
1098 |
|
1099 |
// add terminator if it was truncated in loop or just above here
|
1100 |
if ( $truncated || $force_indicator )
|
1101 |
$output .= $indicator;
|
1102 |
|
1103 |
// Close any open tags
|
1104 |
+
while ( !empty( $tag_stack ) )
|
1105 |
+
$output .= '</'.array_pop( $tag_stack ).'>';
|
1106 |
|
1107 |
return $output;
|
1108 |
}
|
1112 |
if ( empty ( $content ) )
|
1113 |
return $content;
|
1114 |
|
1115 |
+
$keep_whitespace = $atts['keep_whitespace'];
|
1116 |
|
1117 |
+
// wrap our own quote class around the content before any formatting
|
1118 |
// happens
|
1119 |
|
1120 |
+
$temp_content = self::$tag_open_quote;
|
1121 |
+
$temp_content .= $content;
|
1122 |
+
$temp_content .= self::$tag_close_quote;
|
1123 |
+
|
1124 |
+
$content = $temp_content;
|
1125 |
|
1126 |
+
$content = trim( $content );
|
1127 |
+
$content = wptexturize( $content );
|
1128 |
+
$content = convert_smilies( $content );
|
1129 |
+
$content = convert_chars( $content );
|
1130 |
|
1131 |
if ( is_null( $widget_number ) ) {
|
1132 |
+
$content = wpautop( $content );
|
1133 |
+
$content = shortcode_unautop( $content );
|
1134 |
} elseif ( $keep_whitespace ) {
|
1135 |
+
$content = wpautop( $content );
|
1136 |
} else {
|
1137 |
+
$content = strip_shortcodes( $content );
|
1138 |
}
|
1139 |
+
|
1140 |
+
$content = str_replace( ']]>', ']]>', $content );
|
1141 |
+
$content = trim( $content );
|
1142 |
+
|
1143 |
return $content;
|
1144 |
}
|
1145 |
|
1146 |
|
1147 |
+
public static function get_testimonials_paging( $atts, $prepend = true ) {
|
1148 |
+
$html = '';
|
1149 |
|
1150 |
if ( is_home() || 1 === self::$max_num_pages ) {
|
1151 |
return $html;
|
1152 |
}
|
1153 |
|
1154 |
+
$html .= '<div class="paging';
|
1155 |
|
1156 |
if ( $prepend ) {
|
1157 |
+
$html .= ' prepend';
|
1158 |
} else {
|
1159 |
+
$html .= ' append';
|
1160 |
}
|
1161 |
|
1162 |
+
$html .= '">';
|
1163 |
|
1164 |
if ( ! empty( $atts['paged'] ) ) {
|
1165 |
+
$paged = $atts['paged'];
|
1166 |
} else {
|
1167 |
+
$paged = 1;
|
1168 |
}
|
1169 |
|
1170 |
if ( ! function_exists( 'wp_pagenavi' ) ) {
|
1171 |
+
$html .= ' <div class="alignleft">';
|
1172 |
|
1173 |
if ( 1 < $paged ) {
|
1174 |
+
$laquo = apply_filters( 'testimonials_widget_previous_posts_link_text', __( '«', 'testimonials-widget' ) );
|
1175 |
+
$html .= get_previous_posts_link( $laquo, $paged );
|
1176 |
}
|
1177 |
|
1178 |
+
$html .= ' </div>';
|
1179 |
|
1180 |
+
$html .= ' <div class="alignright">';
|
1181 |
|
1182 |
if ( $paged != self::$max_num_pages ) {
|
1183 |
+
$raquo = apply_filters( 'testimonials_widget_next_posts_link_text', __( '»', 'testimonials-widget' ) );
|
1184 |
+
$html .= get_next_posts_link( $raquo, self::$max_num_pages );
|
1185 |
}
|
1186 |
|
1187 |
+
$html .= ' </div>';
|
1188 |
} else {
|
1189 |
+
$args = array(
|
1190 |
+
'echo' => false,
|
1191 |
+
'query' => self::$wp_query,
|
1192 |
);
|
1193 |
+
$args = apply_filters( 'testimonials_widget_wp_pagenavi', $args );
|
1194 |
+
|
1195 |
+
$html .= wp_pagenavi( $args );
|
1196 |
}
|
1197 |
|
1198 |
+
$html .= '</div>';
|
1199 |
|
1200 |
return $html;
|
1201 |
}
|
1203 |
|
1204 |
public static function get_testimonials_css() {
|
1205 |
if ( empty( self::$css_called ) ) {
|
1206 |
+
foreach ( self::$css as $css ) {
|
1207 |
echo $css;
|
1208 |
}
|
1209 |
+
|
1210 |
+
self::$css_called = true;
|
1211 |
}
|
1212 |
}
|
1213 |
|
1214 |
|
1215 |
public static function get_testimonials_scripts() {
|
1216 |
if ( empty( self::$scripts_called ) ) {
|
1217 |
+
foreach ( self::$scripts as $script ) {
|
1218 |
echo $script;
|
1219 |
}
|
1220 |
+
|
1221 |
+
self::$scripts_called = true;
|
1222 |
}
|
1223 |
}
|
1224 |
|
1225 |
|
1226 |
+
/**
|
1227 |
+
*
|
1228 |
+
*
|
1229 |
+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
|
1230 |
+
*/
|
1231 |
public static function get_query_args( $atts ) {
|
1232 |
extract( $atts );
|
1233 |
|
1236 |
}
|
1237 |
|
1238 |
if ( $random ) {
|
1239 |
+
$orderby = 'rand';
|
1240 |
+
$order = false;
|
1241 |
}
|
1242 |
|
1243 |
+
$args = array(
|
1244 |
+
'orderby' => $orderby,
|
1245 |
+
'post_status' => array(
|
1246 |
+
'publish',
|
1247 |
+
'private',
|
1248 |
),
|
1249 |
+
'post_type' => Testimonials_Widget::PT,
|
1250 |
+
'posts_per_page' => $limit,
|
1251 |
);
|
1252 |
|
1253 |
if ( is_single() ) {
|
1254 |
+
$args['post_status'][] = 'pending';
|
1255 |
+
$args['post_status'][] = 'draft';
|
1256 |
}
|
1257 |
|
1258 |
if ( $paging && ! empty( $atts['paged'] ) && is_singular() ) {
|
1259 |
+
$args['paged'] = $atts['paged'];
|
1260 |
}
|
1261 |
|
1262 |
if ( ! $random && $meta_key ) {
|
1263 |
+
$args['meta_key'] = $meta_key;
|
1264 |
+
$args['orderby'] = 'meta_value';
|
1265 |
}
|
1266 |
|
1267 |
if ( $order ) {
|
1268 |
+
$args['order'] = $order;
|
1269 |
}
|
1270 |
|
1271 |
if ( $ids ) {
|
1272 |
+
$ids = explode( ',', $ids );
|
1273 |
|
1274 |
+
$args['post__in'] = $ids;
|
1275 |
|
1276 |
if ( 'none' == $args['orderby'] ) {
|
1277 |
add_filter( 'posts_results', array( 'Testimonials_Widget', 'posts_results_sort_none' ), 10, 2 );
|
1278 |
}
|
1279 |
}
|
1280 |
|
1281 |
+
|
1282 |
if ( $exclude ) {
|
1283 |
+
$exclude = explode( ',', $exclude );
|
1284 |
|
1285 |
+
$args['post__not_in'] = $exclude;
|
1286 |
}
|
1287 |
|
1288 |
if ( $category ) {
|
1289 |
+
$args['category_name'] = $category;
|
1290 |
}
|
1291 |
|
1292 |
if ( $tags ) {
|
1293 |
+
$tags = explode( ',', $tags );
|
1294 |
|
1295 |
if ( $tags_all ) {
|
1296 |
+
$args['tag_slug__and'] = $tags;
|
1297 |
} else {
|
1298 |
+
$args['tag_slug__in'] = $tags;
|
1299 |
}
|
1300 |
}
|
1301 |
|
1302 |
+
$args = apply_filters( 'testimonials_widget_query_args', $args, $atts );
|
1303 |
|
1304 |
return $args;
|
1305 |
}
|
1306 |
|
1307 |
|
1308 |
public static function get_testimonials( $atts ) {
|
1309 |
+
$hide_gravatar = $atts['hide_gravatar'];
|
1310 |
|
1311 |
+
$args = self::get_query_args( $atts );
|
1312 |
+
$args['query'] = true;
|
1313 |
|
1314 |
+
$testimonials = apply_filters( 'testimonials_widget_cache_get', false, $args );
|
1315 |
|
1316 |
if ( false === $testimonials ) {
|
1317 |
+
$testimonials = new WP_Query( $args );
|
1318 |
+
$testimonials = apply_filters( 'testimonials_widget_cache_set', $testimonials, $args );
|
1319 |
}
|
1320 |
|
1321 |
if ( has_filter( 'posts_results', array( 'Testimonials_Widget', 'posts_results_sort_none' ) ) ) {
|
1322 |
remove_filter( 'posts_results', array( 'Testimonials_Widget', 'posts_results_sort_none' ) );
|
1323 |
}
|
1324 |
|
1325 |
+
self::$max_num_pages = $testimonials->max_num_pages;
|
1326 |
+
self::$post_count = $testimonials->post_count;
|
1327 |
+
self::$wp_query = $testimonials;
|
1328 |
|
1329 |
wp_reset_postdata();
|
1330 |
|
1331 |
+
$image_size = apply_filters( 'testimonials_widget_image_size', 'thumbnail' );
|
1332 |
+
$gravatar_size = apply_filters( 'testimonials_widget_gravatar_size', 96 );
|
1333 |
+
|
1334 |
+
$testimonial_data = array();
|
1335 |
|
|
|
|
|
1336 |
if ( empty( self::$post_count ) )
|
1337 |
return $testimonial_data;
|
1338 |
|
1339 |
+
foreach ( $testimonials->posts as $row ) {
|
1340 |
+
$post_id = $row->ID;
|
1341 |
|
1342 |
+
$email = get_post_meta( $post_id, 'testimonials-widget-email', true );
|
1343 |
|
1344 |
if ( has_post_thumbnail( $post_id ) ) {
|
1345 |
+
$image = get_the_post_thumbnail( $post_id, $image_size );
|
1346 |
} elseif ( ! $hide_gravatar && is_email( $email ) ) {
|
1347 |
+
$image = get_avatar( $email, $gravatar_size );
|
1348 |
} else {
|
1349 |
+
$image = false;
|
1350 |
}
|
1351 |
|
1352 |
+
$url = get_post_meta( $post_id, 'testimonials-widget-url', true );
|
1353 |
+
if ( ! empty( $url ) && 0 === preg_match( '#https?://#', $url ) ) {
|
1354 |
+
$url = 'http://' . $url;
|
1355 |
}
|
1356 |
|
1357 |
+
$data = array(
|
1358 |
+
'post_id' => $post_id,
|
1359 |
+
'testimonial_company' => get_post_meta( $post_id, 'testimonials-widget-company', true ),
|
1360 |
+
'testimonial_content' => $row->post_content,
|
1361 |
+
'testimonial_email' => $email,
|
1362 |
+
'testimonial_extra' => '',
|
1363 |
+
'testimonial_image' => $image,
|
1364 |
+
'testimonial_location' => get_post_meta( $post_id, 'testimonials-widget-location', true ),
|
1365 |
+
'testimonial_source' => $row->post_title,
|
1366 |
+
'testimonial_title' => get_post_meta( $post_id, 'testimonials-widget-title', true ),
|
1367 |
+
'testimonial_url' => $url,
|
1368 |
);
|
1369 |
|
1370 |
+
$testimonial_data[] = $data;
|
1371 |
}
|
1372 |
|
1373 |
+
$testimonial_data = apply_filters( 'testimonials_widget_data', $testimonial_data );
|
1374 |
|
1375 |
return $testimonial_data;
|
1376 |
}
|
1377 |
|
1378 |
|
1379 |
public function posts_results_sort_none( $posts, $query ) {
|
1380 |
+
$order = $query->query_vars['post__in'];
|
1381 |
if ( empty( $order ) )
|
1382 |
return $posts;
|
1383 |
|
1384 |
+
$posts_none_sorted = array();
|
1385 |
// put posts in same orders as post__in
|
1386 |
+
foreach ( $order as $id ) {
|
1387 |
+
foreach ( $posts as $key => $post ) {
|
1388 |
if ( $id == $post->ID ) {
|
1389 |
+
$posts_none_sorted[] = $post;
|
1390 |
unset( $posts[$key] );
|
1391 |
}
|
1392 |
}
|
1397 |
|
1398 |
|
1399 |
public function widgets_init() {
|
1400 |
+
require_once 'lib/class-testimonials-widget-widget.php';
|
1401 |
|
1402 |
register_widget( 'Testimonials_Widget_Widget' );
|
1403 |
}
|
1404 |
|
1405 |
|
1406 |
+
/**
|
1407 |
+
*
|
1408 |
+
*
|
1409 |
+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
|
1410 |
+
*/
|
1411 |
public function add_meta_box_testimonials_widget() {
|
1412 |
+
require_once 'lib/class-redrokk-metabox-class.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1413 |
|
1414 |
+
$fields = array(
|
1415 |
+
array(
|
1416 |
+
'name' => __( 'Title', 'testimonials-widget' ),
|
1417 |
+
'id' => 'testimonials-widget-title',
|
1418 |
+
'type' => 'text',
|
1419 |
+
'desc' => '',
|
1420 |
+
),
|
1421 |
+
array(
|
1422 |
+
'name' => __( 'Location', 'testimonials-widget' ),
|
1423 |
+
'id' => 'testimonials-widget-location',
|
1424 |
+
'type' => 'text',
|
1425 |
+
'desc' => '',
|
1426 |
+
),
|
1427 |
+
array(
|
1428 |
+
'name' => __( 'Email', 'testimonials-widget' ),
|
1429 |
+
'id' => 'testimonials-widget-email',
|
1430 |
+
'type' => 'text',
|
1431 |
+
'desc' => '',
|
1432 |
+
),
|
1433 |
+
array(
|
1434 |
+
'name' => __( 'Company', 'testimonials-widget' ),
|
1435 |
+
'id' => 'testimonials-widget-company',
|
1436 |
+
'type' => 'text',
|
1437 |
+
'desc' => '',
|
1438 |
+
),
|
1439 |
+
array(
|
1440 |
+
'name' => __( 'URL', 'testimonials-widget' ),
|
1441 |
+
'id' => 'testimonials-widget-url',
|
1442 |
+
'type' => 'text',
|
1443 |
+
'desc' => '',
|
1444 |
+
),
|
1445 |
+
);
|
1446 |
|
1447 |
+
$fields = apply_filters( 'testimonials_widget_meta_box', $fields );
|
1448 |
+
|
1449 |
+
$meta_box = redrokk_metabox_class::getInstance(
|
1450 |
+
self::OLD_NAME,
|
1451 |
array(
|
1452 |
+
'title' => __( 'Testimonial Data', 'testimonials-widget' ),
|
1453 |
+
'description' => '',
|
1454 |
+
'_object_types' => 'testimonials-widget',
|
1455 |
+
'priority' => 'high',
|
1456 |
+
'_fields' => $fields,
|
1457 |
)
|
1458 |
);
|
1459 |
}
|
1464 |
*
|
1465 |
* Original author: Travis Ballard http://www.travisballard.com
|
1466 |
*
|
1467 |
+
* @param string $translation
|
1468 |
* @return string $translation
|
1469 |
*/
|
1470 |
public function gettext_testimonials( $translation ) {
|
1472 |
|
1473 |
global $post;
|
1474 |
|
1475 |
+
if ( is_object( $post ) && self::PT == $post->post_type ) {
|
1476 |
+
switch ( $translation ) {
|
1477 |
case __( 'Enter title here', 'testimonials-widget' ):
|
1478 |
return __( 'Enter testimonial source here', 'testimonials-widget' );
|
1479 |
break;
|
1491 |
*
|
1492 |
* Original author: Travis Ballard http://www.travisballard.com
|
1493 |
*
|
1494 |
+
* @SuppressWarnings(PHPMD.Superglobals)
|
1495 |
+
* @param mixed $m
|
1496 |
* @return mixed $m
|
1497 |
*/
|
1498 |
public function post_updated_messages( $m ) {
|
1499 |
global $post;
|
1500 |
|
1501 |
+
$m[ self::PT ] = array(
|
1502 |
0 => '', // Unused. Messages start at index 1.
|
1503 |
1 => sprintf( __( 'Testimonial updated. <a href="%s">View testimonial</a>', 'testimonials-widget' ), esc_url( get_permalink( $post->ID ) ) ),
|
1504 |
2 => __( 'Custom field updated.', 'testimonials-widget' ),
|
1505 |
3 => __( 'Custom field deleted.', 'testimonials-widget' ),
|
1506 |
4 => __( 'Testimonial updated.', 'testimonials-widget' ),
|
1507 |
/* translators: %s: date and time of the revision */
|
1508 |
+
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Testimonial restored to revision from %s', 'testimonials-widget' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
1509 |
6 => sprintf( __( 'Testimonial published. <a href="%s">View testimonial</a>', 'testimonials-widget' ), esc_url( get_permalink( $post->ID ) ) ),
|
1510 |
7 => __( 'Testimonial saved.', 'testimonials-widget' ),
|
1511 |
+
8 => sprintf( __( 'Testimonial submitted. <a target="_blank" href="%s">Preview testimonial</a>', 'testimonials-widget' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ),
|
1512 |
9 => sprintf( __( 'Testimonial scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview testimonial</a>', 'testimonials-widget' ), date_i18n( 'M j, Y @ G:i', strtotime( $post->post_date ) ), esc_url( get_permalink( $post->ID ) ) ),
|
1513 |
10 => sprintf( __( 'Testimonial draft updated. <a target="_blank" href="%s">Preview testimonial</a>', 'testimonials-widget' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) )
|
1514 |
);
|
1516 |
return $m;
|
1517 |
}
|
1518 |
|
1519 |
+
|
1520 |
}
|
1521 |
|
1522 |
|
1523 |
+
$Testimonials_Widget = new Testimonials_Widget();
|
1524 |
|
1525 |
|
1526 |
function testimonialswidget_list( $atts = array() ) {
|
1536 |
return $Testimonials_Widget->testimonialswidget_widget( $atts, $widget_number );
|
1537 |
}
|
1538 |
|
1539 |
+
|
1540 |
?>
|