Changeset 17353

Show
Ignore:
Timestamp:
08/24/07 00:24:56 (11 months ago)
Author:
pixline
Message:

now with category selection :-)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • accessible-news-ticker/trunk/ant.php

    r16446 r17353  
    55Description: Display latest posts or RSS news in an accessible/unobtrusive scroll box. Based on Chris Heilmann's <a href="http://onlinetools.org/tools/domnews/">DOMnews 1.0</a>. 
    66Author: Pixline 
    7 Version: 0.3rc1 
     7Version: 0.3rc2 
    88Author URI: http://pixline.net/ 
    99 
     
    3030$parts = pathinfo(__FILE__); 
    3131define("CACHE_PATH",str_replace("plugins/accessible-news-ticker","cache-feed",$parts['dirname'])); 
     32 
     33function widget_ant_install(){ 
     34if(!is_dir(CACHE_PATH) && !is_writeable(CACHE_PATH)){ mkdir(CACHE_PATH, 0777); } 
     35$ant_defaults = array("title"=>"Latest News", "howmany"=>5, "content"=>"posts", "category"=>"", "feedurl"=> ""); 
     36add_option('widget_ant_options',$ant_defauls); 
     37} 
     38 
    3239register_activation_hook(__FILE__, 'widget_ant_install'); 
    33  
    34 function widget_ant_install(){ 
    35 if(!is_dir(CACHE_PATH) && !is_writeable(CACHE_PATH)) 
    36       mkdir(CACHE_PATH, 0777); 
    37 } 
    38  
    3940include_once(get_bloginfo('url')."/wp-content/plugins/accessible-news-ticker/includes/simplepie.inc"); 
    4041 
     
    9697 
    9798function widget_ant($args) {  
    98 #$url = "http://feeds.feedburner.com/pixline"; 
    9999 
    100100        extract($args);  
    101101        $options = get_option('widget_ant_options');  
    102         $title = empty($options['title']) ? 'Latest News' : $options['title'];  
     102           $title = empty($options['title']) ? 'Latest News' : $options['title'];  
    103103        $howmany = empty($options['howmany']) ? 5 : $options['howmany'];  
    104104        $kind = empty($options['content']) ? 'posts' : $options['content'];  
     105        $antcat = empty($options['category']) ? '' : $options['category'];  
    105106        $url = empty($options['feedurl']) ? '' : $options['feedurl'];  
    106107 
     
    110111switch($kind): 
    111112      case 'posts': 
    112       $news = get_posts("numberposts=".$howmany); 
     113      $news = get_posts("numberposts=".$howmany."&category=".$antcat); 
    113114      echo "<div id='accessible-news-ticker'>"; 
    114115            echo "<ul>"; 
     
    162163            $newoptions['howmany'] = strip_tags(stripslashes($_POST['ant-howmany']));  
    163164                  $newoptions['content'] = strip_tags(stripslashes($_POST['ant-content'])); 
     165                  $newoptions['category'] = strip_tags(stripslashes($_POST['ant-category'])); 
    164166                  $newoptions['feedurl'] = strip_tags(stripslashes($_POST['ant-feedurl'])); 
    165167        }  
     
    200202            </label>  
    201203 
     204        <label for="ant-category" style="line-height:35px;display:block;">(if latest posts) Category:  
     205                  <select id='ant-category' name="ant-category"> 
     206                        <option value='' label='All Categories'>All Categories</option> 
     207                        <?php 
     208#                       $opzioni = array("posts"=>"Latest Posts","rss"=>"RSS Feed"); 
     209                        $opzioni = get_categories('type=post&hide_empty=1&hierarchical=0'); 
     210 
     211                        foreach($opzioni as $opzione): 
     212                              if($options['category'] == $opzione->cat_ID) $selected3 = " selected='selected'"; else $selected3 = ""; 
     213                              echo "<option value='".$opzione->cat_ID."' label=' ".$opzione->cat_name."'".$selected3."> ".$opzione->cat_name."</option>"; 
     214#                             print_r($opzione); 
     215                        endforeach; 
     216                        ?> 
     217                  </select> 
     218            </label>  
     219 
     220 
    202221        <label for="ant-feedurl" style="line-height:35px;display:block;">RSS Feed URL:     
    203222                  <?php if($options['feedurl'] != "") $value = $options['feedurl']; ?> 
     
    216235 
    217236    register_sidebar_widget('ANT News Ticker', 'widget_ant');  
    218     register_widget_control('ANT News Ticker', 'widget_ant_control', 350, 260);  
     237    register_widget_control('ANT News Ticker', 'widget_ant_control', 350, 300);  
    219238      if(!is_admin()): 
    220239      add_action('wp_head','widget_ant_headscript');