diff --git a/assets/js/frontend.js b/assets/js/frontend.js index 6e29176..40aa9c0 100644 --- a/assets/js/frontend.js +++ b/assets/js/frontend.js @@ -149,7 +149,7 @@ document.querySelectorAll('[data-ettic-otc-dp-more]').forEach(function (btn) { btn.addEventListener('click', function () { var card = this.closest('.ettic-otc-dp-card'); - var overflow = card.querySelector('.ettic-otc-dp-card__list--overflow'); + var overflow = card && card.querySelector('.ettic-otc-dp-card__list--overflow'); if (overflow) { overflow.hidden = false; } @@ -190,6 +190,7 @@ document.querySelectorAll('[data-ettic-otc-clamp-toggle]').forEach(function (btn) { btn.addEventListener('click', function () { var text = this.previousElementSibling; + if (!text) return; var expanded = text.classList.toggle('ettic-otc-table__clamp-text--expanded'); this.textContent = expanded ? 'less' : 'more'; }); diff --git a/includes/class-ettic-otc-admin-questions.php b/includes/class-ettic-otc-admin-questions.php index 7c689f2..ef92d07 100644 --- a/includes/class-ettic-otc-admin-questions.php +++ b/includes/class-ettic-otc-admin-questions.php @@ -256,30 +256,35 @@ public function handle_export(): void { 'model' => isset($_GET['model']) ? sanitize_text_field((string) wp_unslash($_GET['model'])) : '', 'date_from' => isset($_GET['date_from']) ? sanitize_text_field((string) wp_unslash($_GET['date_from'])) : '', 'date_to' => isset($_GET['date_to']) ? sanitize_text_field((string) wp_unslash($_GET['date_to'])) : '', - 'page' => 1, - 'per_page' => 10000, // hard cap — nobody exports >10k rows per page ]; - $result = Ettic_OTC_Chat_Log::query($filters); - header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=ettic-otc-questions-' . gmdate('Y-m-d') . '.csv'); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen -- Writing to php://output, not filesystem $out = fopen('php://output', 'w'); fputcsv($out, ['Date (UTC)', 'Question', 'Model', 'Provider', 'Citations', 'Tokens In', 'Tokens Out', 'Response ms', 'Refused']); - foreach ($result['rows'] as $row) { - fputcsv($out, [ - $row->created_at, - $row->question, - $row->model, - $row->provider, - $row->citation_count, - $row->tokens_in, - $row->tokens_out, - $row->response_ms, - $row->refused ? 'yes' : 'no', - ]); + + // query() caps per_page at 100, so page through to export the full set. + $per_page = 100; + for ($page = 1; ; $page++) { + $result = Ettic_OTC_Chat_Log::query($filters + ['page' => $page, 'per_page' => $per_page]); + foreach ($result['rows'] as $row) { + fputcsv($out, [ + $row->created_at, + $row->question, + $row->model, + $row->provider, + $row->citation_count, + $row->tokens_in, + $row->tokens_out, + $row->response_ms, + $row->refused ? 'yes' : 'no', + ]); + } + if ($page * $per_page >= $result['total'] || count($result['rows']) < $per_page) { + break; + } } // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose -- Writing to php://output stream fclose($out); diff --git a/languages/open-trust-center-by-ettic-nl_NL.po b/languages/open-trust-center-by-ettic-nl_NL.po index 0e6cd1d..8038003 100644 --- a/languages/open-trust-center-by-ettic-nl_NL.po +++ b/languages/open-trust-center-by-ettic-nl_NL.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: Open Trust Center by Ettic 1.2.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/open-trust-center-" "by-ettic\n" -"POT-Creation-Date: 2026-05-21T20:40:20+00:00\n" +"POT-Creation-Date: 2026-05-21T20:55:06+00:00\n" "PO-Revision-Date: 2026-04-14 21:55+0000\n" "Last-Translator: Ettic bundled starter \n" "Language-Team: Dutch (Netherlands)\n" @@ -379,8 +379,8 @@ msgstr "" #: includes/class-ettic-otc-admin-ai.php:751 #: includes/class-ettic-otc-admin-ai.php:796 #: includes/class-ettic-otc-admin-questions.php:250 -#: includes/class-ettic-otc-admin-questions.php:291 -#: includes/class-ettic-otc-admin-questions.php:308 +#: includes/class-ettic-otc-admin-questions.php:296 +#: includes/class-ettic-otc-admin-questions.php:313 #: includes/class-ettic-otc-admin-tools.php:565 msgid "You do not have permission to perform this action." msgstr "" @@ -568,15 +568,15 @@ msgstr "" msgid "Clear entire question log" msgstr "" -#: includes/class-ettic-otc-admin-questions.php:299 +#: includes/class-ettic-otc-admin-questions.php:304 msgid "Question log cleared." msgstr "" -#: includes/class-ettic-otc-admin-questions.php:318 +#: includes/class-ettic-otc-admin-questions.php:323 msgid "Logging enabled." msgstr "" -#: includes/class-ettic-otc-admin-questions.php:318 +#: includes/class-ettic-otc-admin-questions.php:323 msgid "Logging disabled." msgstr "" diff --git a/languages/open-trust-center-by-ettic.pot b/languages/open-trust-center-by-ettic.pot index e6e399b..931887d 100644 --- a/languages/open-trust-center-by-ettic.pot +++ b/languages/open-trust-center-by-ettic.pot @@ -9,7 +9,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2026-05-21T20:40:20+00:00\n" +"POT-Creation-Date: 2026-05-21T20:55:06+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.12.0\n" "X-Domain: open-trust-center-by-ettic\n" @@ -319,8 +319,8 @@ msgstr "" #: includes/class-ettic-otc-admin-ai.php:751 #: includes/class-ettic-otc-admin-ai.php:796 #: includes/class-ettic-otc-admin-questions.php:250 -#: includes/class-ettic-otc-admin-questions.php:291 -#: includes/class-ettic-otc-admin-questions.php:308 +#: includes/class-ettic-otc-admin-questions.php:296 +#: includes/class-ettic-otc-admin-questions.php:313 #: includes/class-ettic-otc-admin-tools.php:565 msgid "You do not have permission to perform this action." msgstr "" @@ -501,15 +501,15 @@ msgstr "" msgid "Clear entire question log" msgstr "" -#: includes/class-ettic-otc-admin-questions.php:299 +#: includes/class-ettic-otc-admin-questions.php:304 msgid "Question log cleared." msgstr "" -#: includes/class-ettic-otc-admin-questions.php:318 +#: includes/class-ettic-otc-admin-questions.php:323 msgid "Logging enabled." msgstr "" -#: includes/class-ettic-otc-admin-questions.php:318 +#: includes/class-ettic-otc-admin-questions.php:323 msgid "Logging disabled." msgstr ""