Refactor: delete import csv

This commit is contained in:
2026-04-22 13:38:38 +02:00
parent b5b8fde31f
commit cb30dff841
5 changed files with 61 additions and 108 deletions
+4 -6
View File
@@ -91,8 +91,7 @@ function statpress_equipment_page() {
eq.status ASC, eq.name ASC"
);
?>
<div class="wrap">
<h1>Zarządzaj Sprzętem</h1>
<div class="statpress-tab-wrapper">
<?php if ( ! empty( $message ) ) : ?>
<div class="notice <?php echo esc_attr( $notice_class ); ?> is-dismissible"><p><?php echo esc_html( $message ); ?></p></div>
<?php endif; ?>
@@ -124,7 +123,7 @@ function statpress_equipment_page() {
<tbody>
<?php foreach ( $equipment_list as $item ) : ?>
<?php
$details_url = admin_url( 'admin.php?page=statpress-equipment-details&id=' . $item->id );
$details_url = admin_url( 'admin.php?page=statpress-settings&tab=equipment_details&id=' . $item->id );
?>
<tr>
<td><strong><a href="<?php echo esc_url( $details_url ); ?>"><?php echo esc_html( $item->name ); ?></a></strong><br><small><?php echo esc_html( $item->type ); ?></small></td>
@@ -215,9 +214,8 @@ function statpress_equipment_details_page() {
$log_types = array( 'Naprawa', 'Zakup części', 'Przegląd', 'Modyfikacja', 'Inne' );
?>
<div class="wrap">
<h1>Dziennik serwisowy: <?php echo esc_html( $equipment->name ); ?></h1>
<p><a href="<?php echo esc_url( admin_url( 'admin.php?page=statpress-equipment' ) ); ?>">&larr; Powrót do listy sprzętu</a></p>
<div class="statpress-tab-wrapper">
<p><a href="<?php echo esc_url( admin_url( 'admin.php?page=statpress-settings&tab=equipment' ) ); ?>" class="button">&larr; Powrót do listy sprzętu</a></p>
<?php if ( ! empty( $message ) ) : ?>
<div class="notice <?php echo esc_attr( $notice_class ); ?> is-dismissible"><p><?php echo esc_html( $message ); ?></p></div>
+1 -2
View File
@@ -47,8 +47,7 @@ function statpress_event_types_page() {
$event_types = $wpdb->get_results( "SELECT * FROM $table_event_types ORDER BY name ASC" );
?>
<div class="wrap">
<h1>Typy Wydarzeń</h1>
<div class="statpress-tab-wrapper">
<?php if ( ! empty( $message ) ) : ?>
<div class="notice <?php echo esc_attr( $notice_class ); ?> is-dismissible"><p><?php echo esc_html( $message ); ?></p></div>
<?php endif; ?>
+56 -43
View File
@@ -4,70 +4,77 @@ if ( ! defined( 'ABSPATH' ) ) {
}
function statpress_settings_page() {
$active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
?>
<div class="wrap">
<?php
if ( get_transient( 'statpress_migration_reset_notice' ) ) {
echo '<div class="notice notice-success is-dismissible"><p>Status migracji został zresetowany. Wróć do <a href="' . esc_url( admin_url( 'admin.php?page=statpress-dashboard' ) ) . '">głównego panelu</a>, aby ponownie uruchomić migrację.</p></div>';
delete_transient( 'statpress_migration_reset_notice' );
}
?>
<h1>Ustawienia Wtyczki Statystyk</h1>
<form method="post" action="options.php">
<h2 class="nav-tab-wrapper">
<a href="?page=statpress-settings&tab=general" class="nav-tab <?php echo 'general' === $active_tab ? 'nav-tab-active' : ''; ?>">Ogólne i API</a>
<a href="?page=statpress-settings&tab=event_types" class="nav-tab <?php echo 'event_types' === $active_tab ? 'nav-tab-active' : ''; ?>">Typy wydarzeń</a>
<a href="?page=statpress-settings&tab=equipment" class="nav-tab <?php echo in_array( $active_tab, array( 'equipment', 'equipment_details' ), true ) ? 'nav-tab-active' : ''; ?>">Sprzęt i Dziennik</a>
</h2>
<div class="statpress-tab-content" style="margin-top: 20px;">
<?php
settings_fields( 'statpress_settings_group' );
do_settings_sections( 'statpress_settings_page' );
submit_button();
if ( 'general' === $active_tab ) {
statpress_settings_general_tab();
} elseif ( 'event_types' === $active_tab ) {
if ( function_exists( 'statpress_event_types_page' ) ) {
statpress_event_types_page();
} else {
echo '<p>Brak funkcji zarządzania typami wydarzeń.</p>';
}
} elseif ( 'equipment' === $active_tab ) {
statpress_equipment_page();
} elseif ( 'equipment_details' === $active_tab ) {
statpress_equipment_details_page();
}
?>
</form>
<hr>
<h2>Narzędzia deweloperskie</h2>
<div class="postbox">
<div class="postbox-header"><h3 class="hndle">Resetowanie migracji</h3></div>
<div class="inside">
<p>Jeśli migracja danych nie powiodła się, a przycisk do jej ponownego uruchomienia zniknął, możesz użyć tego narzędzia, aby zresetować status migracji. Po kliknięciu, przycisk w głównym panelu wtyczki pojawi się ponownie.</p>
<form method="post">
<input type="hidden" name="statpress_action" value="reset_migration"><?php wp_nonce_field( 'statpress_reset_migration_nonce', '_wpnonce' ); ?><?php submit_button( 'Zresetuj status migracji', 'delete' ); ?></form>
</div>
</div>
</div>
<?php
}
function statpress_settings_general_tab() {
?>
<div class="postbox">
<div class="postbox-header"><h2 class="hndle">Konfiguracja główna</h2></div>
<div class="inside">
<form method="post" action="options.php">
<?php
settings_fields( 'statpress_privacy_settings' );
do_settings_sections( 'statpress-privacy-section' );
settings_fields( 'statpress_api_settings' );
do_settings_sections( 'statpress-api-section' );
?>
<hr>
<?php submit_button( 'Zapisz ustawienia' ); ?>
</form>
</div>
</div>
<?php
}
function statpress_register_settings() {
// Define a single group and page for all settings on this form.
$option_group = 'statpress_settings_group';
$page_slug = 'statpress_settings_page';
// Register Privacy settings under the main group.
register_setting(
$option_group,
'statpress_privacy_settings',
'statpress_privacy_options',
'statpress_sanitize_privacy_options'
);
// Register API settings under the same main group.
register_setting(
$option_group,
'statpress_api_options',
'statpress_sanitize_api_options'
);
// Add the Privacy section to the main page.
add_settings_section(
'statpress_privacy_zone_section',
'Strefa Prywatności GPX',
'statpress_privacy_section_callback',
$page_slug
'statpress-privacy-section'
);
add_settings_field(
'statpress_privacy_latitude',
'Szerokość geograficzna (Latitude)',
'statpress_render_lat_field',
$page_slug,
'statpress-privacy-section',
'statpress_privacy_zone_section'
);
@@ -75,7 +82,7 @@ function statpress_register_settings() {
'statpress_privacy_longitude',
'Długość geograficzna (Longitude)',
'statpress_render_lon_field',
$page_slug,
'statpress-privacy-section',
'statpress_privacy_zone_section'
);
@@ -83,24 +90,30 @@ function statpress_register_settings() {
'statpress_privacy_radius',
'Promień strefy (w metrach)',
'statpress_render_radius_field',
$page_slug,
'statpress-privacy-section',
'statpress_privacy_zone_section'
);
// Add the API section to the same main page.
// API Settings
register_setting(
'statpress_api_settings',
'statpress_api_options',
'statpress_sanitize_api_options'
);
add_settings_section(
'statpress_api_section',
'Ustawienia API',
'statpress_api_section_callback',
$page_slug
'statpress-api-section'
);
add_settings_field(
'statpress_enable_api',
'REST API',
'statpress_render_enable_api_field',
$page_slug,
'statpress_api_section'
'statpress-privacy-section',
'statpress_privacy_zone_section'
);
}