$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugins - Warning: Use of undefined constant list_all - assumed 'list_all' (this will throw an Error in a future|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin8PV0评论

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

Post a comment

comment list (0)

  1. No comments so far