Ultimate Tag Cloud Widget - Version 2.6-beta1

Version Description

= 2.5 =

  • New features, see plugin page at wordpress.org for full details.

= 2.4 =

  • Issues with WPML and custom taxonomies resolved. New features, see plugin page at wordpress.org for full details.

= 2.3.1 =

  • Security fix for sensitive data exposed when using the debug option

= 2.3 =

  • New features, see plugin page at wordpress.org for full details. Watch out for the changes in class names: https://github.com/rickard2/utcw/issues/29

= 2.2.3 =

  • Fixed naming collision issue with other plugins

= 2.2.2 =

  • Fixed widget initialization issue

= 2.2.1 =

  • Fixes compatibility issue with PHP 5.2

= 2.2 =

  • New features, see the plugin page at wordpress.org for full details

= 2.1 =

  • New features, see the plugin page at wordpress.org for full details

= 2.0.1 =

  • Small bug fix in the widget options panel

= 2.0 =

  • New plugin architecture and a big rewrite of the plugin foundation. Watch out for breaking changes, please see http://exz.nu/utcwbreaking for more information.
Download this release

Release Info

Developer exz
Plugin Icon wp plugin Ultimate Tag Cloud Widget
Version 2.6-beta1
Comparing to
See all releases

Code changes from version 2.5 to 2.6-beta1

language/utcw-sv_SE.mo ADDED
Binary file
language/utcw-sv_SE.po ADDED
@@ -0,0 +1,716 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Ultimate Tag Cloud Widget\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-12-26 10:47+0100\n"
6
+ "PO-Revision-Date: 2013-12-26 10:49+0100\n"
7
+ "Last-Translator: Rickard Andersson <rickard@montania.se>\n"
8
+ "Language-Team: 0x539.se <rickard@0x539.se>\n"
9
+ "Language: sv\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: __;_e;_n;_x\n"
14
+ "X-Poedit-Basepath: /www/utcw2\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
17
+ "X-Generator: Poedit 1.6.3\n"
18
+ "X-Poedit-SearchPath-0: /www/utcw2/src\n"
19
+ "X-Poedit-SearchPath-1: /www/utcw2/pages\n"
20
+
21
+ #: /www/utcw2/src/Widget.php:41
22
+ msgid "Highly configurable tag cloud"
23
+ msgstr ""
24
+
25
+ #: /www/utcw2/src/Widget.php:42
26
+ msgid "Ultimate Tag Cloud"
27
+ msgstr ""
28
+
29
+ #: /www/utcw2/pages/settings.php:24
30
+ msgid "Data"
31
+ msgstr ""
32
+
33
+ #: /www/utcw2/pages/settings.php:26
34
+ msgid "Terms"
35
+ msgstr ""
36
+
37
+ #: /www/utcw2/pages/settings.php:28
38
+ msgid "Basic appearance"
39
+ msgstr ""
40
+
41
+ #: /www/utcw2/pages/settings.php:30
42
+ msgid "Advanced appearance"
43
+ msgstr ""
44
+
45
+ #: /www/utcw2/pages/settings.php:32
46
+ msgid "Links"
47
+ msgstr ""
48
+
49
+ #: /www/utcw2/pages/settings.php:34
50
+ msgid "Adv."
51
+ msgstr ""
52
+
53
+ #: /www/utcw2/pages/settings.php:39
54
+ msgid ""
55
+ "How the tag cloud should find tags to display. Popularity based selection is "
56
+ "the default strategy which shows the most popular tags. Creation time will "
57
+ "display the newest terms."
58
+ msgstr ""
59
+
60
+ #: /www/utcw2/pages/settings.php:40
61
+ msgid "Selection strategy:"
62
+ msgstr ""
63
+
64
+ #: /www/utcw2/pages/settings.php:43
65
+ msgid "Popularity"
66
+ msgstr ""
67
+
68
+ #: /www/utcw2/pages/settings.php:47 /www/utcw2/pages/settings.php:102
69
+ msgid "Random"
70
+ msgstr ""
71
+
72
+ #: /www/utcw2/pages/settings.php:51
73
+ msgid "Creation time"
74
+ msgstr ""
75
+
76
+ #: /www/utcw2/pages/settings.php:55
77
+ msgid "Only terms from the current list"
78
+ msgstr ""
79
+
80
+ #: /www/utcw2/pages/settings.php:60
81
+ msgid ""
82
+ "Only posts from the selected authors will be used when calculating the tag "
83
+ "cloud."
84
+ msgstr ""
85
+
86
+ #: /www/utcw2/pages/settings.php:61
87
+ msgid "Authors:"
88
+ msgstr ""
89
+
90
+ #: /www/utcw2/pages/settings.php:65
91
+ msgid "All authors"
92
+ msgstr ""
93
+
94
+ #: /www/utcw2/pages/settings.php:70
95
+ msgid "Selected authors only"
96
+ msgstr ""
97
+
98
+ #: /www/utcw2/pages/settings.php:80 /www/utcw2/pages/settings.php:87
99
+ #: /www/utcw2/pages/settings.php:179 /www/utcw2/pages/settings.php:186
100
+ #: /www/utcw2/pages/settings.php:228 /www/utcw2/pages/settings.php:235
101
+ #: /www/utcw2/pages/settings.php:703
102
+ msgid "Delete"
103
+ msgstr ""
104
+
105
+ #: /www/utcw2/pages/settings.php:97
106
+ msgid ""
107
+ "Which property of the tag should be used when determining the order of the "
108
+ "tags in the cloud."
109
+ msgstr ""
110
+
111
+ #: /www/utcw2/pages/settings.php:98
112
+ msgid "Order:"
113
+ msgstr ""
114
+
115
+ #: /www/utcw2/pages/settings.php:106
116
+ msgid "By name"
117
+ msgstr ""
118
+
119
+ #: /www/utcw2/pages/settings.php:110
120
+ msgid "By slug"
121
+ msgstr ""
122
+
123
+ #: /www/utcw2/pages/settings.php:114
124
+ msgid "By id"
125
+ msgstr ""
126
+
127
+ #: /www/utcw2/pages/settings.php:118
128
+ msgid "By color"
129
+ msgstr ""
130
+
131
+ #: /www/utcw2/pages/settings.php:122
132
+ msgid "Count"
133
+ msgstr ""
134
+
135
+ #: /www/utcw2/pages/settings.php:125
136
+ msgid "Reverse order"
137
+ msgstr ""
138
+
139
+ #: /www/utcw2/pages/settings.php:129
140
+ msgid "Case sensitive"
141
+ msgstr ""
142
+
143
+ #: /www/utcw2/pages/settings.php:133
144
+ msgid ""
145
+ "Which taxonomy should be used in the cloud. You should be able to choose a "
146
+ "custom taxonomy as well."
147
+ msgstr ""
148
+
149
+ #: /www/utcw2/pages/settings.php:135
150
+ msgid "Taxonomies:"
151
+ msgstr ""
152
+
153
+ #: /www/utcw2/pages/settings.php:145
154
+ msgid ""
155
+ "Which post types should be used in the cloud. Only tags from posts from "
156
+ "these post types will be used in the tag cloud."
157
+ msgstr ""
158
+
159
+ #: /www/utcw2/pages/settings.php:157
160
+ msgid ""
161
+ "Only tags which have been used with this many posts will be visible in the "
162
+ "cloud"
163
+ msgstr ""
164
+
165
+ #: /www/utcw2/pages/settings.php:159
166
+ msgid "Tags with fewer posts than this will be automatically excluded."
167
+ msgstr ""
168
+
169
+ #: /www/utcw2/pages/settings.php:159
170
+ msgid "Minimum number of posts: "
171
+ msgstr ""
172
+
173
+ #: /www/utcw2/pages/settings.php:165
174
+ msgid ""
175
+ "Only posts which are posted within this number of days will be used when "
176
+ "generating the cloud"
177
+ msgstr ""
178
+
179
+ #: /www/utcw2/pages/settings.php:167
180
+ msgid ""
181
+ "The maximum number of days back to search for posts, zero means every post."
182
+ msgstr ""
183
+
184
+ #: /www/utcw2/pages/settings.php:167
185
+ msgid "Posts max age:"
186
+ msgstr ""
187
+
188
+ #: /www/utcw2/pages/settings.php:173
189
+ msgid ""
190
+ "Only posts which have any of the selected terms will be used when generating "
191
+ "the cloud"
192
+ msgstr ""
193
+
194
+ #: /www/utcw2/pages/settings.php:174
195
+ msgid "Post term filter"
196
+ msgstr ""
197
+
198
+ #: /www/utcw2/pages/settings.php:194
199
+ msgid ""
200
+ "When used with post term filtering the resulting link in the tag cloud will "
201
+ "contain a query variable to try to filter out the posts that have the term "
202
+ "given in the term filter."
203
+ msgstr ""
204
+
205
+ #: /www/utcw2/pages/settings.php:197
206
+ msgid "Add filter to links"
207
+ msgstr ""
208
+
209
+ #: /www/utcw2/pages/settings.php:205
210
+ msgid ""
211
+ "This setting controls how the tag cloud should handle the selected terms. If "
212
+ "the selected terms below should be the only ones included, or if the "
213
+ "selected terms should be the ones being excluded from the result."
214
+ msgstr ""
215
+
216
+ #: /www/utcw2/pages/settings.php:206
217
+ msgid "Selection type"
218
+ msgstr ""
219
+
220
+ #: /www/utcw2/pages/settings.php:212
221
+ msgid "Include only selected terms"
222
+ msgstr ""
223
+
224
+ #: /www/utcw2/pages/settings.php:218
225
+ msgid "Exclude selected terms"
226
+ msgstr ""
227
+
228
+ #: /www/utcw2/pages/settings.php:222
229
+ msgid "Which tags to include or exclude"
230
+ msgstr ""
231
+
232
+ #: /www/utcw2/pages/settings.php:247
233
+ msgid "The title is the text which is shown above the tag cloud."
234
+ msgstr ""
235
+
236
+ #: /www/utcw2/pages/settings.php:249
237
+ msgid "Title:"
238
+ msgstr ""
239
+
240
+ #: /www/utcw2/pages/settings.php:252
241
+ msgid "Show title"
242
+ msgstr ""
243
+
244
+ #: /www/utcw2/pages/settings.php:259
245
+ msgid ""
246
+ "The tag with the least number of posts will be the smallest, and the tag "
247
+ "with the most number of posts will be the biggest."
248
+ msgstr ""
249
+
250
+ #: /www/utcw2/pages/settings.php:260
251
+ msgid "Tag size:"
252
+ msgstr ""
253
+
254
+ #: /www/utcw2/pages/settings.php:261 /www/utcw2/pages/settings.php:312
255
+ msgid "From"
256
+ msgstr ""
257
+
258
+ #: /www/utcw2/pages/settings.php:265 /www/utcw2/pages/settings.php:316
259
+ msgid "to"
260
+ msgstr ""
261
+
262
+ #: /www/utcw2/pages/settings.php:272
263
+ msgid ""
264
+ "If the total number of tags exceeds this number, only this many tags will be "
265
+ "shown in the cloud."
266
+ msgstr ""
267
+
268
+ #: /www/utcw2/pages/settings.php:274
269
+ msgid "Max tags:"
270
+ msgstr ""
271
+
272
+ #: /www/utcw2/pages/settings.php:281
273
+ msgid ""
274
+ "This setting controls how the tags are colored.<ul><li>Totaly random will "
275
+ "choose between all the 16 million colors available.</li><li>Random from "
276
+ "preset values will choose colors from a predefined set of colors</"
277
+ "li><li>Spanning between values will calculate the corresponding color based "
278
+ "upon how many posts each tag has, similar to how the size is calculated. The "
279
+ "tag with the least number of posts will have the first color and the tag "
280
+ "with the most number of posts will have the second color. All tags in "
281
+ "between will have a color calculated between the first and the second color."
282
+ "</li></ul>The colors for the choice 'Random from preset values' has to be "
283
+ "specified as a comma separated list."
284
+ msgstr ""
285
+
286
+ #: /www/utcw2/pages/settings.php:282
287
+ msgid "Coloring:"
288
+ msgstr ""
289
+
290
+ #: /www/utcw2/pages/settings.php:286 /www/utcw2/pages/settings.php:535
291
+ #: /www/utcw2/pages/settings.php:628
292
+ msgid "None"
293
+ msgstr ""
294
+
295
+ #: /www/utcw2/pages/settings.php:290
296
+ msgid "Totally random"
297
+ msgstr ""
298
+
299
+ #: /www/utcw2/pages/settings.php:295 /www/utcw2/pages/settings.php:300
300
+ msgid "Random from preset values"
301
+ msgstr ""
302
+
303
+ #: /www/utcw2/pages/settings.php:308
304
+ msgid "Spanning between values"
305
+ msgstr ""
306
+
307
+ #: /www/utcw2/pages/settings.php:322
308
+ msgid "Defines how the resulting tag should be aligned in the resulting cloud."
309
+ msgstr ""
310
+
311
+ #: /www/utcw2/pages/settings.php:323
312
+ msgid "Text alignment:"
313
+ msgstr ""
314
+
315
+ #: /www/utcw2/pages/settings.php:325 /www/utcw2/pages/settings.php:482
316
+ #: /www/utcw2/pages/settings.php:499 /www/utcw2/pages/settings.php:517
317
+ #: /www/utcw2/pages/settings.php:581 /www/utcw2/pages/settings.php:596
318
+ #: /www/utcw2/pages/settings.php:611
319
+ msgid "Theme default"
320
+ msgstr ""
321
+
322
+ #: /www/utcw2/pages/settings.php:327
323
+ msgid "Left"
324
+ msgstr ""
325
+
326
+ #: /www/utcw2/pages/settings.php:329
327
+ msgid "Right"
328
+ msgstr ""
329
+
330
+ #: /www/utcw2/pages/settings.php:331
331
+ msgid "Center"
332
+ msgstr ""
333
+
334
+ #: /www/utcw2/pages/settings.php:333
335
+ msgid "Justify"
336
+ msgstr ""
337
+
338
+ #: /www/utcw2/pages/settings.php:339
339
+ msgid "Changes the overall display type of the output."
340
+ msgstr ""
341
+
342
+ #: /www/utcw2/pages/settings.php:340
343
+ msgid "Display type:"
344
+ msgstr ""
345
+
346
+ #: /www/utcw2/pages/settings.php:342
347
+ msgid "Regular cloud"
348
+ msgstr ""
349
+
350
+ #: /www/utcw2/pages/settings.php:344
351
+ msgid "List"
352
+ msgstr ""
353
+
354
+ #: /www/utcw2/pages/settings.php:347
355
+ msgid ""
356
+ "This option will remove some CSS classes commonly used by themes to apply "
357
+ "their own styles to the tag cloud. If the options aren't displaying "
358
+ "correctly, try enabling this feature. This will make styles closer match the "
359
+ "appearance before version 2.3."
360
+ msgstr ""
361
+
362
+ #: /www/utcw2/pages/settings.php:350
363
+ msgid "Avoid theme styling"
364
+ msgstr ""
365
+
366
+ #: /www/utcw2/pages/settings.php:354
367
+ msgid "Term appearance"
368
+ msgstr ""
369
+
370
+ #: /www/utcw2/pages/settings.php:356
371
+ msgid ""
372
+ "Uncheck this option if you do not want your tag cloud to contain links to "
373
+ "the archive page for each tag."
374
+ msgstr ""
375
+
376
+ #: /www/utcw2/pages/settings.php:359
377
+ msgid "Show links"
378
+ msgstr ""
379
+
380
+ #: /www/utcw2/pages/settings.php:360
381
+ msgid ""
382
+ "Select this option if you would like the output to contain the number of "
383
+ "posts associated with each term. Like: Hello World (2)"
384
+ msgstr ""
385
+
386
+ #: /www/utcw2/pages/settings.php:363
387
+ msgid "Show post count"
388
+ msgstr ""
389
+
390
+ #: /www/utcw2/pages/settings.php:364
391
+ msgid ""
392
+ "This option will try to prevent terms with multiple words from breaking up "
393
+ "into two lines."
394
+ msgstr ""
395
+
396
+ #: /www/utcw2/pages/settings.php:367
397
+ msgid "Prevent line breaks in terms"
398
+ msgstr ""
399
+
400
+ #: /www/utcw2/pages/settings.php:370
401
+ msgid "Term titles (hover text)"
402
+ msgstr ""
403
+
404
+ #: /www/utcw2/pages/settings.php:372
405
+ msgid ""
406
+ "The title is the small (usually) yellow label which will appear when the "
407
+ "user hovers the tag. Try to hover the text to the left to see an example of "
408
+ "what a title text looks like."
409
+ msgstr ""
410
+
411
+ #: /www/utcw2/pages/settings.php:376
412
+ msgid "This is a title"
413
+ msgstr ""
414
+
415
+ #: /www/utcw2/pages/settings.php:376
416
+ msgid "Enable titles"
417
+ msgstr ""
418
+
419
+ #: /www/utcw2/pages/settings.php:377
420
+ msgid ""
421
+ "This is the WordPress default option, it will add the post count as title "
422
+ "like this: 2 topics"
423
+ msgstr ""
424
+
425
+ #: /www/utcw2/pages/settings.php:379
426
+ msgid "Post count"
427
+ msgstr ""
428
+
429
+ #: /www/utcw2/pages/settings.php:380
430
+ msgid "This option will use the term name as title"
431
+ msgstr ""
432
+
433
+ #: /www/utcw2/pages/settings.php:382
434
+ msgid "Term name"
435
+ msgstr ""
436
+
437
+ #: /www/utcw2/pages/settings.php:383
438
+ #, php-format
439
+ msgid ""
440
+ "This option allows you to define a C-style printf template to be used when "
441
+ "generating the title. You can use %d and %s to get the post count and term "
442
+ "name. To get a title like this: <br><code>The term Hello World has been used "
443
+ "with 14 posts</code><br><br>Use a template like this:<br><code>The term %s "
444
+ "has been used with %d posts</code>"
445
+ msgstr ""
446
+
447
+ #: /www/utcw2/pages/settings.php:385
448
+ msgid "Custom template"
449
+ msgstr ""
450
+
451
+ #: /www/utcw2/pages/settings.php:387
452
+ msgid "Custom title template"
453
+ msgstr ""
454
+
455
+ #: /www/utcw2/pages/settings.php:393
456
+ msgid ""
457
+ "The spacing is a numerical value which controls how much space there is "
458
+ "between letters, words, tags or rows. To use the default value for these "
459
+ "settings just use the corresponding default value from the CSS "
460
+ "specification: <ul><li>Letter spacing: normal</li><li>Word spacing: normal</"
461
+ "li><li>Tag spacing (CSS margin): auto</li><li>Row spacing (CSS line height): "
462
+ "inherit</li></ul>To use anything but the default values, just specify a "
463
+ "number (the unit is pixels)."
464
+ msgstr ""
465
+
466
+ #: /www/utcw2/pages/settings.php:394
467
+ msgid "Spacing:"
468
+ msgstr ""
469
+
470
+ #: /www/utcw2/pages/settings.php:396
471
+ msgid "Between letters:"
472
+ msgstr ""
473
+
474
+ #: /www/utcw2/pages/settings.php:401
475
+ msgid "Between words:"
476
+ msgstr ""
477
+
478
+ #: /www/utcw2/pages/settings.php:406
479
+ msgid "Between tags:"
480
+ msgstr ""
481
+
482
+ #: /www/utcw2/pages/settings.php:411
483
+ msgid "Between rows:"
484
+ msgstr ""
485
+
486
+ #: /www/utcw2/pages/settings.php:418
487
+ msgid ""
488
+ "The tags can be transformed in a number of different ways. lowercase, "
489
+ "UPPERCASE or Capitalized."
490
+ msgstr ""
491
+
492
+ #: /www/utcw2/pages/settings.php:419
493
+ msgid "Transform tags:"
494
+ msgstr ""
495
+
496
+ #: /www/utcw2/pages/settings.php:423
497
+ msgid "Off"
498
+ msgstr ""
499
+
500
+ #: /www/utcw2/pages/settings.php:428
501
+ msgid "To lowercase"
502
+ msgstr ""
503
+
504
+ #: /www/utcw2/pages/settings.php:433
505
+ msgid "To uppercase"
506
+ msgstr ""
507
+
508
+ #: /www/utcw2/pages/settings.php:438
509
+ msgid "Capitalize"
510
+ msgstr ""
511
+
512
+ #: /www/utcw2/pages/settings.php:442
513
+ msgid ""
514
+ "The tags can be surrounded by a prefix and/or suffix and separated with a "
515
+ "separator. The default separator is just a space but can be changed to "
516
+ "anything you'd like. Remember to add a space before and after the separator, "
517
+ "this is not automatically added by the plugin.<br><br>A short example, these "
518
+ "settings:<ul><li>Separator: &nbsp;-&nbsp; </li><li>Prefix: (</"
519
+ "li><li>Suffix: )</li></ul>… would produce a tag cloud like this: "
520
+ "<br><br>(first tag) - (second tag) - (third tag)<br><br>Prefix and suffix "
521
+ "characters will have the same size and color as the tag, but the separator "
522
+ "will not."
523
+ msgstr ""
524
+
525
+ #: /www/utcw2/pages/settings.php:443
526
+ msgid "Tag separators:"
527
+ msgstr ""
528
+
529
+ #: /www/utcw2/pages/settings.php:445
530
+ msgid "Separator"
531
+ msgstr ""
532
+
533
+ #: /www/utcw2/pages/settings.php:449
534
+ msgid "Prefix"
535
+ msgstr ""
536
+
537
+ #: /www/utcw2/pages/settings.php:453
538
+ msgid "Suffix"
539
+ msgstr ""
540
+
541
+ #: /www/utcw2/pages/settings.php:464
542
+ msgid ""
543
+ "The normal styles will apply to the tags when the user is <b>not</b> "
544
+ "hovering the link."
545
+ msgstr ""
546
+
547
+ #: /www/utcw2/pages/settings.php:466
548
+ msgid "Normal styles"
549
+ msgstr ""
550
+
551
+ #: /www/utcw2/pages/settings.php:468
552
+ msgid ""
553
+ "Yes or no will force the tag setting for the <u>underline</u> style, theme "
554
+ "default will let the blog theme decide."
555
+ msgstr ""
556
+
557
+ #: /www/utcw2/pages/settings.php:469 /www/utcw2/pages/settings.php:568
558
+ msgid "Underline"
559
+ msgstr ""
560
+
561
+ #: /www/utcw2/pages/settings.php:473 /www/utcw2/pages/settings.php:491
562
+ #: /www/utcw2/pages/settings.php:508 /www/utcw2/pages/settings.php:572
563
+ #: /www/utcw2/pages/settings.php:587 /www/utcw2/pages/settings.php:602
564
+ msgid "Yes"
565
+ msgstr ""
566
+
567
+ #: /www/utcw2/pages/settings.php:477 /www/utcw2/pages/settings.php:495
568
+ #: /www/utcw2/pages/settings.php:512 /www/utcw2/pages/settings.php:576
569
+ #: /www/utcw2/pages/settings.php:591 /www/utcw2/pages/settings.php:606
570
+ msgid "No"
571
+ msgstr ""
572
+
573
+ #: /www/utcw2/pages/settings.php:486
574
+ msgid ""
575
+ "Yes or no will force the tag setting for the <b>bold</b> style, theme "
576
+ "default will let the blog theme decide."
577
+ msgstr ""
578
+
579
+ #: /www/utcw2/pages/settings.php:487 /www/utcw2/pages/settings.php:583
580
+ msgid "Bold"
581
+ msgstr ""
582
+
583
+ #: /www/utcw2/pages/settings.php:503
584
+ msgid ""
585
+ "Yes or no will force the tag setting for the <i>italic</i> style, theme "
586
+ "default will let the blog theme decide."
587
+ msgstr ""
588
+
589
+ #: /www/utcw2/pages/settings.php:504 /www/utcw2/pages/settings.php:598
590
+ msgid "Italic"
591
+ msgstr ""
592
+
593
+ #: /www/utcw2/pages/settings.php:521
594
+ msgid ""
595
+ "This setting will change the background color of <b>the link only</b>, not "
596
+ "the whole cloud. The color has to be specified in hexadeximal format, like "
597
+ "ffffff for white, 0000ff for blue or 000000 for black."
598
+ msgstr ""
599
+
600
+ #: /www/utcw2/pages/settings.php:523 /www/utcw2/pages/settings.php:614
601
+ msgid "Background color (hex value):"
602
+ msgstr ""
603
+
604
+ #: /www/utcw2/pages/settings.php:529
605
+ msgid ""
606
+ "This setting will change the border of <b>the link only</b>, not the whole "
607
+ "cloud. <ul><li>The width of the border is a numerical value (in the unit "
608
+ "pixels).</li><li>The color has to be specified in hexadeximal format, like "
609
+ "ffffff for white, 0000ff for blue or 000000 for black.</li></ul>"
610
+ msgstr ""
611
+
612
+ #: /www/utcw2/pages/settings.php:530 /www/utcw2/pages/settings.php:623
613
+ msgid "Border"
614
+ msgstr ""
615
+
616
+ #: /www/utcw2/pages/settings.php:531 /www/utcw2/pages/settings.php:624
617
+ msgid "Style: "
618
+ msgstr ""
619
+
620
+ #: /www/utcw2/pages/settings.php:537 /www/utcw2/pages/settings.php:630
621
+ msgid "Dotted"
622
+ msgstr ""
623
+
624
+ #: /www/utcw2/pages/settings.php:539 /www/utcw2/pages/settings.php:632
625
+ msgid "Dashed"
626
+ msgstr ""
627
+
628
+ #: /www/utcw2/pages/settings.php:541 /www/utcw2/pages/settings.php:634
629
+ msgid "Solid"
630
+ msgstr ""
631
+
632
+ #: /www/utcw2/pages/settings.php:543 /www/utcw2/pages/settings.php:636
633
+ msgid "Double"
634
+ msgstr ""
635
+
636
+ #: /www/utcw2/pages/settings.php:545 /www/utcw2/pages/settings.php:638
637
+ msgid "Groove"
638
+ msgstr ""
639
+
640
+ #: /www/utcw2/pages/settings.php:547 /www/utcw2/pages/settings.php:640
641
+ msgid "Ridge"
642
+ msgstr ""
643
+
644
+ #: /www/utcw2/pages/settings.php:549 /www/utcw2/pages/settings.php:642
645
+ msgid "Inset"
646
+ msgstr ""
647
+
648
+ #: /www/utcw2/pages/settings.php:551 /www/utcw2/pages/settings.php:644
649
+ msgid "Outset"
650
+ msgstr ""
651
+
652
+ #: /www/utcw2/pages/settings.php:555 /www/utcw2/pages/settings.php:648
653
+ msgid "Width:"
654
+ msgstr ""
655
+
656
+ #: /www/utcw2/pages/settings.php:560 /www/utcw2/pages/settings.php:653
657
+ msgid "Color (hex value): "
658
+ msgstr ""
659
+
660
+ #: /www/utcw2/pages/settings.php:565
661
+ msgid ""
662
+ "The hover effects will only affect the style of the tag when the user hovers "
663
+ "the tag. For details about each settings see the section above."
664
+ msgstr ""
665
+
666
+ #: /www/utcw2/pages/settings.php:567
667
+ msgid "Hover effects"
668
+ msgstr ""
669
+
670
+ #: /www/utcw2/pages/settings.php:619
671
+ msgid "Font color (hex value):"
672
+ msgstr ""
673
+
674
+ #: /www/utcw2/pages/settings.php:660
675
+ msgid ""
676
+ "This will add a &lt;-- HTML comment --&gt; to the output with some debugging "
677
+ "information, please use this information when troubleshooting. You can find "
678
+ "the debugging information by using 'view source' in your browser when "
679
+ "viewing the page and searching for 'Ultimate Tag Cloud Debug information'"
680
+ msgstr ""
681
+
682
+ #: /www/utcw2/pages/settings.php:663
683
+ msgid "Include debug output"
684
+ msgstr ""
685
+
686
+ #: /www/utcw2/pages/settings.php:666
687
+ msgid ""
688
+ "This will save the current configuration which enables you to load this "
689
+ "configuration at a later time. Check this box, choose a name in the text "
690
+ "field below and press 'Save' to save the configuration."
691
+ msgstr ""
692
+
693
+ #: /www/utcw2/pages/settings.php:670
694
+ msgid "Save configuration"
695
+ msgstr ""
696
+
697
+ #: /www/utcw2/pages/settings.php:673
698
+ msgid ""
699
+ "This is the name which will be used for the current configuration if you "
700
+ "check the option 'Save configuration' above. If the name is omitted the "
701
+ "current date and time will be used."
702
+ msgstr ""
703
+
704
+ #: /www/utcw2/pages/settings.php:675 /www/utcw2/pages/settings.php:691
705
+ msgid "Configuration name"
706
+ msgstr ""
707
+
708
+ #: /www/utcw2/pages/settings.php:684
709
+ msgid ""
710
+ "This will load the selected configuration to the state which the widget was "
711
+ "when the configuration was saved."
712
+ msgstr ""
713
+
714
+ #: /www/utcw2/pages/settings.php:687
715
+ msgid "Load configuration"
716
+ msgstr ""
pages/settings.php CHANGED
@@ -39,19 +39,19 @@ if ( ! defined( 'ABSPATH' ) ) die();
39
  <a class="utcw-help" title="<?php _e('How the tag cloud should find tags to display. Popularity based selection is the default strategy which shows the most popular tags. Creation time will display the newest terms.', 'utcw') ?>">?</a>
40
  <strong><?php _e('Selection strategy:', 'utcw') ?></strong><br>
41
  <label>
42
- <input type="radio" name="<?php echo $this->get_field_name('strategy') ?>" value="popularity" <?php if ($dataConfig->strategy === 'popularity') echo 'checked="checked"' ?>>
43
  <?php _e('Popularity','utcw') ?>
44
  </label><br>
45
  <label>
46
- <input type="radio" name="<?php echo $this->get_field_name('strategy') ?>" value="random" <?php if ($dataConfig->strategy === 'random') echo 'checked="checked"' ?>>
47
  <?php _e('Random','utcw') ?>
48
  </label><br>
49
  <label>
50
- <input type="radio" name="<?php echo $this->get_field_name('strategy') ?>" value="creation" <?php if ($dataConfig->strategy === 'creation') echo 'checked="checked"' ?>>
51
  <?php _e('Creation time','utcw') ?>
52
  </label><br>
53
  <label>
54
- <input type="radio" name="<?php echo $this->get_field_name('strategy') ?>" value="current_list" <?php if ($dataConfig->strategy === 'current_list') echo 'checked="checked"' ?>>
55
  <?php _e('Only terms from the current list','utcw') ?>
56
  </label><br>
57
  <br>
@@ -343,6 +343,13 @@ if ( ! defined( 'ABSPATH' ) ) die();
343
  <input type="radio" name="<?php echo $this->get_field_name('display') ?>" id="<?php echo $this->get_field_id('display_list') ?>" value="list" <?php if ($renderConfig->display === 'list') echo 'checked="checked"' ?>>
344
  <label for="<?php echo $this->get_field_id('display_list') ?>"><?php _e('List', 'utcw') ?></label><br>
345
  <br>
 
 
 
 
 
 
 
346
 
347
  <strong><?php _e('Term appearance', 'utcw') ?></strong><br>
348
  <a class="utcw-help"
@@ -354,6 +361,10 @@ if ( ! defined( 'ABSPATH' ) ) die();
354
  <input type="checkbox" name="<?php echo $this->get_field_name( 'show_post_count' ) ?>"
355
  id="<?php echo $this->get_field_id( 'show_post_count' ) ?>" <?php echo $renderConfig->show_post_count === true ? 'checked="checked"' : ''?>>
356
  <label for="<?php echo $this->get_field_id( 'show_post_count' ) ?>"><?php _e( 'Show post count', 'utcw' ) ?></label><br>
 
 
 
 
357
  <br>
358
 
359
  <strong><?php _e('Term titles (hover text)', 'utcw') ?></strong><br>
@@ -429,7 +440,7 @@ if ( ! defined( 'ABSPATH' ) ) die();
429
 
430
  <a class="utcw-help"
431
  title="<?php _e( 'The tags can be surrounded by a prefix and/or suffix and separated with a separator. The default separator is just a space but can be changed to anything you\'d like. Remember to add a space before and after the separator, this is not automatically added by the plugin.<br><br>A short example, these settings:<ul><li>Separator: &nbsp;-&nbsp; </li><li>Prefix: (</li><li>Suffix: )</li></ul>… would produce a tag cloud like this: <br><br>(first tag) - (second tag) - (third tag)<br><br>Prefix and suffix characters will have the same size and color as the tag, but the separator will not.', 'utcw' ) ?>">?</a>
432
- <strong><?php _e( 'Tag separators:', 'utcw' )?></strong>
433
  <label class="two-col"
434
  for="<?php echo $this->get_field_id( 'separator' ) ?>"><?php _e( 'Separator', 'utcw' ) ?></label>
435
  <input type="text" size=5 name="<?php echo $this->get_field_name( 'separator' ) ?>"
39
  <a class="utcw-help" title="<?php _e('How the tag cloud should find tags to display. Popularity based selection is the default strategy which shows the most popular tags. Creation time will display the newest terms.', 'utcw') ?>">?</a>
40
  <strong><?php _e('Selection strategy:', 'utcw') ?></strong><br>
41
  <label>
42
+ <input type="radio" name="<?php echo $this->get_field_name('strategy') ?>" value="popularity" <?php if ($dataConfig->strategy instanceof UTCW_PopularityStrategy) echo 'checked="checked"' ?>>
43
  <?php _e('Popularity','utcw') ?>
44
  </label><br>
45
  <label>
46
+ <input type="radio" name="<?php echo $this->get_field_name('strategy') ?>" value="random" <?php if ($dataConfig->strategy instanceof UTCW_RandomStrategy) echo 'checked="checked"' ?>>
47
  <?php _e('Random','utcw') ?>
48
  </label><br>
49
  <label>
50
+ <input type="radio" name="<?php echo $this->get_field_name('strategy') ?>" value="creation" <?php if ($dataConfig->strategy instanceof UTCW_CreationTimeStrategy) echo 'checked="checked"' ?>>
51
  <?php _e('Creation time','utcw') ?>
52
  </label><br>
53
  <label>
54
+ <input type="radio" name="<?php echo $this->get_field_name('strategy') ?>" value="current_list" <?php if ($dataConfig->strategy instanceof UTCW_CurrentListStrategy) echo 'checked="checked"' ?>>
55
  <?php _e('Only terms from the current list','utcw') ?>
56
  </label><br>
57
  <br>
343
  <input type="radio" name="<?php echo $this->get_field_name('display') ?>" id="<?php echo $this->get_field_id('display_list') ?>" value="list" <?php if ($renderConfig->display === 'list') echo 'checked="checked"' ?>>
344
  <label for="<?php echo $this->get_field_id('display_list') ?>"><?php _e('List', 'utcw') ?></label><br>
345
  <br>
346
+ <a class="utcw-help"
347
+ title="<?php _e( 'This option will remove some CSS classes commonly used by themes to apply their own styles to the tag cloud. If the options aren\'t displaying correctly, try enabling this feature. This will make styles closer match the appearance before version 2.3.', 'utcw' ) ?>">?</a>
348
+ <input type="checkbox" name="<?php echo $this->get_field_name( 'avoid_theme_styling' ) ?>"
349
+ id="<?php echo $this->get_field_id( 'avoid_theme_styling' ) ?>" <?php echo $renderConfig->avoid_theme_styling === true ? 'checked="checked"' : ''?>>
350
+ <label for="<?php echo $this->get_field_id( 'avoid_theme_styling' ) ?>"><?php _e( 'Avoid theme styling', 'utcw' ) ?></label><br>
351
+ <br>
352
+
353
 
354
  <strong><?php _e('Term appearance', 'utcw') ?></strong><br>
355
  <a class="utcw-help"
361
  <input type="checkbox" name="<?php echo $this->get_field_name( 'show_post_count' ) ?>"
362
  id="<?php echo $this->get_field_id( 'show_post_count' ) ?>" <?php echo $renderConfig->show_post_count === true ? 'checked="checked"' : ''?>>
363
  <label for="<?php echo $this->get_field_id( 'show_post_count' ) ?>"><?php _e( 'Show post count', 'utcw' ) ?></label><br>
364
+ <a class="utcw-help" title="<?php _e('This option will try to prevent terms with multiple words from breaking up into two lines.', 'utcw') ?>">?</a>
365
+ <input type="checkbox" name="<?php echo $this->get_field_name( 'prevent_breaking' ) ?>"
366
+ id="<?php echo $this->get_field_id( 'prevent_breaking' ) ?>" <?php echo $renderConfig->prevent_breaking === true ? 'checked="checked"' : ''?>>
367
+ <label for="<?php echo $this->get_field_id( 'prevent_breaking' ) ?>"><?php _e( 'Prevent line breaks in terms', 'utcw' ) ?></label><br>
368
  <br>
369
 
370
  <strong><?php _e('Term titles (hover text)', 'utcw') ?></strong><br>
440
 
441
  <a class="utcw-help"
442
  title="<?php _e( 'The tags can be surrounded by a prefix and/or suffix and separated with a separator. The default separator is just a space but can be changed to anything you\'d like. Remember to add a space before and after the separator, this is not automatically added by the plugin.<br><br>A short example, these settings:<ul><li>Separator: &nbsp;-&nbsp; </li><li>Prefix: (</li><li>Suffix: )</li></ul>… would produce a tag cloud like this: <br><br>(first tag) - (second tag) - (third tag)<br><br>Prefix and suffix characters will have the same size and color as the tag, but the separator will not.', 'utcw' ) ?>">?</a>
443
+ <strong><?php _e( 'Tag separators:', 'utcw' )?></strong><br>
444
  <label class="two-col"
445
  for="<?php echo $this->get_field_id( 'separator' ) ?>"><?php _e( 'Separator', 'utcw' ) ?></label>
446
  <input type="text" size=5 name="<?php echo $this->get_field_name( 'separator' ) ?>"
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: exz
3
  Tags: widget, tags, configurable, tag cloud
4
  Requires at least: 3.0
5
- Tested up to: 3.7-beta1
6
  Stable tag: 2.5
7
  Donate link: https://0x539.se/donations/
8
  License: GPLv2 or later
@@ -205,6 +205,8 @@ If you're not able to change your theme you can also use the shortcode `[utcw]`
205
 
206
  The plugin also uses a couple of filters for you to be able to alter the output. These are documented in the [filters documentation at GitHub](https://github.com/rickard2/utcw/blob/master/FILTERS.md).
207
 
 
 
208
  == Configuration ==
209
 
210
  All the configuration options can be found in the [configuration documentation at GitHub](https://github.com/rickard2/utcw/blob/master/CONFIG.md).
2
  Contributors: exz
3
  Tags: widget, tags, configurable, tag cloud
4
  Requires at least: 3.0
5
+ Tested up to: 3.8-beta1
6
  Stable tag: 2.5
7
  Donate link: https://0x539.se/donations/
8
  License: GPLv2 or later
205
 
206
  The plugin also uses a couple of filters for you to be able to alter the output. These are documented in the [filters documentation at GitHub](https://github.com/rickard2/utcw/blob/master/FILTERS.md).
207
 
208
+ As of version 2.6 you can create custom selection strategies, more information can be found in the [strategy documentation at GitHub](https://github.com/rickard2/utcw/blob/master/STRATEGY.md)
209
+
210
  == Configuration ==
211
 
212
  All the configuration options can be found in the [configuration documentation at GitHub](https://github.com/rickard2/utcw/blob/master/CONFIG.md).
src/Config/DataConfig.php CHANGED
@@ -38,6 +38,39 @@
38
  */
39
  class UTCW_DataConfig extends UTCW_Config
40
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  /**
42
  * Creates a new instance of the class and adds all the options
43
  *
@@ -48,7 +81,22 @@ class UTCW_DataConfig extends UTCW_Config
48
  */
49
  public function __construct(array $input, UTCW_Plugin $plugin)
50
  {
51
- $this->addOption('strategy', 'set', array('values' => array('popularity', 'random', 'creation', 'current_list')));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  $this->addOption('order', 'set', array('values' => array('name', 'random', 'slug', 'id', 'color', 'count')));
53
  $this->addOption('tags_list_type', 'set', array('values' => array('exclude', 'include')));
54
  $this->addOption('color', 'set', array('values' => array('none', 'random', 'set', 'span')));
@@ -89,6 +137,8 @@ class UTCW_DataConfig extends UTCW_Config
89
  $this->addOption('case_sensitive', 'boolean');
90
  $this->addOption('post_term_query_var', 'boolean');
91
 
 
 
92
  parent::__construct($input, $plugin);
93
 
94
  $this->checkSizes();
38
  */
39
  class UTCW_DataConfig extends UTCW_Config
40
  {
41
+
42
+ /**
43
+ * @var UTCW_Plugin
44
+ */
45
+ protected $plugin;
46
+
47
+ /**
48
+ * Never serialize the plugin instance
49
+ *
50
+ * @return array
51
+ *
52
+ * @since 2.6
53
+ */
54
+ public function __sleep()
55
+ {
56
+ return array('data', 'options');
57
+ }
58
+
59
+ /**
60
+ * Get a new instance of the plugin
61
+ *
62
+ * @since 2.6
63
+ */
64
+ public function __wakeup()
65
+ {
66
+ $this->plugin = UTCW_Plugin::getInstance();
67
+ }
68
+
69
+ public function strategyFactory($className)
70
+ {
71
+ return new $className($this->plugin);
72
+ }
73
+
74
  /**
75
  * Creates a new instance of the class and adds all the options
76
  *
81
  */
82
  public function __construct(array $input, UTCW_Plugin $plugin)
83
  {
84
+ $this->addOption(
85
+ 'strategy',
86
+ 'class',
87
+ array(
88
+ 'classMap' => array(
89
+ 'popularity' => 'UTCW_PopularityStrategy',
90
+ 'random' => 'UTCW_RandomStrategy',
91
+ 'creation' => 'UTCW_CreationTimeStrategy',
92
+ 'current_list' => 'UTCW_CurrentListStrategy'
93
+ ),
94
+ 'baseClass' => 'UTCW_SelectionStrategy',
95
+ 'default' => 'popularity',
96
+ 'factory' => array($this, 'strategyFactory'),
97
+ )
98
+ );
99
+
100
  $this->addOption('order', 'set', array('values' => array('name', 'random', 'slug', 'id', 'color', 'count')));
101
  $this->addOption('tags_list_type', 'set', array('values' => array('exclude', 'include')));
102
  $this->addOption('color', 'set', array('values' => array('none', 'random', 'set', 'span')));
137
  $this->addOption('case_sensitive', 'boolean');
138
  $this->addOption('post_term_query_var', 'boolean');
139
 
140
+ $this->plugin = $plugin;
141
+
142
  parent::__construct($input, $plugin);
143
 
144
  $this->checkSizes();
src/Config/RenderConfig.php CHANGED
@@ -14,43 +14,45 @@
14
  * Class to represent a the configuration options for cloud rendering retrieval
15
  *
16
  * @since 2.3
17
- * @property-read string title Title text of the widget
18
- * @property-read string letter_spacing CSS letter-spacing value (in pixels)
19
- * @property-read string word_spacing CSS word-spacing value (in pixels)
20
- * @property-read string text_transform CSS text-transform value
21
- * @property-read string show_title If the title attribute should be added to links in the cloud
22
- * @property-read string show_links If the tags should be wrapped in links
23
- * @property-read string link_underline If links should be styled with underline decoration
24
- * @property-read string link_bold If links should be styled as bold
25
- * @property-read string link_italic If links should be styled as italic
26
- * @property-read string link_bg_color Background color for links
27
- * @property-read string link_border_style Border style for links
28
- * @property-read string link_border_width Border width for links
29
- * @property-read string link_border_color Border color for links
30
- * @property-read string hover_underline If links should be decorated with underline decoration in their hover state
31
- * @property-read string hover_bold If links should be styled as bold in their hover state
32
- * @property-read string hover_italic If links should be styled as italic in their hover state
33
- * @property-read string hover_bg_color Background color for links in their hover state
34
- * @property-read string hover_color Text color for links in their hover state
35
- * @property-read string hover_border_style Border style for links in their hover state
36
- * @property-read string hover_border_width Border width for links in their hover state
37
- * @property-read string hover_border_color Border color for links in their hover state
38
- * @property-read string tag_spacing CSS margin between tags
39
- * @property-read bool debug If debug output should be included
40
- * @property-read string line_height CSS line-height for the tags
41
- * @property-read string separator Separator between tags
42
- * @property-read string prefix Prefix before each tag
43
- * @property-read string suffix Suffix after each tag
44
- * @property-read bool show_title_text If the widget title should be shown
45
- * @property-read string alignment How the text in the resulting cloud should be aligned
46
- * @property-read string display How the resulting cloud should be displayed
47
- * @property-read bool show_post_count If the number of posts with that term should be displayed with the name
48
- * @property-read string title_type What type of information the title text should contain
49
- * @property-read string title_custom_template A C-style printf-template for the title text. Include %d to get the post count and %s to get the term name.
50
- * @property-read string before_widget @internal
51
- * @property-read string after_widget @internal
52
- * @property-read string before_title @internal
53
- * @property-read string after_title @internal
 
 
54
  */
55
 
56
  class UTCW_RenderConfig extends UTCW_Config
@@ -169,6 +171,8 @@ class UTCW_RenderConfig extends UTCW_Config
169
  $this->addOption('show_links', 'boolean', array('default' => true));
170
  $this->addOption('show_title_text', 'boolean', array('default' => true));
171
  $this->addOption('show_post_count', 'boolean', array('default' => false));
 
 
172
  $this->addOption('debug', 'boolean');
173
 
174
  parent::__construct($input, $plugin);
14
  * Class to represent a the configuration options for cloud rendering retrieval
15
  *
16
  * @since 2.3
17
+ * @property-read string title Title text of the widget
18
+ * @property-read string letter_spacing CSS letter-spacing value (in pixels)
19
+ * @property-read string word_spacing CSS word-spacing value (in pixels)
20
+ * @property-read string text_transform CSS text-transform value
21
+ * @property-read string show_title If the title attribute should be added to links in the cloud
22
+ * @property-read string show_links If the tags should be wrapped in links
23
+ * @property-read string link_underline If links should be styled with underline decoration
24
+ * @property-read string link_bold If links should be styled as bold
25
+ * @property-read string link_italic If links should be styled as italic
26
+ * @property-read string link_bg_color Background color for links
27
+ * @property-read string link_border_style Border style for links
28
+ * @property-read string link_border_width Border width for links
29
+ * @property-read string link_border_color Border color for links
30
+ * @property-read string hover_underline If links should be decorated with underline decoration in their hover state
31
+ * @property-read string hover_bold If links should be styled as bold in their hover state
32
+ * @property-read string hover_italic If links should be styled as italic in their hover state
33
+ * @property-read string hover_bg_color Background color for links in their hover state
34
+ * @property-read string hover_color Text color for links in their hover state
35
+ * @property-read string hover_border_style Border style for links in their hover state
36
+ * @property-read string hover_border_width Border width for links in their hover state
37
+ * @property-read string hover_border_color Border color for links in their hover state
38
+ * @property-read string tag_spacing CSS margin between tags
39
+ * @property-read bool debug If debug output should be included
40
+ * @property-read string line_height CSS line-height for the tags
41
+ * @property-read string separator Separator between tags
42
+ * @property-read string prefix Prefix before each tag
43
+ * @property-read string suffix Suffix after each tag
44
+ * @property-read bool show_title_text If the widget title should be shown
45
+ * @property-read string alignment How the text in the resulting cloud should be aligned
46
+ * @property-read string display How the resulting cloud should be displayed
47
+ * @property-read bool show_post_count If the number of posts with that term should be displayed with the name
48
+ * @property-read string title_type What type of information the title text should contain
49
+ * @property-read string title_custom_template A C-style printf-template for the title text. Include %d to get the post count and %s to get the term name.
50
+ * @property-read bool prevent_breaking If wrapping lines in the middle of words should be prevented
51
+ * @property-read bool avoid_theme_styling Try to avoid styles applied to the tag cloud from themes
52
+ * @property-read string before_widget @internal
53
+ * @property-read string after_widget @internal
54
+ * @property-read string before_title @internal
55
+ * @property-read string after_title @internal
56
  */
57
 
58
  class UTCW_RenderConfig extends UTCW_Config
171
  $this->addOption('show_links', 'boolean', array('default' => true));
172
  $this->addOption('show_title_text', 'boolean', array('default' => true));
173
  $this->addOption('show_post_count', 'boolean', array('default' => false));
174
+ $this->addOption('prevent_breaking', 'boolean', array('default' => false));
175
+ $this->addOption('avoid_theme_styling', 'boolean', array('default' => false));
176
  $this->addOption('debug', 'boolean');
177
 
178
  parent::__construct($input, $plugin);
src/Config/Type/ClassType.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate Tag Cloud Widget
4
+ *
5
+ * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.5
7
+ * @license GPLv2
8
+ * @package utcw
9
+ * @subpackage config-type
10
+ * @since 2.3
11
+ */
12
+
13
+ /**
14
+ * Class type configuration option
15
+ *
16
+ * @since 2.3
17
+ */
18
+ class UTCW_ClassType extends UTCW_Type
19
+ {
20
+ /**
21
+ * Validates if the value is valid for the given set
22
+ *
23
+ * @param mixed $value
24
+ *
25
+ * @return bool
26
+ * @since 2.3
27
+ */
28
+ function validate($value)
29
+ {
30
+ $classMap = isset($this->options['classMap']) ? $this->options['classMap'] : array();
31
+ $baseClass = $this->options['baseClass'];
32
+
33
+ if ($value instanceof $baseClass) {
34
+ return true;
35
+ }
36
+
37
+ if (!is_string($value)) {
38
+ return false;
39
+ }
40
+
41
+ if (class_exists($value)) {
42
+ $parents = class_parents($value);
43
+
44
+ if (in_array($baseClass, $parents)) {
45
+ return true;
46
+ }
47
+ }
48
+
49
+ if (array_key_exists($value, $classMap)) {
50
+ return true;
51
+ }
52
+
53
+ return false;
54
+ }
55
+
56
+ /**
57
+ * @param mixed $value
58
+ *
59
+ * @return object
60
+ */
61
+ function normalize($value)
62
+ {
63
+ if (is_string($value)) {
64
+
65
+ $className = isset($this->options['classMap'][$value]) ? $this->options['classMap'][$value] : $value;
66
+
67
+ return call_user_func($this->options['factory'], $className);
68
+ }
69
+
70
+ return $value;
71
+ }
72
+
73
+ /**
74
+ * Returns the first value of the set if a default value is not given
75
+ *
76
+ * @return mixed
77
+ * @since 2.3
78
+ */
79
+ function getDefaultValue()
80
+ {
81
+ if (isset($this->options['default'])) {
82
+ return $this->normalize($this->options['default']);
83
+ }
84
+
85
+ if (isset($this->options['classMap']) && is_array($this->options['classMap']) && $this->options['classMap']) {
86
+ return $this->normalize($this->options['classMap'][0]);
87
+ }
88
+
89
+ return '';
90
+ }
91
+ }
src/Config/Type/IntegerType.php CHANGED
@@ -26,7 +26,7 @@ class UTCW_IntegerType extends UTCW_Type
26
  * @return bool
27
  * @since 2.3
28
  */
29
- function validate($value)
30
  {
31
  if (!is_numeric($value)) {
32
  return false;
@@ -62,7 +62,7 @@ class UTCW_IntegerType extends UTCW_Type
62
  * @return int
63
  * @since 2.3
64
  */
65
- function getDefaultValue()
66
  {
67
  if (isset($this->options['default'])) {
68
  return $this->options['default'];
26
  * @return bool
27
  * @since 2.3
28
  */
29
+ public function validate($value)
30
  {
31
  if (!is_numeric($value)) {
32
  return false;
62
  * @return int
63
  * @since 2.3
64
  */
65
+ public function getDefaultValue()
66
  {
67
  if (isset($this->options['default'])) {
68
  return $this->options['default'];
src/Config/Type/MeasurementType.php CHANGED
@@ -15,7 +15,7 @@
15
  *
16
  * @since 2.3
17
  */
18
- class UTCW_MeasurementType extends UTCW_Type
19
  {
20
 
21
  /**
@@ -26,7 +26,7 @@ class UTCW_MeasurementType extends UTCW_Type
26
  * @return bool
27
  * @since 2.3
28
  */
29
- function validate($value)
30
  {
31
  return !!preg_match('/^' . UTCW_DECIMAL_REGEX . '(em|px|%)?$/i', $value);
32
  }
@@ -47,19 +47,4 @@ class UTCW_MeasurementType extends UTCW_Type
47
 
48
  return $value;
49
  }
50
-
51
- /**
52
- * Returns zero if a default value is not given
53
- *
54
- * @return int|mixed
55
- * @since 2.3
56
- */
57
- function getDefaultValue()
58
- {
59
- if (isset($this->options['default'])) {
60
- return $this->options['default'];
61
- }
62
-
63
- return 0;
64
- }
65
  }
15
  *
16
  * @since 2.3
17
  */
18
+ class UTCW_MeasurementType extends UTCW_IntegerType
19
  {
20
 
21
  /**
26
  * @return bool
27
  * @since 2.3
28
  */
29
+ public function validate($value)
30
  {
31
  return !!preg_match('/^' . UTCW_DECIMAL_REGEX . '(em|px|%)?$/i', $value);
32
  }
47
 
48
  return $value;
49
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
src/Data.php CHANGED
@@ -44,14 +44,6 @@ class UTCW_Data
44
  */
45
  protected $plugin;
46
 
47
- /**
48
- * Reference to the selection strategy used
49
- *
50
- * @var UTCW_SelectionStrategy
51
- * @since 2.2
52
- */
53
- protected $strategy;
54
-
55
  /**
56
  * Reference to the translation handler used
57
  *
@@ -76,6 +68,24 @@ class UTCW_Data
76
  */
77
  protected $result;
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  /**
80
  * Creates a new instance
81
  *
@@ -84,25 +94,22 @@ class UTCW_Data
84
  * @since 2.0
85
  */
86
  public function __construct(UTCW_Plugin $plugin)
 
 
 
 
 
 
 
 
 
 
 
 
87
  {
88
  $this->config = $plugin->get('dataConfig');
89
  $this->db = $plugin->get('wpdb');
90
  $this->plugin = $plugin;
91
-
92
- switch ($this->config->strategy) {
93
- case 'popularity':
94
- $this->strategy = new UTCW_PopularityStrategy($this->plugin);
95
- break;
96
- case 'random':
97
- $this->strategy = new UTCW_RandomStrategy($this->plugin);
98
- break;
99
- case 'creation':
100
- $this->strategy = new UTCW_CreationTimeStrategy($this->plugin);
101
- break;
102
- case 'current_list':
103
- $this->strategy = new UTCW_CurrentListStrategy($this->plugin);
104
- break;
105
- }
106
  }
107
 
108
  /**
@@ -114,7 +121,7 @@ class UTCW_Data
114
  public function getTerms()
115
  {
116
  $this->terms = array();
117
- $this->result = $this->strategy->getData();
118
 
119
  // Calculate sizes
120
  $min_count = PHP_INT_MAX;
@@ -163,7 +170,7 @@ class UTCW_Data
163
  switch ($this->config->color) {
164
  case 'random':
165
  foreach ($this->terms as $term) {
166
- $term->color = sprintf(UTCW_HEX_COLOR_FORMAT, rand() % 255, rand() % 255, rand() % 255);
167
  }
168
  break;
169
  case 'set':
@@ -284,31 +291,21 @@ class UTCW_Data
284
  */
285
  protected function addTermFilterQueryVars()
286
  {
287
- $terms = array();
288
  $query = array();
289
 
290
  // First create a map of taxonomy => terms
291
  foreach ($this->config->post_term as $term_id) {
292
- $term = $this->plugin->getTerm($term_id);
293
-
294
- if (!isset($terms[$term->taxonomy])) {
295
- $terms[$term->taxonomy] = array();
296
- }
297
 
298
- $terms[$term->taxonomy][] = $term;
299
- }
300
-
301
- // Create a new map of query_var => terms for each taxonomy that has a query_var
302
- foreach ($terms as $taxonomy => $taxonomyTerms) {
303
-
304
- $taxonomy = $this->plugin->getTaxonomy($taxonomy);
305
 
306
  if ($taxonomy->query_var) {
307
- $query[$taxonomy->query_var] = array();
308
 
309
- foreach ($taxonomyTerms as $term) {
310
- $query[$taxonomy->query_var][] = $term->slug;
311
  }
 
 
312
  }
313
  }
314
 
@@ -339,6 +336,6 @@ class UTCW_Data
339
  unset($this->db);
340
  $this->plugin->remove('wpdb');
341
  $this->plugin->remove('data');
342
- $this->strategy->cleanupForDebug();
343
  }
344
  }
44
  */
45
  protected $plugin;
46
 
 
 
 
 
 
 
 
 
47
  /**
48
  * Reference to the translation handler used
49
  *
68
  */
69
  protected $result;
70
 
71
+ /**
72
+ * Never serialize any of the private members
73
+ *
74
+ * @return array
75
+ */
76
+ public function __sleep()
77
+ {
78
+ return array();
79
+ }
80
+
81
+ /**
82
+ * Reinitialize the private members when waking up
83
+ */
84
+ public function __wakeup()
85
+ {
86
+ $this->init(UTCW_Plugin::getInstance());
87
+ }
88
+
89
  /**
90
  * Creates a new instance
91
  *
94
  * @since 2.0
95
  */
96
  public function __construct(UTCW_Plugin $plugin)
97
+ {
98
+ $this->init($plugin);
99
+ }
100
+
101
+ /**
102
+ * Set up dependencies
103
+ *
104
+ * @param UTCW_Plugin $plugin
105
+ *
106
+ * @since 2.6
107
+ */
108
+ protected function init(UTCW_Plugin $plugin)
109
  {
110
  $this->config = $plugin->get('dataConfig');
111
  $this->db = $plugin->get('wpdb');
112
  $this->plugin = $plugin;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
114
 
115
  /**
121
  public function getTerms()
122
  {
123
  $this->terms = array();
124
+ $this->result = $this->config->strategy->getData();
125
 
126
  // Calculate sizes
127
  $min_count = PHP_INT_MAX;
170
  switch ($this->config->color) {
171
  case 'random':
172
  foreach ($this->terms as $term) {
173
+ $term->color = sprintf(UTCW_HEX_COLOR_FORMAT, rand() % 256, rand() % 256, rand() % 256);
174
  }
175
  break;
176
  case 'set':
291
  */
292
  protected function addTermFilterQueryVars()
293
  {
 
294
  $query = array();
295
 
296
  // First create a map of taxonomy => terms
297
  foreach ($this->config->post_term as $term_id) {
 
 
 
 
 
298
 
299
+ $term = $this->plugin->getTerm($term_id);
300
+ $taxonomy = $this->plugin->getTaxonomy($term->taxonomy);
 
 
 
 
 
301
 
302
  if ($taxonomy->query_var) {
 
303
 
304
+ if (!isset($query[$taxonomy->query_var])) {
305
+ $query[$taxonomy->query_var] = array();
306
  }
307
+
308
+ $query[$taxonomy->query_var][] = $term->slug;
309
  }
310
  }
311
 
336
  unset($this->db);
337
  $this->plugin->remove('wpdb');
338
  $this->plugin->remove('data');
339
+ $this->config->strategy->cleanupForDebug();
340
  }
341
  }
src/Database/QueryBuilder.php CHANGED
@@ -176,17 +176,36 @@ class UTCW_QueryBuilder
176
  /**
177
  * Add post status constraint
178
  *
179
- * @param bool $authenticated
 
180
  *
181
  * @since 2.2
182
  */
183
- public function addPostStatusConstraint($authenticated)
184
  {
 
 
 
 
 
185
  // Authenticated users are allowed to view tags for private posts
186
  if ($authenticated) {
187
- $this->query[] = "AND p.post_status IN ('publish','private')";
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  } else {
189
- $this->query[] = "AND p.post_status = 'publish'";
190
  }
191
  }
192
 
@@ -235,24 +254,21 @@ class UTCW_QueryBuilder
235
  */
236
  public function addTagsListConstraint($type, array $list, array $taxonomy)
237
  {
238
- if ($list) {
239
- $tags_list_parameters = array();
240
-
241
- foreach ($list as $tag_id) {
242
- if ($this->plugin->checkTermTaxonomy($tag_id, $taxonomy)) {
243
- $tags_list_parameters[] = '%d';
244
- $this->parameters[] = $tag_id;
245
- }
246
- }
247
 
248
- if ($tags_list_parameters) {
249
- $tags_list_operator = $type == 'include' ? 'IN' : 'NOT IN';
250
- $this->query[] = 'AND t.term_id ' . $tags_list_operator . ' (' . join(
251
- ',',
252
- $tags_list_parameters
253
- ) . ')';
254
  }
255
  }
 
 
 
 
 
 
 
256
  }
257
 
258
  /**
@@ -304,44 +320,28 @@ class UTCW_QueryBuilder
304
  */
305
  public function addSort($order, $reverse, $case_sensitive)
306
  {
 
 
 
 
 
 
307
  // If the result should be ordered in another way, try to create a sub-query to sort the result
308
  // directly in the database query
309
- $subquery_required = true;
 
310
 
311
- // No subquery is needed if the order should be by count desc (it's already sorted that way)
312
- if ($reverse && $order == 'count') {
313
- $subquery_required = false;
314
- }
315
 
316
- // No subquery is needed if the order should be by color since the sorting is done in PHP afterwards
317
- if ($order == 'color') {
318
- $subquery_required = false;
319
- }
 
 
 
320
 
321
- if ($subquery_required) {
322
- array_unshift($this->query, 'SELECT * FROM (');
323
- $this->query[] = ') AS subQuery';
324
-
325
- $way = $reverse ? 'DESC' : 'ASC';
326
- $binary = $case_sensitive ? 'BINARY ' : '';
327
-
328
- switch ($order) {
329
- case 'random':
330
- $this->query[] = 'ORDER BY RAND() ' . $way;
331
- break;
332
- case 'name':
333
- $this->query[] = 'ORDER BY ' . $binary . 'name ' . $way;
334
- break;
335
- case 'slug':
336
- $this->query[] = 'ORDER BY ' . $binary . 'slug ' . $way;
337
- break;
338
- case 'id':
339
- $this->query[] = 'ORDER BY term_id ' . $way;
340
- break;
341
- case 'count':
342
- $this->query[] = 'ORDER BY count ' . $way;
343
- break;
344
- }
345
- }
346
  }
347
  }
176
  /**
177
  * Add post status constraint
178
  *
179
+ * @param bool $authenticated
180
+ * @param array $post_types
181
  *
182
  * @since 2.2
183
  */
184
+ public function addPostStatusConstraint($authenticated, array $post_types)
185
  {
186
+ $statuses = array('publish');
187
+ $containsAttachment = in_array('attachment', $post_types);
188
+ $singlePostType = count($post_types) === 1;
189
+ $multiPostType = count($post_types) > 1;
190
+
191
  // Authenticated users are allowed to view tags for private posts
192
  if ($authenticated) {
193
+ $statuses[] = 'private';
194
+ }
195
+
196
+ // If attachment is the only post type its safe to include inherit in the IN clause
197
+ if ($containsAttachment && $singlePostType) {
198
+ $statuses[] = 'inherit';
199
+ }
200
+
201
+ $condition = "p.post_status IN ('" . join("','", $statuses) . "')";
202
+
203
+ // If attachment is one of the post types in a multi post type cloud
204
+ // check that only attachments are allowed the post status inherit
205
+ if ($containsAttachment && $multiPostType) {
206
+ $this->query[] = "AND (" . $condition . " OR (post_type = 'attachment' AND post_status = 'inherit'))";
207
  } else {
208
+ $this->query[] = "AND " . $condition;
209
  }
210
  }
211
 
254
  */
255
  public function addTagsListConstraint($type, array $list, array $taxonomy)
256
  {
257
+ $parameters = array();
 
 
 
 
 
 
 
 
258
 
259
+ foreach ($list as $tag_id) {
260
+ if ($this->plugin->checkTermTaxonomy($tag_id, $taxonomy)) {
261
+ $parameters[] = '%d';
262
+ $this->parameters[] = $tag_id;
 
 
263
  }
264
  }
265
+
266
+ if (!$parameters) {
267
+ return;
268
+ }
269
+
270
+ $operator = $type == 'include' ? 'IN' : 'NOT IN';
271
+ $this->query[] = 'AND t.term_id ' . $operator . ' (' . join(',', $parameters) . ')';
272
  }
273
 
274
  /**
320
  */
321
  public function addSort($order, $reverse, $case_sensitive)
322
  {
323
+ // No subquery is needed if the order should be by count desc (it's already sorted that way)
324
+ // No subquery is needed if the order should be by color since the sorting is done in PHP afterwards
325
+ if ($order == 'color' || $reverse && $order == 'count') {
326
+ return;
327
+ }
328
+
329
  // If the result should be ordered in another way, try to create a sub-query to sort the result
330
  // directly in the database query
331
+ array_unshift($this->query, 'SELECT * FROM (');
332
+ $this->query[] = ') AS subQuery';
333
 
334
+ $way = $reverse ? 'DESC' : 'ASC';
335
+ $binary = $case_sensitive ? 'BINARY ' : '';
 
 
336
 
337
+ $orderStatementMap = array(
338
+ 'random' => 'ORDER BY RAND() ' . $way,
339
+ 'name' => 'ORDER BY ' . $binary . 'name ' . $way,
340
+ 'slug' => 'ORDER BY ' . $binary . 'slug ' . $way,
341
+ 'id' => 'ORDER BY term_id ' . $way,
342
+ 'count' => 'ORDER BY count ' . $way,
343
+ );
344
 
345
+ $this->query[] = $orderStatementMap[$order];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
  }
347
  }
src/Plugin.php CHANGED
@@ -78,6 +78,16 @@ class UTCW_Plugin
78
  add_action('wp_ajax_utcw_get_authors', array($this, 'outputAuthorsJson'));
79
  // add_action('init', array($this, 'setCacheHandler')); Disabled for now
80
  add_action('init', array($this, 'setTranslationHandler'));
 
 
 
 
 
 
 
 
 
 
81
  }
82
 
83
  /**
78
  add_action('wp_ajax_utcw_get_authors', array($this, 'outputAuthorsJson'));
79
  // add_action('init', array($this, 'setCacheHandler')); Disabled for now
80
  add_action('init', array($this, 'setTranslationHandler'));
81
+ add_action('init', array($this, 'initLocalisation'));
82
+ }
83
+
84
+ /**
85
+ * Initializes localisation
86
+ *
87
+ * @since 2.6
88
+ */
89
+ public function initLocalisation() {
90
+ load_plugin_textdomain('utcw', false, '/ultimate-tag-cloud-widget/language/');
91
  }
92
 
93
  /**
src/Render.php CHANGED
@@ -101,7 +101,7 @@ class UTCW_Render
101
  $markup[] = $this->plugin->applyFilters('utcw_render_css', $this->css);
102
  }
103
 
104
- if ($this->config->before_widget) {
105
  $markup[] = str_replace('widget_utcw', 'widget_utcw widget_tag_cloud', $this->config->before_widget);
106
  }
107
 
@@ -117,7 +117,13 @@ class UTCW_Render
117
  }
118
  }
119
 
120
- $markup[] = '<div class="tagcloud utcw-' . $this->id . '">';
 
 
 
 
 
 
121
 
122
  $termObjects = $this->plugin->applyFilters('utcw_render_terms', $this->data->getTerms());
123
 
@@ -187,149 +193,35 @@ class UTCW_Render
187
  */
188
  private function buildCSS()
189
  {
190
- $main_styles = array('word-wrap:break-word');
191
-
192
- if (!$this->hasDefaultValue('text_transform')) {
193
- $main_styles[] = sprintf('text-transform:%s', $this->config->text_transform);
194
- }
195
-
196
- if (!$this->hasDefaultValue('letter_spacing')) {
197
- $main_styles[] = sprintf('letter-spacing:%s', $this->config->letter_spacing);
198
- }
199
-
200
- if (!$this->hasDefaultValue('word_spacing')) {
201
- $main_styles[] = sprintf('word-spacing:%s', $this->config->word_spacing);
202
- }
203
-
204
- if (!$this->hasDefaultValue('alignment')) {
205
- $main_styles[] = sprintf('text-align:%s', $this->config->alignment);
206
- }
207
-
208
- $link_styles = array();
209
-
210
- if (!$this->hasDefaultValue('link_underline')) {
211
- $link_styles[] = sprintf(
212
- 'text-decoration:%s',
213
- $this->config->link_underline === 'yes' ? 'underline' : 'none'
214
- );
215
- }
216
-
217
- if (!$this->hasDefaultValue('link_bold')) {
218
- $link_styles[] = sprintf('font-weight:%s', $this->config->link_bold === 'yes' ? 'bold' : 'normal');
219
- }
220
-
221
- if (!$this->hasDefaultValue('link_italic')) {
222
- $link_styles[] = sprintf('font-style:%s', $this->config->link_italic === 'yes' ? 'italic' : 'normal');
223
- }
224
-
225
- if (!$this->hasDefaultValue('link_bg_color')) {
226
- $link_styles[] = sprintf('background-color:%s', $this->config->link_bg_color);
227
- }
228
-
229
- if (
230
- !$this->hasDefaultValue('link_border_style') &&
231
- !$this->hasDefaultValue('link_border_color') &&
232
- !$this->hasDefaultValue('link_border_width')
233
- ) {
234
- $link_styles[] = sprintf(
235
- 'border:%s %s %s',
236
- $this->config->link_border_style,
237
- $this->config->link_border_width,
238
- $this->config->link_border_color
239
- );
240
- } else {
241
- if (!$this->hasDefaultValue('link_border_style')) {
242
- $link_styles[] = sprintf('border-style:%s', $this->config->link_border_style);
243
- }
244
 
245
- if (!$this->hasDefaultValue('link_border_color')) {
246
- $link_styles[] = sprintf('border-color:%s', $this->config->link_border_color);
247
- }
248
-
249
- if (!$this->hasDefaultValue('link_border_width')) {
250
- $link_styles[] = sprintf('border-width:%s', $this->config->link_border_width);
251
- }
252
- }
253
 
254
- if (!$this->hasDefaultValue('tag_spacing')) {
255
- $link_styles[] = sprintf('margin-right:%s', $this->config->tag_spacing);
256
- }
257
 
258
- if (!$this->hasDefaultValue('line_height')) {
259
- $link_styles[] = sprintf('line-height:%s', $this->config->line_height);
260
- }
261
 
262
- $hover_styles = array();
263
 
264
- if (!$this->hasDefaultValue('hover_underline')) {
265
- $hover_styles[] = sprintf(
266
- 'text-decoration:%s',
267
- $this->config->hover_underline === 'yes' ? 'underline' : 'none'
268
- );
269
- }
270
-
271
- if (!$this->hasDefaultValue('hover_bold')) {
272
- $hover_styles[] = sprintf('font-weight:%s', $this->config->hover_bold === 'yes' ? 'bold' : 'normal');
273
- }
274
-
275
- if (!$this->hasDefaultValue('hover_italic')) {
276
- $hover_styles[] = sprintf('font-style:%s', $this->config->hover_italic === 'yes' ? 'italic' : 'normal');
277
- }
278
-
279
- if (!$this->hasDefaultValue('hover_bg_color')) {
280
- $hover_styles[] = sprintf('background-color:%s', $this->config->hover_bg_color);
281
- }
282
-
283
-
284
- if (!$this->hasDefaultValue('hover_border_style') && !$this->hasDefaultValue(
285
- 'hover_border_color'
286
- ) && !$this->hasDefaultValue('hover_border_width')
287
- ) {
288
- $hover_styles[] = sprintf(
289
- 'border:%s %s %s',
290
- $this->config->hover_border_style,
291
- $this->config->hover_border_width,
292
- $this->config->hover_border_color
293
- );
294
- } else {
295
- if (!$this->hasDefaultValue('hover_border_style')) {
296
- $hover_styles[] = sprintf('border-style:%s', $this->config->hover_border_style);
297
- }
298
-
299
- if (!$this->hasDefaultValue('hover_border_color')) {
300
- $hover_styles[] = sprintf('border-color:%s', $this->config->hover_border_color);
301
- }
302
 
303
- if (!$this->hasDefaultValue('hover_border_width')) {
304
- $hover_styles[] = sprintf('border-width:%s', $this->config->hover_border_width);
305
  }
306
- }
307
 
308
- if (!$this->hasDefaultValue('hover_color')) {
309
- $hover_styles[] = sprintf('color:%s', $this->config->hover_color);
310
  }
311
 
312
- $styles = array();
313
-
314
- if ($main_styles) {
315
- $styles[] = sprintf('.utcw-%s{%s}', $this->id, join(';', $main_styles));
316
- }
317
-
318
- if ($link_styles) {
319
- $styles[] = sprintf('.utcw-%s span,.utcw-%s a{%s}', $this->id, $this->id, join(';', $link_styles));
320
- }
321
-
322
- if ($hover_styles) {
323
- $styles[] = sprintf(
324
- '.utcw-%s span:hover,.utcw-%s a:hover{%s}',
325
- $this->id,
326
- $this->id,
327
- join(';', $hover_styles)
328
- );
329
- }
330
-
331
- if ($styles) {
332
- $this->css = sprintf('<style scoped type="text/css">%s</style>', join('', $styles));
333
  }
334
  }
335
 
@@ -385,20 +277,4 @@ class UTCW_Render
385
 
386
  return $title;
387
  }
388
-
389
- /**
390
- * Checks if option still has the default value
391
- *
392
- * @param string $option
393
- *
394
- * @return bool
395
- * @since 2.0
396
- */
397
- private function hasDefaultValue($option)
398
- {
399
- $defaultConfig = new UTCW_RenderConfig(array(), $this->plugin);
400
- $defaults = $defaultConfig->getInstance();
401
-
402
- return $this->config->$option === $defaults[$option];
403
- }
404
  }
101
  $markup[] = $this->plugin->applyFilters('utcw_render_css', $this->css);
102
  }
103
 
104
+ if ($this->config->before_widget && !$this->config->avoid_theme_styling) {
105
  $markup[] = str_replace('widget_utcw', 'widget_utcw widget_tag_cloud', $this->config->before_widget);
106
  }
107
 
117
  }
118
  }
119
 
120
+ $classes = array('utcw-' . $this->id);
121
+
122
+ if (!$this->config->avoid_theme_styling) {
123
+ $classes[] = 'tagcloud';
124
+ }
125
+
126
+ $markup[] = '<div class="' . join(' ', $classes) . '">';
127
 
128
  $termObjects = $this->plugin->applyFilters('utcw_render_terms', $this->data->getTerms());
129
 
193
  */
194
  private function buildCSS()
195
  {
196
+ /** @var UTCW_StyleProvider[] $providers */
197
+ $providers = array(
198
+ new UTCW_MainStyleProvider($this->plugin),
199
+ new UTCW_LinkStyleProvider($this->plugin),
200
+ new UTCW_HoverStyleProvider($this->plugin),
201
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
 
203
+ $css = array();
 
 
 
 
 
 
 
204
 
205
+ foreach ($providers as $provider) {
 
 
206
 
207
+ $selectors = $provider->getSelectors();
208
+ $styles = $provider->getStyles();
 
209
 
210
+ if ($styles) {
211
 
212
+ // Add base class to each selector
213
+ foreach ($selectors as $key => $selector) {
214
+ $selectors[$key] = sprintf('.utcw-%s %s', $this->id, $selector);
215
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
 
217
+ // Construct CSS with comma separated selectors and the styles
218
+ $css[] = sprintf('%s{%s}', join(',', $selectors), join(';', $styles));
219
  }
 
220
 
 
 
221
  }
222
 
223
+ if ($css) {
224
+ $this->css = sprintf('<style scoped type="text/css">%s</style>', join('', $css));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  }
226
  }
227
 
277
 
278
  return $title;
279
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  }
src/Selection/CreationTimeStrategy.php CHANGED
@@ -6,7 +6,7 @@
6
  * @version 2.5
7
  * @license GPLv2
8
  * @package utcw
9
- * @subpackage language
10
  * @since 2.5
11
  */
12
 
@@ -20,97 +20,14 @@
20
  class UTCW_CreationTimeStrategy extends UTCW_SelectionStrategy
21
  {
22
  /**
23
- * Config class instance
24
- *
25
- * @var UTCW_Config
26
- * @since 2.5
27
- */
28
- protected $config;
29
-
30
- /**
31
- * Plugin class instance
32
- *
33
- * @var UTCW_Plugin
34
- * @since 2.5
35
- */
36
- protected $plugin;
37
-
38
- /**
39
- * WP Database class instance
40
- *
41
- * @var wpdb
42
- * @since 2.5
43
- */
44
- protected $db;
45
-
46
- /**
47
- * A copy of the SQL query for debugging purposes
48
- *
49
- * @var string
50
- * @since 2.5
51
- */
52
- protected $query;
53
-
54
- /**
55
- * Creates a new instance
56
  *
57
- * @param UTCW_Plugin $plugin Main plugin instance
58
  *
59
- * @since 2.5
60
  */
61
- public function __construct(UTCW_Plugin $plugin)
62
  {
63
- $this->config = $plugin->get('dataConfig');
64
- $this->db = $plugin->get('wpdb');
65
- $this->plugin = $plugin;
66
- }
67
-
68
- /**
69
- * Returns term data based on current configuration
70
- *
71
- * @return stdClass[]
72
- * @since 2.5
73
- */
74
- public function getData()
75
- {
76
- $builder = new UTCW_QueryBuilder($this->plugin, $this->db);
77
-
78
- $builder->addAuthorConstraint($this->config->authors);
79
- $builder->addPostTypeConstraint($this->config->post_type);
80
- $builder->addPostStatusConstraint($this->plugin->isAuthenticatedUser());
81
- $builder->addDaysOldConstraint($this->config->days_old);
82
- $builder->addTaxonomyConstraint($this->config->taxonomy);
83
- $builder->addTagsListConstraint(
84
- $this->config->tags_list_type,
85
- $this->config->tags_list,
86
- $this->config->taxonomy
87
- );
88
- $builder->addPostTermConstraint($this->config->post_term);
89
- $builder->addGrouping();
90
- $builder->addMinimum($this->config->minimum);
91
  $builder->addStatement('ORDER BY term_id DESC');
92
- $builder->addMaxConstraint($this->config->max);
93
- $builder->addSort($this->config->order, $this->config->reverse, $this->config->case_sensitive);
94
-
95
- $query = $builder->getQuery();
96
- $parameters = $builder->getParameters();
97
- $query = $this->db->prepare($query, $parameters);
98
-
99
- $result = $this->db->get_results($query);
100
- $this->query = $this->db->last_query;
101
-
102
- return $result;
103
- }
104
-
105
- /**
106
- * Clean up the internal members for debug output
107
- *
108
- * @return void
109
- * @since 2.5
110
- */
111
- public function cleanupForDebug()
112
- {
113
- unset($this->db);
114
- $this->plugin->remove('wpdb');
115
  }
116
  }
6
  * @version 2.5
7
  * @license GPLv2
8
  * @package utcw
9
+ * @subpackage selection
10
  * @since 2.5
11
  */
12
 
20
  class UTCW_CreationTimeStrategy extends UTCW_SelectionStrategy
21
  {
22
  /**
23
+ * Add sorting by term_id (effectively by creation time) to query
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  *
25
+ * @param UTCW_QueryBuilder $builder
26
  *
27
+ * @since 2.6
28
  */
29
+ public function buildQuery(UTCW_QueryBuilder $builder)
30
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  $builder->addStatement('ORDER BY term_id DESC');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
  }
src/Selection/CurrentListStrategy.php CHANGED
@@ -6,7 +6,7 @@
6
  * @version 2.5
7
  * @license GPLv2
8
  * @package utcw
9
- * @subpackage language
10
  * @since 2.5
11
  */
12
 
@@ -19,84 +19,19 @@
19
  */
20
  class UTCW_CurrentListStrategy extends UTCW_SelectionStrategy
21
  {
22
- /**
23
- * Config class instance
24
- *
25
- * @var UTCW_Config
26
- * @since 2.5
27
- */
28
- protected $config;
29
 
30
  /**
31
- * Plugin class instance
32
  *
33
- * @var UTCW_Plugin
34
- * @since 2.5
35
- */
36
- protected $plugin;
37
-
38
- /**
39
- * WP Database class instance
40
- *
41
- * @var wpdb
42
- * @since 2.5
43
- */
44
- protected $db;
45
-
46
- /**
47
- * A copy of the SQL query for debugging purposes
48
- *
49
- * @var string
50
- * @since 2.5
51
- */
52
- protected $query;
53
-
54
- /**
55
- * Creates a new instance
56
- *
57
- * @param UTCW_Plugin $plugin Main plugin instance
58
- *
59
- * @since 2.5
60
- */
61
- public function __construct(UTCW_Plugin $plugin)
62
- {
63
- $this->config = $plugin->get('dataConfig');
64
- $this->db = $plugin->get('wpdb');
65
- $this->plugin = $plugin;
66
- }
67
-
68
- /**
69
- * Returns term data based on current configuration
70
  *
71
- * @return stdClass[]
72
- * @since 2.5
73
  */
74
- public function getData()
75
  {
76
- $terms = $this->plugin->getCurrentQueryTerms();
77
-
78
- if (!$terms) {
79
- return array();
80
- }
81
-
82
  $termIds = array_map(create_function('$term', 'return $term->term_id;'), $terms);
83
 
84
- $builder = new UTCW_QueryBuilder($this->plugin, $this->db);
85
-
86
- $builder->addAuthorConstraint($this->config->authors);
87
- $builder->addPostTypeConstraint($this->config->post_type);
88
- $builder->addPostStatusConstraint($this->plugin->isAuthenticatedUser());
89
- $builder->addDaysOldConstraint($this->config->days_old);
90
- $builder->addTaxonomyConstraint($this->config->taxonomy);
91
- $builder->addTagsListConstraint(
92
- $this->config->tags_list_type,
93
- $this->config->tags_list,
94
- $this->config->taxonomy
95
- );
96
- $builder->addPostTermConstraint($this->config->post_term);
97
- $builder->addGrouping();
98
- $builder->addMinimum($this->config->minimum);
99
-
100
  $parameters = array();
101
 
102
  foreach ($termIds as $termId) {
@@ -105,29 +40,22 @@ class UTCW_CurrentListStrategy extends UTCW_SelectionStrategy
105
  }
106
 
107
  $builder->addStatement('AND term_id IN (' . join(',', $parameters) . ')');
108
-
109
- $builder->addMaxConstraint($this->config->max);
110
- $builder->addSort($this->config->order, $this->config->reverse, $this->config->case_sensitive);
111
-
112
- $query = $builder->getQuery();
113
- $parameters = $builder->getParameters();
114
- $query = $this->db->prepare($query, $parameters);
115
-
116
- $result = $this->db->get_results($query);
117
- $this->query = $this->db->last_query;
118
-
119
- return $result;
120
  }
121
 
122
  /**
123
- * Clean up the internal members for debug output
124
  *
125
- * @return void
126
  * @since 2.5
127
  */
128
- public function cleanupForDebug()
129
  {
130
- unset($this->db);
131
- $this->plugin->remove('wpdb');
 
 
 
 
 
132
  }
133
  }
6
  * @version 2.5
7
  * @license GPLv2
8
  * @package utcw
9
+ * @subpackage selection
10
  * @since 2.5
11
  */
12
 
19
  */
20
  class UTCW_CurrentListStrategy extends UTCW_SelectionStrategy
21
  {
 
 
 
 
 
 
 
22
 
23
  /**
24
+ * Add constraint to only contain the terms associated with the terms in the current list
25
  *
26
+ * @param UTCW_QueryBuilder $builder
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  *
28
+ * @since 2.6
 
29
  */
30
+ public function buildQuery(UTCW_QueryBuilder $builder)
31
  {
32
+ $terms = $this->plugin->getCurrentQueryTerms();
 
 
 
 
 
33
  $termIds = array_map(create_function('$term', 'return $term->term_id;'), $terms);
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  $parameters = array();
36
 
37
  foreach ($termIds as $termId) {
40
  }
41
 
42
  $builder->addStatement('AND term_id IN (' . join(',', $parameters) . ')');
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
 
45
  /**
46
+ * Returns an empty array if no terms could be found in the current list
47
  *
48
+ * @return stdClass[]
49
  * @since 2.5
50
  */
51
+ public function getData()
52
  {
53
+ $terms = $this->plugin->getCurrentQueryTerms();
54
+
55
+ if (!$terms) {
56
+ return array();
57
+ }
58
+
59
+ return parent::getData();
60
  }
61
  }
src/Selection/PopularityStrategy.php CHANGED
@@ -6,7 +6,7 @@
6
  * @version 2.3
7
  * @license GPLv2
8
  * @package utcw
9
- * @subpackage language
10
  * @since 2.2
11
  */
12
 
@@ -20,97 +20,14 @@
20
  class UTCW_PopularityStrategy extends UTCW_SelectionStrategy
21
  {
22
  /**
23
- * Config class instance
24
- *
25
- * @var UTCW_Config
26
- * @since 2.2
27
- */
28
- protected $config;
29
-
30
- /**
31
- * Plugin class instance
32
- *
33
- * @var UTCW_Plugin
34
- * @since 2.2
35
- */
36
- protected $plugin;
37
-
38
- /**
39
- * WP Database class instance
40
- *
41
- * @var wpdb
42
- * @since 2.2
43
- */
44
- protected $db;
45
-
46
- /**
47
- * A copy of the SQL query for debugging purposes
48
- *
49
- * @var string
50
- * @since 2.2
51
- */
52
- protected $query;
53
-
54
- /**
55
- * Creates a new instance
56
  *
57
- * @param UTCW_Plugin $plugin Main plugin instance
58
  *
59
- * @since 2.2
60
  */
61
- public function __construct(UTCW_Plugin $plugin)
62
  {
63
- $this->config = $plugin->get('dataConfig');
64
- $this->db = $plugin->get('wpdb');
65
- $this->plugin = $plugin;
66
- }
67
-
68
- /**
69
- * Returns term data based on current configuration
70
- *
71
- * @return stdClass[]
72
- * @since 2.2
73
- */
74
- public function getData()
75
- {
76
- $builder = new UTCW_QueryBuilder($this->plugin, $this->db);
77
-
78
- $builder->addAuthorConstraint($this->config->authors);
79
- $builder->addPostTypeConstraint($this->config->post_type);
80
- $builder->addPostStatusConstraint($this->plugin->isAuthenticatedUser());
81
- $builder->addDaysOldConstraint($this->config->days_old);
82
- $builder->addTaxonomyConstraint($this->config->taxonomy);
83
- $builder->addTagsListConstraint(
84
- $this->config->tags_list_type,
85
- $this->config->tags_list,
86
- $this->config->taxonomy
87
- );
88
- $builder->addPostTermConstraint($this->config->post_term);
89
- $builder->addGrouping();
90
- $builder->addMinimum($this->config->minimum);
91
  $builder->addStatement('ORDER BY count DESC');
92
- $builder->addMaxConstraint($this->config->max);
93
- $builder->addSort($this->config->order, $this->config->reverse, $this->config->case_sensitive);
94
-
95
- $query = $builder->getQuery();
96
- $parameters = $builder->getParameters();
97
- $query = $this->db->prepare($query, $parameters);
98
-
99
- $result = $this->db->get_results($query);
100
- $this->query = $this->db->last_query;
101
-
102
- return $result;
103
- }
104
-
105
- /**
106
- * Clean up the internal members for debug output
107
- *
108
- * @return void
109
- * @since 2.2
110
- */
111
- public function cleanupForDebug()
112
- {
113
- unset($this->db);
114
- $this->plugin->remove('wpdb');
115
  }
116
  }
6
  * @version 2.3
7
  * @license GPLv2
8
  * @package utcw
9
+ * @subpackage selection
10
  * @since 2.2
11
  */
12
 
20
  class UTCW_PopularityStrategy extends UTCW_SelectionStrategy
21
  {
22
  /**
23
+ * Adds sorting by count to the query
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  *
25
+ * @param UTCW_QueryBuilder $builder
26
  *
27
+ * @since 2.6
28
  */
29
+ protected function buildQuery(UTCW_QueryBuilder $builder)
30
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  $builder->addStatement('ORDER BY count DESC');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
  }
src/Selection/RandomStrategy.php CHANGED
@@ -6,7 +6,7 @@
6
  * @version 2.5
7
  * @license GPLv2
8
  * @package utcw
9
- * @subpackage language
10
  * @since 2.2
11
  */
12
 
@@ -20,98 +20,14 @@
20
  class UTCW_RandomStrategy extends UTCW_SelectionStrategy
21
  {
22
  /**
23
- * Config class instance
24
- *
25
- * @var UTCW_Config
26
- * @since 2.2
27
- */
28
- protected $config;
29
-
30
- /**
31
- * Plugin class instance
32
- *
33
- * @var UTCW_Plugin
34
- * @since 2.2
35
- */
36
- protected $plugin;
37
-
38
- /**
39
- * WP Database class instance
40
- *
41
- * @var wpdb
42
- * @since 2.2
43
- */
44
- protected $db;
45
-
46
- /**
47
- * A copy of the SQL query for debugging purposes
48
- *
49
- * @var string
50
- * @since 2.2
51
- */
52
- protected $query;
53
-
54
- /**
55
- * Creates a new instance
56
  *
57
- * @param UTCW_Plugin $plugin Main plugin instance
58
  *
59
- * @since 2.2
60
  */
61
- public function __construct(UTCW_Plugin $plugin)
62
  {
63
- $this->config = $plugin->get('dataConfig');
64
- $this->db = $plugin->get('wpdb');
65
- $this->plugin = $plugin;
66
- }
67
-
68
- /**
69
- * Returns term data based on current configuration
70
- *
71
- * @return stdClass[]
72
- * @since 2.2
73
- */
74
- public function getData()
75
- {
76
- $builder = new UTCW_QueryBuilder($this->plugin, $this->db);
77
-
78
- $builder->addAuthorConstraint($this->config->authors);
79
- $builder->addPostTypeConstraint($this->config->post_type);
80
- $builder->addPostStatusConstraint($this->plugin->isAuthenticatedUser());
81
- $builder->addDaysOldConstraint($this->config->days_old);
82
- $builder->addTaxonomyConstraint($this->config->taxonomy);
83
- $builder->addTagsListConstraint(
84
- $this->config->tags_list_type,
85
- $this->config->tags_list,
86
- $this->config->taxonomy
87
- );
88
- $builder->addPostTermConstraint($this->config->post_term);
89
- $builder->addGrouping();
90
- $builder->addMinimum($this->config->minimum);
91
  $builder->addStatement('ORDER BY RAND()');
92
- $builder->addMaxConstraint($this->config->max);
93
- $builder->addSort($this->config->order, $this->config->reverse, $this->config->case_sensitive);
94
-
95
- $query = $builder->getQuery();
96
- $parameters = $builder->getParameters();
97
- $query = $this->db->prepare($query, $parameters);
98
-
99
- $result = $this->db->get_results($query);
100
- $this->query = $this->db->last_query;
101
-
102
- return $result;
103
- }
104
-
105
- /**
106
- * Clean up the internal members for debug output
107
- *
108
- * @return void
109
- * @since 2.2
110
- */
111
- public function cleanupForDebug()
112
- {
113
- unset($this->db);
114
- $this->plugin->remove('wpdb');
115
-
116
  }
117
  }
6
  * @version 2.5
7
  * @license GPLv2
8
  * @package utcw
9
+ * @subpackage selection
10
  * @since 2.2
11
  */
12
 
20
  class UTCW_RandomStrategy extends UTCW_SelectionStrategy
21
  {
22
  /**
23
+ * Add random sorting to query
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  *
25
+ * @param UTCW_QueryBuilder $builder
26
  *
27
+ * @since 2.6
28
  */
29
+ public function buildQuery(UTCW_QueryBuilder $builder)
30
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  $builder->addStatement('ORDER BY RAND()');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
  }
src/Selection/SelectionStrategy.php CHANGED
@@ -15,31 +15,135 @@
15
  *
16
  * @since 2.2
17
  * @package utcw
18
- * @subpackage language
19
  */
20
- abstract class UTCW_SelectionStrategy
21
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  /**
23
  * Creates a new instance
24
  *
25
  * @param UTCW_Plugin $plugin Main plugin instance
26
  *
27
- * @since 2.0
28
  */
29
- abstract public function __construct(UTCW_Plugin $plugin);
 
 
 
30
 
31
  /**
32
  * Loads terms based on current configuration
33
  *
34
  * @return stdClass[]
35
- * @since 2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  */
37
- abstract public function getData();
 
 
 
38
 
39
  /**
40
  * Clean up the internal members for debug output
41
  *
42
  * @return void
43
  */
44
- abstract public function cleanupForDebug();
 
 
 
45
  }
15
  *
16
  * @since 2.2
17
  * @package utcw
18
+ * @subpackage selection
19
  */
20
+ class UTCW_SelectionStrategy
21
  {
22
+ /**
23
+ * Plugin class instance
24
+ *
25
+ * @var UTCW_Plugin
26
+ * @since 2.2
27
+ */
28
+ protected $plugin;
29
+
30
+ /**
31
+ * A copy of the SQL query for debugging purposes
32
+ *
33
+ * @var string
34
+ * @since 2.2
35
+ */
36
+ protected $query;
37
+
38
+ /**
39
+ * Don't serialize any of the members
40
+ *
41
+ * @return array
42
+ *
43
+ * @since 2.6
44
+ */
45
+ public function __sleep()
46
+ {
47
+ return array();
48
+ }
49
+
50
+ /**
51
+ * Request a new plugin instance when unserialized
52
+ *
53
+ * @since 2.6
54
+ */
55
+ public function __wakeup()
56
+ {
57
+ $this->plugin = UTCW_Plugin::getInstance();
58
+ }
59
+
60
  /**
61
  * Creates a new instance
62
  *
63
  * @param UTCW_Plugin $plugin Main plugin instance
64
  *
65
+ * @since 2.2
66
  */
67
+ public function __construct(UTCW_Plugin $plugin)
68
+ {
69
+ $this->plugin = $plugin;
70
+ }
71
 
72
  /**
73
  * Loads terms based on current configuration
74
  *
75
  * @return stdClass[]
76
+ * @since 2.2
77
+ */
78
+ public function getData()
79
+ {
80
+ $db = $this->plugin->get('wpdb');
81
+ $query = $this->getQuery();
82
+
83
+ $result = $db->get_results($query);
84
+ $this->query = $db->last_query;
85
+
86
+ return $result;
87
+ }
88
+
89
+ /**
90
+ * Returns the SQL query to be used when fetching terms
91
+ *
92
+ * @return string
93
+ * @since 2.6
94
+ */
95
+ protected function getQuery()
96
+ {
97
+ $config = $this->plugin->get('dataConfig');
98
+ $db = $this->plugin->get('wpdb');
99
+
100
+ $builder = new UTCW_QueryBuilder($this->plugin);
101
+
102
+ $builder->addAuthorConstraint($config->authors);
103
+ $builder->addPostTypeConstraint($config->post_type);
104
+ $builder->addPostStatusConstraint($this->plugin->isAuthenticatedUser(), $config->post_type);
105
+ $builder->addDaysOldConstraint($config->days_old);
106
+ $builder->addTaxonomyConstraint($config->taxonomy);
107
+ $builder->addTagsListConstraint(
108
+ $config->tags_list_type,
109
+ $config->tags_list,
110
+ $config->taxonomy
111
+ );
112
+ $builder->addPostTermConstraint($config->post_term);
113
+ $builder->addGrouping();
114
+ $builder->addMinimum($config->minimum);
115
+
116
+ // Add statements from the strategy
117
+ $this->buildQuery($builder);
118
+
119
+ $builder->addMaxConstraint($config->max);
120
+ $builder->addSort($config->order, $config->reverse, $config->case_sensitive);
121
+
122
+ $query = $builder->getQuery();
123
+ $parameters = $builder->getParameters();
124
+
125
+ return $db->prepare($query, $parameters);
126
+ }
127
+
128
+ /**
129
+ * @param UTCW_QueryBuilder $builder
130
+ *
131
+ * @return void
132
+ * @since 2.6
133
+ * @throws Exception
134
  */
135
+ protected function buildQuery(UTCW_QueryBuilder $builder)
136
+ {
137
+ throw new Exception('You need to implement buildQuery() to use the default getData method');
138
+ }
139
 
140
  /**
141
  * Clean up the internal members for debug output
142
  *
143
  * @return void
144
  */
145
+ public function cleanupForDebug()
146
+ {
147
+ $this->plugin->remove('wpdb');
148
+ }
149
  }
src/ShortCode.php CHANGED
@@ -2,13 +2,34 @@
2
 
3
  class UTCW_ShortCode
4
  {
5
-
6
  /**
7
  * @var UTCW_Plugin
8
  * @since 2.4
9
  */
10
  protected $plugin;
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  /**
13
  * @param UTCW_Plugin $plugin
14
  *
2
 
3
  class UTCW_ShortCode
4
  {
 
5
  /**
6
  * @var UTCW_Plugin
7
  * @since 2.4
8
  */
9
  protected $plugin;
10
 
11
+ /**
12
+ * Never serialize private members
13
+ *
14
+ * @return array
15
+ *
16
+ * @since 2.6
17
+ */
18
+ public function __sleep()
19
+ {
20
+ return array();
21
+ }
22
+
23
+ /**
24
+ * Fetch a new copy of the plugin when waking up
25
+ *
26
+ * @since 2.6
27
+ */
28
+ public function __wakeup()
29
+ {
30
+ $this->plugin = UTCW_Plugin::getInstance();
31
+ }
32
+
33
  /**
34
  * @param UTCW_Plugin $plugin
35
  *
src/Style/HoverStyleProvider.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate Tag Cloud Widget
4
+ *
5
+ * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.6
7
+ * @license GPLv2
8
+ * @package utcw
9
+ * @subpackage style
10
+ * @since 2.6
11
+ */
12
+
13
+ /**
14
+ * Class for CSS styles for hovering
15
+ *
16
+ * @since 2.6
17
+ * @package utcw
18
+ * @subpackage style
19
+ */
20
+ class UTCW_HoverStyleProvider extends UTCW_StyleProvider
21
+ {
22
+
23
+ /**
24
+ * @return array
25
+ * @since 2.6
26
+ */
27
+ public function getStyles()
28
+ {
29
+ $config = $this->plugin->get('renderConfig');
30
+ $this->styles = array();
31
+
32
+ $this->addStyle(
33
+ 'hover_underline',
34
+ 'text-decoration:%s',
35
+ $config->hover_underline === 'yes' ? 'underline' : 'none'
36
+ );
37
+
38
+ $this->addStyle('hover_bold', 'font-weight:%s', $config->hover_bold === 'yes' ? 'bold' : 'normal');
39
+ $this->addStyle('hover_italic', 'font-style:%s', $config->hover_italic === 'yes' ? 'italic' : 'normal');
40
+ $this->addStyle('hover_bg_color', 'background-color:%s');
41
+
42
+ if (
43
+ !$this->hasDefaultValue('hover_border_style') &&
44
+ !$this->hasDefaultValue('hover_border_color') &&
45
+ !$this->hasDefaultValue('hover_border_width')
46
+ ) {
47
+ $this->styles[] = sprintf(
48
+ 'border:%s %s %s',
49
+ $config->hover_border_style,
50
+ $config->hover_border_width,
51
+ $config->hover_border_color
52
+ );
53
+ } else {
54
+ $this->addStyle('hover_border_style', 'border-style:%s');
55
+ $this->addStyle('hover_border_color', 'border-color:%s');
56
+ $this->addStyle('hover_border_width', 'border-width:%s');
57
+ }
58
+
59
+ $this->addStyle('hover_color', 'color:%s');
60
+
61
+ return $this->styles;
62
+ }
63
+
64
+ /**
65
+ * @return array
66
+ * @since 2.6
67
+ */
68
+ public function getSelectors()
69
+ {
70
+ return array('span:hover', 'a:hover');
71
+ }
72
+ }
src/Style/LinkStyleProvider.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate Tag Cloud Widget
4
+ *
5
+ * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.6
7
+ * @license GPLv2
8
+ * @package utcw
9
+ * @subpackage style
10
+ * @since 2.6
11
+ */
12
+
13
+ /**
14
+ * Class for CSS styles for links
15
+ *
16
+ * @since 2.6
17
+ * @package utcw
18
+ * @subpackage style
19
+ */
20
+ class UTCW_LinkStyleProvider extends UTCW_StyleProvider
21
+ {
22
+ /**
23
+ * @return array
24
+ * @since 2.6
25
+ */
26
+ public function getStyles()
27
+ {
28
+ $config = $this->plugin->get('renderConfig');
29
+ $this->styles = array();
30
+
31
+ $this->addStyle(
32
+ 'link_underline',
33
+ 'text-decoration:%s',
34
+ $config->link_underline === 'yes' ? 'underline' : 'none'
35
+ );
36
+
37
+ $this->addStyle('link_bold', 'font-weight:%s', $config->link_bold === 'yes' ? 'bold' : 'normal');
38
+ $this->addStyle('link_italic', 'font-style:%s', $config->link_italic === 'yes' ? 'italic' : 'normal');
39
+ $this->addStyle('link_bg_color', 'background-color:%s');
40
+
41
+ if (
42
+ !$this->hasDefaultValue('link_border_style') &&
43
+ !$this->hasDefaultValue('link_border_color') &&
44
+ !$this->hasDefaultValue('link_border_width')
45
+ ) {
46
+ $this->styles[] = sprintf(
47
+ 'border:%s %s %s',
48
+ $config->link_border_style,
49
+ $config->link_border_width,
50
+ $config->link_border_color
51
+ );
52
+ } else {
53
+ $this->addStyle('link_border_style', 'border-style:%s');
54
+ $this->addStyle('link_border_color', 'border-color:%s');
55
+ $this->addStyle('link_border_width', 'border-width:%s');
56
+ }
57
+
58
+ $this->addStyle('tag_spacing', 'margin-right:%s');
59
+ $this->addStyle('line_height', 'line-height:%s');
60
+ $this->addStyle('prevent_breaking', 'white-space:%s', 'nowrap');
61
+
62
+ return $this->styles;
63
+ }
64
+
65
+ /**
66
+ * @return array
67
+ * @since 2.6
68
+ */
69
+ public function getSelectors()
70
+ {
71
+ return array('span', 'a');
72
+ }
73
+ }
src/Style/MainStyleProvider.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate Tag Cloud Widget
4
+ *
5
+ * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.6
7
+ * @license GPLv2
8
+ * @package utcw
9
+ * @subpackage style
10
+ * @since 2.6
11
+ */
12
+
13
+ /**
14
+ * Class for CSS styles for the main element
15
+ *
16
+ * @since 2.6
17
+ * @package utcw
18
+ * @subpackage style
19
+ */
20
+ class UTCW_MainStyleProvider extends UTCW_StyleProvider
21
+ {
22
+ /**
23
+ * @return array
24
+ * @since 2.6
25
+ */
26
+ public function getStyles()
27
+ {
28
+ $this->styles = array('word-wrap:break-word');
29
+
30
+ $this->addStyle('text_transform', 'text-transform:%s');
31
+ $this->addStyle('letter_spacing', 'letter-spacing:%s');
32
+ $this->addStyle('word_spacing', 'word-spacing:%s');
33
+ $this->addStyle('alignment', 'text-align:%s');
34
+
35
+ return $this->styles;
36
+ }
37
+
38
+ /**
39
+ * @return array
40
+ * @since 2.6
41
+ */
42
+ public function getSelectors()
43
+ {
44
+ return array('');
45
+ }
46
+ }
src/Style/StyleProvider.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate Tag Cloud Widget
4
+ *
5
+ * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.6
7
+ * @license GPLv2
8
+ * @package utcw
9
+ * @subpackage style
10
+ * @since 2.6
11
+ */
12
+
13
+ /**
14
+ * Abstract class to define a provider of CSS styles
15
+ *
16
+ * @since 2.6
17
+ * @package utcw
18
+ * @subpackage style
19
+ */
20
+ abstract class UTCW_StyleProvider
21
+ {
22
+ /**
23
+ * @var UTCW_Plugin
24
+ * @since 2.6
25
+ */
26
+ protected $plugin;
27
+
28
+ /**
29
+ * @var array
30
+ * @since 2.6
31
+ */
32
+ protected $styles = array();
33
+
34
+ /**
35
+ * Only save styles when serializing
36
+ *
37
+ * @return array
38
+ *
39
+ * @since 2.6
40
+ */
41
+ public function __sleep()
42
+ {
43
+ return array('styles');
44
+ }
45
+
46
+ /**
47
+ * Get a new copy of the plugin instance when waking up
48
+ *
49
+ * @since 2.6
50
+ */
51
+ public function __wakeup()
52
+ {
53
+ $this->plugin = UTCW_Plugin::getInstance();
54
+ }
55
+
56
+ /**
57
+ * @param UTCW_Plugin $plugin
58
+ *
59
+ * @since 2.6
60
+ */
61
+ public function __construct(UTCW_Plugin $plugin)
62
+ {
63
+ $this->plugin = $plugin;
64
+ }
65
+
66
+ /**
67
+ * Returns an array of css rules
68
+ *
69
+ * @return array
70
+ * @since 2.6
71
+ */
72
+ abstract public function getStyles();
73
+
74
+ /**
75
+ * Returns an array of which selectors these styles should apply to, relative to the tag cloud
76
+ *
77
+ * @return array
78
+ * @since 2.6
79
+ */
80
+ abstract public function getSelectors();
81
+
82
+ /**
83
+ * Checks if option still has the default value
84
+ *
85
+ * @param string $option
86
+ *
87
+ * @return bool
88
+ * @since 2.6
89
+ */
90
+ protected function hasDefaultValue($option)
91
+ {
92
+ $defaultConfig = new UTCW_RenderConfig(array(), $this->plugin);
93
+ $defaults = $defaultConfig->getInstance();
94
+ $config = $this->plugin->get('renderConfig');
95
+
96
+ return $config->$option === $defaults[$option];
97
+ }
98
+
99
+ /**
100
+ * Will add the style to the internal array if the option doesn't have is default value
101
+ *
102
+ * @param string $option
103
+ * @param string $template
104
+ * @param string $value
105
+ *
106
+ * @since 2.6
107
+ */
108
+ protected function addStyle($option, $template, $value = '')
109
+ {
110
+ if (!$value) {
111
+ $value = $this->plugin->get('renderConfig')->$option;
112
+ }
113
+
114
+ if (!$this->hasDefaultValue($option)) {
115
+ $this->styles[] = sprintf($template, $value);
116
+ }
117
+ }
118
+ }
src/Term.php CHANGED
@@ -88,39 +88,73 @@ class UTCW_Term
88
  * Creates a new term
89
  *
90
  * @param stdClass $input Object with properties term_id, count, slug, name, color and taxonomy
91
- * @param UTCW_Plugin $plugin Reference to the plugin instance
92
  *
93
  * @since 2.0
94
  */
95
  public function __construct(stdClass $input, UTCW_Plugin $plugin)
96
  {
 
 
 
 
 
 
97
 
98
- if (isset($input->term_id) && filter_var($input->term_id, FILTER_VALIDATE_INT)) {
99
- $this->term_id = intval($input->term_id);
100
- }
101
-
102
- if (isset($input->count) && filter_var($input->count, FILTER_VALIDATE_INT)) {
103
- $this->count = intval($input->count);
104
- }
105
-
106
- if (isset($input->slug) && strlen($input->slug) > 0 && preg_match('/^[0-9a-z\-]+/i', $input->slug)) {
107
- $this->slug = $input->slug;
108
  }
 
109
 
110
- if (isset($input->name) && strlen($input->name) > 0) {
111
- $this->name = $input->name;
 
 
 
 
 
 
 
 
112
  }
 
113
 
114
- if (isset($input->color) && strlen($input->color) > 0 && preg_match(UTCW_HEX_COLOR_REGEX, $input->color)) {
115
- $this->color = $input->color;
 
 
 
 
 
 
 
 
116
  }
 
117
 
118
- if (isset($input->taxonomy) && strlen($input->taxonomy) > 0) {
119
- $this->taxonomy = $input->taxonomy;
 
 
 
 
 
 
 
 
120
  }
 
121
 
122
- if ($this->term_id && $this->taxonomy) {
123
- $this->link = $plugin->getTermLink($this->term_id, $this->taxonomy);
 
 
 
 
 
 
 
 
124
  }
125
  }
126
  }
88
  * Creates a new term
89
  *
90
  * @param stdClass $input Object with properties term_id, count, slug, name, color and taxonomy
91
+ * @param UTCW_Plugin $plugin Reference to the plugin instance
92
  *
93
  * @since 2.0
94
  */
95
  public function __construct(stdClass $input, UTCW_Plugin $plugin)
96
  {
97
+ $this->setInteger($input, 'term_id');
98
+ $this->setInteger($input, 'count');
99
+ $this->setSlug($input, 'slug');
100
+ $this->setString($input, 'name');
101
+ $this->setString($input, 'taxonomy');
102
+ $this->setColor($input, 'color');
103
 
104
+ if ($this->term_id && $this->taxonomy) {
105
+ $this->link = $plugin->getTermLink($this->term_id, $this->taxonomy);
 
 
 
 
 
 
 
 
106
  }
107
+ }
108
 
109
+ /**
110
+ * Validate and set an integer value
111
+ *
112
+ * @param stdClass $input
113
+ * @param string $key
114
+ */
115
+ protected function setInteger($input, $key)
116
+ {
117
+ if (isset($input->$key) && filter_var($input->$key, FILTER_VALIDATE_INT)) {
118
+ $this->$key = intval($input->$key);
119
  }
120
+ }
121
 
122
+ /**
123
+ * Validate and set a slug value
124
+ *
125
+ * @param stdClass $input
126
+ * @param string $key
127
+ */
128
+ protected function setSlug($input, $key)
129
+ {
130
+ if (isset($input->$key) && strlen($input->$key) > 0 && preg_match('/^[0-9a-z\-]+/i', $input->$key)) {
131
+ $this->$key = $input->$key;
132
  }
133
+ }
134
 
135
+ /**
136
+ * Validate and set a string value
137
+ *
138
+ * @param stdClass $input
139
+ * @param string $key
140
+ */
141
+ protected function setString($input, $key)
142
+ {
143
+ if (isset($input->$key) && strlen($input->$key) > 0) {
144
+ $this->$key = $input->$key;
145
  }
146
+ }
147
 
148
+ /**
149
+ * Validate and set a color value
150
+ *
151
+ * @param stdClass $input
152
+ * @param string $key
153
+ */
154
+ protected function setColor($input, $key)
155
+ {
156
+ if (isset($input->$key) && strlen($input->$key) > 0 && preg_match(UTCW_HEX_COLOR_REGEX, $input->$key)) {
157
+ $this->$key = $input->$key;
158
  }
159
  }
160
  }
src/Widget.php CHANGED
@@ -31,7 +31,7 @@ class UTCW_Widget extends WP_Widget
31
  /**
32
  * Constructor
33
  *
34
- * @param UTCW_Plugin $plugin Optional. UTCW_Plugin instance for dependency injection
35
  *
36
  * @return UTCW_Widget
37
  * @since 1.0
@@ -45,35 +45,90 @@ class UTCW_Widget extends WP_Widget
45
  }
46
 
47
  /**
48
- * Action handler for the form in the admin panel
49
  *
50
  * @param array $new_instance
51
- * @param array $old_instance
52
  *
53
  * @return array
54
- * @since 1.0
55
  */
56
- public function update($new_instance, $old_instance)
57
  {
58
  $load_config = isset($new_instance['load_config']) &&
59
  isset($new_instance['load_config_name']) &&
60
  $new_instance['load_config_name'];
61
 
62
- $save_config = isset($new_instance['save_config']) &&
63
- isset($new_instance['save_config_name']) &&
64
- $new_instance['save_config_name'];
65
-
66
  // Overwrite the form values with the saved configuration
67
  if ($load_config) {
68
  $loaded_configuration = $this->plugin->loadConfiguration($new_instance['load_config_name']);
69
 
70
  if ($loaded_configuration) {
71
- $new_instance = $loaded_configuration;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
  }
 
74
 
 
 
 
 
 
 
 
 
 
 
 
75
  // Checkbox inputs which are unchecked, will not be set in $new_instance. Set them manually to false
76
- $checkbox_settings = array('show_title_text', 'show_links', 'show_title', 'debug', 'reverse', 'case_sensitive');
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  foreach ($checkbox_settings as $checkbox_setting) {
79
  if (!isset($new_instance[$checkbox_setting])) {
@@ -81,20 +136,30 @@ class UTCW_Widget extends WP_Widget
81
  }
82
  }
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  $dataConfig = new UTCW_DataConfig($new_instance, $this->plugin);
85
  $renderConfig = new UTCW_RenderConfig($new_instance, $this->plugin);
86
 
87
  $config = array_merge($dataConfig->getInstance(), $renderConfig->getInstance());
88
 
89
- if ($save_config) {
90
- $this->plugin->saveConfiguration($new_instance['save_config_name'], $config);
91
- }
92
-
93
- if (isset($new_instance['remove_config']) && is_array($new_instance['remove_config'])) {
94
- foreach ($new_instance['remove_config'] as $configuration) {
95
- $this->plugin->removeConfiguration($configuration);
96
- }
97
- }
98
 
99
  return $config;
100
  }
@@ -109,20 +174,8 @@ class UTCW_Widget extends WP_Widget
109
  */
110
  public function form($instance)
111
  {
112
- /** @noinspection PhpUnusedLocalVariableInspection */
113
- $dataConfig = new UTCW_DataConfig($instance, $this->plugin);
114
- /** @noinspection PhpUnusedLocalVariableInspection */
115
- $renderConfig = new UTCW_RenderConfig($instance, $this->plugin);
116
- /** @noinspection PhpUnusedLocalVariableInspection */
117
- $configurations = $this->plugin->getConfigurations();
118
- /** @noinspection PhpUnusedLocalVariableInspection */
119
- $available_post_types = $this->plugin->getAllowedPostTypes();
120
- /** @noinspection PhpUnusedLocalVariableInspection */
121
- $available_taxonomies = $this->plugin->getAllowedTaxonomiesObjects();
122
- /** @noinspection PhpUnusedLocalVariableInspection */
123
  $authors = $this->plugin->getUsers();
124
- /** @noinspection PhpUnusedLocalVariableInspection */
125
- $terms = $this->plugin->getTerms();
126
 
127
  // Create a lookup table with all the terms indexed by their ID
128
  $terms_by_id = array();
@@ -139,8 +192,32 @@ class UTCW_Widget extends WP_Widget
139
  $authors_by_id[$author->ID] = $author;
140
  }
141
 
142
- // Content of the widget settings form
143
- require dirname(__FILE__) . '/../pages/settings.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  }
145
 
146
  /**
31
  /**
32
  * Constructor
33
  *
34
+ * @param UTCW_Plugin $plugin Optional. UTCW_Plugin instance for dependency injection
35
  *
36
  * @return UTCW_Widget
37
  * @since 1.0
45
  }
46
 
47
  /**
48
+ * Loads a saved configuration if given by the settings
49
  *
50
  * @param array $new_instance
 
51
  *
52
  * @return array
53
+ * @since 2.6
54
  */
55
+ protected function load_config($new_instance)
56
  {
57
  $load_config = isset($new_instance['load_config']) &&
58
  isset($new_instance['load_config_name']) &&
59
  $new_instance['load_config_name'];
60
 
 
 
 
 
61
  // Overwrite the form values with the saved configuration
62
  if ($load_config) {
63
  $loaded_configuration = $this->plugin->loadConfiguration($new_instance['load_config_name']);
64
 
65
  if ($loaded_configuration) {
66
+ return $loaded_configuration;
67
+ }
68
+ }
69
+
70
+ return $new_instance;
71
+ }
72
+
73
+ /**
74
+ * Saves the configuration if given by the settings
75
+ *
76
+ * @param array $new_instance
77
+ * @param array $config
78
+ *
79
+ * @since 2.6
80
+ */
81
+ protected function save_config($new_instance, $config)
82
+ {
83
+ $save_config = isset($new_instance['save_config']) &&
84
+ isset($new_instance['save_config_name']) &&
85
+ $new_instance['save_config_name'];
86
+
87
+ if ($save_config) {
88
+ $this->plugin->saveConfiguration($new_instance['save_config_name'], $config);
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Remove configurations if given by the settings
94
+ *
95
+ * @param array $new_instance
96
+ *
97
+ * @since 2.6
98
+ */
99
+ protected function remove_configs($new_instance)
100
+ {
101
+ if (isset($new_instance['remove_config']) && is_array($new_instance['remove_config'])) {
102
+ foreach ($new_instance['remove_config'] as $configuration) {
103
+ $this->plugin->removeConfiguration($configuration);
104
  }
105
  }
106
+ }
107
 
108
+ /**
109
+ * Will iterate all the checkboxes and set the value to false if it is unchecked.
110
+ *
111
+ * @param $new_instance
112
+ *
113
+ * @since 2.6
114
+ *
115
+ * @return array
116
+ */
117
+ protected function check_booleans($new_instance)
118
+ {
119
  // Checkbox inputs which are unchecked, will not be set in $new_instance. Set them manually to false
120
+ $checkbox_settings = array(
121
+ 'show_title_text',
122
+ 'show_links',
123
+ 'show_title',
124
+ 'debug',
125
+ 'reverse',
126
+ 'case_sensitive',
127
+ 'post_term_query_var',
128
+ 'show_post_count',
129
+ 'prevent_breaking',
130
+ 'avoid_theme_styling',
131
+ );
132
 
133
  foreach ($checkbox_settings as $checkbox_setting) {
134
  if (!isset($new_instance[$checkbox_setting])) {
136
  }
137
  }
138
 
139
+ return $new_instance;
140
+ }
141
+
142
+ /**
143
+ * Action handler for the form in the admin panel
144
+ *
145
+ * @param array $new_instance
146
+ * @param array $old_instance
147
+ *
148
+ * @return array
149
+ * @since 1.0
150
+ */
151
+ public function update($new_instance, $old_instance)
152
+ {
153
+ $new_instance = $this->load_config($new_instance);
154
+ $new_instance = $this->check_booleans($new_instance);
155
+
156
  $dataConfig = new UTCW_DataConfig($new_instance, $this->plugin);
157
  $renderConfig = new UTCW_RenderConfig($new_instance, $this->plugin);
158
 
159
  $config = array_merge($dataConfig->getInstance(), $renderConfig->getInstance());
160
 
161
+ $this->save_config($new_instance, $config);
162
+ $this->remove_configs($new_instance);
 
 
 
 
 
 
 
163
 
164
  return $config;
165
  }
174
  */
175
  public function form($instance)
176
  {
 
 
 
 
 
 
 
 
 
 
 
177
  $authors = $this->plugin->getUsers();
178
+ $terms = $this->plugin->getTerms();
 
179
 
180
  // Create a lookup table with all the terms indexed by their ID
181
  $terms_by_id = array();
192
  $authors_by_id[$author->ID] = $author;
193
  }
194
 
195
+ $data = array(
196
+ 'dataConfig' => new UTCW_DataConfig($instance, $this->plugin),
197
+ 'renderConfig' => new UTCW_RenderConfig($instance, $this->plugin),
198
+ 'configurations' => $this->plugin->getConfigurations(),
199
+ 'available_post_types' => $this->plugin->getAllowedPostTypes(),
200
+ 'available_taxonomies' => $this->plugin->getAllowedTaxonomiesObjects(),
201
+ 'authors' => $authors,
202
+ 'terms' => $terms,
203
+ 'authors_by_id' => $authors_by_id,
204
+ 'terms_by_id' => $terms_by_id,
205
+ );
206
+
207
+ $this->render('settings', $data);
208
+ }
209
+
210
+ /**
211
+ * Render a template
212
+ *
213
+ * @param string $template
214
+ * @param array $data
215
+ */
216
+ protected function render($template, array $data)
217
+ {
218
+ extract($data);
219
+
220
+ require dirname(__FILE__) . '/../pages/' . $template . '.php';
221
  }
222
 
223
  /**
ultimate-tag-cloud-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Ultimate Tag Cloud Widget
4
  Plugin URI: https://www.0x539.se/wordpress/ultimate-tag-cloud-widget/
5
  Description: This plugin aims to be the most configurable tag cloud widget out there.
6
- Version: 2.5
7
  Author: Rickard Andersson
8
  Author URI: https://www.0x539.se
9
  License: GPLv2
@@ -15,7 +15,7 @@ License: GPLv2
15
  * @var string
16
  * @since 2.0
17
  */
18
- define('UTCW_VERSION', '2.5');
19
 
20
  /**
21
  * If development mode is currently enabled
@@ -76,6 +76,7 @@ function utcw_load()
76
  'Config/RenderConfig.php',
77
  'Config/Type/Type.php',
78
  'Config/Type/SetType.php',
 
79
  'Config/Type/ColorType.php',
80
  'Config/Type/ArrayType.php',
81
  'Config/Type/IntegerType.php',
@@ -84,6 +85,10 @@ function utcw_load()
84
  'Config/Type/BooleanType.php',
85
  'Cache/WPSuperCacheHandler.php',
86
  'Cache/W3TotalCacheHandler.php',
 
 
 
 
87
  );
88
 
89
  foreach ($files as $file) {
3
  Plugin Name: Ultimate Tag Cloud Widget
4
  Plugin URI: https://www.0x539.se/wordpress/ultimate-tag-cloud-widget/
5
  Description: This plugin aims to be the most configurable tag cloud widget out there.
6
+ Version: 2.6-beta1
7
  Author: Rickard Andersson
8
  Author URI: https://www.0x539.se
9
  License: GPLv2
15
  * @var string
16
  * @since 2.0
17
  */
18
+ define('UTCW_VERSION', '2.6-beta1');
19
 
20
  /**
21
  * If development mode is currently enabled
76
  'Config/RenderConfig.php',
77
  'Config/Type/Type.php',
78
  'Config/Type/SetType.php',
79
+ 'Config/Type/ClassType.php',
80
  'Config/Type/ColorType.php',
81
  'Config/Type/ArrayType.php',
82
  'Config/Type/IntegerType.php',
85
  'Config/Type/BooleanType.php',
86
  'Cache/WPSuperCacheHandler.php',
87
  'Cache/W3TotalCacheHandler.php',
88
+ 'Style/StyleProvider.php',
89
+ 'Style/HoverStyleProvider.php',
90
+ 'Style/MainStyleProvider.php',
91
+ 'Style/LinkStyleProvider.php',
92
  );
93
 
94
  foreach ($files as $file) {