I have read a lot of turorials an even the codex widget API, but can't solve my doubts: What are the really difference writing WorPress 3.x widget plugins? if there exists.
this doubt came when trying to create plugin containing an widget I have actived WP_DEBUG
and saw the notice that register_sidebar_widget()
is deprecated and I should use wp_register_sidebar_widget()
instead.
So I have changed and now I get:
Notice: Uninitialized string offset: 0 in /.../wp-content/plugins/raz/index.php on line 54
Notice: Uninitialized string offset: 0 in /.../wp-content/plugins/raz/index.php on line 55
Notice: Uninitialized string offset: 0 in /.../wp-content/plugins/raz/index.php on line 55
Here is the code:
<?php
// widget to show an iframe containing Brazilian CPTEC weather forecast
function previsao_tempo_cptec_widget_display($args) {
// print some HTML for the widget to display here
print $args['before_widget'];
print $args['before_title'] . "Previsão IN TITLE do Tempo - CPTEC" . $args['after_title'];
// print "content of the widget";
print '<center><!-- Widget Previsão de Tempo CPTEC/INPE --><iframe allowtransparency="true" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" src="http://www.cptec.inpe.br/widget/widget.php?p=4599&w=h&c=909090&f=ffffff" height="200px" width="215px"></iframe><noscript>Previsão de <a href="http://www.cptec.inpe.br/cidades/tempo/4599">Santa Maria/RS</a> oferecido por <a href="http://www.cptec.inpe.br">CPTEC/INPE</a></noscript><!-- Widget Previsão de Tempo CPTEC/INPE --></center>';
print $args['after_widget'];
}
// Activate the sidebar
wp_register_sidebar_widget(
'TempoCPTEC_1',
'Previsão de Tempo - CPTEC',
'previsao_tempo_cptec_widget_display',
array(
'description' => "Este widget mostra a previsão de Tempo pelo CPTEC - INPE/BR"
),
array(
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
)
);
// Loads the widget
add_action('widgets_init','previsao_tempo_cptec_widget_display');
?>
Other doubt, why this widget is always displayed in the top of my website and in the sidebar widgets also?
Thanks for any incoming handy answer.