Plugin rename

This commit is contained in:
2026-02-12 22:34:54 +01:00
parent 0e5be7b590
commit d303a55638
16 changed files with 279 additions and 282 deletions
+18 -18
View File
@@ -3,12 +3,12 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function mystat_import_csv_page() {
function statpress_import_csv_page() {
echo '<div class="wrap"><h1>Importuj aktywności z pliku CSV</h1>';
// Handle the form submission
if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['mystat_csv_import_nonce_field'] ) ) {
mystat_handle_csv_import();
if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['statpress_csv_import_nonce_field'] ) ) {
statpress_handle_csv_import();
}
// Display the form
@@ -28,15 +28,15 @@ function mystat_import_csv_page() {
</p>
<hr>
<form method="post" enctype="multipart/form-data">
<?php wp_nonce_field( 'mystat_csv_import_nonce', 'mystat_csv_import_nonce_field' ); ?>
<?php wp_nonce_field( 'statpress_csv_import_nonce', 'statpress_csv_import_nonce_field' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="mystat_csv_file">Opcja 1: Wgraj plik CSV</label></th>
<td><input type="file" id="mystat_csv_file" name="mystat_csv_file" accept=".csv,text/csv" /></td>
<th scope="row"><label for="statpress_csv_file">Opcja 1: Wgraj plik CSV</label></th>
<td><input type="file" id="statpress_csv_file" name="statpress_csv_file" accept=".csv,text/csv" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="mystat_csv_data">Opcja 2: Wklej dane CSV</label></th>
<td><textarea name="mystat_csv_data" id="mystat_csv_data" rows="15" class="large-text" placeholder="Wklej tutaj zawartość swojego pliku CSV...&#10;Typ aktywności,Data,Tytuł,Dystans,...&#10;Rower,2025-01-01,Nowy Rok,10.5,..."></textarea></td>
<th scope="row"><label for="statpress_csv_data">Opcja 2: Wklej dane CSV</label></th>
<td><textarea name="statpress_csv_data" id="statpress_csv_data" rows="15" class="large-text" placeholder="Wklej tutaj zawartość swojego pliku CSV...&#10;Typ aktywności,Data,Tytuł,Dystans,...&#10;Rower,2025-01-01,Nowy Rok,10.5,..."></textarea></td>
</tr>
</table>
<?php submit_button( 'Importuj' ); ?>
@@ -47,10 +47,10 @@ function mystat_import_csv_page() {
echo '</div>';
}
function mystat_handle_csv_import() {
function statpress_handle_csv_import() {
global $wpdb;
if ( ! isset( $_POST['mystat_csv_import_nonce_field'] ) || ! wp_verify_nonce( $_POST['mystat_csv_import_nonce_field'], 'mystat_csv_import_nonce' ) ) {
if ( ! isset( $_POST['statpress_csv_import_nonce_field'] ) || ! wp_verify_nonce( $_POST['statpress_csv_import_nonce_field'], 'statpress_csv_import_nonce' ) ) {
echo '<div class="notice notice-error"><p>Błąd weryfikacji bezpieczeństwa.</p></div>';
return;
}
@@ -62,10 +62,10 @@ function mystat_handle_csv_import() {
// Unify input source: prefer textarea, fall back to file upload.
$csv_content = '';
if ( ! empty( $_POST['mystat_csv_data'] ) ) {
$csv_content = stripslashes( $_POST['mystat_csv_data'] );
} elseif ( ! empty( $_FILES['mystat_csv_file']['tmp_name'] ) && UPLOAD_ERR_OK === $_FILES['mystat_csv_file']['error'] ) {
$csv_content = file_get_contents( $_FILES['mystat_csv_file']['tmp_name'] );
if ( ! empty( $_POST['statpress_csv_data'] ) ) {
$csv_content = stripslashes( $_POST['statpress_csv_data'] );
} elseif ( ! empty( $_FILES['statpress_csv_file']['tmp_name'] ) && UPLOAD_ERR_OK === $_FILES['statpress_csv_file']['error'] ) {
$csv_content = file_get_contents( $_FILES['statpress_csv_file']['tmp_name'] );
}
if ( empty( trim( $csv_content ) ) ) {
@@ -120,9 +120,9 @@ function mystat_handle_csv_import() {
);
// --- START: Robust, case-insensitive lookup ---
$table_categories = $wpdb->prefix . 'mystat_categories';
$table_event_types = $wpdb->prefix . 'mystat_event_types';
$table_equipment = $wpdb->prefix . 'mystat_equipment';
$table_categories = $wpdb->prefix . 'statpress_categories';
$table_event_types = $wpdb->prefix . 'statpress_event_types';
$table_equipment = $wpdb->prefix . 'statpress_equipment';
$create_lookup = function( $table_name ) use ( $wpdb ) {
$items = $wpdb->get_results( "SELECT id, name FROM {$table_name}" );
@@ -143,7 +143,7 @@ function mystat_handle_csv_import() {
// --- END: Robust, case-insensitive lookup ---
// Process the CSV file
$table_activities = $wpdb->prefix . 'mystat_activities';
$table_activities = $wpdb->prefix . 'statpress_activities';
$imported_count = 0;
$skipped_details = array();
$row_number = 1; // Header is row 1