plugins - Warning: Use of undefined constant list_all - assumed 'list_all' (this will throw an Error in a future

admin2025-06-04  2

I have a problem with php 7 syntax. I installed this plugin called simple table manager /

and upon activation I got these warnings

Warning: Use of undefined constant list_all - assumed 'list_all' (this will throw an Error in a future version of PHP) in C:\xampp\htdocs\wp2\wp-content\plugins\simple-table-manager\controller.php on line 52

Warning: Use of undefined constant add_new - assumed 'add_new' (this will throw an Error in a future version of PHP) ....

Warning: Use of undefined constant settings - assumed 'settings' (this will throw an Error.....

Warning: Use of undefined constant edit - assumed 'edit' (this will throw an Error.....

the code looks something like this

class Controller {
....

public function add_menu() {
        add_menu_page('Simple Table Manager - List', 'Simple Table Manager', 'manage_options', $this->slug['list'], array($this, list_all ));
        add_submenu_page(null, 'Simple Table Manager - Add New', 'Add New', 'manage_options', $this->slug['add'], array($this, add_new));
        add_submenu_page($this->slug['list'], 'Simple Table Manager - Settings', 'Settings', 'manage_options', $this->slug['settings'], array($this, settings));
        add_submenu_page(null, 'Simple Table Manager - Edit', 'Edit', 'manage_options', $this->slug['edit'], array($this, edit));
    }
public function list_all() {....}
public function add_new() {...}
public function edit() {...}
public function settings() {...}

}

I have php 7, I'm assuming the syntax used by the developer of the plugin is obsolete

so basically the 4 variables giving errors are actually other functions(methods) of the class itself. what is the correct way to call these methods? I tried array($this, $this->add_new) but it didn't work

I will appreciate it if can help with this.

Thanks in advance

I have a problem with php 7 syntax. I installed this plugin called simple table manager https://wordpress/plugins/simple-table-manager/

and upon activation I got these warnings

Warning: Use of undefined constant list_all - assumed 'list_all' (this will throw an Error in a future version of PHP) in C:\xampp\htdocs\wp2\wp-content\plugins\simple-table-manager\controller.php on line 52

Warning: Use of undefined constant add_new - assumed 'add_new' (this will throw an Error in a future version of PHP) ....

Warning: Use of undefined constant settings - assumed 'settings' (this will throw an Error.....

Warning: Use of undefined constant edit - assumed 'edit' (this will throw an Error.....

the code looks something like this

class Controller {
....

public function add_menu() {
        add_menu_page('Simple Table Manager - List', 'Simple Table Manager', 'manage_options', $this->slug['list'], array($this, list_all ));
        add_submenu_page(null, 'Simple Table Manager - Add New', 'Add New', 'manage_options', $this->slug['add'], array($this, add_new));
        add_submenu_page($this->slug['list'], 'Simple Table Manager - Settings', 'Settings', 'manage_options', $this->slug['settings'], array($this, settings));
        add_submenu_page(null, 'Simple Table Manager - Edit', 'Edit', 'manage_options', $this->slug['edit'], array($this, edit));
    }
public function list_all() {....}
public function add_new() {...}
public function edit() {...}
public function settings() {...}

}

I have php 7, I'm assuming the syntax used by the developer of the plugin is obsolete

so basically the 4 variables giving errors are actually other functions(methods) of the class itself. what is the correct way to call these methods? I tried array($this, $this->add_new) but it didn't work

I will appreciate it if can help with this.

Thanks in advance

Share Improve this question edited Jan 28, 2019 at 20:59 user206904 asked Jan 28, 2019 at 20:27 user206904user206904 1812 silver badges8 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

There is a bug in this code:

    add_menu_page('Simple Table Manager - List', 'Simple Table Manager', 'manage_options', $this->slug['list'], array($this, list_all ));

The part array($this, list_all ) is a function callback, but there should be name of a function passed as string as second item in the array. So it should be:

array($this, 'list_all' )

PS. It should have been a problem with earlier versions of PHP too...

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748967666a315235.html

最新回复(0)