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
+9 -9
View File
@@ -1,12 +1,12 @@
/* Styles for WordPress Activity Stats Plugin - Admin Area */ /* Styles for WordPress Activity Stats Plugin - Admin Area */
/* Infografika */ /* Infografika */
.mystat-infographic-grid { .statpress-infographic-grid {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px; gap: 20px;
} }
.mystat-infographic-card { .statpress-infographic-card {
background: #fff; background: #fff;
border: 1px solid #e0e0e0; border: 1px solid #e0e0e0;
border-radius: 5px; border-radius: 5px;
@@ -14,12 +14,12 @@
text-align: center; text-align: center;
box-shadow: 0 2px 4px rgba(0,0,0,0.05); box-shadow: 0 2px 4px rgba(0,0,0,0.05);
} }
.mystat-infographic-card h3 { .statpress-infographic-card h3 {
margin-top: 0; margin-top: 0;
color: #555; color: #555;
font-size: 1.1em; font-size: 1.1em;
} }
.mystat-infographic-card p { .statpress-infographic-card p {
font-size: 1.8em; font-size: 1.8em;
font-weight: bold; font-weight: bold;
color: #333; color: #333;
@@ -27,19 +27,19 @@
} }
/* Kontener dla szczegółów aktywności */ /* Kontener dla szczegółów aktywności */
#mystat-details-container { #statpress-details-container {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 2%; gap: 2%;
} }
/* Szczegóły aktywności */ /* Szczegóły aktywności */
.mystat-details-col { .statpress-details-col {
flex: 1 1 48%; /* Pozwala na elastyczne dopasowanie, z bazową szerokością 48% */ flex: 1 1 48%; /* Pozwala na elastyczne dopasowanie, z bazową szerokością 48% */
min-width: 300px; /* Zapobiega zbytniemu ściskaniu kolumn na mniejszych ekranach */ min-width: 300px; /* Zapobiega zbytniemu ściskaniu kolumn na mniejszych ekranach */
} }
/* Chart Controls */ /* Chart Controls */
.mystat-chart-controls { .statpress-chart-controls {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
@@ -49,12 +49,12 @@
padding-bottom: 10px; padding-bottom: 10px;
} }
.mystat-chart-tabs.nav-tab-wrapper { .statpress-chart-tabs.nav-tab-wrapper {
border-bottom: none; border-bottom: none;
margin-bottom: 0; margin-bottom: 0;
} }
.mystat-xaxis-switcher { .statpress-xaxis-switcher {
padding-top: 5px; padding-top: 5px;
white-space: nowrap; white-space: nowrap;
} }
+17 -17
View File
@@ -3,16 +3,16 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
function mystat_add_new_page() { function statpress_add_new_page() {
echo '<div class="wrap"><h1>Dodaj Nowy Trening</h1>'; echo '<div class="wrap"><h1>Dodaj Nowy Trening</h1>';
// Obsługa zapisu formularza (musi być przed renderowaniem, aby wyświetlić komunikat) // Obsługa zapisu formularza (musi być przed renderowaniem, aby wyświetlić komunikat)
mystat_handle_activity_form_submission(); statpress_handle_activity_form_submission();
// Formularz dodawania // Formularz dodawania
mystat_render_add_form(); statpress_render_add_form();
echo '</div>'; echo '</div>';
} }
function mystat_edit_activity_page() { function statpress_edit_activity_page() {
global $wpdb; global $wpdb;
$activity_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; $activity_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0;
@@ -22,9 +22,9 @@ function mystat_edit_activity_page() {
} }
// Handle form submission for update // Handle form submission for update
mystat_handle_activity_form_submission(); statpress_handle_activity_form_submission();
$table_activities = $wpdb->prefix . 'mystat_activities'; $table_activities = $wpdb->prefix . 'statpress_activities';
$activity = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_activities WHERE id = %d", $activity_id ) ); $activity = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_activities WHERE id = %d", $activity_id ) );
if ( ! $activity ) { if ( ! $activity ) {
@@ -33,23 +33,23 @@ function mystat_edit_activity_page() {
} }
echo '<div class="wrap"><h1>Edytuj Trening</h1>'; echo '<div class="wrap"><h1>Edytuj Trening</h1>';
mystat_render_add_form( $activity ); statpress_render_add_form( $activity );
echo '</div>'; echo '</div>';
} }
/** /**
* Obsługa zapisu nowego lub edytowanego wpisu do bazy danych * Obsługa zapisu nowego lub edytowanego wpisu do bazy danych
*/ */
function mystat_handle_activity_form_submission() { function statpress_handle_activity_form_submission() {
global $wpdb; global $wpdb;
// Sprawdź czy formularz został wysłany // Sprawdź czy formularz został wysłany
if ( ! isset( $_POST['mystat_submit_activity'] ) ) { if ( ! isset( $_POST['statpress_submit_activity'] ) ) {
return; return;
} }
$activity_id = isset( $_POST['activity_id'] ) ? intval( $_POST['activity_id'] ) : 0; $activity_id = isset( $_POST['activity_id'] ) ? intval( $_POST['activity_id'] ) : 0;
$nonce_action = $activity_id > 0 ? 'mystat_edit_entry_' . $activity_id : 'mystat_add_entry'; $nonce_action = $activity_id > 0 ? 'statpress_edit_entry_' . $activity_id : 'statpress_add_entry';
// Weryfikacja bezpieczeństwa (Nonce) // Weryfikacja bezpieczeństwa (Nonce)
if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], $nonce_action ) ) { if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], $nonce_action ) ) {
@@ -59,7 +59,7 @@ function mystat_handle_activity_form_submission() {
// Use the refactored function to save data. // Use the refactored function to save data.
// We can pass $_POST directly as the function will sanitize it. // We can pass $_POST directly as the function will sanitize it.
$result = mystat_save_activity_data( $_POST, $activity_id ); $result = statpress_save_activity_data( $_POST, $activity_id );
if ( $activity_id > 0 ) { if ( $activity_id > 0 ) {
$message = 'Trening zaktualizowany pomyślnie!'; $message = 'Trening zaktualizowany pomyślnie!';
@@ -77,20 +77,20 @@ function mystat_handle_activity_form_submission() {
/** /**
* Renderowanie formularza HTML * Renderowanie formularza HTML
*/ */
function mystat_render_add_form( $activity = null ) { function statpress_render_add_form( $activity = null ) {
// Enqueue media scripts for the uploader // Enqueue media scripts for the uploader
wp_enqueue_media(); wp_enqueue_media();
global $wpdb; global $wpdb;
$table_categories = $wpdb->prefix . 'mystat_categories'; $table_categories = $wpdb->prefix . 'statpress_categories';
$table_event_types = $wpdb->prefix . 'mystat_event_types'; $table_event_types = $wpdb->prefix . 'statpress_event_types';
$table_equipment = $wpdb->prefix . 'mystat_equipment'; $table_equipment = $wpdb->prefix . 'statpress_equipment';
$categories = $wpdb->get_results( "SELECT * FROM $table_categories ORDER BY name ASC" ); $categories = $wpdb->get_results( "SELECT * FROM $table_categories ORDER BY name ASC" );
$event_types = $wpdb->get_results( "SELECT * FROM $table_event_types ORDER BY name ASC" ); $event_types = $wpdb->get_results( "SELECT * FROM $table_event_types ORDER BY name ASC" );
$equipment_list = $wpdb->get_results( "SELECT * FROM $table_equipment ORDER BY name ASC" ); $equipment_list = $wpdb->get_results( "SELECT * FROM $table_equipment ORDER BY name ASC" );
$is_edit_mode = ! is_null( $activity ); $is_edit_mode = ! is_null( $activity );
$nonce_action = $is_edit_mode ? 'mystat_edit_entry_' . $activity->id : 'mystat_add_entry'; $nonce_action = $is_edit_mode ? 'statpress_edit_entry_' . $activity->id : 'statpress_add_entry';
$form_title = $is_edit_mode ? 'Edytuj Aktywność' : 'Dodaj Nową Aktywność'; $form_title = $is_edit_mode ? 'Edytuj Aktywność' : 'Dodaj Nową Aktywność';
$button_text = $is_edit_mode ? 'Zaktualizuj Trening' : 'Zapisz Trening'; $button_text = $is_edit_mode ? 'Zaktualizuj Trening' : 'Zapisz Trening';
@@ -218,7 +218,7 @@ function mystat_render_add_form( $activity = null ) {
</tr> </tr>
</table> </table>
<p class="submit"> <p class="submit">
<input type="submit" name="mystat_submit_activity" id="submit" class="button button-primary" value="<?php echo esc_attr( $button_text ); ?>"> <input type="submit" name="statpress_submit_activity" id="submit" class="button button-primary" value="<?php echo esc_attr( $button_text ); ?>">
</p> </p>
</form> </form>
<script> <script>
+31 -31
View File
@@ -3,7 +3,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
function mystat_view_activity_page() { function statpress_view_activity_page() {
global $wpdb; global $wpdb;
$activity_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; $activity_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0;
@@ -13,10 +13,10 @@ function mystat_view_activity_page() {
return; return;
} }
$table_activities = $wpdb->prefix . 'mystat_activities'; $table_activities = $wpdb->prefix . 'statpress_activities';
$table_categories = $wpdb->prefix . 'mystat_categories'; $table_categories = $wpdb->prefix . 'statpress_categories';
$table_event_types = $wpdb->prefix . 'mystat_event_types'; $table_event_types = $wpdb->prefix . 'statpress_event_types';
$table_equipment = $wpdb->prefix . 'mystat_equipment'; $table_equipment = $wpdb->prefix . 'statpress_equipment';
$sql = $wpdb->prepare( $sql = $wpdb->prepare(
" "
@@ -51,7 +51,7 @@ function mystat_view_activity_page() {
$gpx_data = array(); $gpx_data = array();
$has_gpx_data = false; $has_gpx_data = false;
if ( ! empty( $activity->gpx_url ) ) { if ( ! empty( $activity->gpx_url ) ) {
$gpx_data = mystat_parse_gpx_data( $activity->gpx_url ); $gpx_data = statpress_parse_gpx_data( $activity->gpx_url );
$has_gpx_data = ! empty( $gpx_data['points'] ); $has_gpx_data = ! empty( $gpx_data['points'] );
} }
@@ -60,8 +60,8 @@ function mystat_view_activity_page() {
wp_enqueue_script( 'leaflet-js', 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js', array(), '1.9.4', true ); wp_enqueue_script( 'leaflet-js', 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js', array(), '1.9.4', true );
wp_enqueue_script( 'chart-js', 'https://cdn.jsdelivr.net/npm/chart.js', array(), null, true ); wp_enqueue_script( 'chart-js', 'https://cdn.jsdelivr.net/npm/chart.js', array(), null, true );
wp_register_script( 'mystat-details-loader', false ); wp_register_script( 'statpress-details-loader', false );
wp_enqueue_script( 'mystat-details-loader' ); wp_enqueue_script( 'statpress-details-loader' );
// Check which profiles have data // Check which profiles have data
$available_profiles = array(); $available_profiles = array();
@@ -82,7 +82,7 @@ function mystat_view_activity_page() {
let activeChart = null; let activeChart = null;
if (typeof L !== "undefined" && track_points.length > 0) { if (typeof L !== "undefined" && track_points.length > 0) {
const map = L.map("mystat-activity-map"); const map = L.map("statpress-activity-map");
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { attribution: \'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>\' }).addTo(map); L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { attribution: \'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>\' }).addTo(map);
const polyline = L.polyline(track_points, {color: "' . esc_js( $activity->color ) . '"}).addTo(map); const polyline = L.polyline(track_points, {color: "' . esc_js( $activity->color ) . '"}).addTo(map);
map.fitBounds(polyline.getBounds().pad(0.1)); map.fitBounds(polyline.getBounds().pad(0.1));
@@ -106,8 +106,8 @@ function mystat_view_activity_page() {
function renderChart() { function renderChart() {
if (activeChart) activeChart.destroy(); if (activeChart) activeChart.destroy();
const chartType = document.querySelector(".mystat-chart-tabs .nav-tab-active").getAttribute("href").substring(1); const chartType = document.querySelector(".statpress-chart-tabs .nav-tab-active").getAttribute("href").substring(1);
const xAxisType = document.querySelector(\'input[name="mystat_xaxis"]:checked\').value; const xAxisType = document.querySelector(\'input[name="statpress_xaxis"]:checked\').value;
const yData = profiles[chartType], xData = xAxisConfigs[xAxisType].data; const yData = profiles[chartType], xData = xAxisConfigs[xAxisType].data;
const filteredY = [], filteredX = []; const filteredY = [], filteredX = [];
@@ -120,7 +120,7 @@ function mystat_view_activity_page() {
} }
} }
const ctx = document.getElementById("mystat-details-chart").getContext("2d"); const ctx = document.getElementById("statpress-details-chart").getContext("2d");
activeChart = new Chart(ctx, { activeChart = new Chart(ctx, {
type: "line", type: "line",
data: { data: {
@@ -143,34 +143,34 @@ function mystat_view_activity_page() {
}); });
} }
document.querySelectorAll(".mystat-chart-tabs .nav-tab").forEach(t => t.addEventListener("click", e => { document.querySelectorAll(".statpress-chart-tabs .nav-tab").forEach(t => t.addEventListener("click", e => {
e.preventDefault(); e.preventDefault();
document.querySelector(".mystat-chart-tabs .nav-tab-active").classList.remove("nav-tab-active"); document.querySelector(".statpress-chart-tabs .nav-tab-active").classList.remove("nav-tab-active");
e.target.classList.add("nav-tab-active"); e.target.classList.add("nav-tab-active");
renderChart(); renderChart();
})); }));
document.querySelectorAll(\'input[name="mystat_xaxis"]\').forEach(r => r.addEventListener("change", renderChart)); document.querySelectorAll(\'input[name="statpress_xaxis"]\').forEach(r => r.addEventListener("change", renderChart));
if (document.querySelector(".mystat-chart-tabs .nav-tab")) renderChart(); if (document.querySelector(".statpress-chart-tabs .nav-tab")) renderChart();
'; ';
wp_add_inline_script( 'mystat-details-loader', 'document.addEventListener("DOMContentLoaded", function() {' . $chart_js . '});' ); wp_add_inline_script( 'statpress-details-loader', 'document.addEventListener("DOMContentLoaded", function() {' . $chart_js . '});' );
} }
?> ?>
<div class="wrap"> <div class="wrap">
<h1> <h1>
Szczegóły treningu: <?php echo esc_html( $activity->title ); ?> Szczegóły treningu: <?php echo esc_html( $activity->title ); ?>
<a href="<?php echo esc_url( add_query_arg( array( 'page' => 'mystat-edit-activity', 'id' => $activity->id ), admin_url( 'admin.php' ) ) ); ?>" class="page-title-action"> <a href="<?php echo esc_url( add_query_arg( array( 'page' => 'statpress-edit-activity', 'id' => $activity->id ), admin_url( 'admin.php' ) ) ); ?>" class="page-title-action">
Edytuj Edytuj
</a> </a>
</h1> </h1>
<p><a href="<?php echo esc_url( admin_url( 'admin.php?page=moje-statystyki' ) ); ?>">&larr; Powrót do listy aktywności</a></p> <p><a href="<?php echo esc_url( admin_url( 'admin.php?page=statpress-dashboard' ) ); ?>">&larr; Powrót do listy aktywności</a></p>
<div class="postbox" style="margin-top: 20px;"> <div class="postbox" style="margin-top: 20px;">
<div class="postbox-header"><h2 class="hndle">Podsumowanie</h2></div> <div class="postbox-header"><h2 class="hndle">Podsumowanie</h2></div>
<div class="inside"> <div class="inside">
<div id="mystat-details-container"> <div id="statpress-details-container">
<div class="mystat-details-col"> <div class="statpress-details-col">
<h3>Główne dane</h3> <h3>Główne dane</h3>
<table class="form-table"> <table class="form-table">
<?php $render_row( 'Kategoria', $activity->category_name ); ?> <?php $render_row( 'Kategoria', $activity->category_name ); ?>
@@ -182,7 +182,7 @@ function mystat_view_activity_page() {
<?php $render_row( 'Sprzęt', $activity->equipment_name ); ?> <?php $render_row( 'Sprzęt', $activity->equipment_name ); ?>
</table> </table>
</div> </div>
<div class="mystat-details-col"> <div class="statpress-details-col">
<h3>Dane szczegółowe</h3> <h3>Dane szczegółowe</h3>
<table class="form-table"> <table class="form-table">
<?php $render_row( 'Średnia prędkość', number_format( $activity->avg_speed, 1, ',', ' ' ), 'km/h' ); ?> <?php $render_row( 'Średnia prędkość', number_format( $activity->avg_speed, 1, ',', ' ' ), 'km/h' ); ?>
@@ -213,13 +213,13 @@ function mystat_view_activity_page() {
<?php if ( $has_gpx_data ) : ?> <?php if ( $has_gpx_data ) : ?>
<hr> <hr>
<h3>Mapa Trasy</h3> <h3>Mapa Trasy</h3>
<div id="mystat-activity-map" style="height: 450px; width: 100%; border: 1px solid #ddd; margin-bottom: 20px;"></div> <div id="statpress-activity-map" style="height: 450px; width: 100%; border: 1px solid #ddd; margin-bottom: 20px;"></div>
<?php if ( ! empty( $available_profiles ) ) : ?> <?php if ( ! empty( $available_profiles ) ) : ?>
<h3>Wykresy</h3> <h3>Wykresy</h3>
<div class="mystat-charts-container"> <div class="statpress-charts-container">
<div class="mystat-chart-controls"> <div class="statpress-chart-controls">
<nav class="nav-tab-wrapper mystat-chart-tabs"> <nav class="nav-tab-wrapper statpress-chart-tabs">
<?php <?php
$is_first = true; $is_first = true;
foreach ( $available_profiles as $key => $label ) : foreach ( $available_profiles as $key => $label ) :
@@ -233,18 +233,18 @@ function mystat_view_activity_page() {
<?php endforeach; ?> <?php endforeach; ?>
</nav> </nav>
<?php if ( $has_time_data ) : ?> <?php if ( $has_time_data ) : ?>
<div class="mystat-xaxis-switcher"> <div class="statpress-xaxis-switcher">
<strong>Oś X:</strong>&nbsp; <strong>Oś X:</strong>&nbsp;
<label><input type="radio" name="mystat_xaxis" value="distance" checked> Dystans</label> <label><input type="radio" name="statpress_xaxis" value="distance" checked> Dystans</label>
&nbsp; &nbsp;
<label><input type="radio" name="mystat_xaxis" value="time"> Czas</label> <label><input type="radio" name="statpress_xaxis" value="time"> Czas</label>
</div> </div>
<?php else : ?> <?php else : ?>
<input type="hidden" name="mystat_xaxis" value="distance" checked> <input type="hidden" name="statpress_xaxis" value="distance" checked>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div style="position: relative; height:250px; width:100%;"> <div style="position: relative; height:250px; width:100%;">
<canvas id="mystat-details-chart"></canvas> <canvas id="statpress-details-chart"></canvas>
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
+14 -14
View File
@@ -3,27 +3,27 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
function mystat_dashboard_page() { function statpress_dashboard_page() {
echo '<div class="wrap"><h1>Moje Statystyki Sportowe</h1>'; echo '<div class="wrap"><h1>StatPress Dashboard</h1>';
mystat_render_history_table(); statpress_render_history_table();
echo '</div>'; echo '</div>';
} }
function mystat_render_history_table() { function statpress_render_history_table() {
global $wpdb; global $wpdb;
// Definicje nazw tabel (z uwzględnieniem prefixu WP, jeśli był użyty przy tworzeniu) // Definicje nazw tabel (z uwzględnieniem prefixu WP, jeśli był użyty przy tworzeniu)
// Zakładam, że tabele nazywają się dokładnie tak jak w dokumentacji, ale dobrą praktyką jest $wpdb->prefix // Zakładam, że tabele nazywają się dokładnie tak jak w dokumentacji, ale dobrą praktyką jest $wpdb->prefix
// Jeśli tabele są "sztywne" (bez prefixu wp_), usuń $wpdb->prefix. // Jeśli tabele są "sztywne" (bez prefixu wp_), usuń $wpdb->prefix.
$table_activities = $wpdb->prefix . 'mystat_activities'; $table_activities = $wpdb->prefix . 'statpress_activities';
$table_categories = $wpdb->prefix . 'mystat_categories'; $table_categories = $wpdb->prefix . 'statpress_categories';
// --- 1. OBSŁUGA USUWANIA (DELETE) --- // --- 1. OBSŁUGA USUWANIA (DELETE) ---
if ( isset( $_GET['action'], $_GET['id'], $_GET['_wpnonce'] ) && 'mystat_delete' === $_GET['action'] ) { if ( isset( $_GET['action'], $_GET['id'], $_GET['_wpnonce'] ) && 'statpress_delete' === $_GET['action'] ) {
$activity_id = intval( $_GET['id'] ); $activity_id = intval( $_GET['id'] );
// Weryfikacja bezpieczeństwa (Nonce) // Weryfikacja bezpieczeństwa (Nonce)
if ( wp_verify_nonce( $_GET['_wpnonce'], 'mystat_delete_' . $activity_id ) ) { if ( wp_verify_nonce( $_GET['_wpnonce'], 'statpress_delete_' . $activity_id ) ) {
$result = $wpdb->delete( $result = $wpdb->delete(
$table_activities, $table_activities,
array( 'id' => $activity_id ), array( 'id' => $activity_id ),
@@ -56,8 +56,8 @@ function mystat_render_history_table() {
SELECT a.*, c.name as category_name, c.icon, c.color, et.name as event_type_name, eq.name as equipment_name SELECT a.*, c.name as category_name, c.icon, c.color, et.name as event_type_name, eq.name as equipment_name
FROM $table_activities a FROM $table_activities a
LEFT JOIN $table_categories c ON a.category_id = c.id LEFT JOIN $table_categories c ON a.category_id = c.id
LEFT JOIN {$wpdb->prefix}mystat_event_types et ON a.event_type_id = et.id LEFT JOIN {$wpdb->prefix}statpress_event_types et ON a.event_type_id = et.id
LEFT JOIN {$wpdb->prefix}mystat_equipment eq ON a.equipment_id = eq.id LEFT JOIN {$wpdb->prefix}statpress_equipment eq ON a.equipment_id = eq.id
ORDER BY a.date DESC, a.id DESC ORDER BY a.date DESC, a.id DESC
LIMIT %d OFFSET %d LIMIT %d OFFSET %d
", ",
@@ -115,16 +115,16 @@ function mystat_render_history_table() {
$delete_url = wp_nonce_url( $delete_url = wp_nonce_url(
add_query_arg( add_query_arg(
array( array(
'action' => 'mystat_delete', 'action' => 'statpress_delete',
'id' => $row->id, 'id' => $row->id,
) )
), ),
'mystat_delete_' . $row->id 'statpress_delete_' . $row->id
); );
$edit_url = add_query_arg( $edit_url = add_query_arg(
array( array(
'page' => 'mystat-edit-activity', 'page' => 'statpress-edit-activity',
'id' => $row->id, 'id' => $row->id,
), ),
admin_url( 'admin.php' ) admin_url( 'admin.php' )
@@ -132,7 +132,7 @@ function mystat_render_history_table() {
$details_url = add_query_arg( $details_url = add_query_arg(
array( array(
'page' => 'mystat-view-activity', 'page' => 'statpress-view-activity',
'id' => $row->id, 'id' => $row->id,
), ),
admin_url( 'admin.php' ) admin_url( 'admin.php' )
+19 -19
View File
@@ -3,14 +3,14 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
function mystat_equipment_page() { function statpress_equipment_page() {
global $wpdb; global $wpdb;
$table_equipment = $wpdb->prefix . 'mystat_equipment'; $table_equipment = $wpdb->prefix . 'statpress_equipment';
$message = ''; $message = '';
$notice_class = ''; $notice_class = '';
// Handle POST requests (add/update) // Handle POST requests (add/update)
if ( isset( $_POST['submit'] ) && check_admin_referer( 'mystat_manage_equipment' ) ) { if ( isset( $_POST['submit'] ) && check_admin_referer( 'statpress_manage_equipment' ) ) {
$item_id = isset( $_POST['equipment_id'] ) ? intval( $_POST['equipment_id'] ) : 0; $item_id = isset( $_POST['equipment_id'] ) ? intval( $_POST['equipment_id'] ) : 0;
$data = array( $data = array(
'name' => sanitize_text_field( $_POST['equipment_name'] ), 'name' => sanitize_text_field( $_POST['equipment_name'] ),
@@ -49,13 +49,13 @@ function mystat_equipment_page() {
// Handle GET requests (delete) // Handle GET requests (delete)
if ( isset( $_GET['action'], $_GET['id'], $_GET['_wpnonce'] ) && 'delete' === $_GET['action'] ) { if ( isset( $_GET['action'], $_GET['id'], $_GET['_wpnonce'] ) && 'delete' === $_GET['action'] ) {
if ( wp_verify_nonce( $_GET['_wpnonce'], 'mystat_delete_equipment_' . $_GET['id'] ) ) { if ( wp_verify_nonce( $_GET['_wpnonce'], 'statpress_delete_equipment_' . $_GET['id'] ) ) {
// Sprawdź, czy sprzęt nie jest używany // Sprawdź, czy sprzęt nie jest używany
$usage_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}mystat_activities WHERE equipment_id = %d", intval( $_GET['id'] ) ) ); $usage_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}statpress_activities WHERE equipment_id = %d", intval( $_GET['id'] ) ) );
if ( 0 == $usage_count ) { if ( 0 == $usage_count ) {
$wpdb->delete( $table_equipment, array( 'id' => intval( $_GET['id'] ) ) ); $wpdb->delete( $table_equipment, array( 'id' => intval( $_GET['id'] ) ) );
// Usuń również powiązane wpisy w dzienniku // Usuń również powiązane wpisy w dzienniku
$wpdb->delete( $wpdb->prefix . 'mystat_equipment_log', array( 'equipment_id' => intval( $_GET['id'] ) ) ); $wpdb->delete( $wpdb->prefix . 'statpress_equipment_log', array( 'equipment_id' => intval( $_GET['id'] ) ) );
$message = 'Sprzęt usunięty.'; $message = 'Sprzęt usunięty.';
$notice_class = 'notice-success'; $notice_class = 'notice-success';
} else { } else {
@@ -72,7 +72,7 @@ function mystat_equipment_page() {
$item_to_edit = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_equipment WHERE id = %d", intval( $_GET['id'] ) ) ); $item_to_edit = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_equipment WHERE id = %d", intval( $_GET['id'] ) ) );
} }
$table_activities = $wpdb->prefix . 'mystat_activities'; $table_activities = $wpdb->prefix . 'statpress_activities';
$equipment_list = $wpdb->get_results(" $equipment_list = $wpdb->get_results("
SELECT SELECT
eq.id, eq.id,
@@ -104,7 +104,7 @@ function mystat_equipment_page() {
<h2><?php echo $item_to_edit ? 'Edytuj pozycję' : 'Dodaj nowy sprzęt'; ?></h2> <h2><?php echo $item_to_edit ? 'Edytuj pozycję' : 'Dodaj nowy sprzęt'; ?></h2>
<form method="post"> <form method="post">
<input type="hidden" name="equipment_id" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->id ) : '0'; ?>"> <input type="hidden" name="equipment_id" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->id ) : '0'; ?>">
<?php wp_nonce_field( 'mystat_manage_equipment' ); ?> <?php wp_nonce_field( 'statpress_manage_equipment' ); ?>
<div class="form-field form-required"><label for="equipment_name">Nazwa</label><input type="text" name="equipment_name" id="equipment_name" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->name ) : ''; ?>" required></div> <div class="form-field form-required"><label for="equipment_name">Nazwa</label><input type="text" name="equipment_name" id="equipment_name" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->name ) : ''; ?>" required></div>
<div class="form-field"><label for="equipment_type">Typ</label><input type="text" name="equipment_type" id="equipment_type" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->type ) : 'Rower'; ?>"></div> <div class="form-field"><label for="equipment_type">Typ</label><input type="text" name="equipment_type" id="equipment_type" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->type ) : 'Rower'; ?>"></div>
<div class="form-field"><label for="purchase_date">Data zakupu</label><input type="date" name="purchase_date" id="purchase_date" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->purchase_date ) : ''; ?>"></div> <div class="form-field"><label for="purchase_date">Data zakupu</label><input type="date" name="purchase_date" id="purchase_date" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->purchase_date ) : ''; ?>"></div>
@@ -124,7 +124,7 @@ function mystat_equipment_page() {
<tbody> <tbody>
<?php foreach ( $equipment_list as $item ) : ?> <?php foreach ( $equipment_list as $item ) : ?>
<?php <?php
$details_url = admin_url( 'admin.php?page=mystat-equipment-details&id=' . $item->id ); $details_url = admin_url( 'admin.php?page=statpress-equipment-details&id=' . $item->id );
?> ?>
<tr> <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> <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>
@@ -134,7 +134,7 @@ function mystat_equipment_page() {
<td> <td>
<a href="<?php echo esc_url( $details_url ); ?>" class="button button-small">Dziennik / Serwis</a> <a href="<?php echo esc_url( $details_url ); ?>" class="button button-small">Dziennik / Serwis</a>
<a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'id' => $item->id ) ) ); ?>" class="button button-small">Edytuj</a> <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'id' => $item->id ) ) ); ?>" class="button button-small">Edytuj</a>
<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'id' => $item->id ) ), 'mystat_delete_equipment_' . $item->id ) ); ?>" onclick="return confirm('Czy na pewno chcesz usunąć ten sprzęt?')" class="button button-small button-link-delete">Usuń</a> <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'id' => $item->id ) ), 'statpress_delete_equipment_' . $item->id ) ); ?>" onclick="return confirm('Czy na pewno chcesz usunąć ten sprzęt?')" class="button button-small button-link-delete">Usuń</a>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
@@ -147,7 +147,7 @@ function mystat_equipment_page() {
<?php <?php
} }
function mystat_equipment_details_page() { function statpress_equipment_details_page() {
global $wpdb; global $wpdb;
$equipment_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; $equipment_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0;
@@ -156,14 +156,14 @@ function mystat_equipment_details_page() {
return; return;
} }
$table_equipment = $wpdb->prefix . 'mystat_equipment'; $table_equipment = $wpdb->prefix . 'statpress_equipment';
$table_equipment_log = $wpdb->prefix . 'mystat_equipment_log'; $table_equipment_log = $wpdb->prefix . 'statpress_equipment_log';
$table_activities = $wpdb->prefix . 'mystat_activities'; $table_activities = $wpdb->prefix . 'statpress_activities';
$message = ''; $message = '';
$notice_class = ''; $notice_class = '';
// --- Handle Service Log form submissions (add/update/delete) --- // --- Handle Service Log form submissions (add/update/delete) ---
if ( isset( $_POST['submit_log'] ) && check_admin_referer( 'mystat_manage_equipment_log' ) ) { if ( isset( $_POST['submit_log'] ) && check_admin_referer( 'statpress_manage_equipment_log' ) ) {
$log_id = isset( $_POST['log_id'] ) ? intval( $_POST['log_id'] ) : 0; $log_id = isset( $_POST['log_id'] ) ? intval( $_POST['log_id'] ) : 0;
$log_data = array( $log_data = array(
'equipment_id' => $equipment_id, 'equipment_id' => $equipment_id,
@@ -190,7 +190,7 @@ function mystat_equipment_details_page() {
} }
if ( isset( $_GET['action'], $_GET['log_id'], $_GET['_wpnonce'] ) && 'delete_log' === $_GET['action'] ) { if ( isset( $_GET['action'], $_GET['log_id'], $_GET['_wpnonce'] ) && 'delete_log' === $_GET['action'] ) {
if ( wp_verify_nonce( $_GET['_wpnonce'], 'mystat_delete_log_' . $_GET['log_id'] ) ) { if ( wp_verify_nonce( $_GET['_wpnonce'], 'statpress_delete_log_' . $_GET['log_id'] ) ) {
$wpdb->delete( $table_equipment_log, array( 'id' => intval( $_GET['log_id'] ) ) ); $wpdb->delete( $table_equipment_log, array( 'id' => intval( $_GET['log_id'] ) ) );
$message = 'Wpis z dziennika usunięty.'; $message = 'Wpis z dziennika usunięty.';
$notice_class = 'notice-success'; $notice_class = 'notice-success';
@@ -217,7 +217,7 @@ function mystat_equipment_details_page() {
?> ?>
<div class="wrap"> <div class="wrap">
<h1>Dziennik serwisowy: <?php echo esc_html( $equipment->name ); ?></h1> <h1>Dziennik serwisowy: <?php echo esc_html( $equipment->name ); ?></h1>
<p><a href="<?php echo esc_url( admin_url( 'admin.php?page=mystat-equipment' ) ); ?>">&larr; Powrót do listy sprzętu</a></p> <p><a href="<?php echo esc_url( admin_url( 'admin.php?page=statpress-equipment' ) ); ?>">&larr; Powrót do listy sprzętu</a></p>
<?php if ( ! empty( $message ) ) : ?> <?php if ( ! empty( $message ) ) : ?>
<div class="notice <?php echo esc_attr( $notice_class ); ?> is-dismissible"><p><?php echo esc_html( $message ); ?></p></div> <div class="notice <?php echo esc_attr( $notice_class ); ?> is-dismissible"><p><?php echo esc_html( $message ); ?></p></div>
@@ -246,7 +246,7 @@ function mystat_equipment_details_page() {
<h2><?php echo $log_to_edit ? 'Edytuj wpis' : 'Dodaj wpis do dziennika'; ?></h2> <h2><?php echo $log_to_edit ? 'Edytuj wpis' : 'Dodaj wpis do dziennika'; ?></h2>
<form method="post"> <form method="post">
<input type="hidden" name="log_id" value="<?php echo $log_to_edit ? esc_attr( $log_to_edit->id ) : '0'; ?>"> <input type="hidden" name="log_id" value="<?php echo $log_to_edit ? esc_attr( $log_to_edit->id ) : '0'; ?>">
<?php wp_nonce_field( 'mystat_manage_equipment_log' ); ?> <?php wp_nonce_field( 'statpress_manage_equipment_log' ); ?>
<div class="form-field form-required"><label for="log_date">Data</label><input type="date" name="log_date" id="log_date" value="<?php echo $log_to_edit ? esc_attr( $log_to_edit->log_date ) : current_time( 'Y-m-d' ); ?>" required></div> <div class="form-field form-required"><label for="log_date">Data</label><input type="date" name="log_date" id="log_date" value="<?php echo $log_to_edit ? esc_attr( $log_to_edit->log_date ) : current_time( 'Y-m-d' ); ?>" required></div>
<div class="form-field form-required"><label for="log_type">Typ</label><select name="log_type" id="log_type" required><?php foreach ( $log_types as $type ) : ?><option value="<?php echo esc_attr( $type ); ?>" <?php if ( $log_to_edit ) { <div class="form-field form-required"><label for="log_type">Typ</label><select name="log_type" id="log_type" required><?php foreach ( $log_types as $type ) : ?><option value="<?php echo esc_attr( $type ); ?>" <?php if ( $log_to_edit ) {
selected( $log_to_edit->log_type, $type );} ?>><?php echo esc_html( $type ); ?></option><?php endforeach; ?></select></div> selected( $log_to_edit->log_type, $type );} ?>><?php echo esc_html( $type ); ?></option><?php endforeach; ?></select></div>
@@ -282,7 +282,7 @@ function mystat_equipment_details_page() {
<td><?php echo $log->mileage ? number_format( $log->mileage, 0, '', ' ' ) . ' km' : '-'; ?></td> <td><?php echo $log->mileage ? number_format( $log->mileage, 0, '', ' ' ) . ' km' : '-'; ?></td>
<td> <td>
<a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit_log', 'log_id' => $log->id ) ) ); ?>">Edytuj</a> | <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit_log', 'log_id' => $log->id ) ) ); ?>">Edytuj</a> |
<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete_log', 'log_id' => $log->id ) ), 'mystat_delete_log_' . $log->id ) ); ?>" onclick="return confirm('Czy na pewno chcesz usunąć ten wpis?')" style="color: #a00;">Usuń</a> <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete_log', 'log_id' => $log->id ) ), 'statpress_delete_log_' . $log->id ) ); ?>" onclick="return confirm('Czy na pewno chcesz usunąć ten wpis?')" style="color: #a00;">Usuń</a>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
+6 -6
View File
@@ -3,14 +3,14 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
function mystat_event_types_page() { function statpress_event_types_page() {
global $wpdb; global $wpdb;
$table_event_types = $wpdb->prefix . 'mystat_event_types'; $table_event_types = $wpdb->prefix . 'statpress_event_types';
$message = ''; $message = '';
$notice_class = ''; $notice_class = '';
// Handle POST requests (add/update) // Handle POST requests (add/update)
if ( isset( $_POST['submit'] ) && check_admin_referer( 'mystat_manage_event_type' ) ) { if ( isset( $_POST['submit'] ) && check_admin_referer( 'statpress_manage_event_type' ) ) {
$name = sanitize_text_field( $_POST['event_type_name'] ); $name = sanitize_text_field( $_POST['event_type_name'] );
$type_id = isset( $_POST['event_type_id'] ) ? intval( $_POST['event_type_id'] ) : 0; $type_id = isset( $_POST['event_type_id'] ) ? intval( $_POST['event_type_id'] ) : 0;
@@ -32,7 +32,7 @@ function mystat_event_types_page() {
// Handle GET requests (delete) // Handle GET requests (delete)
if ( isset( $_GET['action'], $_GET['id'], $_GET['_wpnonce'] ) && 'delete' === $_GET['action'] ) { if ( isset( $_GET['action'], $_GET['id'], $_GET['_wpnonce'] ) && 'delete' === $_GET['action'] ) {
if ( wp_verify_nonce( $_GET['_wpnonce'], 'mystat_delete_event_type_' . $_GET['id'] ) ) { if ( wp_verify_nonce( $_GET['_wpnonce'], 'statpress_delete_event_type_' . $_GET['id'] ) ) {
$wpdb->delete( $table_event_types, array( 'id' => intval( $_GET['id'] ) ) ); $wpdb->delete( $table_event_types, array( 'id' => intval( $_GET['id'] ) ) );
$message = 'Typ wydarzenia usunięty.'; $message = 'Typ wydarzenia usunięty.';
$notice_class = 'notice-success'; $notice_class = 'notice-success';
@@ -60,7 +60,7 @@ function mystat_event_types_page() {
<h2><?php echo $item_to_edit ? 'Edytuj typ wydarzenia' : 'Dodaj nowy typ wydarzenia'; ?></h2> <h2><?php echo $item_to_edit ? 'Edytuj typ wydarzenia' : 'Dodaj nowy typ wydarzenia'; ?></h2>
<form method="post"> <form method="post">
<input type="hidden" name="event_type_id" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->id ) : '0'; ?>"> <input type="hidden" name="event_type_id" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->id ) : '0'; ?>">
<?php wp_nonce_field( 'mystat_manage_event_type' ); ?> <?php wp_nonce_field( 'statpress_manage_event_type' ); ?>
<div class="form-field"> <div class="form-field">
<label for="event_type_name">Nazwa</label> <label for="event_type_name">Nazwa</label>
<input type="text" name="event_type_name" id="event_type_name" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->name ) : ''; ?>" required> <input type="text" name="event_type_name" id="event_type_name" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->name ) : ''; ?>" required>
@@ -76,7 +76,7 @@ function mystat_event_types_page() {
<thead><tr><th>Nazwa</th><th style="width: 100px;">Akcje</th></tr></thead> <thead><tr><th>Nazwa</th><th style="width: 100px;">Akcje</th></tr></thead>
<tbody> <tbody>
<?php foreach ( $event_types as $type ) : ?> <?php foreach ( $event_types as $type ) : ?>
<tr><td><?php echo esc_html( $type->name ); ?></td><td><a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'id' => $type->id ) ) ); ?>">Edytuj</a> | <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'id' => $type->id ) ), 'mystat_delete_event_type_' . $type->id ) ); ?>" onclick="return confirm('Czy na pewno chcesz usunąć ten typ?')" style="color: #a00;">Usuń</a></td></tr> <tr><td><?php echo esc_html( $type->name ); ?></td><td><a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'id' => $type->id ) ) ); ?>">Edytuj</a> | <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'id' => $type->id ) ), 'statpress_delete_event_type_' . $type->id ) ); ?>" onclick="return confirm('Czy na pewno chcesz usunąć ten typ?')" style="color: #a00;">Usuń</a></td></tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
+14 -14
View File
@@ -9,9 +9,9 @@ if ( ! defined( 'ABSPATH' ) ) {
* @param object $goal The goal object from the database. * @param object $goal The goal object from the database.
* @return array An array containing 'current_value' and 'percentage'. * @return array An array containing 'current_value' and 'percentage'.
*/ */
function mystat_get_goal_progress( $goal ) { function statpress_get_goal_progress( $goal ) {
global $wpdb; global $wpdb;
$table_activities = $wpdb->prefix . 'mystat_activities'; $table_activities = $wpdb->prefix . 'statpress_activities';
$sql_select = ''; $sql_select = '';
switch ( $goal->goal_type ) { switch ( $goal->goal_type ) {
@@ -52,15 +52,15 @@ function mystat_get_goal_progress( $goal ) {
); );
} }
function mystat_goals_page() { function statpress_goals_page() {
global $wpdb; global $wpdb;
$table_goals = $wpdb->prefix . 'mystat_goals'; $table_goals = $wpdb->prefix . 'statpress_goals';
$table_categories = $wpdb->prefix . 'mystat_categories'; $table_categories = $wpdb->prefix . 'statpress_categories';
$message = ''; $message = '';
$notice_class = ''; $notice_class = '';
// Handle POST requests (add/update) // Handle POST requests (add/update)
if ( isset( $_POST['submit'] ) && check_admin_referer( 'mystat_manage_goal' ) ) { if ( isset( $_POST['submit'] ) && check_admin_referer( 'statpress_manage_goal' ) ) {
$goal_id = isset( $_POST['goal_id'] ) ? intval( $_POST['goal_id'] ) : 0; $goal_id = isset( $_POST['goal_id'] ) ? intval( $_POST['goal_id'] ) : 0;
// Convert hours to seconds for duration goal type before saving // Convert hours to seconds for duration goal type before saving
@@ -96,7 +96,7 @@ function mystat_goals_page() {
// Handle GET requests (delete) // Handle GET requests (delete)
if ( isset( $_GET['action'], $_GET['id'], $_GET['_wpnonce'] ) && 'delete' === $_GET['action'] ) { if ( isset( $_GET['action'], $_GET['id'], $_GET['_wpnonce'] ) && 'delete' === $_GET['action'] ) {
if ( wp_verify_nonce( $_GET['_wpnonce'], 'mystat_delete_goal_' . $_GET['id'] ) ) { if ( wp_verify_nonce( $_GET['_wpnonce'], 'statpress_delete_goal_' . $_GET['id'] ) ) {
$wpdb->delete( $table_goals, array( 'id' => intval( $_GET['id'] ) ) ); $wpdb->delete( $table_goals, array( 'id' => intval( $_GET['id'] ) ) );
$message = 'Cel usunięty.'; $message = 'Cel usunięty.';
$notice_class = 'notice-success'; $notice_class = 'notice-success';
@@ -125,7 +125,7 @@ function mystat_goals_page() {
<h2><?php echo $item_to_edit ? 'Edytuj cel' : 'Dodaj nowy cel'; ?></h2> <h2><?php echo $item_to_edit ? 'Edytuj cel' : 'Dodaj nowy cel'; ?></h2>
<form method="post"> <form method="post">
<input type="hidden" name="goal_id" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->id ) : '0'; ?>"> <input type="hidden" name="goal_id" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->id ) : '0'; ?>">
<?php wp_nonce_field( 'mystat_manage_goal' ); ?> <?php wp_nonce_field( 'statpress_manage_goal' ); ?>
<div class="form-field form-required"><label for="goal_name">Nazwa celu</label><input type="text" name="goal_name" id="goal_name" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->name ) : ''; ?>" required></div> <div class="form-field form-required"><label for="goal_name">Nazwa celu</label><input type="text" name="goal_name" id="goal_name" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->name ) : ''; ?>" required></div>
<div class="form-field form-required"><label for="goal_type">Typ celu</label><select name="goal_type" id="goal_type" required><option value="distance" <?php if ( $item_to_edit ) { selected( $item_to_edit->goal_type, 'distance' ); } ?>>Dystans (km)</option><option value="duration_sec" <?php if ( $item_to_edit ) { selected( $item_to_edit->goal_type, 'duration_sec' ); } ?>>Czas (w godzinach)</option><option value="count" <?php if ( $item_to_edit ) { selected( $item_to_edit->goal_type, 'count' ); } ?>>Liczba aktywności</option></select></div> <div class="form-field form-required"><label for="goal_type">Typ celu</label><select name="goal_type" id="goal_type" required><option value="distance" <?php if ( $item_to_edit ) { selected( $item_to_edit->goal_type, 'distance' ); } ?>>Dystans (km)</option><option value="duration_sec" <?php if ( $item_to_edit ) { selected( $item_to_edit->goal_type, 'duration_sec' ); } ?>>Czas (w godzinach)</option><option value="count" <?php if ( $item_to_edit ) { selected( $item_to_edit->goal_type, 'count' ); } ?>>Liczba aktywności</option></select></div>
<div class="form-field form-required"><label for="target_value">Wartość docelowa</label><input type="text" name="target_value" id="target_value" value="<?php echo $item_to_edit ? esc_attr( 'duration_sec' === $item_to_edit->goal_type ? $item_to_edit->target_value / 3600 : $item_to_edit->target_value ) : ''; ?>" required><p>Dla czasu podaj wartość w godzinach (np. 100.5).</p></div> <div class="form-field form-required"><label for="target_value">Wartość docelowa</label><input type="text" name="target_value" id="target_value" value="<?php echo $item_to_edit ? esc_attr( 'duration_sec' === $item_to_edit->goal_type ? $item_to_edit->target_value / 3600 : $item_to_edit->target_value ) : ''; ?>" required><p>Dla czasu podaj wartość w godzinach (np. 100.5).</p></div>
@@ -147,7 +147,7 @@ function mystat_goals_page() {
<?php else : ?> <?php else : ?>
<?php foreach ( $goals as $goal ) : ?> <?php foreach ( $goals as $goal ) : ?>
<?php <?php
$progress = mystat_get_goal_progress( $goal ); $progress = statpress_get_goal_progress( $goal );
$percentage = min( 100, $progress['percentage'] ); $percentage = min( 100, $progress['percentage'] );
$target_formatted = ''; $target_formatted = '';
@@ -173,14 +173,14 @@ function mystat_goals_page() {
</small> </small>
</td> </td>
<td> <td>
<div class="mystat-progress-bar-container"> <div class="statpress-progress-bar-container">
<div class="mystat-progress-bar" style="width: <?php echo esc_attr( $percentage ); ?>%;"></div> <div class="statpress-progress-bar" style="width: <?php echo esc_attr( $percentage ); ?>%;"></div>
</div> </div>
<small><?php echo $current_formatted; ?> z <?php echo $target_formatted; ?> (<?php echo round( $percentage, 1 ); ?>%)</small> <small><?php echo $current_formatted; ?> z <?php echo $target_formatted; ?> (<?php echo round( $percentage, 1 ); ?>%)</small>
</td> </td>
<td> <td>
<a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'id' => $goal->id ) ) ); ?>">Edytuj</a> | <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'id' => $goal->id ) ) ); ?>">Edytuj</a> |
<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'id' => $goal->id ) ), 'mystat_delete_goal_' . $goal->id ) ); ?>" onclick="return confirm('Czy na pewno chcesz usunąć ten cel?')" style="color: #a00;">Usuń</a> <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'id' => $goal->id ) ), 'statpress_delete_goal_' . $goal->id ) ); ?>" onclick="return confirm('Czy na pewno chcesz usunąć ten cel?')" style="color: #a00;">Usuń</a>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
@@ -192,8 +192,8 @@ function mystat_goals_page() {
</div> </div>
</div> </div>
<style> <style>
.mystat-progress-bar-container { background: #eee; border-radius: 4px; height: 12px; width: 100%; overflow: hidden; margin-bottom: 4px; } .statpress-progress-bar-container { background: #eee; border-radius: 4px; height: 12px; width: 100%; overflow: hidden; margin-bottom: 4px; }
.mystat-progress-bar { background: #3498db; height: 100%; border-radius: 4px; transition: width 0.5s ease-in-out; } .statpress-progress-bar { background: #3498db; height: 100%; border-radius: 4px; transition: width 0.5s ease-in-out; }
</style> </style>
<?php <?php
} }
+18 -18
View File
@@ -3,12 +3,12 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
function mystat_import_csv_page() { function statpress_import_csv_page() {
echo '<div class="wrap"><h1>Importuj aktywności z pliku CSV</h1>'; echo '<div class="wrap"><h1>Importuj aktywności z pliku CSV</h1>';
// Handle the form submission // Handle the form submission
if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['mystat_csv_import_nonce_field'] ) ) { if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['statpress_csv_import_nonce_field'] ) ) {
mystat_handle_csv_import(); statpress_handle_csv_import();
} }
// Display the form // Display the form
@@ -28,15 +28,15 @@ function mystat_import_csv_page() {
</p> </p>
<hr> <hr>
<form method="post" enctype="multipart/form-data"> <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"> <table class="form-table">
<tr valign="top"> <tr valign="top">
<th scope="row"><label for="mystat_csv_file">Opcja 1: Wgraj plik CSV</label></th> <th scope="row"><label for="statpress_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> <td><input type="file" id="statpress_csv_file" name="statpress_csv_file" accept=".csv,text/csv" /></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<th scope="row"><label for="mystat_csv_data">Opcja 2: Wklej dane CSV</label></th> <th scope="row"><label for="statpress_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> <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> </tr>
</table> </table>
<?php submit_button( 'Importuj' ); ?> <?php submit_button( 'Importuj' ); ?>
@@ -47,10 +47,10 @@ function mystat_import_csv_page() {
echo '</div>'; echo '</div>';
} }
function mystat_handle_csv_import() { function statpress_handle_csv_import() {
global $wpdb; 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>'; echo '<div class="notice notice-error"><p>Błąd weryfikacji bezpieczeństwa.</p></div>';
return; return;
} }
@@ -62,10 +62,10 @@ function mystat_handle_csv_import() {
// Unify input source: prefer textarea, fall back to file upload. // Unify input source: prefer textarea, fall back to file upload.
$csv_content = ''; $csv_content = '';
if ( ! empty( $_POST['mystat_csv_data'] ) ) { if ( ! empty( $_POST['statpress_csv_data'] ) ) {
$csv_content = stripslashes( $_POST['mystat_csv_data'] ); $csv_content = stripslashes( $_POST['statpress_csv_data'] );
} elseif ( ! empty( $_FILES['mystat_csv_file']['tmp_name'] ) && UPLOAD_ERR_OK === $_FILES['mystat_csv_file']['error'] ) { } elseif ( ! empty( $_FILES['statpress_csv_file']['tmp_name'] ) && UPLOAD_ERR_OK === $_FILES['statpress_csv_file']['error'] ) {
$csv_content = file_get_contents( $_FILES['mystat_csv_file']['tmp_name'] ); $csv_content = file_get_contents( $_FILES['statpress_csv_file']['tmp_name'] );
} }
if ( empty( trim( $csv_content ) ) ) { if ( empty( trim( $csv_content ) ) ) {
@@ -120,9 +120,9 @@ function mystat_handle_csv_import() {
); );
// --- START: Robust, case-insensitive lookup --- // --- START: Robust, case-insensitive lookup ---
$table_categories = $wpdb->prefix . 'mystat_categories'; $table_categories = $wpdb->prefix . 'statpress_categories';
$table_event_types = $wpdb->prefix . 'mystat_event_types'; $table_event_types = $wpdb->prefix . 'statpress_event_types';
$table_equipment = $wpdb->prefix . 'mystat_equipment'; $table_equipment = $wpdb->prefix . 'statpress_equipment';
$create_lookup = function( $table_name ) use ( $wpdb ) { $create_lookup = function( $table_name ) use ( $wpdb ) {
$items = $wpdb->get_results( "SELECT id, name FROM {$table_name}" ); $items = $wpdb->get_results( "SELECT id, name FROM {$table_name}" );
@@ -143,7 +143,7 @@ function mystat_handle_csv_import() {
// --- END: Robust, case-insensitive lookup --- // --- END: Robust, case-insensitive lookup ---
// Process the CSV file // Process the CSV file
$table_activities = $wpdb->prefix . 'mystat_activities'; $table_activities = $wpdb->prefix . 'statpress_activities';
$imported_count = 0; $imported_count = 0;
$skipped_details = array(); $skipped_details = array();
$row_number = 1; // Header is row 1 $row_number = 1; // Header is row 1
+19 -19
View File
@@ -3,10 +3,10 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
function mystat_infographic_page() { function statpress_infographic_page() {
global $wpdb; global $wpdb;
$table_activities = $wpdb->prefix . 'mystat_activities'; $table_activities = $wpdb->prefix . 'statpress_activities';
$table_categories = $wpdb->prefix . 'mystat_categories'; $table_categories = $wpdb->prefix . 'statpress_categories';
$current_year = isset( $_GET['year'] ) ? intval( $_GET['year'] ) : current_time( 'Y' ); $current_year = isset( $_GET['year'] ) ? intval( $_GET['year'] ) : current_time( 'Y' );
@@ -71,13 +71,13 @@ function mystat_infographic_page() {
// Włączenie skryptów dla Chart.js // Włączenie skryptów dla Chart.js
wp_enqueue_script( 'chart-js', 'https://cdn.jsdelivr.net/npm/chart.js', array(), null, true ); wp_enqueue_script( 'chart-js', 'https://cdn.jsdelivr.net/npm/chart.js', array(), null, true );
wp_register_script( 'mystat-infographic-chart-loader', false ); wp_register_script( 'statpress-infographic-chart-loader', false );
wp_enqueue_script( 'mystat-infographic-chart-loader' ); wp_enqueue_script( 'statpress-infographic-chart-loader' );
wp_add_inline_script( wp_add_inline_script(
'mystat-infographic-chart-loader', 'statpress-infographic-chart-loader',
' '
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
const ctx = document.getElementById("mystatCategoryPieChart"); const ctx = document.getElementById("statpressCategoryPieChart");
if (!ctx) return; if (!ctx) return;
new Chart(ctx, { new Chart(ctx, {
type: "pie", type: "pie",
@@ -114,7 +114,7 @@ function mystat_infographic_page() {
<div class="tablenav top"> <div class="tablenav top">
<div class="alignleft actions"> <div class="alignleft actions">
<form method="get" style="display: flex; gap: 5px; align-items: center;"> <form method="get" style="display: flex; gap: 5px; align-items: center;">
<input type="hidden" name="page" value="mystat-infographic"> <input type="hidden" name="page" value="statpress-infographic">
<label for="filter-by-year" class="screen-reader-text">Filtruj według roku</label> <label for="filter-by-year" class="screen-reader-text">Filtruj według roku</label>
<select name="year" id="filter-by-year"> <select name="year" id="filter-by-year">
<?php foreach ( $available_years as $year_option ) : ?> <?php foreach ( $available_years as $year_option ) : ?>
@@ -128,21 +128,21 @@ function mystat_infographic_page() {
<div class="postbox" style="margin-bottom: 20px;"> <div class="postbox" style="margin-bottom: 20px;">
<div class="postbox-header"><h2 class="hndle">Statystyki Ogólne (wszystkie lata)</h2></div> <div class="postbox-header"><h2 class="hndle">Statystyki Ogólne (wszystkie lata)</h2></div>
<div class="inside mystat-infographic-grid"> <div class="inside statpress-infographic-grid">
<div class="mystat-infographic-card"><h3>Dystans</h3><p><?php echo number_format( $overall_stats->total_distance, 2, ',', ' ' ); ?> km</p></div> <div class="statpress-infographic-card"><h3>Dystans</h3><p><?php echo number_format( $overall_stats->total_distance, 2, ',', ' ' ); ?> km</p></div>
<div class="mystat-infographic-card"><h3>Czas</h3><p><?php echo esc_html( $overall_stats->total_duration ); ?></p></div> <div class="statpress-infographic-card"><h3>Czas</h3><p><?php echo esc_html( $overall_stats->total_duration ); ?></p></div>
<div class="mystat-infographic-card"><h3>Wznios</h3><p><?php echo number_format( $overall_stats->total_elevation_gain, 0, ',', ' ' ); ?> m</p></div> <div class="statpress-infographic-card"><h3>Wznios</h3><p><?php echo number_format( $overall_stats->total_elevation_gain, 0, ',', ' ' ); ?> m</p></div>
<div class="mystat-infographic-card"><h3>Aktywności</h3><p><?php echo number_format( $overall_stats->total_activities, 0, ',', ' ' ); ?></p></div> <div class="statpress-infographic-card"><h3>Aktywności</h3><p><?php echo number_format( $overall_stats->total_activities, 0, ',', ' ' ); ?></p></div>
</div> </div>
</div> </div>
<div class="postbox" style="margin-bottom: 20px;"> <div class="postbox" style="margin-bottom: 20px;">
<div class="postbox-header"><h2 class="hndle">Statystyki dla <?php echo esc_html( $current_year ); ?></h2></div> <div class="postbox-header"><h2 class="hndle">Statystyki dla <?php echo esc_html( $current_year ); ?></h2></div>
<div class="inside mystat-infographic-grid"> <div class="inside statpress-infographic-grid">
<div class="mystat-infographic-card"><h3>Dystans</h3><p><?php echo number_format( $yearly_stats->total_distance, 2, ',', ' ' ); ?> km</p></div> <div class="statpress-infographic-card"><h3>Dystans</h3><p><?php echo number_format( $yearly_stats->total_distance, 2, ',', ' ' ); ?> km</p></div>
<div class="mystat-infographic-card"><h3>Czas</h3><p><?php echo esc_html( $yearly_stats->total_duration ); ?></p></div> <div class="statpress-infographic-card"><h3>Czas</h3><p><?php echo esc_html( $yearly_stats->total_duration ); ?></p></div>
<div class="mystat-infographic-card"><h3>Wznios</h3><p><?php echo number_format( $yearly_stats->total_elevation_gain, 0, ',', ' ' ); ?> m</p></div> <div class="statpress-infographic-card"><h3>Wznios</h3><p><?php echo number_format( $yearly_stats->total_elevation_gain, 0, ',', ' ' ); ?> m</p></div>
<div class="mystat-infographic-card"><h3>Aktywności</h3><p><?php echo number_format( $yearly_stats->total_activities, 0, ',', ' ' ); ?></p></div> <div class="statpress-infographic-card"><h3>Aktywności</h3><p><?php echo number_format( $yearly_stats->total_activities, 0, ',', ' ' ); ?></p></div>
</div> </div>
</div> </div>
@@ -150,7 +150,7 @@ function mystat_infographic_page() {
<div class="postbox-header"><h2 class="hndle">Rozkład Dystansu wg Kategorii w <?php echo esc_html( $current_year ); ?></h2></div> <div class="postbox-header"><h2 class="hndle">Rozkład Dystansu wg Kategorii w <?php echo esc_html( $current_year ); ?></h2></div>
<div class="inside"> <div class="inside">
<div style="position: relative; height:40vh; width:100%; max-width: 600px; margin: 0 auto;"> <div style="position: relative; height:40vh; width:100%; max-width: 600px; margin: 0 auto;">
<canvas id="mystatCategoryPieChart"></canvas> <canvas id="statpressCategoryPieChart"></canvas>
</div> </div>
</div> </div>
</div> </div>
+50 -50
View File
@@ -3,16 +3,16 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
function mystat_settings_page() { function statpress_settings_page() {
?> ?>
<div class="wrap"> <div class="wrap">
<h1>Ustawienia Wtyczki Statystyk</h1> <h1>Ustawienia Wtyczki Statystyk</h1>
<form method="post" action="options.php"> <form method="post" action="options.php">
<?php <?php
settings_fields( 'mystat_privacy_settings' ); settings_fields( 'statpress_privacy_settings' );
do_settings_sections( 'mystat-privacy-section' ); do_settings_sections( 'statpress-privacy-section' );
settings_fields( 'mystat_api_settings' ); settings_fields( 'statpress_api_settings' );
do_settings_sections( 'mystat-api-section' ); do_settings_sections( 'statpress-api-section' );
submit_button(); submit_button();
?> ?>
</form> </form>
@@ -20,91 +20,91 @@ function mystat_settings_page() {
<?php <?php
} }
function mystat_register_settings() { function statpress_register_settings() {
register_setting( register_setting(
'mystat_privacy_settings', 'statpress_privacy_settings',
'mystat_privacy_options', 'statpress_privacy_options',
'mystat_sanitize_privacy_options' 'statpress_sanitize_privacy_options'
); );
add_settings_section( add_settings_section(
'mystat_privacy_zone_section', 'statpress_privacy_zone_section',
'Strefa Prywatności GPX', 'Strefa Prywatności GPX',
'mystat_privacy_section_callback', 'statpress_privacy_section_callback',
'mystat-privacy-section' 'statpress-privacy-section'
); );
add_settings_field( add_settings_field(
'mystat_privacy_latitude', 'statpress_privacy_latitude',
'Szerokość geograficzna (Latitude)', 'Szerokość geograficzna (Latitude)',
'mystat_render_lat_field', 'statpress_render_lat_field',
'mystat-privacy-section', 'statpress-privacy-section',
'mystat_privacy_zone_section' 'statpress_privacy_zone_section'
); );
add_settings_field( add_settings_field(
'mystat_privacy_longitude', 'statpress_privacy_longitude',
'Długość geograficzna (Longitude)', 'Długość geograficzna (Longitude)',
'mystat_render_lon_field', 'statpress_render_lon_field',
'mystat-privacy-section', 'statpress-privacy-section',
'mystat_privacy_zone_section' 'statpress_privacy_zone_section'
); );
add_settings_field( add_settings_field(
'mystat_privacy_radius', 'statpress_privacy_radius',
'Promień strefy (w metrach)', 'Promień strefy (w metrach)',
'mystat_render_radius_field', 'statpress_render_radius_field',
'mystat-privacy-section', 'statpress-privacy-section',
'mystat_privacy_zone_section' 'statpress_privacy_zone_section'
); );
// API Settings // API Settings
register_setting( register_setting(
'mystat_api_settings', 'statpress_api_settings',
'mystat_api_options', 'statpress_api_options',
'mystat_sanitize_api_options' 'statpress_sanitize_api_options'
); );
add_settings_section( add_settings_section(
'mystat_api_section', 'statpress_api_section',
'Ustawienia API', 'Ustawienia API',
'mystat_api_section_callback', 'statpress_api_section_callback',
'mystat-api-section' 'statpress-api-section'
); );
add_settings_field( add_settings_field(
'mystat_enable_api', 'statpress_enable_api',
'REST API', 'REST API',
'mystat_render_enable_api_field', 'statpress_render_enable_api_field',
'mystat-privacy-section', 'statpress-privacy-section',
'mystat_privacy_zone_section' 'statpress_privacy_zone_section'
); );
} }
function mystat_privacy_section_callback() { function statpress_privacy_section_callback() {
echo '<p>Zdefiniuj strefę prywatności, aby ukryć początek i koniec swoich tras GPX. Punkty wewnątrz tego okręgu nie będą wyświetlane na mapie.</p>'; echo '<p>Zdefiniuj strefę prywatności, aby ukryć początek i koniec swoich tras GPX. Punkty wewnątrz tego okręgu nie będą wyświetlane na mapie.</p>';
echo '<p>Aby znaleźć swoje współrzędne, kliknij prawym przyciskiem myszy na mapie Google w wybranym miejscu - współrzędne pojawią się jako pierwsza pozycja w menu.</p>'; echo '<p>Aby znaleźć swoje współrzędne, kliknij prawym przyciskiem myszy na mapie Google w wybranym miejscu - współrzędne pojawią się jako pierwsza pozycja w menu.</p>';
} }
function mystat_render_lat_field() { function statpress_render_lat_field() {
$options = get_option( 'mystat_privacy_options' ); $options = get_option( 'statpress_privacy_options' );
$latitude = isset( $options['latitude'] ) ? esc_attr( $options['latitude'] ) : ''; $latitude = isset( $options['latitude'] ) ? esc_attr( $options['latitude'] ) : '';
echo "<input type='text' name='mystat_privacy_options[latitude]' value='{$latitude}' placeholder='np. 52.2297' class='regular-text' />"; echo "<input type='text' name='statpress_privacy_options[latitude]' value='{$latitude}' placeholder='np. 52.2297' class='regular-text' />";
} }
function mystat_render_lon_field() { function statpress_render_lon_field() {
$options = get_option( 'mystat_privacy_options' ); $options = get_option( 'statpress_privacy_options' );
$longitude = isset( $options['longitude'] ) ? esc_attr( $options['longitude'] ) : ''; $longitude = isset( $options['longitude'] ) ? esc_attr( $options['longitude'] ) : '';
echo "<input type='text' name='mystat_privacy_options[longitude]' value='{$longitude}' placeholder='np. 21.0122' class='regular-text' />"; echo "<input type='text' name='statpress_privacy_options[longitude]' value='{$longitude}' placeholder='np. 21.0122' class='regular-text' />";
} }
function mystat_render_radius_field() { function statpress_render_radius_field() {
$options = get_option( 'mystat_privacy_options' ); $options = get_option( 'statpress_privacy_options' );
$radius = isset( $options['radius'] ) ? esc_attr( $options['radius'] ) : '500'; $radius = isset( $options['radius'] ) ? esc_attr( $options['radius'] ) : '500';
echo "<input type='number' name='mystat_privacy_options[radius]' value='{$radius}' class='small-text' /> metrów"; echo "<input type='number' name='statpress_privacy_options[radius]' value='{$radius}' class='small-text' /> metrów";
} }
function mystat_sanitize_privacy_options( $input ) { function statpress_sanitize_privacy_options( $input ) {
$sanitized_input = array(); $sanitized_input = array();
if ( isset( $input['latitude'] ) ) { if ( isset( $input['latitude'] ) ) {
$sanitized_input['latitude'] = floatval( str_replace( ',', '.', $input['latitude'] ) ); $sanitized_input['latitude'] = floatval( str_replace( ',', '.', $input['latitude'] ) );
@@ -118,18 +118,18 @@ function mystat_sanitize_privacy_options( $input ) {
return $sanitized_input; return $sanitized_input;
} }
function mystat_api_section_callback() { function statpress_api_section_callback() {
echo '<p>Ustawienia związane z integracją wtyczki z zewnętrznymi aplikacjami, np. mobilnymi.</p>'; echo '<p>Ustawienia związane z integracją wtyczki z zewnętrznymi aplikacjami, np. mobilnymi.</p>';
} }
function mystat_render_enable_api_field() { function statpress_render_enable_api_field() {
$options = get_option( 'mystat_api_options' ); $options = get_option( 'statpress_api_options' );
$checked = isset( $options['enable_api'] ) && $options['enable_api'] ? 'checked' : ''; $checked = isset( $options['enable_api'] ) && $options['enable_api'] ? 'checked' : '';
echo "<label><input type='checkbox' name='mystat_api_options[enable_api]' value='1' {$checked} /> Włącz REST API</label>"; echo "<label><input type='checkbox' name='statpress_api_options[enable_api]' value='1' {$checked} /> Włącz REST API</label>";
echo '<p class="description">Umożliwia zewnętrznym aplikacjom (np. na Androida) komunikację z wtyczką w celu dodawania i odczytywania aktywności. Jeśli nie korzystasz z takich integracji, możesz to wyłączyć dla większego bezpieczeństwa.</p>'; echo '<p class="description">Umożliwia zewnętrznym aplikacjom (np. na Androida) komunikację z wtyczką w celu dodawania i odczytywania aktywności. Jeśli nie korzystasz z takich integracji, możesz to wyłączyć dla większego bezpieczeństwa.</p>';
} }
function mystat_sanitize_api_options( $input ) { function statpress_sanitize_api_options( $input ) {
$sanitized_input = array(); $sanitized_input = array();
// If the checkbox is not checked, it won't be in the $input array. // If the checkbox is not checked, it won't be in the $input array.
// So we check for its existence to determine if it's on or off. // So we check for its existence to determine if it's on or off.
+17 -17
View File
@@ -3,9 +3,9 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
function mystat_yearly_summary_page() { function statpress_yearly_summary_page() {
global $wpdb; global $wpdb;
$table_activities = $wpdb->prefix . 'mystat_activities'; $table_activities = $wpdb->prefix . 'statpress_activities';
$current_year = isset( $_GET['year'] ) ? intval( $_GET['year'] ) : current_time( 'Y' ); $current_year = isset( $_GET['year'] ) ? intval( $_GET['year'] ) : current_time( 'Y' );
@@ -16,7 +16,7 @@ function mystat_yearly_summary_page() {
} }
// --- GOALS SECTION --- // --- GOALS SECTION ---
$table_goals = $wpdb->prefix . 'mystat_goals'; $table_goals = $wpdb->prefix . 'statpress_goals';
$goals_for_year = $wpdb->get_results( $goals_for_year = $wpdb->get_results(
$wpdb->prepare( $wpdb->prepare(
"SELECT * FROM {$table_goals} WHERE year = %d ORDER BY name ASC", "SELECT * FROM {$table_goals} WHERE year = %d ORDER BY name ASC",
@@ -103,8 +103,8 @@ function mystat_yearly_summary_page() {
// Włączenie skryptów dla Chart.js // Włączenie skryptów dla Chart.js
wp_enqueue_script( 'chart-js', 'https://cdn.jsdelivr.net/npm/chart.js', array(), null, true ); wp_enqueue_script( 'chart-js', 'https://cdn.jsdelivr.net/npm/chart.js', array(), null, true );
wp_register_script( 'mystat-chart-loader', false ); wp_register_script( 'statpress-chart-loader', false );
wp_enqueue_script( 'mystat-chart-loader' ); wp_enqueue_script( 'statpress-chart-loader' );
$chart_configs = array( $chart_configs = array(
'distance' => array( 'distance' => array(
@@ -138,7 +138,7 @@ function mystat_yearly_summary_page() {
); );
wp_add_inline_script( wp_add_inline_script(
'mystat-chart-loader', 'statpress-chart-loader',
' '
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
const chartLabels = ' . json_encode( $chart_labels_js ) . '; const chartLabels = ' . json_encode( $chart_labels_js ) . ';
@@ -162,7 +162,7 @@ function mystat_yearly_summary_page() {
activeChart.destroy(); activeChart.destroy();
} }
const config = chartConfigs[type]; const config = chartConfigs[type];
const ctx = document.getElementById("mystatYearlyChart").getContext("2d"); const ctx = document.getElementById("statpressYearlyChart").getContext("2d");
activeChart = new Chart(ctx, { activeChart = new Chart(ctx, {
type: "bar", type: "bar",
data: { data: {
@@ -198,7 +198,7 @@ function mystat_yearly_summary_page() {
<div class="alignleft actions"> <div class="alignleft actions">
<label for="filter-by-year" class="screen-reader-text">Filtruj według roku</label> <label for="filter-by-year" class="screen-reader-text">Filtruj według roku</label>
<form method="get" style="display: flex; gap: 5px; align-items: center;"> <form method="get" style="display: flex; gap: 5px; align-items: center;">
<input type="hidden" name="page" value="mystat-yearly-summary"> <input type="hidden" name="page" value="statpress-yearly-summary">
<select name="year" id="filter-by-year"> <select name="year" id="filter-by-year">
<?php foreach ( $available_years as $year_option ) : ?> <?php foreach ( $available_years as $year_option ) : ?>
<option value="<?php echo esc_attr( $year_option ); ?>" <?php selected( $current_year, $year_option ); ?>><?php echo esc_html( $year_option ); ?></option> <option value="<?php echo esc_attr( $year_option ); ?>" <?php selected( $current_year, $year_option ); ?>><?php echo esc_html( $year_option ); ?></option>
@@ -213,10 +213,10 @@ function mystat_yearly_summary_page() {
<div class="postbox" style="margin-bottom: 20px;"> <div class="postbox" style="margin-bottom: 20px;">
<div class="postbox-header"><h2 class="hndle">Cele na <?php echo esc_html( $current_year ); ?></h2></div> <div class="postbox-header"><h2 class="hndle">Cele na <?php echo esc_html( $current_year ); ?></h2></div>
<div class="inside"> <div class="inside">
<ul class="mystat-goals-list"> <ul class="statpress-goals-list">
<?php <?php
foreach ( $goals_for_year as $goal ) : foreach ( $goals_for_year as $goal ) :
$progress = mystat_get_goal_progress( $goal ); $progress = statpress_get_goal_progress( $goal );
$percentage = min( 100, $progress['percentage'] ); $percentage = min( 100, $progress['percentage'] );
$target_formatted = ''; $target_formatted = '';
@@ -232,13 +232,13 @@ function mystat_yearly_summary_page() {
$current_formatted = (int) $progress['current_value']; $current_formatted = (int) $progress['current_value'];
} }
?> ?>
<li class="mystat-goal-item"> <li class="statpress-goal-item">
<div class="mystat-goal-info"> <div class="statpress-goal-info">
<strong><?php echo esc_html( $goal->name ); ?></strong> <strong><?php echo esc_html( $goal->name ); ?></strong>
<small><?php echo $current_formatted; ?> / <?php echo $target_formatted; ?> (<?php echo round( $percentage, 1 ); ?>%)</small> <small><?php echo $current_formatted; ?> / <?php echo $target_formatted; ?> (<?php echo round( $percentage, 1 ); ?>%)</small>
</div> </div>
<div class="mystat-progress-bar-container"> <div class="statpress-progress-bar-container">
<div class="mystat-progress-bar" style="width: <?php echo esc_attr( $percentage ); ?>%;"></div> <div class="statpress-progress-bar" style="width: <?php echo esc_attr( $percentage ); ?>%;"></div>
</div> </div>
</li> </li>
<?php endforeach; ?> <?php endforeach; ?>
@@ -246,8 +246,8 @@ function mystat_yearly_summary_page() {
</div> </div>
</div> </div>
<style> <style>
.mystat-goals-list { list-style: none; margin: 0; padding: 0; } .mystat-goal-item { margin-bottom: 15px; } .mystat-goal-info { display: flex; justify-content: space-between; margin-bottom: 5px; } .statpress-goals-list { list-style: none; margin: 0; padding: 0; } .statpress-goal-item { margin-bottom: 15px; } .statpress-goal-info { display: flex; justify-content: space-between; margin-bottom: 5px; }
.mystat-progress-bar-container { background: #eee; border-radius: 4px; height: 18px; width: 100%; overflow: hidden; } .mystat-progress-bar { background: #3498db; height: 100%; border-radius: 4px; transition: width 0.5s ease-in-out; text-align: center; color: white; font-size: 11px; line-height: 18px; } .statpress-progress-bar-container { background: #eee; border-radius: 4px; height: 18px; width: 100%; overflow: hidden; } .statpress-progress-bar { background: #3498db; height: 100%; border-radius: 4px; transition: width 0.5s ease-in-out; text-align: center; color: white; font-size: 11px; line-height: 18px; }
</style> </style>
<?php endif; ?> <?php endif; ?>
@@ -261,7 +261,7 @@ function mystat_yearly_summary_page() {
<a href="#activities" class="nav-tab">Aktywności</a> <a href="#activities" class="nav-tab">Aktywności</a>
</nav> </nav>
<div style="position: relative; height:40vh; width:100%;"> <div style="position: relative; height:40vh; width:100%;">
<canvas id="mystatYearlyChart"></canvas> <canvas id="statpressYearlyChart"></canvas>
</div> </div>
</div> </div>
</div> </div>
+28 -28
View File
@@ -12,8 +12,8 @@ if ( ! defined( 'ABSPATH' ) ) {
/** /**
* Register REST API routes. * Register REST API routes.
*/ */
function mystat_register_rest_routes() { function statpress_register_rest_routes() {
$namespace = 'mystat/v1'; $namespace = 'statpress/v1';
// Route for getting a collection of activities // Route for getting a collection of activities
register_rest_route( register_rest_route(
@@ -22,8 +22,8 @@ function mystat_register_rest_routes() {
array( array(
array( array(
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => 'mystat_get_activities_api', 'callback' => 'statpress_get_activities_api',
'permission_callback' => 'mystat_api_permissions_check', 'permission_callback' => 'statpress_api_permissions_check',
'args' => array( 'args' => array(
'page' => array( 'page' => array(
'validate_callback' => 'is_numeric', 'validate_callback' => 'is_numeric',
@@ -35,8 +35,8 @@ function mystat_register_rest_routes() {
), ),
array( array(
'methods' => WP_REST_Server::CREATABLE, 'methods' => WP_REST_Server::CREATABLE,
'callback' => 'mystat_create_activity_api', 'callback' => 'statpress_create_activity_api',
'permission_callback' => 'mystat_api_permissions_check', 'permission_callback' => 'statpress_api_permissions_check',
), ),
) )
); );
@@ -48,18 +48,18 @@ function mystat_register_rest_routes() {
array( array(
array( array(
'methods' => WP_REST_Server::READABLE, 'methods' => WP_REST_Server::READABLE,
'callback' => 'mystat_get_activity_api', 'callback' => 'statpress_get_activity_api',
'permission_callback' => 'mystat_api_permissions_check', 'permission_callback' => 'statpress_api_permissions_check',
), ),
array( array(
'methods' => WP_REST_Server::EDITABLE, 'methods' => WP_REST_Server::EDITABLE,
'callback' => 'mystat_update_activity_api', 'callback' => 'statpress_update_activity_api',
'permission_callback' => 'mystat_api_permissions_check', 'permission_callback' => 'statpress_api_permissions_check',
), ),
array( array(
'methods' => WP_REST_Server::DELETABLE, 'methods' => WP_REST_Server::DELETABLE,
'callback' => 'mystat_delete_activity_api', 'callback' => 'statpress_delete_activity_api',
'permission_callback' => 'mystat_api_permissions_check', 'permission_callback' => 'statpress_api_permissions_check',
), ),
) )
); );
@@ -70,7 +70,7 @@ function mystat_register_rest_routes() {
* *
* @return bool * @return bool
*/ */
function mystat_api_permissions_check() { function statpress_api_permissions_check() {
return current_user_can( 'manage_options' ); return current_user_can( 'manage_options' );
} }
@@ -80,9 +80,9 @@ function mystat_api_permissions_check() {
* @param WP_REST_Request $request Full details about the request. * @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response|WP_Error * @return WP_REST_Response|WP_Error
*/ */
function mystat_get_activities_api( WP_REST_Request $request ) { function statpress_get_activities_api( WP_REST_Request $request ) {
global $wpdb; global $wpdb;
$table_activities = $wpdb->prefix . 'mystat_activities'; $table_activities = $wpdb->prefix . 'statpress_activities';
$per_page = $request->get_param( 'per_page' ) ? (int) $request->get_param( 'per_page' ) : 20; $per_page = $request->get_param( 'per_page' ) ? (int) $request->get_param( 'per_page' ) : 20;
$page = $request->get_param( 'page' ) ? (int) $request->get_param( 'page' ) : 1; $page = $request->get_param( 'page' ) ? (int) $request->get_param( 'page' ) : 1;
@@ -91,9 +91,9 @@ function mystat_get_activities_api( WP_REST_Request $request ) {
$sql = $wpdb->prepare( $sql = $wpdb->prepare(
"SELECT a.*, c.name as category_name, et.name as event_type_name, eq.name as equipment_name "SELECT a.*, c.name as category_name, et.name as event_type_name, eq.name as equipment_name
FROM $table_activities a FROM $table_activities a
LEFT JOIN {$wpdb->prefix}mystat_categories c ON a.category_id = c.id LEFT JOIN {$wpdb->prefix}statpress_categories c ON a.category_id = c.id
LEFT JOIN {$wpdb->prefix}mystat_event_types et ON a.event_type_id = et.id LEFT JOIN {$wpdb->prefix}statpress_event_types et ON a.event_type_id = et.id
LEFT JOIN {$wpdb->prefix}mystat_equipment eq ON a.equipment_id = eq.id LEFT JOIN {$wpdb->prefix}statpress_equipment eq ON a.equipment_id = eq.id
ORDER BY a.date DESC, a.id DESC ORDER BY a.date DESC, a.id DESC
LIMIT %d OFFSET %d", LIMIT %d OFFSET %d",
$per_page, $per_page,
@@ -111,11 +111,11 @@ function mystat_get_activities_api( WP_REST_Request $request ) {
* @param WP_REST_Request $request Full details about the request. * @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response|WP_Error * @return WP_REST_Response|WP_Error
*/ */
function mystat_get_activity_api( WP_REST_Request $request ) { function statpress_get_activity_api( WP_REST_Request $request ) {
global $wpdb; global $wpdb;
$id = (int) $request['id']; $id = (int) $request['id'];
$sql = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mystat_activities WHERE id = %d", $id ); $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}statpress_activities WHERE id = %d", $id );
$activity = $wpdb->get_row( $sql ); $activity = $wpdb->get_row( $sql );
if ( ! $activity ) { if ( ! $activity ) {
@@ -131,15 +131,15 @@ function mystat_get_activity_api( WP_REST_Request $request ) {
* @param WP_REST_Request $request Full details about the request. * @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response|WP_Error * @return WP_REST_Response|WP_Error
*/ */
function mystat_create_activity_api( WP_REST_Request $request ) { function statpress_create_activity_api( WP_REST_Request $request ) {
$params = $request->get_json_params(); $params = $request->get_json_params();
$activity_id = mystat_save_activity_data( $params ); $activity_id = statpress_save_activity_data( $params );
if ( ! $activity_id ) { if ( ! $activity_id ) {
return new WP_Error( 'cant-create', 'Error creating activity', array( 'status' => 500 ) ); return new WP_Error( 'cant-create', 'Error creating activity', array( 'status' => 500 ) );
} }
$response = mystat_get_activity_api( new WP_REST_Request( 'GET', "/mystat/v1/activities/{$activity_id}" ) ); $response = statpress_get_activity_api( new WP_REST_Request( 'GET', "/statpress/v1/activities/{$activity_id}" ) );
$response->set_status( 201 ); // 201 Created $response->set_status( 201 ); // 201 Created
return $response; return $response;
} }
@@ -150,16 +150,16 @@ function mystat_create_activity_api( WP_REST_Request $request ) {
* @param WP_REST_Request $request Full details about the request. * @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response|WP_Error * @return WP_REST_Response|WP_Error
*/ */
function mystat_update_activity_api( WP_REST_Request $request ) { function statpress_update_activity_api( WP_REST_Request $request ) {
$id = (int) $request['id']; $id = (int) $request['id'];
$params = $request->get_json_params(); $params = $request->get_json_params();
$activity_id = mystat_save_activity_data( $params, $id ); $activity_id = statpress_save_activity_data( $params, $id );
if ( ! $activity_id ) { if ( ! $activity_id ) {
return new WP_Error( 'cant-update', 'Error updating activity', array( 'status' => 500 ) ); return new WP_Error( 'cant-update', 'Error updating activity', array( 'status' => 500 ) );
} }
return mystat_get_activity_api( $request ); return statpress_get_activity_api( $request );
} }
/** /**
@@ -168,11 +168,11 @@ function mystat_update_activity_api( WP_REST_Request $request ) {
* @param WP_REST_Request $request Full details about the request. * @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response|WP_Error * @return WP_REST_Response|WP_Error
*/ */
function mystat_delete_activity_api( WP_REST_Request $request ) { function statpress_delete_activity_api( WP_REST_Request $request ) {
global $wpdb; global $wpdb;
$id = (int) $request['id']; $id = (int) $request['id'];
$result = $wpdb->delete( $wpdb->prefix . 'mystat_activities', array( 'id' => $id ), array( '%d' ) ); $result = $wpdb->delete( $wpdb->prefix . 'statpress_activities', array( 'id' => $id ), array( '%d' ) );
if ( ! $result ) { if ( ! $result ) {
return new WP_Error( 'cant-delete', 'Error deleting activity', array( 'status' => 500 ) ); return new WP_Error( 'cant-delete', 'Error deleting activity', array( 'status' => 500 ) );
+2 -2
View File
@@ -16,10 +16,10 @@ if ( ! defined( 'ABSPATH' ) ) {
* @param int $activity_id The ID of the activity to update. 0 for new activity. * @param int $activity_id The ID of the activity to update. 0 for new activity.
* @return int|false The ID of the saved/updated activity, or false on failure. * @return int|false The ID of the saved/updated activity, or false on failure.
*/ */
function mystat_save_activity_data( array $data, int $activity_id = 0 ) { function statpress_save_activity_data( array $data, int $activity_id = 0 ) {
global $wpdb; global $wpdb;
$table_activities = $wpdb->prefix . 'mystat_activities'; $table_activities = $wpdb->prefix . 'statpress_activities';
// Helper to convert empty strings to NULL for the database. // Helper to convert empty strings to NULL for the database.
$null_if_empty = function( $value ) { $null_if_empty = function( $value ) {
+2 -2
View File
@@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* @param string $gpx_url The URL of the GPX file. * @param string $gpx_url The URL of the GPX file.
* @return array An array containing 'points' for the map and 'elevation_profile'. * @return array An array containing 'points' for the map and 'elevation_profile'.
*/ */
function mystat_parse_gpx_data( $gpx_url ) { function statpress_parse_gpx_data( $gpx_url ) {
if ( empty( $gpx_url ) ) { if ( empty( $gpx_url ) ) {
return array(); return array();
} }
@@ -26,7 +26,7 @@ function mystat_parse_gpx_data( $gpx_url ) {
} }
// --- Privacy Zone --- // --- Privacy Zone ---
$privacy_options = get_option( 'mystat_privacy_options' ); $privacy_options = get_option( 'statpress_privacy_options' );
$privacy_enabled = ! empty( $privacy_options['latitude'] ) && ! empty( $privacy_options['longitude'] ) && ! empty( $privacy_options['radius'] ); $privacy_enabled = ! empty( $privacy_options['latitude'] ) && ! empty( $privacy_options['longitude'] ) && ! empty( $privacy_options['radius'] );
$privacy_center_lat = $privacy_enabled ? (float) $privacy_options['latitude'] : 0; $privacy_center_lat = $privacy_enabled ? (float) $privacy_options['latitude'] : 0;
$privacy_center_lon = $privacy_enabled ? (float) $privacy_options['longitude'] : 0; $privacy_center_lon = $privacy_enabled ? (float) $privacy_options['longitude'] : 0;
+2 -2
View File
@@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* @param array $mimes Allowed mime types. * @param array $mimes Allowed mime types.
* @return array Modified mime types. * @return array Modified mime types.
*/ */
function mystat_add_gpx_mime_type( $mimes ) { function statpress_add_gpx_mime_type( $mimes ) {
$mimes['gpx'] = 'application/gpx+xml'; $mimes['gpx'] = 'application/gpx+xml';
return $mimes; return $mimes;
} }
@@ -24,7 +24,7 @@ function mystat_add_gpx_mime_type( $mimes ) {
* @param array $mimes Mime types. * @param array $mimes Mime types.
* @return array Modified file data. * @return array Modified file data.
*/ */
function mystat_fix_gpx_upload_permission( $data, $file, $filename, $mimes ) { function statpress_fix_gpx_upload_permission( $data, $file, $filename, $mimes ) {
if ( strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) ) === 'gpx' ) { if ( strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) ) === 'gpx' ) {
$data['ext'] = 'gpx'; $data['ext'] = 'gpx';
$data['type'] = 'application/gpx+xml'; $data['type'] = 'application/gpx+xml';
+30 -33
View File
@@ -1,6 +1,6 @@
<?php <?php
/** /**
* Plugin Name: WordPress Activity Stats * Plugin Name: StatPress
* Description: Wtyczka do śledzenia statystyk sportowych (Rower, Bieganie, itp.). * Description: Wtyczka do śledzenia statystyk sportowych (Rower, Bieganie, itp.).
* Version: 1.0 * Version: 1.0
* Author: Jacek Fefliński * Author: Jacek Fefliński
@@ -11,48 +11,45 @@ if ( ! defined( 'ABSPATH' ) ) {
} }
// Definicja stałych // Definicja stałych
define( 'MYSTAT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'STATPRESS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'MYSTAT_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'STATPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// --- 1. PLIKI RDZENNE I AKTYWACJA --- // --- 1. PLIKI RDZENNE I AKTYWACJA ---
require_once MYSTAT_PLUGIN_DIR . 'includes/activation.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/activation.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/core/gpx-parser.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/core/gpx-parser.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/core/crud-activity.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/core/crud-activity.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/core/gpx-upload.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/core/gpx-upload.php';
register_activation_hook( __FILE__, 'mystat_activate' ); register_activation_hook( __FILE__, 'statpress_activate' );
// --- 2. PLIKI I HOOKI PANELU ADMINA --- // --- 2. PLIKI I HOOKI PANELU ADMINA ---
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/hooks.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/hooks.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/menu.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/menu.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/pages/page-dashboard.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/pages/page-dashboard.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/pages/page-activity-form.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/pages/page-activity-form.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/pages/page-activity-view.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/pages/page-activity-view.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/pages/page-event-types.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/pages/page-event-types.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/pages/page-equipment.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/pages/page-equipment.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/pages/page-goals.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/pages/page-goals.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/pages/page-settings.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/pages/page-settings.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/pages/page-yearly-summary.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/pages/page-yearly-summary.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/pages/page-infographic.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/pages/page-infographic.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/pages/page-import-csv.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/pages/page-import-csv.php';
add_action( 'admin_menu', 'statpress_add_admin_menu' );
$mystat_plugin_hooks = []; add_action( 'admin_init', 'statpress_admin_init_setup' );
add_action( 'admin_enqueue_scripts', 'statpress_enqueue_admin_styles' );
add_action( 'admin_menu', 'mystat_add_admin_menu' );
add_action( 'admin_init', 'mystat_admin_init_setup' );
add_action( 'admin_enqueue_scripts', 'mystat_enqueue_admin_styles' );
// --- 3. REST API --- // --- 3. REST API ---
$api_options = get_option( 'mystat_api_options' ); $api_options = get_option( 'statpress_api_options' );
if ( ! empty( $api_options['enable_api'] ) ) { if ( ! empty( $api_options['enable_api'] ) ) {
require_once MYSTAT_PLUGIN_DIR . 'includes/admin/pages/routes.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/admin/pages/routes.php';
add_action( 'rest_api_init', 'mystat_register_rest_routes' ); add_action( 'rest_api_init', 'statpress_register_rest_routes' );
} }
// --- 4. SHORTCODE DO WYŚWIETLANIA NA FRONCIE --- // --- 4. SHORTCODE DO WYŚWIETLANIA NA FRONCIE ---
require_once MYSTAT_PLUGIN_DIR . 'includes/frontend/assets.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/frontend/assets.php';
require_once MYSTAT_PLUGIN_DIR . 'includes/frontend/shortcodes.php'; require_once STATPRESS_PLUGIN_DIR . 'includes/frontend/shortcodes.php';
add_action( 'wp_enqueue_scripts', 'mystat_enqueue_frontend_assets' ); add_action( 'wp_enqueue_scripts', 'statpress_enqueue_frontend_assets' );
add_action( 'init', 'mystat_register_shortcode' ); add_action( 'init', 'statpress_register_shortcode' );