I’m trying to create my own test widget plugin like the example in Widget API, but after I activate the widget plugin and in wp-admin go to Appearance>Widgets, I get the error:
“Fatal error: Cannot redeclare widget_myuniquewidget_register() (previously declared in /home/mycomput/public_html/test/wp-content/plugins/widgets.php:9) in /home/mycomput/public_html/test/wp-content/plugins/widgets.php on line 8”
I’m using the code from the codex:
function widget_myuniquewidget_register() {
function widget_myuniquewidget($args) {
extract($args);
?>
<?php echo $before_widget; ?>
<?php echo $before_title
. 'My Unique Widget'
. $after_title; ?>
Hello, World!
<?php echo $after_widget; ?>
<?php
}
register_sidebar_widget('My Unique Widget',
'widget_myuniquewidget');
}
add_action('init', widget_myuniquewidget_register);
What am I doing wrong?