Hi,
I have a rss widget that I'm writing.
I want to give the user the option to customize the link color, background color etc by entering it in the widget options.
I dont want any inline css so this is how I tackled it.
In the constructor I do:
class CustomRSSFeedsAggregatorTicker extends WP_Widget{
var $bgColor = "#FFFFFF";
var $linkColor = "#0000FF";
var $descWordLimit = 15; //max number of words to allow in the description.
var $maxRssEntries = 10; //max number of feeds to get from each rss URI.
function CustomRSSFeedsAggregatorTicker(){
$widget_ops = array('classname' => 'custom_rss_feeds', 'description' => __( "Custom RSS Feeds Aggregator Widget") );
$this->WP_Widget('ticker', __('RSS Feeds Aggregator Ticker'), $widget_ops);
add_action('wp_head', array(&$this,'addStyle'), 1);
add_action('wp_footer', array(&$this,'addScript'), 1);
}
In my addStyle function:
function addStyle(){
$height = $this->height;
$width = $this->width;
echo '<link type="text/css" rel="stylesheet" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/custom-rss-feeds-aggregator-ticker/css/rss-aggregator-ticker.php?version=1.0.1'
. '&bgcolor=' . $this->bgColor
. '&linkcolor=' . $this->linkColor
. '" />' . "\n";
}
Then when the widget options are updated, in the update() method I update this variabled bgColor and linkColor:
$this->bgColor = $instance['bgcolor'];
$this->linkColor = $instance['linkcolor'];
remove_action('wp_head',array(&$this, 'addStyle'), 1);
add_action('wp_head', array(&$this,'addStyle'), 1);
The hope is that in the update method, i remove the old css include and replace it with a new one that include the new params...
only problem is that the remove doesn't seem to happen, when I look at the page, I still see the old css include.
Can anyone help?