我试图在wordpress上提交新插件。org和审阅者向我发送了以下关于我在这些行中的代码的消息,您能告诉我我可以添加什么替代代码以使审阅者批准我的插件审阅者评论>>“当您在插件中包含POST/GET/REQUEST/FILE调用时,对其进行清理、验证和转义非常重要。这里的目标是防止用户意外地通过系统发送垃圾数据,并保护他们免受潜在的安全问题。”
我的代码是
// set options
public function set_options() {
$nonce = \'kfw_options_nonce\'. $this->unique;
if( isset( $_POST[$nonce] ) && wp_verify_nonce( $_POST[$nonce], \'kfw_options_nonce\' ) ) {
$request = ( ! empty( $_POST[$this->unique] ) ) ? $_POST[$this->unique] : array();
$transient = ( ! empty( $_POST[\'kfw_transient\'] ) ) ? $_POST[\'kfw_transient\'] : array();
$section_id = ( ! empty( $transient[\'section\'] ) ) ? $transient[\'section\'] : \'\';
// import data
if( ! empty( $transient[\'kfw_import_data\'] ) ) {
$import_data = json_decode( stripslashes( trim( $transient[\'kfw_import_data\'] ) ), true );
$request = ( is_array( $import_data ) ) ? $import_data : array();
$this->notice = esc_html__( \'Success. Imported backup options.\', \'kfw\' );
} else if( ! empty( $transient[\'reset\'] ) ) {
foreach( $this->pre_fields as $field ) {
if( ! empty( $field[\'id\'] ) ) {
$request[$field[\'id\']] = $this->get_default( $field );
}
}
$this->notice = esc_html__( \'Default options restored.\', \'kfw\' );
} else if( ! empty( $transient[\'reset_section\'] ) && ! empty( $section_id ) ) {
if( ! empty( $this->pre_sections[$section_id-1][\'fields\'] ) ) {
foreach( $this->pre_sections[$section_id-1][\'fields\'] as $field ) {
if( ! empty( $field[\'id\'] ) ) {
$request[$field[\'id\']] = $this->get_default( $field );
}
}
}
$this->notice = esc_html__( \'Default options restored for only this section.\', \'kfw\' );
}