[wp-hackers] Writing plugins with classes
Aaron Brazell
abrazell at b5media.com
Sat Feb 24 21:57:59 GMT 2007
Hey guys-
Maybe someone can give me a quick pointer here. I've always wrote
plugins procedurally, but decided with this new one to write as a
class. Problem is, I'm obviously screwing up some syntax somewhere
because the class is being redeclared. There's really only two places
it could be happening and it boils down to WP syntax, not PHP... Help.
So I have a class with a function to add a administrative submenu
under management:
class myclass {
function admin_manage()
{
if ( function_exists('add_management_page') )
add_management_page('Thingy', 'Thingy', 1, basename(__FILE__), array
(new myclass(), 'admin_screen'));
}
function admin_screen
{
echo "My page";
}
}
Then I hook on admin_head:
add_action('admin_head', array('myclass', 'admin_manage'));
What am I missing here?
The error in WP 2.1 is:
Fatal error: Cannot redeclare class myclass in /home/emmense/
public_html/wp-content/plugins/wp-103bees.php on line 11
The only two places I could be redclaring is in the
add_management_page() call or the add_action() call...
Help?
--
Aaron Brazell
Technology Manager, b5media
"A Global New Media Company"
web:: www.b5media.com, www.technosailor.com
phone:: 410-608-6620
skype:: technosailor
More information about the wp-hackers
mailing list