Plugin Directory

Changeset 584049


Ignore:
Timestamp:
08/10/2012 08:32:42 PM (14 years ago)
Author:
submarine
Message:

parameters added to get_cat_icon_lite()

Location:
category-icons-lite/tags/1.2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • category-icons-lite/tags/1.2/caticons-lite.class.php

    r583156 r584049  
    33   
    44    class CategoryIconsLite {
    5        
    65        private $meta_key = '_wp_attachment_category'; // hidden custom field
    76        private $settings = 'caticonslite_settings';
     
    241240            if ( in_the_loop() AND $text == $GLOBALS['post']->post_title ) {// if in the loop & post title is the same than the one being processed
    242241                $this->reset_flags();
    243                 /*$icon=$this->get_icon();
    244                 if (!empty($icon)) {
    245                     $image = $this->html_tag($icon,$text);
    246                 }
    247                 */
    248242                $image = $this->get_cat_icon();
    249243            }
     
    292286        }
    293287       
    294        
    295288        /**
    296289        * This function returns the icon url
     
    304297                    $cat_id = array();
    305298                    $result = array();
    306                     if (count($catlist) > 0) {
     299                    if (0 < count($catlist) ) {
    307300                        $max = $this->options['caticonslite-maxicons'];
    308                         if (count($catlist)<$max) {
     301                        if (count($catlist) < $max) {
    309302                            $max = count($catlist);
    310303                        }
    311                         for ($i=0;$i<$max;$i++) {
     304                        for ($i=0; $i<$max; $i++) {
    312305                            $cat_id[] = (int) $catlist[$i]->term_id;
    313306                        }
     
    318311                    }   
    319312                }
    320                 else {
     313                else { // one category
    321314                    $cat_id = (int) $catlist->term_id;
    322315                }   
     
    325318            $cat_id = apply_filters('caticonslite_cat_id', $cat_id);
    326319            if (is_array($cat_id)) {
    327                 for ($i=0; $i<count($cat_id);$i++) { 
    328                      $index = $cat_id[$i];
    329                     if (0 < $index AND isset($this->caticons_array[$index]['url'])) {   
    330                         $result[] = $this->caticons_array[$index]['url'];
    331                        
     320                for ($i=0; $i<count($cat_id); $i++) { 
     321                    $idcat = $cat_id[$i];
     322                    if (0 < $idcat AND isset($this->caticons_array[$idcat]['url'])) {   
     323                        $result[] = $this->caticons_array[$idcat]['url'];
    332324                    }
    333325                }
     
    338330                }
    339331            }
     332           
    340333            return $result;
    341334        }
     
    373366        * Returns the category icons
    374367        */
    375         function get_cat_icon($cat_id=-1) {
     368        function get_cat_icon($cat_id=-1,$maxicons=0) {
     369            if (isset($this->options['caticonslite-maxicons']) AND 1 < $this->options['caticonslite-maxicons'] AND $maxicons == 0) {
     370                $maxicons = $this->options['caticonslite-maxicons'];
     371            }
    376372            $result = '';
    377373            $icons = $this->get_icon($cat_id);
    378374            if (!empty($icons)) {
    379375                if (is_array($icons)) {
     376                    $icons = array_slice($icons,0,$maxicons);
    380377                    foreach ($icons as $icon) {
    381                         $result .= $this->html_tag($icon);       
     378                        $result .= $this->html_tag($icon);
    382379                    }
    383380                }
  • category-icons-lite/tags/1.2/caticonslite.php

    r583156 r584049  
    99*/
    1010
     11global $pagenow;
     12include_once('caticons-lite.class.php'); // Loads Category Icons Lite class
     13
    1114/**
    1215* This function removes all traces of the plugin in the postmeta table
    1316*/
    14 
    15 global $pagenow;
    16 
    1717function category_icons_lite_uninstall() {
    1818    global $wpdb;
    1919    $metas = $wpdb->get_results( "DELETE FROM {$wpdb->prefix}postmeta WHERE meta_key = '_wp_attachment_category'" );   
    2020}
    21 
    22 include_once('caticons-lite.class.php');
    2321
    2422if(class_exists('CategoryIconsLite')) {
     
    3331    $rss = $CategoryIconsLite->is_rss();
    3432   
     33    // --- RSS
    3534    if ($rss) {// RSS
    3635        add_filter('the_excerpt_rss',array($CategoryIconsLite,'rss_content'));
     
    3938    }
    4039   
    41    
     40    // --- Sidebar
    4241    if ($sidebar_icons) { // if the option is checked, display the icon in the sidebar
    4342        add_filter('wp_list_categories',array($CategoryIconsLite,'list_cats'), 10, 2);
    4443    }
    4544   
     45    // --- Posts title
    4646    if ($post_titles_icon) { // if the option is checked, display the icon in front of the post titles
    4747        add_filter('the_title', array($CategoryIconsLite,'page_filter'), 10,2);
    4848       
    4949        //--- The automagic mechanic
     50        //add_filter('woo_embed',array($CategoryIconsLite,'reset_flags'),10,2);
     51        add_filter('post_thumbnail_html',array($CategoryIconsLite,'reset_flags'),10,2);
     52        add_filter('the_category',array($CategoryIconsLite,'reset_flags'),10,2);
     53       
    5054        add_action('the_content',array($CategoryIconsLite,'reset_flags'));
    5155        add_action('the_post',array($CategoryIconsLite,'reset_flags'));
    52         add_filter('the_excerpt',array($CategoryIconsLite,'reset_flags'));
     56        add_filter('the_excerpt',array($CategoryIconsLite,'reset_flags'),10,2);
    5357        add_filter('get_comments_number',array($CategoryIconsLite,'reset_flags'),10,2);
    5458        add_filter('the_time',array($CategoryIconsLite,'reset_flags'),10,2);
     
    6165    }
    6266   
    63     // WP Admin GUI     
    64    
     67    // --- WP Admin GUI     
    6568    if (is_admin() /*&& current_user_can( 'manage_categories' )*/ ) {
    66    
    6769        add_action('admin_menu',array($CategoryIconsLite,'add_menu'),1);
    6870        add_action('admin_init', array($CategoryIconsLite,'set_options'),1);
     
    8385            add_filter('deleted_term_taxonomy', array($CategoryIconsLite,'category_removed'));
    8486        }
    85        
    8687    }
    8788   
     89    // --- get_cat_icon_lite()
    8890    if (!function_exists('get_cat_icon_lite')) {
    89         function get_cat_icon_lite($cat_id=-1) {
     91        function get_cat_icon_lite($args='') {//$cat_id=-1,$maxicons=0
    9092            global $CategoryIconsLite;
    91             return $CategoryIconsLite->get_cat_icon($cat_id);
     93            $max_icons = 0;
     94            $cat_id = -1;
     95            if (is_integer($args)) { // if parameter is an integer, use it as cat_id
     96                $cat_id = $args;
     97            }
     98            else {
     99                parse_str($args, $parameter);
     100                if (isset($parameter['cat'])) { // cat=X : display category id X icon
     101                    $cat_id = (int) $parameter['cat'];
     102                }
     103               
     104                if (isset($parameter['max'])) { // max=Y : display Y icon(s) maximum
     105                    $max_icons = (int) $parameter['max'];
     106                } 
     107            }
     108           
     109            return $CategoryIconsLite->get_cat_icon($cat_id,$max_icons);
    92110        }
    93111    }
  • category-icons-lite/tags/1.2/readme.txt

    r583442 r584049  
    2525* automatically displays icons in the categories widget, next to the category names or **just category icons** (you can disable it too)
    2626* is compatible with My Category Order
     27* works with more themes ([ColorWay](http://wordpress.org/extend/themes/colorway) for example)
    2728
    2829= For Designers & Developers : =
     
    6364== Buy me a coffee ==
    6465
    65 If you like this plugin, or it has benefited you, [buy me a coffee](http://www.category-icons.com/support-the-plugin/).
     66If you like this plugin, or it has benefited you, you can [buy me a coffee](http://www.category-icons.com/support-the-plugin/).
    6667
    6768== Changelog ==
Note: See TracChangeset for help on using the changeset viewer.