diff --git a/assets/js/admin.js b/assets/js/admin.js
index ef3d4e4..b8345b5 100644
--- a/assets/js/admin.js
+++ b/assets/js/admin.js
@@ -51,7 +51,7 @@
type: 'POST',
data: {
action: 'trash_log_delete_csv',
- nonce: trashLogAdmin.nonce,
+ nonce: trashLogAdmin.nonceDelete,
},
success: function( response ) {
if ( response.success ) {
@@ -87,7 +87,7 @@
type: 'POST',
data: {
action: 'trash_log_generate_csv',
- nonce: trashLogAdmin.nonce,
+ nonce: trashLogAdmin.nonceGenerate,
},
success: function( response ) {
if ( response.success ) {
@@ -123,7 +123,7 @@
type: 'POST',
data: {
action: 'trash_log_generate_csv',
- nonce: trashLogAdmin.nonce,
+ nonce: trashLogAdmin.nonceGenerate,
},
success: function( response ) {
if ( response.success ) {
diff --git a/autoload.php b/autoload.php
index a0bfd21..27b7850 100644
--- a/autoload.php
+++ b/autoload.php
@@ -1,5 +1,5 @@
admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'trash_log_admin' ),
+ 'nonceDelete' => wp_create_nonce( 'trash_log_delete_csv' ),
+ 'nonceGenerate' => wp_create_nonce( 'trash_log_generate_csv' ),
'confirmText' => __( 'Are you sure you want to delete the CSV file?', 'trash-log' ),
'confirmPurgeText' => __( 'Are you sure you want to purge all log entries from the database? This action cannot be undone.', 'trash-log' ),
]
@@ -203,10 +201,6 @@ public function enqueue_scripts( string $hook_suffix ): void {
* @return void
*/
public function render_admin_page(): void {
- if ( ! $this->current_user_can_access() ) {
- wp_die( esc_html__( 'You do not have permission to access this page.', 'trash-log' ) );
- }
-
$csv_handler = CSV_Handler::get_instance();
$logger = Logger::get_instance();
$csv_exists = $csv_handler->csv_exists();
@@ -296,7 +290,7 @@ public function ajax_download_csv(): void {
* @return void
*/
public function ajax_delete_csv(): void {
- if ( ! $this->verify_ajax_request( 'trash_log_admin' ) ) {
+ if ( ! $this->verify_ajax_request( 'trash_log_delete_csv' ) ) {
return;
}
@@ -318,7 +312,7 @@ public function ajax_delete_csv(): void {
* @return void
*/
public function ajax_generate_csv(): void {
- if ( ! $this->verify_ajax_request( 'trash_log_admin' ) ) {
+ if ( ! $this->verify_ajax_request( 'trash_log_generate_csv' ) ) {
return;
}
diff --git a/classes/CSV_Handler.php b/classes/CSV_Handler.php
index e607dc0..bbc80f2 100644
--- a/classes/CSV_Handler.php
+++ b/classes/CSV_Handler.php
@@ -1,6 +1,6 @@
\n";
- $htaccess_content .= " Order allow,deny\n";
- $htaccess_content .= " Deny from all\n";
- $htaccess_content .= "\n";
-
- $written = file_put_contents( $htaccess_file, $htaccess_content );
- if ( false === $written ) {
- return false;
- }
-
- chmod( $htaccess_file, 0644 );
+ $htaccess_file = trailingslashit( $csv_dir ) . '.htaccess';
+ $marker = 'Trash Log';
+ $insertion = [
+ '',
+ ' Order allow,deny',
+ ' Deny from all',
+ '',
+ ];
- return true;
+ return insert_with_markers( $htaccess_file, $marker, $insertion );
}
}
diff --git a/classes/Helpers.php b/classes/Helpers.php
index ff2574e..1169992 100644
--- a/classes/Helpers.php
+++ b/classes/Helpers.php
@@ -1,6 +1,6 @@
format( 'U' ) );
}
- /**
- * Format a timestamp to DD/MM/YYYY format.
- *
- * @since 1.0.0
- *
- * @param int $timestamp Unix timestamp.
- * @return string Formatted date in DD/MM/YYYY format.
- */
- public static function format_date_dd_mm_yyyy( int $timestamp ): string {
- if ( $timestamp <= 0 ) {
- return '';
- }
-
- return date_i18n( 'd/m/Y', $timestamp );
- }
-
/**
* Get estimated database size for an option value.
*
diff --git a/classes/Logger.php b/classes/Logger.php
index 448a17f..b0a1d24 100644
--- a/classes/Logger.php
+++ b/classes/Logger.php
@@ -1,6 +1,6 @@
1);\n"
+
+#. Plugin Name of the plugin
+#: trash-log.php classes/Admin.php:124 classes/Admin.php:125
+msgid "Trash Log"
+msgstr "Journal de la corbeille"
+
+#. Plugin URI of the plugin
+#. Author URI of the plugin
+#: trash-log.php
+msgid "https://beapi.fr"
+msgstr "https://beapi.fr"
+
+#. Description of the plugin
+#: trash-log.php
+msgid "Simply logs everything sent to trash - sponsored by CDC Habitat"
+msgstr "Enregistre tout ce qui est envoyé à la corbeille - parrainé par CDC Habitat"
+
+#. Author of the plugin
+#: trash-log.php
+msgid "Be API Technical team"
+msgstr "Équipe technique Be API"
+
+#: classes/Admin.php:100 classes/Admin.php:242
+msgid "Security check failed."
+msgstr "Échec de la vérification de sécurité."
+
+#: classes/Admin.php:105
+msgid "You do not have permission to perform this action."
+msgstr "Vous n'avez pas les droits pour effectuer cette action."
+
+#: classes/Admin.php:190
+msgid "Are you sure you want to delete the CSV file?"
+msgstr "Êtes-vous sûr de vouloir supprimer le fichier CSV ?"
+
+#: classes/Admin.php:191
+msgid ""
+"Are you sure you want to purge all log entries from the database? This "
+"action cannot be undone."
+msgstr ""
+"Êtes-vous sûr de vouloir purger toutes les entrées du journal dans la base "
+"de données ? Cette action est irréversible."
+
+#: classes/Admin.php:238
+msgid "You must be logged in to access this file."
+msgstr "Vous devez être connecté pour accéder à ce fichier."
+
+#: classes/Admin.php:238 classes/Admin.php:242 classes/Admin.php:246
+#: classes/Admin.php:254
+msgid "Error"
+msgstr "Erreur"
+
+#: classes/Admin.php:246
+msgid "You do not have permission to access this file."
+msgstr "Vous n'avez pas les droits pour accéder à ce fichier."
+
+#: classes/Admin.php:304
+msgid "CSV file deleted successfully."
+msgstr "Fichier CSV supprimé avec succès."
+
+#: classes/Admin.php:331
+msgid "CSV file generated successfully."
+msgstr "Fichier CSV généré avec succès."
+
+#: classes/Admin.php:354
+msgid "Failed to purge log entries."
+msgstr "Échec de la purge des entrées du journal."
+
+#: classes/Admin.php:357
+msgid "All log entries have been purged from the database."
+msgstr "Toutes les entrées du journal ont été purgées de la base de données."
+
+#: classes/CSV_Handler.php:132
+msgid "No log entries found."
+msgstr "Aucune entrée de journal trouvée."
+
+#: classes/CSV_Handler.php:140
+msgid "Unable to access upload directory."
+msgstr "Impossible d'accéder au répertoire des téléversements."
+
+#: classes/CSV_Handler.php:149
+msgid "Failed to create CSV directory."
+msgstr "Échec de la création du répertoire CSV."
+
+#: classes/CSV_Handler.php:160
+msgid "Invalid CSV file path."
+msgstr "Chemin du fichier CSV invalide."
+
+#: classes/CSV_Handler.php:168
+msgid "Failed to open CSV file for writing."
+msgstr "Échec de l'ouverture du fichier CSV en écriture."
+
+#: classes/CSV_Handler.php:176
+msgid "Contributor Name"
+msgstr "Nom du contributeur"
+
+#: classes/CSV_Handler.php:177
+msgid "Deleted Item"
+msgstr "Élément supprimé"
+
+#: classes/CSV_Handler.php:178
+msgid "Date"
+msgstr "Date"
+
+#: classes/CSV_Handler.php:179
+msgid "Document Size"
+msgstr "Taille du document"
+
+#: classes/CSV_Handler.php:180
+msgid "URL"
+msgstr "URL"
+
+#: classes/CSV_Handler.php:212 classes/CSV_Handler.php:237
+msgid "CSV file not found."
+msgstr "Fichier CSV introuvable."
+
+#: classes/CSV_Handler.php:220
+msgid "Failed to delete CSV file."
+msgstr "Échec de la suppression du fichier CSV."
+
+#: classes/Logger.php:119
+msgid "Automatic action"
+msgstr "Action automatique"
+
+#. translators: %d: Post ID
+#: classes/Logger.php:135
+msgid "Item #%d"
+msgstr "Élément #%d"
+
+#: views/admin-page.php:25
+msgid "CSV File Information"
+msgstr "Informations sur le fichier CSV"
+
+#: views/admin-page.php:30
+msgid "File Size"
+msgstr "Taille du fichier"
+
+#: views/admin-page.php:38
+msgid "File URL"
+msgstr "URL du fichier"
+
+#: views/admin-page.php:51
+msgid ""
+"No CSV file has been generated yet. Click the button below to generate it "
+"from the logged entries."
+msgstr ""
+"Aucun fichier CSV n'a encore été généré. Cliquez sur le bouton ci-dessous "
+"pour le générer à partir des entrées enregistrées."
+
+#: views/admin-page.php:59
+msgid "Download CSV"
+msgstr "Télécharger le CSV"
+
+#: views/admin-page.php:62
+msgid "Delete CSV"
+msgstr "Supprimer le CSV"
+
+#: views/admin-page.php:65
+msgid "Regenerate CSV"
+msgstr "Régénérer le CSV"
+
+#: views/admin-page.php:71
+msgid "Generate CSV"
+msgstr "Générer le CSV"
+
+#: views/admin-page.php:80
+msgid "Database Logs"
+msgstr "Journaux de la base de données"
+
+#: views/admin-page.php:85
+msgid "Number of Entries"
+msgstr "Nombre d'entrées"
+
+#: views/admin-page.php:93
+msgid "Database Size"
+msgstr "Taille de la base de données"
+
+#: views/admin-page.php:96
+msgid "N/A"
+msgstr "N/D"
+
+#: views/admin-page.php:103
+msgid "Purge All Logs"
+msgstr "Purger tous les journaux"
+
+#: assets/js/admin.js:47
+msgid "Deleting..."
+msgstr "Suppression…"
+
+#: assets/js/admin.js:64 assets/js/admin.js:100 assets/js/admin.js:136
+#: assets/js/admin.js:176
+msgid "An error occurred."
+msgstr "Une erreur s'est produite."
+
+#: assets/js/admin.js:69
+msgid "An error occurred while deleting the CSV file."
+msgstr "Une erreur s'est produite lors de la suppression du fichier CSV."
+
+#: assets/js/admin.js:83
+msgid "Generating..."
+msgstr "Génération…"
+
+#: assets/js/admin.js:105
+msgid "An error occurred while generating the CSV file."
+msgstr "Une erreur s'est produite lors de la génération du fichier CSV."
+
+#: assets/js/admin.js:119
+msgid "Regenerating..."
+msgstr "Régénération…"
+
+#: assets/js/admin.js:141
+msgid "An error occurred while regenerating the CSV file."
+msgstr "Une erreur s'est produite lors de la régénération du fichier CSV."
+
+#: assets/js/admin.js:159
+msgid "Purging..."
+msgstr "Purge…"
+
+#: assets/js/admin.js:181
+msgid "An error occurred while purging log entries."
+msgstr "Une erreur s'est produite lors de la purge des entrées du journal."
diff --git a/languages/trash-log.pot b/languages/trash-log.pot
index 521e315..a233479 100644
--- a/languages/trash-log.pot
+++ b/languages/trash-log.pot
@@ -9,19 +9,15 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"POT-Creation-Date: 2026-01-02T12:07:30+01:00\n"
+"POT-Creation-Date: 2026-01-30T09:03:18+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"X-Generator: WP-CLI 2.12.0\n"
-"Plugin Name: Trash Log\n"
-"Plugin URI: https://beapi.fr\n"
-"Author: Be API Technical team\n"
-"Author URI: https://beapi.fr\n"
+"X-Generator: WP-CLI 2.11.0\n"
"X-Domain: trash-log\n"
#. Plugin Name of the plugin
#: trash-log.php
-#: classes/Admin.php:129
-#: classes/Admin.php:130
+#: classes/Admin.php:124
+#: classes/Admin.php:125
msgid "Trash Log"
msgstr ""
@@ -41,114 +37,109 @@ msgstr ""
msgid "Be API Technical team"
msgstr ""
-#: classes/Admin.php:105
-#: classes/Admin.php:253
+#: classes/Admin.php:100
+#: classes/Admin.php:242
msgid "Security check failed."
msgstr ""
-#: classes/Admin.php:110
+#: classes/Admin.php:105
msgid "You do not have permission to perform this action."
msgstr ""
-#: classes/Admin.php:195
+#: classes/Admin.php:190
msgid "Are you sure you want to delete the CSV file?"
msgstr ""
-#: classes/Admin.php:196
+#: classes/Admin.php:191
msgid "Are you sure you want to purge all log entries from the database? This action cannot be undone."
msgstr ""
-#: classes/Admin.php:210
-msgid "You do not have permission to access this page."
-msgstr ""
-
-#: classes/Admin.php:248
+#: classes/Admin.php:238
msgid "You must be logged in to access this file."
msgstr ""
-#: classes/Admin.php:248
-#: classes/Admin.php:253
-#: classes/Admin.php:257
-#: classes/Admin.php:266
+#: classes/Admin.php:238
+#: classes/Admin.php:242
+#: classes/Admin.php:246
+#: classes/Admin.php:254
msgid "Error"
msgstr ""
-#: classes/Admin.php:257
+#: classes/Admin.php:246
msgid "You do not have permission to access this file."
msgstr ""
-#: classes/Admin.php:321
+#: classes/Admin.php:304
msgid "CSV file deleted successfully."
msgstr ""
-#: classes/Admin.php:349
+#: classes/Admin.php:331
msgid "CSV file generated successfully."
msgstr ""
-#: classes/Admin.php:373
+#: classes/Admin.php:354
msgid "Failed to purge log entries."
msgstr ""
-#: classes/Admin.php:376
+#: classes/Admin.php:357
msgid "All log entries have been purged from the database."
msgstr ""
-#: classes/CSV_Handler.php:133
+#: classes/CSV_Handler.php:132
msgid "No log entries found."
msgstr ""
-#: classes/CSV_Handler.php:142
+#: classes/CSV_Handler.php:140
msgid "Unable to access upload directory."
msgstr ""
-#: classes/CSV_Handler.php:152
+#: classes/CSV_Handler.php:149
msgid "Failed to create CSV directory."
msgstr ""
-#: classes/CSV_Handler.php:165
+#: classes/CSV_Handler.php:160
msgid "Invalid CSV file path."
msgstr ""
-#: classes/CSV_Handler.php:174
+#: classes/CSV_Handler.php:168
msgid "Failed to open CSV file for writing."
msgstr ""
-#: classes/CSV_Handler.php:183
+#: classes/CSV_Handler.php:176
msgid "Contributor Name"
msgstr ""
-#: classes/CSV_Handler.php:184
+#: classes/CSV_Handler.php:177
msgid "Deleted Item"
msgstr ""
-#: classes/CSV_Handler.php:185
+#: classes/CSV_Handler.php:178
msgid "Date"
msgstr ""
-#: classes/CSV_Handler.php:186
+#: classes/CSV_Handler.php:179
msgid "Document Size"
msgstr ""
-#: classes/CSV_Handler.php:187
+#: classes/CSV_Handler.php:180
msgid "URL"
msgstr ""
-#: classes/CSV_Handler.php:221
-#: classes/CSV_Handler.php:246
+#: classes/CSV_Handler.php:212
+#: classes/CSV_Handler.php:237
msgid "CSV file not found."
msgstr ""
-#: classes/CSV_Handler.php:229
+#: classes/CSV_Handler.php:220
msgid "Failed to delete CSV file."
msgstr ""
-#: classes/Logger.php:182
+#: classes/Logger.php:119
msgid "Automatic action"
msgstr ""
#. translators: %d: Post ID
-#: classes/Logger.php:198
-#, php-format
+#: classes/Logger.php:135
msgid "Item #%d"
msgstr ""
diff --git a/psalm.xml b/psalm.xml
new file mode 100644
index 0000000..8e8404a
--- /dev/null
+++ b/psalm.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trash-log.php b/trash-log.php
index c637de7..00e953e 100644
--- a/trash-log.php
+++ b/trash-log.php
@@ -37,8 +37,6 @@
// Plugin constants
define( 'TRASH_LOG_VERSION', '1.0.0' );
define( 'TRASH_LOG_VIEWS_FOLDER_NAME', 'trash-log' );
-define( 'TRASH_LOG_CPT_NAME', 'custom_post_type' );
-define( 'TRASH_LOG_TAXO_NAME', 'custom_taxonomy' );
// Plugin URL and PATH
define( 'TRASH_LOG_URL', plugin_dir_url( __FILE__ ) );
@@ -48,20 +46,24 @@
// Load autoloader
require_once TRASH_LOG_DIR . 'autoload.php';
-// instantiate the loader
-$loader = new \Trash_Log\Trash_Log\Autoloader();
+// Instantiate the loader
+$loader = new \BEAPI\Trash_Log\Autoloader();
-// register the autoloader
+// Register the autoloader
$loader->register();
-// register the base directories for the namespace prefix
-$loader->addNamespace( 'Trash_Log\Trash_Log', TRASH_LOG_DIR . 'classes' );
+// Register the base directories for the namespace prefix
+$loader->addNamespace( 'BEAPI\Trash_Log', TRASH_LOG_DIR . 'classes' );
add_action( 'plugins_loaded', 'init_trash_log_plugin' );
/**
- * Init the plugin
+ * Init the plugin.
+ *
+ * @return void
*/
function init_trash_log_plugin(): void {
- // Client
- \Trash_Log\Trash_Log\Main::get_instance();
+ \BEAPI\Trash_Log\Main::get_instance();
+ \BEAPI\Trash_Log\Logger::get_instance();
+ \BEAPI\Trash_Log\CSV_Handler::get_instance();
+ \BEAPI\Trash_Log\Admin::get_instance();
}