Plugin Directory

Changeset 1045683


Ignore:
Timestamp:
12/16/2014 01:21:16 PM (10 years ago)
Author:
benohead
Message:

tagging version 1.3

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  
    44Plugin URI:  https://wordpress.org/plugins/wp-category-tag-could/
    55Description: Display a configurable cloud of tags, categories or any other taxonomy filtered by tags or categories.
    6 Version:     1.2
     6Version:     1.3
    77Author:      Henri Benoit
    88Author URI:  http://benohead.com
  • wp-category-tag-could/tags/1.3/classes/wp-category-tag-cloud.php

    r1044933 r1045683  
    1212        protected $modified_types = array();
    1313
    14         const VERSION = '1.2';
     14        const VERSION = '1.3';
    1515        const PREFIX = 'wpctc_';
    1616        const DEBUG_MODE = false;
  • wp-category-tag-could/tags/1.3/classes/wpctc-widget.php

    r1044933 r1045683  
    6767    }
    6868
     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
    69104    /**
    70105     * @param array $args
     
    83118            if ($wp_ctc_cache[1] > $current_time && $wp_ctc_cache[2] == $md5) {
    84119                echo $wp_ctc_cache[0];
    85                 error_log("Returning cached widget: " . $cache_id . "(" . $md5 . ")");
    86 
    87120                return;
    88121            }
     
    140173            $where);
    141174
     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
    142183        $includeTags = '';
    143184        if (count($tags) > 0) {
    144185            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'])) {
    146187                    continue;
    147188                }
    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                }
    149198            }
    150199        }
     200
    151201        $cloud_args = array(
    152202            'smallest' => $instance['format'] == 'price' ? '100' : $instance['smallest'],
     
    165215            $cloud_args['include'] = $includeTags;
    166216        }
    167         error_log("cloud_args=" . print_r($cloud_args, true));
     217
     218        error_log("cloud_args=".print_r($cloud_args, true));
    168219        ?>
    169220    <div
     
    281332            $timeout = isset($instance['timeout']) && is_numeric($instance['timeout']) ? $instance['timeout'] : 60;
    282333            update_option($cache_id, array($output, $current_time + $timeout, $md5));
    283             error_log("Caching widget for " . $timeout . " seconds: " . $cache_id . "(" . $md5 . ")");
    284334        }
    285335
     
    296346    {
    297347        $title = (!empty($instance['title'])) ? strip_tags($instance['title']) : '';
     348        $exclude = (!empty($instance['exclude'])) ? strip_tags($instance['exclude']) : '';
    298349        $font = (!empty($instance['font'])) ? strip_tags($instance['font']) : '';
    299350        $category_id = isset($instance['category_id']) ? $instance['category_id'] : array();
     
    352403        </p>
    353404        <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>
    354411            <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Max displayed items:'); ?></label>
    355412            <input class="widefat" id="<?php echo $this->get_field_id('number'); ?>"
     
    366423                <?php
    367424                $post_types = get_post_types('', 'objects');
    368                 error_log(print_r($post_types, true));
    369425                if ($post_types) {
    370426                    foreach ($post_types as $name => $type) {
     
    668724        $instance = array();
    669725        $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']) : '';
    670727        $instance['font'] = (!empty($new_instance['font'])) ? strip_tags($new_instance['font']) : '';
    671728        $custom_taxonomies = get_taxonomies(array('public' => true, '_builtin' => false), 'objects', 'and');
  • wp-category-tag-could/tags/1.3/readme.txt

    r1045681 r1045683  
    55Requires at least: 3.0.1
    66Tested up to: 4.0.1
    7 Stable tag: 1.2
     7Stable tag: 1.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4848If 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.
    4949
     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
    5055== Installation ==
    5156
     
    6974
    7075* taxonomy: the taxonomy to be displayed e.g. post_tag, category...
     76* exclude: comma separated list of term IDs not to be displayed
    7177* number: max number of terms to be displayed
    7278* order_by: field by which to sort the terms in the tag. Should be "name" or "count"
     
    8288* cache: set to 1 to cache the rendering of the cloud
    8389* 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)
    8492* zoom: initial zoom factor e.g. 1
    8593* smallest: smallest font size in percent of the default font size e.g. 75
     
    152160
    153161== 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.
    154167
    155168= 1.2 =
  • wp-category-tag-could/trunk/bootstrap.php

    r1044933 r1045683  
    44Plugin URI:  https://wordpress.org/plugins/wp-category-tag-could/
    55Description: Display a configurable cloud of tags, categories or any other taxonomy filtered by tags or categories.
    6 Version:     1.2
     6Version:     1.3
    77Author:      Henri Benoit
    88Author URI:  http://benohead.com
  • wp-category-tag-could/trunk/classes/wp-category-tag-cloud.php

    r1044933 r1045683  
    1212        protected $modified_types = array();
    1313
    14         const VERSION = '1.2';
     14        const VERSION = '1.3';
    1515        const PREFIX = 'wpctc_';
    1616        const DEBUG_MODE = false;
  • wp-category-tag-could/trunk/classes/wpctc-widget.php

    r1044933 r1045683  
    6767    }
    6868
     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
    69104    /**
    70105     * @param array $args
     
    83118            if ($wp_ctc_cache[1] > $current_time && $wp_ctc_cache[2] == $md5) {
    84119                echo $wp_ctc_cache[0];
    85                 error_log("Returning cached widget: " . $cache_id . "(" . $md5 . ")");
    86 
    87120                return;
    88121            }
     
    140173            $where);
    141174
     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
    142183        $includeTags = '';
    143184        if (count($tags) > 0) {
    144185            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'])) {
    146187                    continue;
    147188                }
    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                }
    149198            }
    150199        }
     200
    151201        $cloud_args = array(
    152202            'smallest' => $instance['format'] == 'price' ? '100' : $instance['smallest'],
     
    165215            $cloud_args['include'] = $includeTags;
    166216        }
    167         error_log("cloud_args=" . print_r($cloud_args, true));
     217
     218        error_log("cloud_args=".print_r($cloud_args, true));
    168219        ?>
    169220    <div
     
    281332            $timeout = isset($instance['timeout']) && is_numeric($instance['timeout']) ? $instance['timeout'] : 60;
    282333            update_option($cache_id, array($output, $current_time + $timeout, $md5));
    283             error_log("Caching widget for " . $timeout . " seconds: " . $cache_id . "(" . $md5 . ")");
    284334        }
    285335
     
    296346    {
    297347        $title = (!empty($instance['title'])) ? strip_tags($instance['title']) : '';
     348        $exclude = (!empty($instance['exclude'])) ? strip_tags($instance['exclude']) : '';
    298349        $font = (!empty($instance['font'])) ? strip_tags($instance['font']) : '';
    299350        $category_id = isset($instance['category_id']) ? $instance['category_id'] : array();
     
    352403        </p>
    353404        <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>
    354411            <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Max displayed items:'); ?></label>
    355412            <input class="widefat" id="<?php echo $this->get_field_id('number'); ?>"
     
    366423                <?php
    367424                $post_types = get_post_types('', 'objects');
    368                 error_log(print_r($post_types, true));
    369425                if ($post_types) {
    370426                    foreach ($post_types as $name => $type) {
     
    668724        $instance = array();
    669725        $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']) : '';
    670727        $instance['font'] = (!empty($new_instance['font'])) ? strip_tags($new_instance['font']) : '';
    671728        $custom_taxonomies = get_taxonomies(array('public' => true, '_builtin' => false), 'objects', 'and');
  • wp-category-tag-could/trunk/readme.txt

    r1044933 r1045683  
    55Requires at least: 3.0.1
    66Tested up to: 4.0.1
    7 Stable tag: 1.2
     7Stable tag: 1.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4848If 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.
    4949
     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
    5055== Installation ==
    5156
     
    6974
    7075* taxonomy: the taxonomy to be displayed e.g. post_tag, category...
     76* exclude: comma separated list of term IDs not to be displayed
    7177* number: max number of terms to be displayed
    7278* order_by: field by which to sort the terms in the tag. Should be "name" or "count"
     
    8288* cache: set to 1 to cache the rendering of the cloud
    8389* 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)
    8492* zoom: initial zoom factor e.g. 1
    8593* smallest: smallest font size in percent of the default font size e.g. 75
     
    152160
    153161== 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.
    154167
    155168= 1.2 =
Note: See TracChangeset for help on using the changeset viewer.