我认为这可能是一个更一般的php问题,但我在这里发布它,因为它与WP函数有关。我对add_action
在…上manage_posts_custom_column
在类内部。以下是代码(略为精简):
class The_class{
function __construct() {
$this->add_actions();
}
function add_actions() {
add_action(\'admin_notices\', array($this, \'admin_notices\'));
add_action(\'manage_posts_custom_column\', array($this, \'manage_post_columns\', 10, 2));
}
function admin_notices() {
// Works fine
}
function manage_post_columns($column_name, $post_id)
switch ($column_name) {
case \'xxxyyzz\':
// The code
break;
default:
// Error
break;
}
}
}
我得到的错误是
Warning: call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members in xxx/wp-includes/plugin.php on line 405
.
深入观察,我发现manage_posts_custom_column
在中引用WP_Posts_List_Table
扩展的类WP_List_Table
我想知道这是否是错误的原因?
我该怎么解决这个问题?
Edit:
对于初学者,我可以正确地编写动作!!!而不是add_action(\'manage_posts_custom_column\', array($this, \'manage_post_columns\', 10, 2));
应该是这样的add_action(\'manage_posts_custom_column\', array($this, \'manage_post_columns\'), 10, 2);
. 注意)
. :-)