我正在尝试使用设置 API 为脚本(wordpress 插件)做一些导入/导出选项。
代码的相关部分是:
function o99_brsa_options_page() {
global $o99_brsa_options; // declare as global so we can access everywhere
$o99_brsa_options2 = get_option( 'o99_brsa_settings' );
$currentsettings = "";
if ( isset( $_POST['import'] ) && trim($_POST['brsa_keep_settings_imp']) != "" ) {
$currentsettings = base64_encode($_POST['brsa_keep_settings_imp']);
} elseif ( isset( $o99_brsa_options2 ) && ( $o99_brsa_options2 != "" ) ) {
$currentsettings = base64_encode( serialize( $o99_brsa_options2 ) );
}
// continue a lot of settings ...
<!-- / IMPORT o99_brsa_settings[brsa_keep_settings_exp] -->
<p>
<form method="post" action="#">
<textarea cols="50" rows="5" id="brsa_keep_settings_imp" name="brsa_keep_settings_imp" /><?php
?></textarea>
<label class="description" for="brsa_keep_settings_imp">
</br><?php _e('Import Data', 'k99-brsa-domain'); ?>
</label>
<input type="submit" value="Import" id="import" name="import" class="button-primary" onClick="return confirm('Are you sure you want to import these settings?')" />
</form></p>
}
完整代码在这里: http: //pastebin.com/uBHHxJYJ
我只是找不到我做错了什么,为什么它不起作用,我显然在这里遗漏了一些东西......