php - WordPress 调试 - call_user_func_array() 期望参数 1 是有效的回调
问题描述
我刚刚将我的 WordPress 更新到了新版本,我收到了这个错误:
警告:call_user_func_array() 期望参数 1 是有效的回调,在第 287 行的 /home/burngeopk/public_html/members/wp-includes/class-wp-hook.php 中未找到函数“restrict_admin”或无效函数名
在我的主题的function.php 中只有1 个字符串具有restrict_admin。我正在寻找如何改写这个字符串以使其工作的指导。
add_action( 'admin_init', 'restrict_admin', 1 );
function my_function_admin_bar($content) {
return ( current_user_can( 'administrator' ) ) ? $content : false;
}
解决方案
看起来这个功能restrict_admin
已经不存在了。
尝试将其添加回您的主题?这里是它的源代码:
function restrict_admin() {
if ( ! current_user_can( 'manage_options' ) && ( ! wp_doing_ajax() ) ) {
wp_die( __( 'You are not allowed to access this part of the site' ) );
}
}
来源: https ://developer.wordpress.org/reference/hooks/admin_init/
推荐阅读
- javascript - 如何在js中window.open的url中使用var
- react-native - 如何在 React 导航屏幕之间共享状态?
- arrays - 在 C 中的 2 个列表中对元素进行分组
- visual-studio-code - 我可以将 VS Code Ubuntu 终端与 RedHat 的 YAML 语言支持结合使用吗
- java - Firebase 身份验证用户为空
- django - 在 Django 模板中显示关系数据
- vba - VBA在换行符内查找替换
- javascript - 如何检索 Twilio 可编程聊天频道中的所有消息?
- php - 如何在 img src 中插入函数调用?
- typescript - 当与另一个类型化函数一起传递给泛型函数时,字符串缩小为字符串文字类型