我正在使用Chip Bennett的代码为我的插件创建一个设置选项页面。问题是,我得到一个警告错误,如下所示,我无法找出它。非常感谢您的帮助。
警告:call\\u user\\u func(ch\\u settings\\u defaults\\u style\\u section\\u text)[函数.call user func]:第一个参数应该是/home/loc123/public\\u html/domaindvb中的有效回调。com/wp admin/includes/template。php在线1083
<?php
function ch_admin_options_page() {
global $pagenow;
?>
<div class="wrap">
<?php
/* Calls function to add tabs */
ch_admin_options_page_tabs ();
/* adds the "updated" admin notice */
if ( isset( $_GET[\'settings-updated\'] ) ) {
echo "<div class=\'updated\'><p>Custom Header settings updated successfully.</p></div>";
}
?>
<form action="options.php" method="post">
<?php
settings_fields(\'mycustom_options\');
do_settings_sections(\'mycustom\');
?>
<?php
if ( \'themes.php\' == $pagenow && isset( $_GET[\'page\'] ) && \'ch-settings\' == $_GET[\'page\'] ) :
if ( isset ( $_GET[\'tab\'] ) ) :
$tab = $_GET[\'tab\'];
else:
$tab = \'general\';
endif;
switch ( $tab ) :
case \'general\' :
require (\'options-register-defaults.php\') ;
break;
case \'Home Page\' :
require( \'options-register-homepage.php\' );
break;
endswitch;
endif;
?>
<p></br></p>
<input name="mycustom_options[submit-<?php echo $tab; ?>]" type="submit" class="button-primary" value="<?php esc_attr_e(\'Save Settings\', \'default\'); ?>" />
<?php /* Add a Reset Button */ ?>
<input name="mycustom_options[reset-<?php echo $tab; ?>]" type="submit" class="button-secondary" value="<?php esc_attr_e(\'Reset Defaults\', \'default\'); ?>" />
</form>
</div>
<?php
}
?>
<?php
add_action(\'admin_init\', \'chr_settings\');
function chr_settings() {
/* register_setting( $option_group, $option_name, $sanitize_callback )- Associates an option group passed to settings_fields with database entry */
register_setting( \'mycustom_options\', \'mycustom_options\', \'ch_options_validate\' );
add_settings_section(\'ch_settings_defaults_style\', \'Style Options\', \'ch_settings_defaults_style_section_text\', \'mycustom\');
}
?>
File: options-register-defaults.php
<?php
function ch_settings_defaults_style_section_text() { ?>
<p><?php _e( \'Manage Header options for the Oenology Theme. Refer to the contextual help screen for descriptions and help regarding each theme option.\', \'mycustom\' ); ?></p>
<?php
}
?>
SO网友:Ralf912
您应该包括options-register-defaults.php
使回调可用。
function chr_settings() {
require_once \'options-register-defaults.php\'; // add path to file
/* register_setting( $option_group, $option_name, $sanitize_callback )- Associates an option group passed to settings_fields with database entry */
register_setting( \'mycustom_options\', \'mycustom_options\', \'ch_options_validate\' );
add_settings_section(\'ch_settings_defaults_style\', \'Style Options\', \'ch_settings_defaults_style_section_text\', \'mycustom\');
}