WP_Widget ( False, __('Feed Link', 'theme'));
$this->base_url = get_option('home').'/'.Str_Replace("\\", '/', SubStr( RealPath(DirName(__FILE__)), Strlen(ABSPATH) ));
// Read alle .pngs
$this->arr_icon = Array();
$handle = OpenDir(DirName(__FILE__));
While ($file = ReadDir ($handle)){
If (StrToLower(SubStr($file, -4)) == '.png') $this->arr_icon[] = $file;
}
CloseDir($handle);
Sort ($this->arr_icon);
// Register as Widget
Add_Action ('widgets_init', Array($this, 'Register'));
}
Function Register(){
Register_Widget('widget_theme_feed_link');
}
Function widget ($args, $settings){
If ($settings['file'] == '') $settings['file'] = $this->arr_icon[Array_Rand($this->arr_icon)];
$img_url = $this->base_url.'/'.$settings['file'];
If ($settings['title'] == '') $settings['title'] = __('RSS 2.0 Feed', 'theme');
Echo $args['before_widget'];
Echo $args['before_title'].$settings['title'].$args['after_title'];
Echo '';
Echo $args['after_widget'];
}
Function form ($settings){
// Show Form:
Echo __('Title', 'theme').':
';
Echo __('Choose an icon', 'theme').':
';
Echo '
| '.__('Random RSS Icon' , 'theme').' |