我正在开发我的第一个插件,我有一个选项页面设置。现在,我正在尝试添加一些字段。
我有这个xxx-admin.php
在里面admin
文件夹
public function section_callback() {
echo \'<p>Select which areas of content you wish to display.</p>\';
}
public function field_callback() {
$html = \'<input type="text" id="input_offer" name="questionaire[input_field]" />\';
echo $html;
}
public function register_settings() {
// First, we register a section. This is necessary since all future options must belong to a
add_settings_section(
\'my_settings_section\', // ID used to identify this section and with which to register options
\'iPhones\', // Title to be displayed on the administration page
\'section_callback\', // Callback used to render the description of the section
$this->plugin_name // Page on which to add this section of options
);
// Next, we\'ll introduce the fields for toggling the visibility of content elements.
add_settings_field(
\'input_field\', // ID used to identify the field throughout the theme
\'Offer\', // The label to the left of the option interface element
\'field_callback\', // The name of the function responsible for rendering the option interface
$this->plugin_name, // The page on which this option will be displayed
\'my_settings_section\' // The name of the section to which this field belongs
);
register_setting( $this->plugin_name, \'input_field\' );
}
总的来说
class-xxx.php
中的文件
includes
我拥有的文件夹:
private function define_admin_hooks() {
$plugin_admin = new Questionaire_Admin( $this->get_plugin_name(), $this->get_version() );
...
$this->loader->add_action( \'admin_init\', $plugin_admin, \'register_settings\' );
...
}
但我得到了:
警告:call\\u user\\u func()要求参数1为有效回调,在/Users/eamonwhite/wordpress-plugin-playplace/wp-admin/includes/template中找不到函数“section\\u callback”,或函数名无效。phpon线1332
警告:call\\u user\\u func()要求参数1为有效回调,在/Users/eamonwhite/wordpress-plugin-playplace/wp-admin/includes/template中找不到函数“field\\u callback”,或函数名无效。php
在线1378
如何让它看到回调函数?