Version Description
- Removed all the PHP short tags
- Can now sort by name, slug, id or color (!) case sensitive or case insensitive
- Exclude now takes either tag name or id
Download this release
Release Info
Developer | exz |
Plugin | Ultimate Tag Cloud Widget |
Version | 1.2 |
Comparing to | |
See all releases |
Code changes from version 1.1 to 1.2
- readme.txt +11 -3
- ultimate-tag-cloud-widget.php +159 -81
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: exz
|
|
3 |
Tags: widget, tags, configurable, tag cloud
|
4 |
Requires at least: 2.8
|
5 |
Tested up to: 3.0.1
|
6 |
-
Stable tag: 1.
|
7 |
|
8 |
This plugin aims to be the most configurable tag cloud widget out there, able to suit all your wierd tag cloud needs.
|
9 |
|
@@ -24,6 +24,8 @@ Current version supports the following preferences:
|
|
24 |
* Transform tags into lowercase, uppercase or Capitalize them
|
25 |
* Can also show categories
|
26 |
|
|
|
|
|
27 |
== Installation ==
|
28 |
|
29 |
This is the same procedure as with all ordinary plugins.
|
@@ -43,11 +45,17 @@ This is a new plugin, haven't had any questions yet. If you have any, be sure to
|
|
43 |
== Screenshots ==
|
44 |
|
45 |
1. This shows my widget with the default settings on the default wordpress theme.
|
46 |
-
2. This is a more colorful
|
47 |
3. Maybe a more realistic usage of the widget with spanning colors and capitalized tags.
|
48 |
|
49 |
== Changelog ==
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
= 1.1 =
|
52 |
|
53 |
* Fixed bug with options page
|
@@ -59,7 +67,7 @@ This is a new plugin, haven't had any questions yet. If you have any, be sure to
|
|
59 |
|
60 |
== Upgrade Notice ==
|
61 |
|
62 |
-
= 1.1 =
|
63 |
|
64 |
* Just bug fixes, should be safe to upgrade.
|
65 |
|
3 |
Tags: widget, tags, configurable, tag cloud
|
4 |
Requires at least: 2.8
|
5 |
Tested up to: 3.0.1
|
6 |
+
Stable tag: 1.2
|
7 |
|
8 |
This plugin aims to be the most configurable tag cloud widget out there, able to suit all your wierd tag cloud needs.
|
9 |
|
24 |
* Transform tags into lowercase, uppercase or Capitalize them
|
25 |
* Can also show categories
|
26 |
|
27 |
+
My goal is to try to help everyone who have issues or suggestions for this plugin, so if you're not completely happy with this plugin, don't hesitate to contact me.
|
28 |
+
|
29 |
== Installation ==
|
30 |
|
31 |
This is the same procedure as with all ordinary plugins.
|
45 |
== Screenshots ==
|
46 |
|
47 |
1. This shows my widget with the default settings on the default wordpress theme.
|
48 |
+
2. This is a more colorful example with random colors and all tags in uppercase. I'd like to actually see someone use it like this.
|
49 |
3. Maybe a more realistic usage of the widget with spanning colors and capitalized tags.
|
50 |
|
51 |
== Changelog ==
|
52 |
|
53 |
+
= 1.2 =
|
54 |
+
|
55 |
+
* Removed all the PHP short tags
|
56 |
+
* Can now sort by name, slug, id or color (!) case sensitive or case insensitive
|
57 |
+
* Exclude now takes either tag name or id
|
58 |
+
|
59 |
= 1.1 =
|
60 |
|
61 |
* Fixed bug with options page
|
67 |
|
68 |
== Upgrade Notice ==
|
69 |
|
70 |
+
= 1.1 and 1.2 =
|
71 |
|
72 |
* Just bug fixes, should be safe to upgrade.
|
73 |
|
ultimate-tag-cloud-widget.php
CHANGED
@@ -1,11 +1,27 @@
|
|
1 |
-
<?
|
2 |
/*
|
3 |
Plugin Name: Ultimate tag cloud widget
|
4 |
Plugin URI: http://bennison.se/?page_id=173
|
5 |
Description: This plugin aims to be the most configurable tag cloud widget out there, able to suit all your wierd tag cloud needs.
|
6 |
-
Version: 1.
|
7 |
Author: Rickard Andersson
|
8 |
Author URI: http://bennison.se
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
/**
|
@@ -16,7 +32,7 @@ class UTCW extends WP_Widget {
|
|
16 |
|
17 |
// Default values if the widget isn't configured properly
|
18 |
private $default_title = "Tag Cloud";
|
19 |
-
private $default_order = "
|
20 |
private $default_size_from = 10;
|
21 |
private $default_size_to = 30;
|
22 |
private $default_max = 45;
|
@@ -26,9 +42,10 @@ class UTCW extends WP_Widget {
|
|
26 |
private $default_letter_spacing = "normal";
|
27 |
private $default_word_spacing = "normal";
|
28 |
private $default_case = "off";
|
|
|
29 |
|
30 |
// Allowed values for miscellanious options in the widget
|
31 |
-
private $allowed_orders = array('random', '
|
32 |
private $allowed_taxonomys = array('post_tag', 'category');
|
33 |
private $allowed_colors = array('none', 'random', 'set', 'span');
|
34 |
private $allowed_cases = array('lowercase', 'uppercase', 'capitalize', 'off');
|
@@ -60,10 +77,11 @@ class UTCW extends WP_Widget {
|
|
60 |
$instance['max'] = is_numeric($max) ? $max : $this->default_max;
|
61 |
$instance['letter_spacing'] = is_numeric($letter_spacing) ? $letter_spacing : $this->default_letter_spacing;
|
62 |
$instance['word_spacing'] = is_numeric($word_spacing) ? $word_spacing : $this->default_word_spacing;
|
63 |
-
$instance['reverse'] = $reverse == "on"
|
64 |
$instance['exclude'] = strlen($exclude) > 0 ? @explode(",", $exclude) : array();
|
65 |
$instance['color_set'] = strlen($color_set) > 0 ? @explode(",", $color_set) : array();
|
66 |
$instance['authors'] = array();
|
|
|
67 |
|
68 |
$instance['color_span_from'] = preg_match('/#([a-f0-9]{6}|[a-f0-9]{3})/i', $color_span_from) > 0 ? $color_span_from : "";
|
69 |
$instance['color_span_to'] = preg_match('/#([a-f0-9]{6}|[a-f0-9]{3})/i', $color_span_to) > 0 ? $color_span_to : "";
|
@@ -123,6 +141,7 @@ class UTCW extends WP_Widget {
|
|
123 |
$word_spacing = is_numeric($word_spacing) ? $word_spacing . "px" : $this->default_word_spacing;
|
124 |
$color_span_from = is_string($color_span_from) ? $color_span_from : "";
|
125 |
$color_span_to = is_string($color_span_to) ? $color_span_to : "";
|
|
|
126 |
|
127 |
$order = in_array($order, $this->allowed_orders) ? $order : $this->default_order;
|
128 |
$taxonomy = in_array($taxonomy, $this->allowed_taxonomys) ? $taxonomy : $this->default_taxonomy;
|
@@ -145,7 +164,11 @@ class UTCW extends WP_Widget {
|
|
145 |
$q .= "AND post_author IN (" . implode(",", $authors) . ") ";
|
146 |
}
|
147 |
if (count($exclude) > 0) {
|
148 |
-
|
|
|
|
|
|
|
|
|
149 |
}
|
150 |
|
151 |
$q .= "GROUP BY t.term_id ";
|
@@ -239,7 +262,7 @@ class UTCW extends WP_Widget {
|
|
239 |
break;
|
240 |
}
|
241 |
|
242 |
-
// Check the ordering preference, default is
|
243 |
switch ($order) {
|
244 |
case "random":
|
245 |
shuffle($tag_array);
|
@@ -249,8 +272,21 @@ class UTCW extends WP_Widget {
|
|
249 |
usort($tag_array, 'utcw_cmp_count');
|
250 |
break;
|
251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
default:
|
253 |
-
usort($tag_array, 'utcw_cmp_name');
|
254 |
break;
|
255 |
}
|
256 |
|
@@ -317,6 +353,7 @@ class UTCW extends WP_Widget {
|
|
317 |
$reverse = $instance['reverse'];
|
318 |
$authors = $instance['authors'];
|
319 |
$color_set = $instance['color_set'];
|
|
|
320 |
|
321 |
// Fallbacks
|
322 |
if (!is_array($authors)) {
|
@@ -332,81 +369,90 @@ class UTCW extends WP_Widget {
|
|
332 |
// Content of the widget settings form
|
333 |
?>
|
334 |
<fieldset class="utcw">
|
335 |
-
<legend><?_e("Data")?></legend>
|
336 |
-
<? _e("Authors:"); ?><br/>
|
337 |
<?php foreach (get_users_of_blog() as $user) : ?>
|
338 |
-
<input type="checkbox" name="
|
339 |
-
<label for="
|
340 |
<?php endforeach; ?>
|
341 |
<br/>
|
342 |
-
<? _e("Order:"); ?><br/>
|
343 |
-
<input type="radio" name="
|
344 |
-
<label for="
|
345 |
-
<input type="radio" name="
|
346 |
-
<label for="
|
347 |
-
<input type="radio" name="
|
348 |
-
<label for="
|
349 |
-
<input type="
|
350 |
-
<label for="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
<br/>
|
352 |
-
<label for="
|
353 |
-
<select id="
|
354 |
-
<option value="post_tag"
|
355 |
-
<option value="category"
|
356 |
</select><br/>
|
357 |
<br/>
|
358 |
-
<label for="
|
359 |
-
<input type="text" name="
|
|
|
360 |
</fieldset>
|
361 |
|
362 |
<fieldset class="utcw">
|
363 |
-
<legend><?_e("Appearance")?></legend>
|
364 |
-
<label for="
|
365 |
-
<input type="text" id="
|
366 |
<br/>
|
367 |
-
<?_e("Tag size (in px):")?><br/>
|
368 |
-
<label for="
|
369 |
-
<input type="text" name="
|
370 |
-
<label for="
|
371 |
-
<input type="text" name="
|
372 |
<br/>
|
373 |
-
<label for="
|
374 |
-
<input type="text" name="
|
375 |
<br/>
|
376 |
-
<?_e("Coloring:") ?><br/>
|
377 |
-
<input type="radio" name="
|
378 |
-
<label for="
|
379 |
-
<input type="radio" name="
|
380 |
-
<label for="
|
381 |
-
<input type="radio" name="
|
382 |
-
<label for="
|
383 |
-
<div id="
|
384 |
-
<input type="text" name="
|
385 |
</div>
|
386 |
-
<input type="radio" name="
|
387 |
-
<label for="
|
388 |
-
<div id="
|
389 |
-
<?_e("From")?> <input type="text" size="7" name="
|
390 |
-
<?_e("to")?> <input type="text" size="7" name="
|
391 |
</div>
|
392 |
<br/>
|
393 |
-
<?_e("Spacing (in px):")?><br/>
|
394 |
-
<label for="
|
395 |
-
<input type="text" size="5" name="
|
396 |
-
<label for="
|
397 |
-
<input type="text" size="5" name="
|
398 |
<br/>
|
399 |
-
<?_e("Transform tags:")?><br/>
|
400 |
-
<input type="radio" name="
|
401 |
-
<label for="
|
402 |
-
<input type="radio" name="
|
403 |
-
<label for="
|
404 |
-
<input type="radio" name="
|
405 |
-
<label for="
|
406 |
-
<input type="radio" name="
|
407 |
-
<label for="
|
408 |
</fieldset>
|
409 |
-
<?
|
410 |
}
|
411 |
/**
|
412 |
* Used to calculate how step size in spanning values
|
@@ -435,8 +481,8 @@ class UTCW extends WP_Widget {
|
|
435 |
add_action('widgets_init', create_function('', 'return register_widget("UTCW");'));
|
436 |
|
437 |
//Register scripts and css with wordpress
|
438 |
-
wp_register_script('utcw-js', '/wp-content/plugins/ultimate-tag-cloud-widget/utcw.js', array('jquery'),
|
439 |
-
wp_register_style('utcw-css', '/wp-content/plugins/ultimate-tag-cloud-widget/utcw.css', array(),
|
440 |
|
441 |
/**
|
442 |
* Action handler for wordpress init used to attach scripts and styles
|
@@ -449,26 +495,58 @@ function utcw_init() {
|
|
449 |
add_action('init', 'utcw_init');
|
450 |
|
451 |
|
452 |
-
|
453 |
-
* Compare
|
454 |
-
* @param array $a
|
455 |
-
* @param array $b
|
456 |
-
* @return integer
|
457 |
*/
|
458 |
function utcw_cmp_count($a, $b) {
|
459 |
if ($a['count'] == $b['count']) {
|
460 |
return 0;
|
461 |
-
} else{
|
462 |
return ($a['count'] < $b['count']) ? -1 : 1;
|
463 |
}
|
464 |
}
|
465 |
|
466 |
-
|
467 |
-
* Compare function for sorting by name
|
468 |
-
* @param array $a
|
469 |
-
* @param array $b
|
470 |
-
* @return integer
|
471 |
-
*/
|
472 |
-
function utcw_cmp_name($a, $b) {
|
473 |
return strcasecmp($a['name'], $b['name']);
|
474 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
/*
|
3 |
Plugin Name: Ultimate tag cloud widget
|
4 |
Plugin URI: http://bennison.se/?page_id=173
|
5 |
Description: This plugin aims to be the most configurable tag cloud widget out there, able to suit all your wierd tag cloud needs.
|
6 |
+
Version: 1.2
|
7 |
Author: Rickard Andersson
|
8 |
Author URI: http://bennison.se
|
9 |
+
License: GPLv2
|
10 |
+
*/
|
11 |
+
|
12 |
+
/*
|
13 |
+
This program is free software; you can redistribute it and/or modify
|
14 |
+
it under the terms of the GNU General Public License as published by
|
15 |
+
the Free Software Foundation; version 2 of the License.
|
16 |
+
|
17 |
+
This program is distributed in the hope that it will be useful,
|
18 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
+
GNU General Public License for more details.
|
21 |
+
|
22 |
+
You should have received a copy of the GNU General Public License
|
23 |
+
along with this program; if not, write to the Free Software
|
24 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
*/
|
26 |
|
27 |
/**
|
32 |
|
33 |
// Default values if the widget isn't configured properly
|
34 |
private $default_title = "Tag Cloud";
|
35 |
+
private $default_order = "name";
|
36 |
private $default_size_from = 10;
|
37 |
private $default_size_to = 30;
|
38 |
private $default_max = 45;
|
42 |
private $default_letter_spacing = "normal";
|
43 |
private $default_word_spacing = "normal";
|
44 |
private $default_case = "off";
|
45 |
+
private $default_case_sensisive = false;
|
46 |
|
47 |
// Allowed values for miscellanious options in the widget
|
48 |
+
private $allowed_orders = array('random', 'name', 'slug', 'id', 'color', 'count');
|
49 |
private $allowed_taxonomys = array('post_tag', 'category');
|
50 |
private $allowed_colors = array('none', 'random', 'set', 'span');
|
51 |
private $allowed_cases = array('lowercase', 'uppercase', 'capitalize', 'off');
|
77 |
$instance['max'] = is_numeric($max) ? $max : $this->default_max;
|
78 |
$instance['letter_spacing'] = is_numeric($letter_spacing) ? $letter_spacing : $this->default_letter_spacing;
|
79 |
$instance['word_spacing'] = is_numeric($word_spacing) ? $word_spacing : $this->default_word_spacing;
|
80 |
+
$instance['reverse'] = ($reverse == "on");
|
81 |
$instance['exclude'] = strlen($exclude) > 0 ? @explode(",", $exclude) : array();
|
82 |
$instance['color_set'] = strlen($color_set) > 0 ? @explode(",", $color_set) : array();
|
83 |
$instance['authors'] = array();
|
84 |
+
$instance['case_sensitive'] = ($case_sensitive == "on");
|
85 |
|
86 |
$instance['color_span_from'] = preg_match('/#([a-f0-9]{6}|[a-f0-9]{3})/i', $color_span_from) > 0 ? $color_span_from : "";
|
87 |
$instance['color_span_to'] = preg_match('/#([a-f0-9]{6}|[a-f0-9]{3})/i', $color_span_to) > 0 ? $color_span_to : "";
|
141 |
$word_spacing = is_numeric($word_spacing) ? $word_spacing . "px" : $this->default_word_spacing;
|
142 |
$color_span_from = is_string($color_span_from) ? $color_span_from : "";
|
143 |
$color_span_to = is_string($color_span_to) ? $color_span_to : "";
|
144 |
+
$case_sensitive = is_bool($case_sensitive) ? $case_sensitive : $this->default_case_sensitive;
|
145 |
|
146 |
$order = in_array($order, $this->allowed_orders) ? $order : $this->default_order;
|
147 |
$taxonomy = in_array($taxonomy, $this->allowed_taxonomys) ? $taxonomy : $this->default_taxonomy;
|
164 |
$q .= "AND post_author IN (" . implode(",", $authors) . ") ";
|
165 |
}
|
166 |
if (count($exclude) > 0) {
|
167 |
+
if (is_array_numeric($exclude)) {
|
168 |
+
$q .= "AND t.term_id NOT IN ('" . implode("', '", $exclude) . "') ";
|
169 |
+
} else {
|
170 |
+
$q .= "AND t.name NOT IN ('" . implode("', '", $exclude) . "') ";
|
171 |
+
}
|
172 |
}
|
173 |
|
174 |
$q .= "GROUP BY t.term_id ";
|
262 |
break;
|
263 |
}
|
264 |
|
265 |
+
// Check the ordering preference, default is name
|
266 |
switch ($order) {
|
267 |
case "random":
|
268 |
shuffle($tag_array);
|
272 |
usort($tag_array, 'utcw_cmp_count');
|
273 |
break;
|
274 |
|
275 |
+
case "slug";
|
276 |
+
usort($tag_array, $case_sensitive === true ? 'utcw_cmp_slug' : 'utcw_icmp_slug');
|
277 |
+
break;
|
278 |
+
|
279 |
+
case "id":
|
280 |
+
usort($tag_array, 'utcw_cmp_id');
|
281 |
+
break;
|
282 |
+
|
283 |
+
case "color":
|
284 |
+
usort($tag_array, 'utcw_cmp_color');
|
285 |
+
break;
|
286 |
+
|
287 |
+
case "name":
|
288 |
default:
|
289 |
+
usort($tag_array, $case_sensitive === true ? 'utcw_cmp_name' : 'utcw_icmp_name');
|
290 |
break;
|
291 |
}
|
292 |
|
353 |
$reverse = $instance['reverse'];
|
354 |
$authors = $instance['authors'];
|
355 |
$color_set = $instance['color_set'];
|
356 |
+
$case_sensitive = $instance['case_sensitive'];
|
357 |
|
358 |
// Fallbacks
|
359 |
if (!is_array($authors)) {
|
369 |
// Content of the widget settings form
|
370 |
?>
|
371 |
<fieldset class="utcw">
|
372 |
+
<legend><?php _e("Data"); ?></legend>
|
373 |
+
<?php _e("Authors:"); ?><br/>
|
374 |
<?php foreach (get_users_of_blog() as $user) : ?>
|
375 |
+
<input type="checkbox" name="<?php echo $this->get_field_name('authors'); ?>[]" id="<?php echo $this->get_field_id('author_' . $user->ID); ?>" value="<?php echo $user->ID?>" <?php echo in_array($user->ID, $authors, true) ? 'checked="checked"' : ""; ?> />
|
376 |
+
<label for="<?php echo $this->get_field_id('author_' . $user->ID); ?>"><?php echo $user->user_login?></label><br/>
|
377 |
<?php endforeach; ?>
|
378 |
<br/>
|
379 |
+
<?php _e("Order:"); ?><br/>
|
380 |
+
<input type="radio" name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order_random'); ?>" value="random" <?php echo $order == "random" ? ' checked="checked" ' : ""; ?>/>
|
381 |
+
<label for="<?php echo $this->get_field_id('order_random'); ?>"><?php _e("Random"); ?></label><br/>
|
382 |
+
<input type="radio" name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order_name'); ?>" value="name" <?php echo $order == "name" ? ' checked="checked"' : ""; ?>/>
|
383 |
+
<label for="<?php echo $this->get_field_id('order_name'); ?>"><?php _e("By name"); ?></label><br/>
|
384 |
+
<input type="radio" name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order_slug'); ?>" value="slug" <?php echo $order == "slug" ? ' checked="checked"' : ""; ?>/>
|
385 |
+
<label for="<?php echo $this->get_field_id('order_slug'); ?>"><?php _e("By slug"); ?></label><br/>
|
386 |
+
<input type="radio" name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order_id'); ?>" value="id" <?php echo $order == "id" ? ' checked="checked"' : ""; ?>/>
|
387 |
+
<label for="<?php echo $this->get_field_id('order_id'); ?>"><?php _e("By id"); ?></label><br/>
|
388 |
+
<input type="radio" name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order_color'); ?>" value="name" <?php echo $order == "color" ? ' checked="checked"' : ""; ?>/>
|
389 |
+
<label for="<?php echo $this->get_field_id('order_color'); ?>"><?php _e("By color"); ?></label><br/>
|
390 |
+
<input type="radio" name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order_count'); ?>" value="count" <?php echo $order == "count" || strlen($order) == 0 ? ' checked="checked" ' : ""; ?>/>
|
391 |
+
<label for="<?php echo $this->get_field_id('order_count'); ?>"><?php _e("Count"); ?></label><br/>
|
392 |
+
<input type="checkbox" name="<?php echo $this->get_field_name('reverse'); ?>" id="<?php echo $this->get_field_id('reverse'); ?>" <?php echo $reverse === true ? ' checked="checked"' : ""; ?> />
|
393 |
+
<label for="<?php echo $this->get_field_id('reverse'); ?>"><?php _e("Reverse order"); ?></label><br/>
|
394 |
+
<input type="checkbox" name="<?php echo $this->get_field_name('case_sensitive'); ?>" id="<?php echo $this->get_field_id('case_sensitive'); ?>" <?php echo $case_sensitive === true ? ' checked="checked"' : ""; ?> />
|
395 |
+
<label for="<?php echo $this->get_field_id('case_sensitive'); ?>"><?php _e("Case sensitive"); ?></label><br/>
|
396 |
<br/>
|
397 |
+
<label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e("Taxonomy:"); ?></label><br/>
|
398 |
+
<select id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>">
|
399 |
+
<option value="post_tag" <?php echo $taxonomy == "post_tag" || strlen($taxonomy) == 0 ? 'selected="selected"' : ""?>><?php _e("Post Tags"); ?></option>
|
400 |
+
<option value="category" <?php echo $taxonomy == "category" ? 'selected="selected"' : ""?>><?php _e("Categories"); ?></option>
|
401 |
</select><br/>
|
402 |
<br/>
|
403 |
+
<label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e("Exclude:"); ?></label>
|
404 |
+
<input type="text" name="<?php echo $this->get_field_name('exclude'); ?>" id="<?php echo $this->get_field_id('exclude'); ?>" value="<?php echo implode(",", $exclude); ?>" />
|
405 |
+
<small><?php _e("Enter either the names or IDs of the tags you'd like to exclude."); ?></small>
|
406 |
</fieldset>
|
407 |
|
408 |
<fieldset class="utcw">
|
409 |
+
<legend><?php _e("Appearance"); ?></legend>
|
410 |
+
<label for="<?php echo $this->get_field_id('title');?>"><?php _e("Title:") ?></label><br/>
|
411 |
+
<input type="text" id="<?php echo $this->get_field_id('title');?>" name="<?php echo $this->get_field_name('title');?>" value="<?php echo strlen($title) > 0 ? $title : $this->default_title?>" /><br/>
|
412 |
<br/>
|
413 |
+
<?php _e("Tag size (in px):"); ?><br/>
|
414 |
+
<label for="<?php echo $this->get_field_id('size_from'); ?>"><?php _e("From"); ?></label>
|
415 |
+
<input type="text" name="<?php echo $this->get_field_name('size_from'); ?>" id="<?php echo $this->get_field_id('size_from'); ?>" size="3" value="<?php echo is_numeric($size_from) ? $size_from : $this->default_size_from?>" />
|
416 |
+
<label for="<?php echo $this->get_field_id('size_to'); ?>"><?php _e("to"); ?></label>
|
417 |
+
<input type="text" name="<?php echo $this->get_field_name('size_to'); ?>" id="<?php echo $this->get_field_id('size_to'); ?>" size="3" value="<?php echo is_numeric($size_to) ? $size_to : $this->default_size_to?>" /><br/>
|
418 |
<br/>
|
419 |
+
<label for="<?php echo $this->get_field_id('max'); ?>"><?php _e("Max tags:"); ?></label><br/>
|
420 |
+
<input type="text" name="<?php echo $this->get_field_name('max'); ?>" id="<?php echo $this->get_field_id('max'); ?>" value="<?php echo is_numeric($max) ? $max : $this->default_max?>" /><br/>
|
421 |
<br/>
|
422 |
+
<?php _e("Coloring:") ?><br/>
|
423 |
+
<input type="radio" name="<?php echo $this->get_field_name('color'); ?>" id="<?php echo $this->get_field_id('color_none'); ?>" value="none" <?php echo $color == "none" || empty($color) ? 'checked="checked"' : ""; ?> onclick="javascript:utcw_change()" />
|
424 |
+
<label for="<?php echo $this->get_field_id('color_none'); ?>"><?php _e("None"); ?></label><br/>
|
425 |
+
<input type="radio" name="<?php echo $this->get_field_name('color'); ?>" id="<?php echo $this->get_field_id('color_random'); ?>" value="random" <?php echo $color == "random" ? 'checked="checked"' : ""; ?> onclick="javascript:utcw_change()" />
|
426 |
+
<label for="<?php echo $this->get_field_id('color_random'); ?>"><?php _e("Totally random"); ?></label><br/>
|
427 |
+
<input type="radio" name="<?php echo $this->get_field_name('color'); ?>" id="<?php echo $this->get_field_id('color_set'); ?>" value="set" <?php echo $color == "set" ? 'checked="checked"' : ""; ?> onclick="javascript:utcw_change()" />
|
428 |
+
<label for="<?php echo $this->get_field_id('color_set'); ?>"><?php _e("Random from preset values"); ?></label><br/>
|
429 |
+
<div id="<?php echo $this->get_field_id('set_chooser'); ?>" <?php echo $color != "set" ? 'class="utcw-hidden"' : ""; ?>>
|
430 |
+
<input type="text" name="<?php echo $this->get_field_name('color_set'); ?>" id="<?php echo $this->get_field_id('color_set_chooser'); ?>" value="<?php echo implode(",", $color_set) ?>" />
|
431 |
</div>
|
432 |
+
<input type="radio" name="<?php echo $this->get_field_name('color'); ?>" id="<?php echo $this->get_field_id('color_span'); ?>" value="span" <?php echo $color == "span" ? 'checked="checked"' : ""; ?> onclick="javascript:utcw_change()" />
|
433 |
+
<label for="<?php echo $this->get_field_id('color_span'); ?>"><?php _e("Spanning between values"); ?></label><br/>
|
434 |
+
<div id="<?php echo $this->get_field_id('span_chooser'); ?>" <?php echo $color != "span" ? 'class="utcw-hidden"' : ""; ?>>
|
435 |
+
<?php _e("From"); ?> <input type="text" size="7" name="<?php echo $this->get_field_name('color_span_from'); ?>" id="<?php echo $this->get_field_id('color_span_from'); ?>" value="<?php echo $color_span_from?>" />
|
436 |
+
<?php _e("to"); ?> <input type="text" size="7" name="<?php echo $this->get_field_name('color_span_to'); ?>"" id="<?php echo $this->get_field_id('color_span_to'); ?>" value="<?php echo $color_span_to?>" />
|
437 |
</div>
|
438 |
<br/>
|
439 |
+
<?php _e("Spacing (in px):"); ?><br/>
|
440 |
+
<label for="<?php echo $this->get_field_id('letter_spacing'); ?>"><?php _e("Between letters:"); ?></label>
|
441 |
+
<input type="text" size="5" name="<?php echo $this->get_field_name('letter_spacing'); ?>" id="<?php echo $this->get_field_id?>" value="<?php echo strlen($letter_spacing) > 0 ? $letter_spacing : $this->default_letter_spacing?>" /><br/>
|
442 |
+
<label for="<?php echo $this->get_field_id('word_spacing'); ?>"><?php _e("Between words:"); ?></label>
|
443 |
+
<input type="text" size="5" name="<?php echo $this->get_field_name('word_spacing'); ?>" id="<?php echo $this->get_field_id('word_spacing'); ?>" value="<?php echo strlen($word_spacing) > 0 ? $word_spacing : $this->default_word_spacing?>" /><br/>
|
444 |
<br/>
|
445 |
+
<?php _e("Transform tags:"); ?><br/>
|
446 |
+
<input type="radio" name="<?php echo $this->get_field_name('case'); ?>" id="<?php echo $this->get_field_id('text_transform_off'); ?>" value="off" <?php echo ($case == "off" || empty($case)) ? ' checked="checked"' : ""; ?> />
|
447 |
+
<label for="<?php echo $this->get_field_id('text_transform_off'); ?>"><?php _e("Off"); ?></label><br/>
|
448 |
+
<input type="radio" name="<?php echo $this->get_field_name('case'); ?>" id="<?php echo $this->get_field_id('text_transform_lowercase'); ?>" value="lowercase" <?php echo $case == "lowercase" ? ' checked="checked"' : ""; ?> />
|
449 |
+
<label for="<?php echo $this->get_field_id('text_transform_lowercase'); ?>"><?php _e("To lowercase"); ?></label><br/>
|
450 |
+
<input type="radio" name="<?php echo $this->get_field_name('case'); ?>" id="<?php echo $this->get_field_id('text_transform_uppercase'); ?>" value="uppercase" <?php echo $case == "uppercase" ? ' checked="checked"' : ""; ?> />
|
451 |
+
<label for="<?php echo $this->get_field_id('text_transform_uppercase'); ?>"><?php _e("To uppercase"); ?></label><br/>
|
452 |
+
<input type="radio" name="<?php echo $this->get_field_name('case'); ?>" id="<?php echo $this->get_field_id('text_transform_capitalize'); ?>" value="capitalize" <?php echo $case == "capitalize" ? ' checked="checked"' : ""; ?> />
|
453 |
+
<label for="<?php echo $this->get_field_id('text_transform_capitalize'); ?>"><?php _e("Capitalize"); ?></label><br/>
|
454 |
</fieldset>
|
455 |
+
<?php
|
456 |
}
|
457 |
/**
|
458 |
* Used to calculate how step size in spanning values
|
481 |
add_action('widgets_init', create_function('', 'return register_widget("UTCW");'));
|
482 |
|
483 |
//Register scripts and css with wordpress
|
484 |
+
wp_register_script('utcw-js', '/wp-content/plugins/ultimate-tag-cloud-widget/utcw.js', array('jquery'), "1.2", false);
|
485 |
+
wp_register_style('utcw-css', '/wp-content/plugins/ultimate-tag-cloud-widget/utcw.css', array(), "1.2", 'all');
|
486 |
|
487 |
/**
|
488 |
* Action handler for wordpress init used to attach scripts and styles
|
495 |
add_action('init', 'utcw_init');
|
496 |
|
497 |
|
498 |
+
/*
|
499 |
+
* Compare functions
|
|
|
|
|
|
|
500 |
*/
|
501 |
function utcw_cmp_count($a, $b) {
|
502 |
if ($a['count'] == $b['count']) {
|
503 |
return 0;
|
504 |
+
} else {
|
505 |
return ($a['count'] < $b['count']) ? -1 : 1;
|
506 |
}
|
507 |
}
|
508 |
|
509 |
+
function utcw_icmp_name($a, $b) {
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
return strcasecmp($a['name'], $b['name']);
|
511 |
}
|
512 |
+
|
513 |
+
function utcw_cmp_name($a, $b) {
|
514 |
+
return strcmp($a['name'], $b['name']);
|
515 |
+
}
|
516 |
+
|
517 |
+
function utcw_icmp_slug($a, $b) {
|
518 |
+
return strcasecmp($a['slug'], $b['slug']);
|
519 |
+
}
|
520 |
+
|
521 |
+
function utcw_cmp_slug($a, $b) {
|
522 |
+
return strcmp($a['slug'], $b['slug']);
|
523 |
+
}
|
524 |
+
|
525 |
+
function utcw_cmp_id($a, $b) {
|
526 |
+
if ($a['term_id'] == $b['term_id']) {
|
527 |
+
return 0;
|
528 |
+
} else {
|
529 |
+
return ($a['term_id'] < $b['term_id']) ? -1 : 1;
|
530 |
+
}
|
531 |
+
}
|
532 |
+
|
533 |
+
function utcw_cmp_color($a, $b) {
|
534 |
+
return strcasecmp($a['color'], $b['color']);
|
535 |
+
}
|
536 |
+
|
537 |
+
/**
|
538 |
+
* Function for checking if every item within an array is a numeric value
|
539 |
+
* @param arrau $array
|
540 |
+
* @return boolean
|
541 |
+
*/
|
542 |
+
function is_array_numeric($array) {
|
543 |
+
|
544 |
+
foreach ($array as $item) {
|
545 |
+
if (!is_numeric($item)) {
|
546 |
+
return false;
|
547 |
+
}
|
548 |
+
}
|
549 |
+
|
550 |
+
return true;
|
551 |
+
|
552 |
+
}
|