https://www.youtube.com/watch?v=j9DY0avQagU .请检查此视频,此表单我通过设置API开发.此错误显示“选项页不在允许的选项列表中.”当我尝试使用此add_menu_page()此设置AI脚本工作.但当我在此选项卡中使用此脚本.这是不工作.如何解决这个问题.请你能告诉我.
class GeneralTab {
public function __construct() {
add_action('admin_init', [$this, 'orange_general_settings']);
$this->orang_general_settings_page();
}
public function orang_general_settings_page() {
// You can put your HTML and settings fields here
echo '<div class="wrap">';
echo '<h2>General Settings</h2>';
echo '<hr>';
echo '<form method="post" action="options.php">';
// Use the correct options group name here
settings_fields('orange-general-setting-gp');
// Add a settings section
add_settings_section(
'orang_general_custom',
'', // section name blank
'',
'orange_general_custom_page'
);
// Add a settings field
add_settings_field(
'orange_general_email_id', // ID
'From email address', // field label name
[$this, 'orange_general_email'], // callback function
'orange_general_custom_page', // setting page callback
'orang_general_custom' // section page callback
);
add_settings_field(
'organge_general_from_name_id', // ID
'From Name', // field name
[$this, 'orange_general_name'], // callback function
'orange_general_custom_page', // setting page callback
'orang_general_custom' // section page callback
);
do_settings_sections('orange_general_custom_page');
submit_button('Save Settings');
echo '</form>';
echo '</div>';
}
public function orange_general_email() {
$value = get_option('orange_general_emailfield');
echo '<input type="text" name="orange_general_emailfield" value="' . esc_attr($value) . '">';
}
public function orange_general_name() {
$value = get_option('orange_general_namefield');
echo '<input type="text" name="orange_general_namefield" value="' . esc_attr($value) . '">';
}
public function orange_general_settings() {
// Use the correct options group name here
register_setting('orange-general-setting-gp', 'orange_general_emailfield');
register_setting('orange-general-setting-gp', 'orange_general_namefield');
}
}
字符串
1条答案
按热度按时间voj3qocg1#
尝试在rest_API_init操作上调用register_setting(),以及正常的admin_init操作。
我的意思是在__construct方法中添加以下行:
字符串