Need help creating an options page for a plugin
-
So I’ve been working on WeatherIcon a lot lately with one of the plugin’s original makers and my latest project for it is updating it to WP 1.5 standards.
It had been before doing an
add_options_pageon itself and then aif (is_plugin()) {or whatever it is to display the configuration page.Since that is depreciated, I’m trying to switch it to using a function to display the options page and I cannot figure out for the life of me what I’m doing wrong.
Here’s what I have currently: http://test.viper007bond.com/WeatherIcon.phps
And the error I’m getting:
Fatal error: Cannot redeclare weather_options_page() (previously declared in c:phpdevprivateprojectsnewblogwordpresswp-contentpluginsWeatherIconWeatherIcon.php:169) in c:phpdevprivateprojectsnewblogwordpresswp-contentpluginsWeatherIconWeatherIcon.php on line 168Ideas?
-
Have you read Writing a Plugin and the Plugin API documentation?
See, particularly, the Adding Administration Panels section from the first link above.
// This function displays the options page in the WP admin area
if (! function_exists('weather_options_page')) {
function weather_options_page() {
... weather options code here
} // close function
} // close if function_existsI know how to do it. I even threw together a test plugin that makes a tab that displays “Test!” for it’s content to double check that I did and it worked fine:
add_action('admin_menu', 'viper_add_options_page');function viper_add_options_page() {
if (function_exists('add_options_page'))
add_options_page("Viper's Page", "Viper's Tab", 5, __FILE__, 'viper_options_page');
}function viper_options_page() {
echo "Testing!!! :D";
}My problem isn’t with how to do it, it’s with what I’m doing wrong in the above link. 😉
I experienced this before, and I worked around it by not using __FILE__. You can just use a unique string and you should be fine.
add_options_page("Viper's Page", "Viper's Tab", 5, 'ViperTab', 'viper_options_page');Going back to the old method for this current release. I’ll deal with in a few days when working on the next build. Hopefully then I won’t hate PHP/WordPress so much. 😛
Thanks for all of your guys’ help. 🙂
The topic ‘Need help creating an options page for a plugin’ is closed to new replies.