Changeset 157897
- Timestamp:
- 09/25/2009 02:03:56 PM (17 years ago)
- Location:
- category-text
- Files:
-
- 6 added
- 2 edited
-
tags/1.1.1 (added)
-
tags/1.1.1/ctext-it_IT.mo (added)
-
tags/1.1.1/ctext-it_IT.po (added)
-
tags/1.1.1/ctext.php (added)
-
tags/1.1.1/logo_isikom_small.jpg (added)
-
tags/1.1.1/readme.txt (added)
-
trunk/ctext.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
category-text/trunk/ctext.php
r157571 r157897 6 6 Author: Michele Menciassi 7 7 Author URI: http://www.isikom.it 8 Version: 1.1. 08 Version: 1.1.1 9 9 10 10 Copyright 2008 Michele Menciassi (email : michele at miblogo dot com) … … 674 674 global $wp_query, $wpdb, $ctext; 675 675 extract($args); 676 676 echo "<!-- DEBUG: ctext -->"; 677 677 // se la pagina è una categoria, esegui i vari controlli 678 678 // se non siamo in una categoria non visualizzo il widget … … 737 737 } 738 738 } 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 } 739 809 } 740 810 } 741 811 742 812 function get_ctext_elements($list, $title = false){ 743 global $wp_query, $wpdb, $ctext; 744 813 global $wp_query, $wpdb, $ctext; 745 814 if (is_category()){ 746 815 // recupero l'ID del widget per recuperarne le opzioni … … 784 853 $table_name_categories = $ctext['tables']['table_name_categories']; 785 854 foreach(get_the_category() as $cat) { 786 $categoria = $cat->term_id; 855 $categoria = $cat->term_id; 856 array_push($padri, $categoria); 787 857 $parent_chain = ctext_get_category_parents($categoria); 788 858 if (count($parent_chain) > 1){ … … 791 861 } 792 862 } 793 if (!empty($padri) and!empty($figli)){863 if (!empty($padri) or !empty($figli)){ 794 864 $lista_padri = implode(",",$padri); 795 865 $lista_figli = implode(",",$figli); -
category-text/trunk/readme.txt
r157581 r157897 13 13 It's very usefull for SEO, because you can make different text for different category, so also different banner ect. 14 14 15 T estested also with Wordpress MU (WPMU)15 The plugin born from idea of [RossoZingone](http://www.rossozingone.it "web agency") for his blog [Fantagiochi](http://blog www.fantagiochi.it "on line games") 16 16 17 17 == Installation == … … 39 39 == Screenshots == 40 40 41 the screenshots coming soon 41 http://michele.menciassi.name/en/wordpress-plugins/category-text/3/ 42 42 43 43 == Changelog == 44 44 45 = 1.1.1 = 46 Fix widget bug. 47 Elements with check 'posts' not showed correctly. 48 45 49 = 1.1.0 = 46 50 Posts 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.