Load_TextDomain();
// Widget ready
$this->WP_Widget ( False, $this->t('RSS Badge Feed Linker'),
Array('description' => $this->t('Enables you to add a RSS Badge to your sidebar.')));
$this->base_url = get_option('siteurl').'/'.Str_Replace("\\", '/', SubStr(RealPath(DirName(__FILE__)), Strlen(ABSPATH)));
// Read all .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(get_class($this));
}
Function Load_TextDomain(){
$this->text_domain = get_class($this);
load_textdomain ($this->text_domain, DirName(__FILE__).'/language/'.get_locale().'.mo');
}
Function t ($text, $context = ''){
// Translates the string $text with context $context
If ($context == '')
return __($text, $this->text_domain);
Else
return _x($text, $context, $this->text_domain);
}
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'] = $this->t('RSS 2.0 Feed');
Echo $args['before_widget'];
Echo $args['before_title'].$settings['title'].$args['after_title'];
Echo '';
Echo $args['after_widget'];
}
Function form ($settings){
// Show Form:
?>
t('Title:')?>
t('Please choose a rss icon.')?>
/> | t('Random RSS Icon')?> |
/> |