Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am developing a theme for my website. As soon as I activated the theme, the following errors/warnings shows up on the top of the admin panel on every page.

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method WPEditorAdmin::removeDefaultEditorMenus() should not be called statically in C:\Users\...\wp-includes\plugin.php on line 406

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method WPEditorAdmin::buildAdminMenu() should not be called statically in C:\Users\...\wp-includes\plugin.php on line 406

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method WPEditorAdmin::addThemesPage() should not be called statically in C:\Users\...\wp-includes\plugin.php on line 406

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method WPEditorAdmin::editorStylesheetAndScripts() should not be called statically in C:\Users\...\wp-includes\plugin.php on line 406

I am wondering how do I solve these errors and not have this happen anymore? Here's a screenshot.

enter image description here

share|improve this question
    
Can you provide your code where you're using add_action or add_filter in relation to removeDefaultEditorMenus? e.g., add_action('SOME_HOOK', array($SOME_OBJ, 'removeDefaultEditorMenus')); –  akTed Jan 18 '13 at 23:53
add comment

1 Answer

So you have your code in a class, let's say it looks like this...

<?php
class WPSE82245
{
    public function action_init()
    {
        // do stuff
    }
}

Now you try to hook it into something...

add_action('init', 'array('WPSE82245', 'action_init'));

What happens is when the init hook fires, WordPress tries to call your method. It would similar to if you just wrote this...

WPSE82245::action_init();

But PHP doesn't like that because you haven't declare you method static, that is, able to be used without an instance of its container class (like the example directly above).

This makes sense, what if you used $this in your method? Calling it statically would cause a runtime error saying that $this was being used outside an object context.

You can remove the errors by declaring your method static...

<?php
class WPSE82245
{
    public static function action_init()
    {
        // do stuff
    }
}

Or using an instance of your class as the first element of the array the callable argument of add_action.

<?php
class WPSE82245
{
    public function action_init()
    {
        // do stuff
    }
}

$cls = new WPSE82245();
add_action('init', array($cls, 'action_init'));

The above is just an example there are many different ways to instantiate a class in a WordPress theme/plugin.

share|improve this answer
    
Where would this be? I don't get it because this started with a blank wordpress theme. –  devs Jan 19 '13 at 7:15
    
that you developed? Or that you go from somewhere? Without seeing its code, it could be anywhere, but most likely in functions.php. –  chrisguitarguy Jan 19 '13 at 16:48
    
Yeah, it doesn't have anything related to wordpress in the functions.php –  devs Jan 19 '13 at 21:53
    
Edited with screenshot –  devs Jan 25 '13 at 2:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.