time(), 'user' => get_current_user_id(), 'source' => isset( $entry['source'] ) ? absint( $entry['source'] ) : 0, 'result' => isset( $entry['result'] ) ? absint( $entry['result'] ) : 0, 'product' => isset( $entry['product'] ) ? absint( $entry['product'] ) : 0, 'mode' => isset( $entry['mode'] ) ? sanitize_key( $entry['mode'] ) : '', 'outcome' => isset( $entry['outcome'] ) ? sanitize_key( $entry['outcome'] ) : '', 'code' => isset( $entry['code'] ) ? sanitize_key( $entry['code'] ) : '', ) ); update_option( self::OPTION, array_slice( $log, 0, self::MAX ), false ); } /** * Entries, newest first. * * @return array[] */ public static function all() { $log = get_option( self::OPTION, array() ); return is_array( $log ) ? $log : array(); } /** * Remove all entries. */ public static function clear() { delete_option( self::OPTION ); } }