我有下面的代码来显示每个选项卡的不同设置。显示的内容取决于url参数action
. 当我尝试选择选项卡时,wordpress会给我一个Sorry, you are not allowed to access this page.
错误请参阅下面的代码。
function minutes_settings_content() {
?>
<div class="wrap">
<div id="icon-themes" class="icon32"></div>
<h2>Email & SMS Settings</h2>
<?php settings_errors(); ?>
<?php $active_tab = isset( $_GET[ \'action\' ] ) ? $_GET[ \'action\' ] : \'email_sms_options\'; ?>
<h2 class="nav-tab-wrapper">
<a href="<?php echo esc_url( add_query_arg( array( \'action\' => \'email_sms_options\' ), admin_url( \'edit.php?post_type=wellbeing-minutes&page=minutes-email-settings\' ) ) ); ?>" class="nav-tab">Email & SMS</a>
<a href="<?php echo esc_url( add_query_arg( array( \'action\' => \'testing_mode_options\' ), admin_url( \'edit.php?post_type=wellbeing-minutes&page=minutes-email-settings\' ) ) ); ?>" class="nav-tab">Testing Mode</a>
</h2>
<form action=\'options.php\' method=\'post\'>
<?php
if ( $active_tab == \'email_sms_options\' ) {
settings_fields( \'EmailSmsMinute\' );
do_settings_sections( \'EmailSmsMinute\' );
}
elseif ( $active_tab == \'testing_mode_options\' ) {
settings_fields( \'wb_minute_testing_mode\' );
do_settings_sections( \'wb_minute_testing_mode\' );
}
submit_button();
?>
</form>
</div>
<?php
}