Changeset 1045683
- Timestamp:
- 12/16/2014 01:21:16 PM (10 years ago)
- Location:
- wp-category-tag-could
- Files:
-
- 1 added
- 6 edited
- 11 copied
Legend:
- Unmodified
- Added
- Removed
-
wp-category-tag-could/tags/1.3/bootstrap.php
r1045681 r1045683 4 4 Plugin URI: https://wordpress.org/plugins/wp-category-tag-could/ 5 5 Description: Display a configurable cloud of tags, categories or any other taxonomy filtered by tags or categories. 6 Version: 1. 26 Version: 1.3 7 7 Author: Henri Benoit 8 8 Author URI: http://benohead.com -
wp-category-tag-could/tags/1.3/classes/wp-category-tag-cloud.php
r1044933 r1045683 12 12 protected $modified_types = array(); 13 13 14 const VERSION = '1. 2';14 const VERSION = '1.3'; 15 15 const PREFIX = 'wpctc_'; 16 16 const DEBUG_MODE = false; -
wp-category-tag-could/tags/1.3/classes/wpctc-widget.php
r1044933 r1045683 67 67 } 68 68 69 70 /** 71 * @param $options settings for this plugin 72 * @return array 73 */ 74 private function get_exclude_array($exclude) 75 { 76 $exclude_array = array(); 77 78 foreach (explode(',', $exclude) as $id) { 79 if ($id != "") { 80 array_push($exclude_array, $id); 81 } 82 } 83 return $exclude_array; 84 } 85 86 /** 87 * Converts any array to an array of ints by converting each element in the array to an int. 88 * 89 * @param $array_in array to be converted 90 * @return array converted array 91 */ 92 private function to_int_array($array_in) 93 { 94 $array_out = array(); 95 96 if (isset($array_in) && is_array($array_in)) { 97 foreach ($array_in as $id) { 98 array_push($array_out, intval($id)); 99 } 100 } 101 return $array_out; 102 } 103 69 104 /** 70 105 * @param array $args … … 83 118 if ($wp_ctc_cache[1] > $current_time && $wp_ctc_cache[2] == $md5) { 84 119 echo $wp_ctc_cache[0]; 85 error_log("Returning cached widget: " . $cache_id . "(" . $md5 . ")");86 87 120 return; 88 121 } … … 140 173 $where); 141 174 175 $exclude = array(); 176 177 if (!empty($instance['exclude'])) { 178 $exclude = $this->to_int_array($this->get_exclude_array($instance['exclude'])); 179 } 180 error_log("exclude=".print_r($instance['exclude'], true)); 181 error_log("exclude=".print_r($exclude, true)); 182 142 183 $includeTags = ''; 143 184 if (count($tags) > 0) { 144 185 foreach ($tags as $tag) { 145 if ( count($instance['tag_id']) > 0 && !in_array($tag->tag_id, $instance['tag_id'])) {186 if ($instance['taxonomy'] == 'post_tag' && count($instance['tag_id']) > 0 && !in_array($tag->tag_id, $instance['tag_id'])) { 146 187 continue; 147 188 } 148 $includeTags = $tag->tag_id . ',' . $includeTags; 189 if (isset($instance[$instance['taxonomy'] + '_id']) 190 && count($instance[$instance['taxonomy'] + '_id']) > 0 191 && !in_array($tag->tag_id, $instance[$instance['taxonomy'] + '_id']) 192 ) { 193 continue; 194 } 195 if (!in_array($tag->tag_id, $exclude)) { 196 $includeTags = $tag->tag_id . ',' . $includeTags; 197 } 149 198 } 150 199 } 200 151 201 $cloud_args = array( 152 202 'smallest' => $instance['format'] == 'price' ? '100' : $instance['smallest'], … … 165 215 $cloud_args['include'] = $includeTags; 166 216 } 167 error_log("cloud_args=" . print_r($cloud_args, true)); 217 218 error_log("cloud_args=".print_r($cloud_args, true)); 168 219 ?> 169 220 <div … … 281 332 $timeout = isset($instance['timeout']) && is_numeric($instance['timeout']) ? $instance['timeout'] : 60; 282 333 update_option($cache_id, array($output, $current_time + $timeout, $md5)); 283 error_log("Caching widget for " . $timeout . " seconds: " . $cache_id . "(" . $md5 . ")");284 334 } 285 335 … … 296 346 { 297 347 $title = (!empty($instance['title'])) ? strip_tags($instance['title']) : ''; 348 $exclude = (!empty($instance['exclude'])) ? strip_tags($instance['exclude']) : ''; 298 349 $font = (!empty($instance['font'])) ? strip_tags($instance['font']) : ''; 299 350 $category_id = isset($instance['category_id']) ? $instance['category_id'] : array(); … … 352 403 </p> 353 404 <p> 405 <label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e('Exclude:'); ?></label> 406 <input class="widefat" id="<?php echo $this->get_field_id('exclude'); ?>" 407 name="<?php echo $this->get_field_name('exclude'); ?>" type="text" 408 value="<?php echo esc_attr($exclude); ?>"/> 409 </p> 410 <p> 354 411 <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Max displayed items:'); ?></label> 355 412 <input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" … … 366 423 <?php 367 424 $post_types = get_post_types('', 'objects'); 368 error_log(print_r($post_types, true));369 425 if ($post_types) { 370 426 foreach ($post_types as $name => $type) { … … 668 724 $instance = array(); 669 725 $instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : __('New title', 'wpctc_widget_domain'); 726 $instance['exclude'] = (!empty($new_instance['exclude'])) ? strip_tags($new_instance['exclude']) : ''; 670 727 $instance['font'] = (!empty($new_instance['font'])) ? strip_tags($new_instance['font']) : ''; 671 728 $custom_taxonomies = get_taxonomies(array('public' => true, '_builtin' => false), 'objects', 'and'); -
wp-category-tag-could/tags/1.3/readme.txt
r1045681 r1045683 5 5 Requires at least: 3.0.1 6 6 Tested up to: 4.0.1 7 Stable tag: 1. 27 Stable tag: 1.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 48 48 If you do not want to display the cloud as a side bar widget but in the content of a page or post, you can use the short code (see the frequently asked questions). You can also use a PHP function to have the cloud displayed. More details also in the frequently asked section. 49 49 50 **Note that in version 1.3, the logic to filter displayed terms was changed:** 51 52 * up to version 1.2: If categories were displayed and you selected category A and B but there was a post with category B and C, category C was also displayed. 53 * from version 1.3: If categories are displayed and you select category A and B but there was a post with category B and C, category C will NOT be displayed. 54 50 55 == Installation == 51 56 … … 69 74 70 75 * taxonomy: the taxonomy to be displayed e.g. post_tag, category... 76 * exclude: comma separated list of term IDs not to be displayed 71 77 * number: max number of terms to be displayed 72 78 * order_by: field by which to sort the terms in the tag. Should be "name" or "count" … … 82 88 * cache: set to 1 to cache the rendering of the cloud 83 89 * timeout: the cache timeout in seconds 90 * width: width of the 3D canvas. 0 means no specific width set. Use this to define the size of the generated canvas (to prevent pixelization due to stretching) 91 * height: height of the 3D canvas. 0 means no specific height set. Use this to define the size of the generated canvas (to prevent pixelization due to stretching) 84 92 * zoom: initial zoom factor e.g. 1 85 93 * smallest: smallest font size in percent of the default font size e.g. 75 … … 152 160 153 161 == Changelog == 162 163 = 1.3 = 164 165 * Added exclude list which contains a comma-separated list of term IDs (numbers) e.g. 1,3,7 which will not be displayed. 166 * If taxonomy X is selected and a filter is configured for this taxonomy X, the non-selected terms will not be displayed anymore even if there are posts with this term and one of the selected ones. 154 167 155 168 = 1.2 = -
wp-category-tag-could/trunk/bootstrap.php
r1044933 r1045683 4 4 Plugin URI: https://wordpress.org/plugins/wp-category-tag-could/ 5 5 Description: Display a configurable cloud of tags, categories or any other taxonomy filtered by tags or categories. 6 Version: 1. 26 Version: 1.3 7 7 Author: Henri Benoit 8 8 Author URI: http://benohead.com -
wp-category-tag-could/trunk/classes/wp-category-tag-cloud.php
r1044933 r1045683 12 12 protected $modified_types = array(); 13 13 14 const VERSION = '1. 2';14 const VERSION = '1.3'; 15 15 const PREFIX = 'wpctc_'; 16 16 const DEBUG_MODE = false; -
wp-category-tag-could/trunk/classes/wpctc-widget.php
r1044933 r1045683 67 67 } 68 68 69 70 /** 71 * @param $options settings for this plugin 72 * @return array 73 */ 74 private function get_exclude_array($exclude) 75 { 76 $exclude_array = array(); 77 78 foreach (explode(',', $exclude) as $id) { 79 if ($id != "") { 80 array_push($exclude_array, $id); 81 } 82 } 83 return $exclude_array; 84 } 85 86 /** 87 * Converts any array to an array of ints by converting each element in the array to an int. 88 * 89 * @param $array_in array to be converted 90 * @return array converted array 91 */ 92 private function to_int_array($array_in) 93 { 94 $array_out = array(); 95 96 if (isset($array_in) && is_array($array_in)) { 97 foreach ($array_in as $id) { 98 array_push($array_out, intval($id)); 99 } 100 } 101 return $array_out; 102 } 103 69 104 /** 70 105 * @param array $args … … 83 118 if ($wp_ctc_cache[1] > $current_time && $wp_ctc_cache[2] == $md5) { 84 119 echo $wp_ctc_cache[0]; 85 error_log("Returning cached widget: " . $cache_id . "(" . $md5 . ")");86 87 120 return; 88 121 } … … 140 173 $where); 141 174 175 $exclude = array(); 176 177 if (!empty($instance['exclude'])) { 178 $exclude = $this->to_int_array($this->get_exclude_array($instance['exclude'])); 179 } 180 error_log("exclude=".print_r($instance['exclude'], true)); 181 error_log("exclude=".print_r($exclude, true)); 182 142 183 $includeTags = ''; 143 184 if (count($tags) > 0) { 144 185 foreach ($tags as $tag) { 145 if ( count($instance['tag_id']) > 0 && !in_array($tag->tag_id, $instance['tag_id'])) {186 if ($instance['taxonomy'] == 'post_tag' && count($instance['tag_id']) > 0 && !in_array($tag->tag_id, $instance['tag_id'])) { 146 187 continue; 147 188 } 148 $includeTags = $tag->tag_id . ',' . $includeTags; 189 if (isset($instance[$instance['taxonomy'] + '_id']) 190 && count($instance[$instance['taxonomy'] + '_id']) > 0 191 && !in_array($tag->tag_id, $instance[$instance['taxonomy'] + '_id']) 192 ) { 193 continue; 194 } 195 if (!in_array($tag->tag_id, $exclude)) { 196 $includeTags = $tag->tag_id . ',' . $includeTags; 197 } 149 198 } 150 199 } 200 151 201 $cloud_args = array( 152 202 'smallest' => $instance['format'] == 'price' ? '100' : $instance['smallest'], … … 165 215 $cloud_args['include'] = $includeTags; 166 216 } 167 error_log("cloud_args=" . print_r($cloud_args, true)); 217 218 error_log("cloud_args=".print_r($cloud_args, true)); 168 219 ?> 169 220 <div … … 281 332 $timeout = isset($instance['timeout']) && is_numeric($instance['timeout']) ? $instance['timeout'] : 60; 282 333 update_option($cache_id, array($output, $current_time + $timeout, $md5)); 283 error_log("Caching widget for " . $timeout . " seconds: " . $cache_id . "(" . $md5 . ")");284 334 } 285 335 … … 296 346 { 297 347 $title = (!empty($instance['title'])) ? strip_tags($instance['title']) : ''; 348 $exclude = (!empty($instance['exclude'])) ? strip_tags($instance['exclude']) : ''; 298 349 $font = (!empty($instance['font'])) ? strip_tags($instance['font']) : ''; 299 350 $category_id = isset($instance['category_id']) ? $instance['category_id'] : array(); … … 352 403 </p> 353 404 <p> 405 <label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e('Exclude:'); ?></label> 406 <input class="widefat" id="<?php echo $this->get_field_id('exclude'); ?>" 407 name="<?php echo $this->get_field_name('exclude'); ?>" type="text" 408 value="<?php echo esc_attr($exclude); ?>"/> 409 </p> 410 <p> 354 411 <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Max displayed items:'); ?></label> 355 412 <input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" … … 366 423 <?php 367 424 $post_types = get_post_types('', 'objects'); 368 error_log(print_r($post_types, true));369 425 if ($post_types) { 370 426 foreach ($post_types as $name => $type) { … … 668 724 $instance = array(); 669 725 $instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : __('New title', 'wpctc_widget_domain'); 726 $instance['exclude'] = (!empty($new_instance['exclude'])) ? strip_tags($new_instance['exclude']) : ''; 670 727 $instance['font'] = (!empty($new_instance['font'])) ? strip_tags($new_instance['font']) : ''; 671 728 $custom_taxonomies = get_taxonomies(array('public' => true, '_builtin' => false), 'objects', 'and'); -
wp-category-tag-could/trunk/readme.txt
r1044933 r1045683 5 5 Requires at least: 3.0.1 6 6 Tested up to: 4.0.1 7 Stable tag: 1. 27 Stable tag: 1.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 48 48 If you do not want to display the cloud as a side bar widget but in the content of a page or post, you can use the short code (see the frequently asked questions). You can also use a PHP function to have the cloud displayed. More details also in the frequently asked section. 49 49 50 **Note that in version 1.3, the logic to filter displayed terms was changed:** 51 52 * up to version 1.2: If categories were displayed and you selected category A and B but there was a post with category B and C, category C was also displayed. 53 * from version 1.3: If categories are displayed and you select category A and B but there was a post with category B and C, category C will NOT be displayed. 54 50 55 == Installation == 51 56 … … 69 74 70 75 * taxonomy: the taxonomy to be displayed e.g. post_tag, category... 76 * exclude: comma separated list of term IDs not to be displayed 71 77 * number: max number of terms to be displayed 72 78 * order_by: field by which to sort the terms in the tag. Should be "name" or "count" … … 82 88 * cache: set to 1 to cache the rendering of the cloud 83 89 * timeout: the cache timeout in seconds 90 * width: width of the 3D canvas. 0 means no specific width set. Use this to define the size of the generated canvas (to prevent pixelization due to stretching) 91 * height: height of the 3D canvas. 0 means no specific height set. Use this to define the size of the generated canvas (to prevent pixelization due to stretching) 84 92 * zoom: initial zoom factor e.g. 1 85 93 * smallest: smallest font size in percent of the default font size e.g. 75 … … 152 160 153 161 == Changelog == 162 163 = 1.3 = 164 165 * Added exclude list which contains a comma-separated list of term IDs (numbers) e.g. 1,3,7 which will not be displayed. 166 * If taxonomy X is selected and a filter is configured for this taxonomy X, the non-selected terms will not be displayed anymore even if there are posts with this term and one of the selected ones. 154 167 155 168 = 1.2 =
Note: See TracChangeset
for help on using the changeset viewer.