Warning/Error in Admin Panel while developing theme

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-includesplugin.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-includesplugin.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-includesplugin.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-includesplugin.php on line 406

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

Read More

enter image description here

Related posts

Leave a Reply

1 comment

  1. 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.