' . $instance['aa_widget_title'] . '' . "\n"; } else { return ''; } } function aa_get_widget_title($instance) { return (! empty($instance['aa_widget_title'])) ? strip_tags($instance['aa_widget_title']) : false; } function aa_build_widget_title_input($instance, $count, $widget_field_name) { $field = array( 'name' => 'aa_widget_title', 'id' => 'aa_widget_title', 'tip' => 'A title to appear above the widget (optional)', 'title' => 'Widget Title' ); //If title already set then use that, otherwise use empty string $set_value = (isset($instance[$field['name']])) ? $instance[$field['name']] : ''; //Widgetized field name $field['name'] = $widget_field_name; aa_create_param_input($field, $count, $set_value); } class Auction_Affiliate_Widget extends WP_Widget { protected $widget_id; protected $widget_name; protected $widget_desc; protected $widget_tool; public function widget($args, $instance) { echo '' . "\n"; } public function form($instance) { global $aa_settings; $count = 0; echo '
' . "\n"; echo ' ' . "\n"; } echo ' ' . "\n"; echo '' . "\n"; } public function update($new_instance, $old_instance) { global $aa_settings; $instance = array(); $instance['aa_widget_title'] = aa_get_widget_title($new_instance); foreach($aa_settings['custom_field_inputs'] as $field) { $prefixed_field_name = aa_prefix($field['name'], $this->widget_tool); //Param is valid for the tool if($field[$this->widget_tool . '_param'] == true) { $param_value = trim($new_instance[$prefixed_field_name]); if($param_value !== '' || in_array($prefixed_field_name, $aa_settings['param_store_empty_string'])) { $instance[$prefixed_field_name] = strip_tags($param_value); } else { $instance[$prefixed_field_name] = ''; } } } return $instance; } } class Auction_Affiliate_Lister_Widget extends Auction_Affiliate_Widget { public function __construct() { $this->widget_id = 'aa_lister_widget'; $this->widget_name = 'Auction Affiliate Lister'; $this->widget_desc = 'Use this widget to...'; $this->widget_tool = 'lister'; parent::__construct($this->widget_id, $this->widget_name, array( 'description' => $this->widget_desc ) ); } } class Auction_Affiliate_Banner_Widget extends Auction_Affiliate_Widget { public function __construct() { $this->widget_id = 'aa_banner_widget'; $this->widget_name = 'Auction Affiliate Banner'; $this->widget_desc = 'Use this widget to...'; $this->widget_tool = 'banner'; parent::__construct($this->widget_id, $this->widget_name, array( 'description' => $this->widget_desc ) ); } } function aa_widgets_init() { register_widget('Auction_Affiliate_Lister_Widget'); register_widget('Auction_Affiliate_Banner_Widget'); } add_action('widgets_init', 'aa_widgets_init');