Hi, i'm new to WP... i'm trying to write a plugin that enable a widget to display on the sidebar a charts of bestseller book from a website.
I've read some documentation and i start with a test:
<?
// init widget
add_action("widgets_init", array('gdl_charts', 'register'));
//include jQuery
function my_init() {
if (!is_admin()) {
wp_enqueue_script('jquery');
}
}
add_action('init', 'my_init');
//main class
class gdl_charts {
// build controls
function control($data){
$data = get_option('gdl_charts');
?>
<p><label>Website <select name="gdl_charts_website">
<option value="www.website.com" <?php if ($data['website']=='www.website.com'){echo 'selected';} ?> >WebSite.com</option>
...
...
<?php
if (isset($_POST['gdl_charts_website'])){
$data['website'] = attribute_escape($_POST['gdl_charts_website']);
...
...
update_option('gdl_charts', $data);
}
}
//print widget
function widget($args, $instance){
////////////////////////////////////
$instance = get_option('gdl_charts');
$gdl_website = $instance['website'];
..
..
echo $args['before_widget'];
echo $args['before_title'] . 'GDL Charts' . $args['after_title'];
?>
<div class="gdl_chart_show">
<h3 style="background-color:#ccc;padding:3px;margin:3px 0;">Books Chart</h3>
<?php
echo "<ul>";
echo "<li><strong>" . $gdl_website . "</strong> </li>";
echo "</ul>";
?>
</div>
<?php
echo $args['after_widget'];
}
//register widget
function register(){
register_sidebar_widget('GDL Charts', array('gdl_charts', 'widget'));
register_widget_control('GDL Charts', array('gdl_charts', 'control'));
}
}
?>
It seems to work, but i get 2 errors for missing arguments.
The first is on the backend, it says "Missing argument 1 for gdl_charts::control() in /home/mhd-01/htdocs/wp-content/plugins/gdl-charts/gdl-charts.php on line 37".
Then on the frontend, it says "Missing argument 2 for gdl_charts::widget() in /home/mhd-01/htdocs/wp-content/plugins/gdl-charts/gdl-charts.php on line 74".
I'm sure i miss something in the plugin syntax... someone can help me?
Thanx in advance.