php - Wordpress:函数名必须是字符串
问题描述
我有一个 wordpress 插件,它会抛出错误“函数必须是字符串”。这是代码:
function make_fields() {
global $post;
$output = '';
foreach($this->fields as $field) {
if(method_exists($this, $field['type'])) {
$field = $this->clean_field_attributes($field);
$field_value = rvn_get_post_meta($post->ID, $field['id']);
if(!empty($field_value))
$field['value'] = $field_value;
field_output = $this->$field['type']($field);
if($field['type'] == 'group_start' || $field['type'] == 'group_end')
$output.= $field_output;
else
$output.= $this->output_wrapper($field, $field_output);
}
}
$output.='<input type="hidden" name="'.$this->box_data['id'].'_noncename" id="'.$this->box_data['id'].'_noncename" value="'.wp_create_nonce(plugin_basename(__FILE__)).'" />';
echo $output;
似乎是问题的行是:
$field_output = $this->$field['type']($field);
有任何想法吗?
解决方案
推荐阅读
- navigation - 如何为 NavigationLink 设置条件?斯威夫特
- macos - 在 macOS (OS X) 下以编程方式安装字体
- elasticsearch - ElasticSearch:从布尔查询中的每个查询中获取单独的分数
- xcode - 代码错误。修饰符 public 无效。为什么?
- python - CodingBat 帮助。list.remove(x): x not in list 错误?不明白为什么这不起作用
- java - 有没有办法从文件中读取值并初始化这些值?
- microsoft-cognitive - 获取分析表单结果 API 返回错误代码 3003
- javascript - 找不到模块 React 要求
- javascript - 无法使用动态创建的按钮复制文本
- node.js - 为什么我会收到“网站或应用程序上的数据泄露泄露了您的密码。Chrome 建议立即更改您在“SITENAME”上的密码。”