我正在尝试让 update_options 使用此功能。基本上,用户输入激活码并通过插件选项页面提交。代码发送给第三方,如果成功则返回状态。这一切都可以正常工作,但我无法获得 update_options 来更改相关选项的状态。
这是更新功能(我正在使用的 OOP 框架的一部分):
private function _admin_options_update() {
// Verify submission for processing using wp_nonce
if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-update-options" ) ) {
$data = array();
/**
* Loop through each POSTed value and sanitize it to protect against malicious code. Please
* note that rich text (or full HTML fields) should not be processed by this function and
* dealt with directly.
*/
foreach( $_POST['data'] as $key => $val ) {
$data[$key] = $this->_sanitize( $val );
}
/**
* Place your options processing and storage code here
*/
// Update the options value with the data submitted
update_option( $this->option_name, $data );
// Redirect back to the options page with the message flag to show the saved message
wp_safe_redirect( $_REQUEST['_wp_http_referer'] . '&update=1' );
exit;
}
}
我正在尝试运行此功能:
update_option($WPBackitup->options['status'], $license_data->license);