我的自定义插件目前有问题。它实际上记录了所有激发到文件(或屏幕)的操作/过滤器。提交表单时,我需要以某种方式更新数据库中的选项。下面是代码列表本身:
class WP_Test_Logging_Plugin {
//required for the file name
private $yymmddhhmmss;
private $data;
public function __construct() {
add_action( \'all\', array( $this, \'log_to\' ) );
add_action( \'admin_menu\', array( $this, \'menu\' ) );
add_action( \'admin_print_styles\', array( $this, \'plugin_theme_style\' ) );
add_action( \'template_redirect\', array( $this, \'on_admin_form_submit\' ) );
$this->yymmddhhmmss = date( \'YMDHis\' );
if ( get_option( \'where_to_log_to\' ) == false ) {
update_option( \'where_to_log_to\', 1 );
}
$this->data = get_option( \'where_to_log_to\' );
}
我用来处理表单的方法public function on_admin_form_submit() {
if ( isset( $_POST[\'selection\'] ) ) {
update_option( \'where_to_log_to\', $_POST[\'selection\'] );
}
}
有什么办法吗?谢谢