Ticket #5770: widgets.php_8180-5770.diff

File widgets.php_8180-5770.diff, 4.6 KB (added by AndrewFrazier, 5 years ago)

Slightly tweaked version of the patch, based on revision 8180

Line 
1Index: wp-includes/widgets.php
2===================================================================
3--- wp-includes/widgets.php     (revision 8180)
4+++ wp-includes/widgets.php     (working copy)
5@@ -1364,18 +1364,42 @@
6        extract($args);
7        $options = get_option('widget_tag_cloud');
8        $title = empty($options['title']) ? __('Tags') : apply_filters('widget_title', $options['title']);
9+       $smallest = empty($options['smallest']) ? '8' : $options['smallest'];
10+       $largest = empty($options['largest']) ? '22' : $options['largest'];
11+       $unit = empty($options['unit']) ? 'pt' : $options['unit'];
12+       $number = empty($options['number']) ? '45' : $options['number'];
13+       $format = empty($options['format']) ? 'flat' : $options['format'];
14+       $orderby = empty($options['orderby']) ? 'name' : $options['orderby'];
15+       $order = empty($options['order']) ? 'ASC' : $options['order'];
16 
17        echo $before_widget;
18        echo $before_title . $title . $after_title;
19-       wp_tag_cloud();
20+       wp_tag_cloud('smallest='.$smallest.'&largest='.$largest.'&unit='.$unit.'&number='.$number.'&format='.$format.'&orderby='.$orderby.'&order='.$order);
21        echo $after_widget;
22 }
23 
24 function wp_widget_tag_cloud_control() {
25        $options = $newoptions = get_option('widget_tag_cloud');
26 
27+       $smallest = 8;
28+       $largest = 22;
29+       $unit = 'pt';
30+       $number = 45;
31+       $format = 'flat';
32+       $orderby = 'name';
33+       $order = 'ASC';
34+       $exclude = '';
35+       $include = '';
36+
37        if ( $_POST['tag-cloud-submit'] ) {
38                $newoptions['title'] = strip_tags(stripslashes($_POST['tag-cloud-title']));
39+               $newoptions['smallest'] = strip_tags(stripslashes($_POST['tag-cloud-minsize']));
40+               $newoptions['largest'] = strip_tags(stripslashes($_POST['tag-cloud-maxsize']));
41+               $newoptions['unit'] = strip_tags(stripslashes($_POST['tag-cloud-unit']));
42+               $newoptions['number'] = strip_tags(stripslashes($_POST['tag-cloud-number']));
43+               $newoptions['format'] = strip_tags(stripslashes($_POST['tag-cloud-format']));
44+               $newoptions['orderby'] = strip_tags(stripslashes($_POST['tag-cloud-orderby']));
45+               $newoptions['order'] = strip_tags(stripslashes($_POST['tag-cloud-order']));
46        }
47 
48        if ( $options != $newoptions ) {
49@@ -1384,10 +1408,48 @@
50        }
51 
52        $title = attribute_escape( $options['title'] );
53+       $smallest = attribute_escape( $options['smallest'] );
54+       $largest = attribute_escape( $options['largest'] );
55+       $unit = attribute_escape( $options['unit'] );
56+       $number = attribute_escape( $options['number'] );
57+       $format = attribute_escape( $options['format'] );
58+       $orderby = attribute_escape( $options['orderby'] );
59+       $order = attribute_escape( $options['order'] );
60 ?>
61        <p><label for="tag-cloud-title">
62        <?php _e('Title:') ?> <input type="text" class="widefat" id="tag-cloud-title" name="tag-cloud-title" value="<?php echo $title ?>" /></label>
63        </p>
64+       <p><label for="tag-cloud-maxsize">
65+       <?php _e('Maximum Font Size:')?> <input type="text" class="" id="tag-cloud-maxsize" name="tag-cloud-maxsize" value="<?php echo $largest ?>" size="4" /></label>
66+       </p>
67+       <p><label for="tag-cloud-minsize">
68+       <?php _e('Minimum Font Size:')?> <input type="text" class="" id="tag-cloud-minsize" name="tag-cloud-minsize" value="<?php echo $smallest ?>" size="4" /></label>
69+       </p>
70+       <p><label for="tag-cloud-unit">
71+       <?php _e('Unit:')?> <input type="text" class="" id="tag-cloud-unit" name="tag-cloud-unit" value="<?php echo $unit ?>" size="4" /></label>
72+       </p>
73+       <p><label for="tag-cloud-number">
74+       <?php _e('Number:')?> <input type="text" class="" id="tag-cloud-number" name="tag-cloud-number" value="<?php echo $number ?>" size="4" /></label>
75+       </p>
76+       <p><label for="tag-cloud-format">
77+       <?php _e('Format:')?> <select size="1" id="tag-cloud-format" name="tag-cloud-format">
78+                       <option value="flat" <?php if($format == 'flat'){echo "selected";}?>>Flat</option>
79+                       <option value="list" <?php if($format == 'list'){echo "selected";}?>>List</option>
80+                       <option value="array" <?php if($format == 'array'){echo "selected";}?>>Array</option>
81+               </select></label>
82+       </p>
83+       <p><label for="tag-cloud-orderby">
84+       <?php _e('Order By:')?> <select size="1" id="tag-cloud-orderby" name="tag-cloud-orderby">
85+                       <option value="name" <?php if($orderby == 'name'){echo "selected";}?>>Name</option>
86+                       <option value="count" <?php if($orderby == 'count'){echo "selected";}?>>Count</option>
87+               </select></label>
88+       </p>
89+       <p><label for="tag-cloud-order">
90+       <?php _e('Order:')?> <select size="1" id="tag-cloud-order" name="tag-cloud-order">
91+                       <option value="ASC" <?php if($order == 'ASC'){echo "selected";}?>>Ascending</option>
92+                       <option value="DESC" <?php if($order == 'DESC'){echo "selected";}?>>Descending</option>
93+               </select></label>
94+       </p>
95        <input type="hidden" name="tag-cloud-submit" id="tag-cloud-submit" value="1" />
96 <?php
97 }