option );//初始化选项 $this->logs = get_option( $this->option ); $this->record_log = get_option( 'nicen_make_plugin_record_log' ); } /** * 获取单例 * */ public static function getInstance() { /*如果实例不存在*/ if ( ! self::$self ) { self::$self = new self(); } return self::$self; } /** * 新增一条日志 * * @param log,操作之后的结果 * * @return array */ public function add( $log ) { if ( ! $this->record_log ) { return $log; } $now = date( "Y-m-d H:i:s", time() ); /** * 判断结果 * */ if ( $log['code'] ) { $this->logs .= $now . ',' . '本地化成功,' . $log['result'] . "\n"; } else { $this->logs .= $now . ',' . '本地化失败,' . $log['result'] . "\n"; } update_option( $this->option, $this->logs ); return $log; } /** * @return false|mixed|null */ public function get_logs() { return $this->logs; } /** * 清空日志 * */ public function clear() { update_option( $this->option, "" ); } }