Plugin Directory

Changeset 581647


Ignore:
Timestamp:
08/04/2012 07:44:12 AM (14 years ago)
Author:
submarine
Message:

1.2 updated

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

Legend:

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

    r581219 r581647  
    1414        private $sb_position = 'left';
    1515        private $default_options = array (
    16             "caticonslite-sidebar-position"  => "left",
    17             "caticonslite-sidebar"   => "checked",
    18             "caticonslite-posttitle" => "checked"
     16            'caticonslite-sidebar-position'  => 'left',
     17            'caticonslite-sidebar'   => 'checked',
     18            'caticonslite-posttitle' => 'checked',
     19            'caticonslite-rss' => ''
    1920            );
    2021        private $options = array();
     22        private $rss = false;
    2123               
    2224        function __construct() {
    2325            $this->set_cat_icons();
    2426            $options = get_option(CIL_OPTIONS);
    25             if (!is_array($options) || count($options) == 0) {
     27            if ( !is_array($options) || 0 == count($options) ) {
    2628                add_option(CIL_OPTIONS,$this->default_options);
    2729                $options = $this->default_options;
     
    3739       
    3840        function reset_settings($options) {
    39             if(!empty($options['reset']))
    40               return $this->default_options;
    41             else
    42               return $options;
     41            if(!empty($options['reset'])) {
     42                return $this->default_options;
     43            } 
     44            else {
     45                return $options;
     46            } 
    4347        }
    4448       
    4549        function set_options() {
    4650            register_setting(CIL_GROUP, CIL_OPTIONS, array($this, 'reset_settings'));
    47          
     51        }   
    4852         
    4953        function is_checked($option,$suboption='') {
    5054            $resultat = '';
    5155            $checked = ' checked="checked" ';
    52             if (empty($suboption) AND $this->options[$option] == "checked") {
     56            if ( empty($suboption) AND isset($this->options[$option]) AND 'checked' == $this->options[$option] ) {
    5357                $resultat = $checked;
    5458            }
    5559            if (!empty($suboption)) {
    56                 if ( $this->options[$option] == $suboption) {
     60                if ( isset($this->options[$option]) AND $this->options[$option] == $suboption) {
    5761                    $resultat = $checked;
    5862                }
     
    106110                            <p class="description">('.__('Sidebar').')</p></td>
    107111                        </tr>
     112                        <tr valign="top">
     113                          <th scope="row">'.__('RSS').'</th>
     114                          <td><label >
     115                              <input type="checkbox" value="checked" name="'.CIL_OPTIONS.'[caticonslite-rss]" '.$this->is_checked('caticonslite-rss').' />
     116                            </label>
     117                          </td>
     118                        </tr>
    108119                      </table>
    109120                      <p>
     
    120131        function are_icons_sidebar() {
    121132            $result = false;
    122             if ($this->options['caticonslite-sidebar']=="checked") {
     133            if (isset($this->options['caticonslite-sidebar']) AND 'checked' == $this->options['caticonslite-sidebar']) {
    123134                $result = true;
    124135            }
     
    132143        function are_icons_post_title() {
    133144            $result = false;
    134             if ($this->options['caticonslite-posttitle']=="checked") {
     145            if (isset($this->options['caticonslite-posttitle']) AND 'checked' == $this->options['caticonslite-posttitle']) {
    135146                $result = true;
    136147            }
     
    138149        }
    139150       
     151        function is_rss() {
     152            $result = false;
     153            if (isset($this->options['caticonslite-rss']) AND 'checked' == $this->options['caticonslite-rss']) {
     154                $result = true;
     155            }
     156            return $result;
     157        }
     158        /**
     159         * If a RSS feed is created, 'raise the flag'
     160         */
     161        function rss_flag() {
     162            $this->rss = true;
     163        }
     164       
     165        /**
     166         * Inject the icons into the feeds
     167         * Working only with RSS2 and Atom. (And RDF, but only in Safari)
     168         * @param string The content to process
     169         * @return string The feed content
     170         */
     171        function rss($content) {
     172            if ( $this->rss AND isset($this->options['caticonslite-rss']) AND 'checked' == $this->options['caticonslite-rss']  ) // If the rss flag is raised, inject icons
     173                $content = get_cat_icon_lite().'<br/>'.$content;
     174            return $content;
     175        }
     176       
    140177        /**
    141178        * Sets the display of the icons on the right or on the left of the sidebar category name
    142179        */
    143180        function set_sidebar_icons_position($position='left') {
    144             if ($position=='left' OR $position=='right' OR $position=='center') {
     181            if ( 'left' == $position OR 'right' == $position OR 'center' == $position ) {
    145182                $this->sb_position = $position;
    146183            }
     
    151188        */
    152189        function page_filter($text) {//if (is_category())  // use this if you want to display icons in front of the post title only in the category page, for example
    153             if ($this->the_title == 1 && $this->permalink == 1) $text = $this->post_title($text);
    154             if  ($this->the_title == 0) $this->the_title = 1;           
     190            if ( 1 == $this->the_title AND 1 == $this->permalink ) {
     191                $text = $this->post_title($text);
     192            }   
     193            if  ( 0 == $this->the_title ) {
     194                $this->the_title = 1;
     195            }
    155196            return $text;
    156197        }
     
    161202        function post_title($text) {
    162203            $image = '';
    163             if (in_the_loop() && $GLOBALS['post']->post_title==$text) {// if in the loop & post title is the same than the one being processed
     204            if ( in_the_loop() AND $text == $GLOBALS['post']->post_title ) {// if in the loop & post title is the same than the one being processed
    164205                $this->reset_flags();
    165206                $icon=$this->get_icon();
    166                 if (!empty($icon)) $image = $this->html_tag($icon,$text);
     207                if (!empty($icon)) {
     208                    $image = $this->html_tag($icon,$text);
     209                }
    167210            }
    168211            return $image.$text; // if you want to display it after the title : return $text.$image;
     
    170213       
    171214        /**
    172         * Returns the html tag of the icon
     215        * Returns the html code of the icon
    173216        */
    174217        function html_tag($url,$title='') {
     
    177220            $cat_name = esc_attr($cat_object->name);
    178221            $alt = $cat_name;
    179             //$alt = 'caticonslite_bm_alt';         
    180222            $alt = apply_filters('caticonslite_alt', $alt);
    181             //$title = esc_attr($title);
    182             $title = $cat_name;
     223            if (!empty($title)) {
     224                $title = esc_attr($title);
     225            }
     226            else {
     227                $title = $cat_name;             
     228            }   
    183229            $title = apply_filters('caticonslite_title', $title);
    184             if (!empty($url)) $html = "<img class='caticonslite_bm' alt=\"$alt\" src=\"".esc_url($url)."\" title=\"$title\" />";
     230            if (!empty($url)) {
     231                $html = "<img class='caticonslite_bm' alt=\"$alt\" src=\"".esc_url($url)."\" title=\"$title\" />";
     232            }   
    185233            $html = apply_filters('caticonslite_htmltag', $html);
    186234            return $html;
    187235        }
     236       
    188237       
    189238        /**
     
    193242            global $wpdb;
    194243            $result = '';
     244            $cat_id = (int) $cat_id;
    195245            if ( 0 == $cat_id ) {   
    196246                $catlist = get_the_category(get_the_ID());
     
    204254                    }   
    205255                }
    206                 else
     256                else {
    207257                    $cat_id = (int) $catlist->term_id;
     258                }   
    208259            }
    209260           
    210261            $cat_id = apply_filters('caticonslite_cat_id', $cat_id);
    211            
    212             if ($cat_id > 0 AND isset($this->caticons_array[$cat_id]['url'])) {         
     262            if ($cat_id > 0 AND isset($this->caticons_array[$cat_id]['url'])) {
    213263                $result = $this->caticons_array[$cat_id]['url'];
    214             }
    215                        
     264            }           
    216265            return $result;
    217266        }
     
    234283                wp_cache_add( 'categoryiconslite_results', $results );
    235284            }
    236             if (is_array($results) && count($results)>0) {             
     285            if ( is_array($results) AND 0 < count($results) ) {             
    237286                foreach($results as $result) {
    238287                    $this->caticons_array[$result->cat_id] = array(
    239                                                                'icon_id' => $result->icon_id,
    240                                                                'url' => esc_url($result->image_url),
    241                                                                'slug' => $result->slug,
    242                                                                'name' => $result->name
    243                                                             );
     288                           'icon_id' => $result->icon_id,
     289                           'url' => esc_url($result->image_url),
     290                           'slug' => $result->slug,
     291                           'name' => $result->name
     292                           );
    244293                    $this->slugs[$result->slug] = $result->cat_id;
    245294                }
     
    258307        */
    259308        function list_cats( $output ) {         
    260             if (count($this->slugs)==0) return $output;
     309            if ( 0 == count($this->slugs) ) {
     310                return $output;
     311            }   
    261312            if (!empty($output)) {
    262313                $myarray = $this->url_extractor($output);
     
    264315                    $cats = array();
    265316                    $array = preg_match('/.*?\\/.*?\\/.*?\\/\\?cat=(\\d+)/is', $child[0], $correspondances) ;
    266                     if ($array == 1 && isset($correspondances[1]) && $correspondances[1] > 0) {
     317                    if (1 == $array AND isset($correspondances[1]) AND 0 < $correspondances[1] ) {
    267318                        $cats[] = $correspondances[1];// standard permalinks
    268319                    }
     
    290341                               $output = str_replace($cat_name.'<', $cat_name.$img.'<', $output);
    291342                               break;
    292                            
    293343                            case 'center': // Icons only
    294344                               $toto = preg_match('/(>.*)</i',$child[1],$result);
     
    296346                               $output = str_replace($cat_name.'<','>'.$img.'<', $output);
    297347                               break;
    298                            
    299348                        }           
    300349                    }
     
    304353            return $output;
    305354        }
    306        
    307        
     355               
    308356        /**
    309357        * Displays the category assigned to the image (icon) in the media library
     
    311359        function catagory_name($actions, $post) {
    312360            $cat_name = get_cat_name(get_post_meta($post->ID, $this->meta_key, true));
    313             if (!empty($cat_name)) echo '<i>'.esc_html(__('Category').' : '. $cat_name).'</i>';
     361            if ( !empty($cat_name) ) {
     362                echo '<i>'.esc_html(__('Category').' : '. $cat_name).'</i>';
     363            }   
    314364            return $actions;
    315365        }
     
    374424                    $post_meta = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->prefix}postmeta WHERE meta_key = '".esc_sql($this->meta_key)."' AND meta_value=$cat_id"));// search in postmeta table if the category exists
    375425                    $post_id2 = get_post_meta($post_id,$this->meta_key,true);
    376                     if ( !is_null($post_meta) && $post_id != $post_meta ) { // tests if the image is different than the one already assigned to the category and throws an error if it's the case, does nothing otherwise
     426                    if ( !is_null($post_meta) AND $post_id != $post_meta ) { // tests if the image is different than the one already assigned to the category and throws an error if it's the case, does nothing otherwise
    377427                        delete_post_meta($post_meta,$this->meta_key);
    378428                    }
     
    397447        function categories_custom_column( $data, $column, $id) {//$empty, $columnName, $id
    398448            $row = '';
    399             if ($column == 'caticonslite_icon') {
     449            if ( 'caticonslite_icon' == $column ) {
    400450                $icon = $this->get_icon($id);
    401451                $icon_img = '';
     
    445495        function category_removed($term_id) { 
    446496            global $wpdb;
    447             if($_POST['taxonomy'] == 'category') {         
     497            if('category' == $_POST['taxonomy'] ) {         
    448498                $query = "DELETE FROM {$wpdb->prefix}postmeta WHERE meta_key ='".esc_sql($this->meta_key)."' and meta_value = ".$term_id;
    449499                $results = $wpdb->get_results( $wpdb->prepare($query ));
     
    512562        */
    513563        function caticons_media_filter( $query ) {
    514             global  $pagenow, $wp_query;
    515             if ( is_admin() && $pagenow=='upload.php' && isset( $_GET['caticons'] ) && $_GET['caticons'] == '1' ) {
     564            global $pagenow, $wp_query;
     565            if ( is_admin() AND 'upload.php' == $pagenow AND isset( $_GET['caticons'] ) AND '1' == $_GET['caticons'] ) {
    516566                set_query_var( 'meta_key',  $this->meta_key ) ;
    517567            }
     
    523573        function show_caticons_dropdown() {
    524574            global $post_type, $post_mime_type, $pagenow;
    525             if ($post_type=='attachment' AND ($post_mime_type=='image' OR !isset($post_mime_type))) {
     575            if ( 'attachment' == $post_type AND ( 'image' == $post_mime_type OR !isset($post_mime_type))) {
    526576                $caticons = isset( $_GET['caticons'] ) ? (int) $_GET['caticons'] : 0;
    527577                ?>
     
    530580                    <option <?php selected( $caticons, 1 ); ?> value='1'>Category Icons</option>
    531581                </select>
    532                
    533582                <?php
    534583            }
  • category-icons-lite/tags/1.2/caticonslite.php

    r581219 r581647  
    2626    if (function_exists('register_uninstall_hook')) register_uninstall_hook(__FILE__,'category_icons_lite_uninstall');
    2727   
    28     $caticonslite_icons = $CategoryIconsLite->get_all();
     28    //$caticonslite_icons = $CategoryIconsLite->get_all();
    2929    $post_titles_icon = $CategoryIconsLite->are_icons_post_title();
    3030    $sidebar_icons = $CategoryIconsLite->are_icons_sidebar();
     31    $rss = $CategoryIconsLite->is_rss();
     32   
     33    if ($rss) {// RSS
     34        add_action('rss2_head',array($CategoryIconsLite,'rss_flag'));
     35        add_action('rdf_header',array($CategoryIconsLite,'rss_flag')); // only for Safari
     36        add_action('atom_ns',array($CategoryIconsLite,'rss_flag'));
     37        add_filter('the_excerpt_rss',array($CategoryIconsLite,'rss'));
     38        add_filter('the_content',array($CategoryIconsLite,'rss'));
     39        add_filter('the_content_rss',array($CategoryIconsLite,'rss'));
     40    }
    3141   
    3242    if ($sidebar_icons) { // if the option is checked, display the icon in the sidebar
     
    7484        }
    7585    }
     86   
     87    if (!function_exists('get_cat_icon_lite')) {
     88
     89        function get_cat_icon_lite($cat_id=0) {
     90           global $CategoryIconsLite;
     91            //return caticonslite_html_tag(caticonslite_get_icon($cat_id));
     92            return $CategoryIconsLite->get_cat_icon($cat_id);
     93        }
     94
     95    }
    7696}
    77 
    78 if (!function_exists('get_cat_icon_lite')) {
    79 
    80     function get_cat_icon_lite($cat_id=0) {
    81         return caticonslite_html_tag(caticonslite_get_icon($cat_id));
    82     }
    83    
    84     function caticonslite_html_tag($url,$title='') {
    85         $html = '';
    86         $alt = 'caticonslite_bm_alt';
    87         $alt = apply_filters('caticonslite_alt', $alt);
    88         if (!empty($title))  $title = esc_attr($title);
    89         $title = apply_filters('caticonslite_title', $title);
    90         if (!empty($url)) $html = "<img class='caticonslite_bm' alt=\"$alt\" src=\"".esc_url($url)."\" title=\"$title\" />";
    91         $html = apply_filters('caticonslite_htmltag', $html);
    92         return $html;
    93     }
    94        
    95     function caticonslite_get_icon($cat_id=0) {
    96         global $caticonslite_icons;
    97         $result = '';
    98         $cat_id = (int) $cat_id;
    99         if ( 0 == $cat_id ) {   
    100             $catlist = get_the_category(get_the_ID());
    101             if (is_array($catlist)) {// If there are several categories,
    102                 if (count($catlist) > 0) {
    103                     $cat_id = (int) $catlist[0]->term_id; // I take only the first one
    104                     $cat_id = apply_filters('caticonslite_cat_priority', $cat_id, $catlist);
    105                 }   
    106                 else {
    107                     return $result;
    108                 }   
    109             }
    110             else
    111                 $cat_id = (int) $catlist->term_id;
    112         }
    113        
    114         $cat_id = apply_filters('caticonslite_cat_id', $cat_id);
    115        
    116         if ($cat_id > 0 AND isset($caticonslite_icons[$cat_id]['url'])) {           
    117             $result = $caticonslite_icons[$cat_id]['url'];
    118         }
    119                    
    120         return $result;
    121     }
    122 }
  • category-icons-lite/tags/1.2/readme.txt

    r581219 r581647  
    77Stable tag: 1.2
    88
    9 The No. 1 plugin to assign icons to categories easily.
     9The No. 1 plugin to assign icons to categories easily. Category Icons allows you to associate a unique image with each of your WordPress categories.
    1010
    1111== Description ==
    1212
    13 Assigns icons to categories with WordPress 3.1 or higher. This plugin :
     13This plugin allows you to associate a unique image with each of your WordPress categories in order to prettify your pages a bit. That will make your category pages look better than 90% of the category pages out there.
    1414
    15 * automagically displays an icon in front of your post title (optional)
    16 * automagically displays icons next to the category names in the sidebar (optional)
    17 * offers template tags : designers & developers can [use template tag with this plugin](http://www.category-icons.com/2011/02/how-to-use-a-tag-to-display-icons-with-category-icons-lite/) to display category icons wherever you want.
     15Everything is configurable from the settings menu, you can use it on your index (home) page, post pages, or even your sidebar ! You can do icons only, or text and icons. This wonderful plugin :
     16
     17* automagically displays an icon in front of your post title (optional : you can disable it)
     18* automagically displays icons next to the category names in the sidebar (optional : you can disable it)
     19* offers 2 template tags : designers & developers can [use template tag with this plugin](http://www.category-icons.com/2011/02/how-to-use-a-tag-to-display-icons-with-category-icons-lite/) to display category icons wherever you want.
    1820* offers 4 filters for developers : caticonslite_htmltag, caticonslite_alt, caticonslite_title & caticonslite_widget.
    1921* generates valid XHTML (and Strict XHTML)
     
    4951If you like this plugin, or it has benefited you, [buy me a coffee](http://www.category-icons.com/support-the-plugin/).
    5052
    51 == I've found a bug, how can I tell you about it so you'll fix it for me? ==
    52 
    53 Go to the [support page](http://wordpress.org/support/plugin/category-icons-lite). Make sure you let me know the following:
    54 
    55 * What version of WordPress you're using
    56 * What exactly is your issue
    57 * Provide a screenshot or a link to your website is better
    58 
    5953== Changelog ==
    6054
    6155= 1.2 =
    6256* Now you can display icons only in the sidebar by selecting 'center' in the settings
     57* You can enable the display of category icons in the rss
    6358
    6459= 1.1.4 =
Note: See TracChangeset for help on using the changeset viewer.