Plugin Directory

Changeset 157897


Ignore:
Timestamp:
09/25/2009 02:03:56 PM (17 years ago)
Author:
isikom
Message:

aggiornamento readme per versione 1.1.1

Location:
category-text
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • category-text/trunk/ctext.php

    r157571 r157897  
    66Author: Michele Menciassi
    77Author URI: http://www.isikom.it
    8 Version: 1.1.0
     8Version: 1.1.1
    99
    1010Copyright 2008  Michele Menciassi  (email : michele at miblogo dot com)
     
    674674    global $wp_query, $wpdb, $ctext;
    675675    extract($args);
    676    
     676echo "<!-- DEBUG: ctext -->";
    677677    // se la pagina è una categoria, esegui i vari controlli
    678678    // se non siamo in una categoria non visualizzo il widget
     
    737737            }
    738738        }
     739    }else if(is_single()){
     740        // number indica l'ID numerico assegnato al widget e ci serve per recuperarne le opzioni dall'array delle opzioni.
     741        $number = 0;
     742        $prefix = $ctext['prefix'];
     743        //$widget_id = $args['widget_id'];
     744        if (!empty($widget_id)){
     745            $number = intval(substr($widget_id, strlen($prefix)+1));
     746        }
     747        $options = get_option('widget_ctext');
     748       
     749        // se l'ID recuperato non è presente nell'array opzioni termino la funzione
     750        if ( !isset($options[$number]) )
     751            return;
     752       
     753        // recuperiamo il title (se impostato) per la sua visualizzazione
     754        $title = apply_filters('widget_title', $options[$number]['title']);
     755        $list = $options[$number]['list'];
     756        if (!empty($list)){
     757            $padri = array();
     758            $figli = array();
     759            $table_name_elements = $ctext['tables']['table_name_elements'];
     760            $table_name_categories = $ctext['tables']['table_name_categories'];
     761            foreach(get_the_category() as $cat) {
     762
     763                $categoria = $cat->term_id;
     764                array_push($padri, $categoria);
     765                $parent_chain = ctext_get_category_parents($categoria);
     766                if (count($parent_chain) > 1){
     767                    array_pop($parent_chain);
     768                    $figli = array_merge($figli, $parent_chain);
     769                }               
     770            }
     771            if (!empty($padri) or !empty($figli)){
     772                $lista_padri = implode(",",$padri);
     773                $lista_figli = implode(",",$figli);
     774                $SQL  = "SELECT `title`, `text` FROM `$table_name_elements` ";
     775                $SQL .= "LEFT JOIN `$table_name_categories` ";
     776                $SQL .= "ON `$table_name_elements`.`id_element` = `$table_name_categories`.`id_element` ";
     777                $SQL .= "WHERE `$table_name_elements`.`id_list` = '". $wpdb->escape($list) ."' AND ";
     778                $SQL .= " `$table_name_elements`.`posts` = 1 AND ( ";
     779                if ($lista_padri){
     780                    $SQL .= "( `id_category` IN ($lista_padri) )";
     781                    if($lista_figli){
     782                        $SQL .= "OR ( `id_category` IN ($lista_figli) AND `$table_name_elements`.`child` = 1  ) ";
     783                    }
     784                }else if($lista_figli){
     785                    $SQL .= "( `id_category` IN ($lista_figli) AND `$table_name_elements`.`child` = 1  ) ";
     786                }
     787                $SQL .= ") ";
     788            }
     789            $elements = $wpdb->get_results($SQL);
     790            if (!empty($elements)){
     791                // titolo del widget
     792                if ( !empty( $title) ){
     793                    echo $before_widget;
     794                    echo $before_title . $title . $after_title;
     795                    echo '<div class="textwidget">';
     796                    echo '</div>';
     797                    echo $after_widget;
     798                }
     799                foreach($elements as $element){
     800                    echo $before_widget;
     801                    if ( !empty( $element->title ) and $element->showtitle == 1) { echo $before_title . $element->title . $after_title; }
     802                    echo '<div class="textwidget">';
     803                    echo stripslashes($element->text);
     804                    echo '</div>';
     805                    echo $after_widget;
     806                }
     807            }
     808        }
    739809    }
    740810}
    741811
    742812function get_ctext_elements($list, $title = false){
    743     global $wp_query, $wpdb, $ctext;
    744    
     813    global $wp_query, $wpdb, $ctext;   
    745814    if (is_category()){
    746815        // recupero l'ID del widget per recuperarne le opzioni
     
    784853            $table_name_categories = $ctext['tables']['table_name_categories'];
    785854            foreach(get_the_category() as $cat) {
    786                 $categoria = $cat->term_id;
     855                $categoria = $cat->term_id;
     856                array_push($padri, $categoria);
    787857                $parent_chain = ctext_get_category_parents($categoria);
    788858                if (count($parent_chain) > 1){
     
    791861                }               
    792862            }
    793             if (!empty($padri) and !empty($figli)){
     863            if (!empty($padri) or !empty($figli)){
    794864                $lista_padri = implode(",",$padri);
    795865                $lista_figli = implode(",",$figli);
  • category-text/trunk/readme.txt

    r157581 r157897  
    1313It's very usefull for SEO, because you can make different text for different category, so also different banner ect.
    1414
    15 Testested also with Wordpress MU (WPMU)
     15The plugin born from idea of [RossoZingone](http://www.rossozingone.it "web agency") for his blog [Fantagiochi](http://blog www.fantagiochi.it "on line games")
    1616
    1717== Installation ==
     
    3939== Screenshots ==
    4040
    41 the screenshots coming soon
     41http://michele.menciassi.name/en/wordpress-plugins/category-text/3/
    4242
    4343== Changelog ==
    4444
     45= 1.1.1 =
     46Fix widget bug.
     47Elements with check 'posts' not showed correctly.
     48
    4549= 1.1.0 =
    4650Posts checkbox added, it allow to show your text also into a post of the selected category.
Note: See TracChangeset for help on using the changeset viewer.