current_time( 'Y' ), 'month' => current_time( 'n' ), ), $atts, 'statpress_summary' ); $year = intval( $atts['year'] ); $month = intval( $atts['month'] ); // Pobieranie danych z bazy $table_activities = $wpdb->prefix . 'statpress_activities'; $sql = $wpdb->prepare( " SELECT a.*, c.name as category_name, c.icon, c.color, eq.name as equipment_name FROM $table_activities a LEFT JOIN {$wpdb->prefix}statpress_categories c ON a.category_id = c.id LEFT JOIN {$wpdb->prefix}statpress_equipment eq ON a.equipment_id = eq.id WHERE YEAR(a.date) = %d AND MONTH(a.date) = %d ORDER BY a.date ASC ", $year, $month ); $activities = $wpdb->get_results( $sql ); // Obliczanie podsumowań $total_distance = 0; $total_seconds = 0; foreach ( $activities as $activity ) { $total_distance += $activity->distance; if ( ! empty( $activity->duration ) ) { list($h, $m, $s) = explode( ':', $activity->duration ); $total_seconds += $h * 3600 + $m * 60 + $s; } } $hours = floor( $total_seconds / 3600 ); $minutes = floor( ( $total_seconds % 3600 ) / 60 ); $total_duration_formatted = sprintf( '%d godz. %d min.', $hours, $minutes ); // Rozpoczęcie buforowania wyjścia ob_start(); ?>

Podsumowanie miesiąca

Całkowity dystans
km
Całkowity czas

Lista aktywności

icon, 'groups' ) !== false ) { $material_icon = 'directions_bike'; } elseif ( strpos( $row->icon, 'businessman' ) !== false ) { $material_icon = 'directions_run'; } $bg_color = !empty($row->color) ? $row->color : '#1a73e8'; ?>

title ); ?>

date ) ) ); ?> category_name ); ?> equipment_name ) : ?> equipment_name ); ?>

Dystansdistance, 2, ',', ' ' ); ?> km
Czasduration ); ?>
avg_speed ) : ?>
Śr. prędkośćavg_speed, 1, ',', ' ' ); ?> km/h
avg_heart_rate ) : ?>
Śr. tętnoavg_heart_rate ); ?> bpm

Brak aktywności w tym miesiącu.

0, ), $atts, 'statpress_activity' ); $activity_id = intval( $atts['id'] ); if ( 0 === $activity_id ) { return '

Błąd: Nie podano ID wpisu w shortcode.

'; } // Pobieranie danych z bazy $table_activities = $wpdb->prefix . 'statpress_activities'; $sql = $wpdb->prepare( " SELECT a.*, c.name as category_name, c.color as category_color, et.name as event_type_name, eq.name as equipment_name FROM $table_activities a LEFT JOIN {$wpdb->prefix}statpress_categories c ON a.category_id = c.id LEFT JOIN {$wpdb->prefix}statpress_event_types et ON a.event_type_id = et.id LEFT JOIN {$wpdb->prefix}statpress_equipment eq ON a.equipment_id = eq.id WHERE a.id = %d ", $activity_id ); $activity = $wpdb->get_row( $sql ); if ( ! $activity ) { return '

Błąd: Nie znaleziono wpisu o ID ' . esc_html( $activity_id ) . '.

'; } // Funkcja pomocnicza do wyświetlania wiersza $render_row = function( $label, $value, $unit = '' ) { if ( ! is_null( $value ) && '' !== $value && 0 != $value ) { echo '
'; echo '' . esc_html( $label ) . ''; echo '' . esc_html( $value ) . ( $unit ? ' ' . esc_html( $unit ) : '' ) . ''; echo '
'; } }; ob_start(); // Prepare map and chart data if GPX exists $gpx_data = array(); $has_gpx_data = false; if ( ! empty( $activity->gpx_url ) ) { $gpx_data = statpress_parse_gpx_data( $activity->gpx_url ); $has_gpx_data = ! empty( $gpx_data['points'] ); } $unique_id = 'statpress-activity-' . esc_attr( $activity->id ); if ( $has_gpx_data ) { wp_enqueue_style( 'leaflet-css', 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css' ); 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 ); $map_id = 'map-' . $unique_id; $chart_id = 'chart-' . $unique_id; $available_profiles = array(); if ( ! empty( array_filter( $gpx_data['profiles']['elevation'] ) ) ) { $available_profiles['elevation'] = 'Wysokość';} if ( ! empty( array_filter( $gpx_data['profiles']['speed'] ) ) ) { $available_profiles['speed'] = 'Prędkość';} if ( ! empty( array_filter( $gpx_data['profiles']['hr'] ) ) ) { $available_profiles['hr'] = 'Tętno';} if ( ! empty( array_filter( $gpx_data['profiles']['cadence'] ) ) ) { $available_profiles['cadence'] = 'Kadencja';} $has_time_data = ! empty( array_filter( $gpx_data['profiles']['time'], fn( $t ) => ! is_null( $t ) ) ); wp_register_script( 'statpress-shortcode-loader-' . $activity->id, false ); wp_enqueue_script( 'statpress-shortcode-loader-' . $activity->id ); $js_script = ' (function() { document.addEventListener("DOMContentLoaded", function() { const uniqueId = "' . esc_js( $unique_id ) . '"; const containerEl = document.getElementById(uniqueId); if (!containerEl || typeof L === "undefined" || typeof Chart === "undefined") return; const trackPoints = ' . json_encode( $gpx_data['points'] ) . '; const profiles = ' . json_encode( $gpx_data['profiles'] ) . '; let activeChart = null; const mapId = "' . esc_js( $map_id ) . '"; const mapEl = document.getElementById(mapId); if (mapEl && trackPoints.length > 0) { if (mapEl._leaflet_id) mapEl._leaflet_id = null; const map = L.map(mapId); L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { attribution: \'© OpenStreetMap\' }).addTo(map); const polyline = L.polyline(trackPoints, {color: "' . esc_js( $activity->category_color ) . '"}).addTo(map); map.fitBounds(polyline.getBounds().pad(0.1)); } const chartId = "' . esc_js( $chart_id ) . '"; const chartEl = document.getElementById(chartId); if (!chartEl) return; const chartConfigs = { elevation: { label: "Wysokość", unit: "m n.p.m.", color: "#8e44ad" }, speed: { label: "Prędkość", unit: "km/h", color: "#2980b9" }, hr: { label: "Tętno", unit: "bpm", color: "#c0392b" }, cadence: { label: "Kadencja", unit: "rpm", color: "#27ae60" } }; const xAxisConfigs = { distance: { label: "Dystans (km)", data: profiles.distance }, time: { label: "Czas", data: profiles.time, formatter: (s) => s === null ? "" : new Date(s * 1000).toISOString().substr(11, 8) } }; function renderChart() { if (activeChart) activeChart.destroy(); const activeTab = containerEl.querySelector(".statpress-chart-tab.active"); if (!activeTab) return; const chartType = activeTab.dataset.type; const xAxisRadio = containerEl.querySelector(\'input[name="xaxis-\' + uniqueId + \'"]:checked\'); if (!xAxisRadio) return; const xAxisType = xAxisRadio.value; const yData = profiles[chartType], xData = xAxisConfigs[xAxisType].data; const filteredY = [], filteredX = []; if(yData) { for(let i=0; i v, maxRotation: 0, autoSkip: true, maxTicksLimit: 7 } }, y: { title: { display: true, text: chartConfigs[chartType].unit } } }, plugins: { legend: { display: false } }, interaction: { intersect: false, mode: "index" }, } }); } containerEl.querySelectorAll(".statpress-chart-tab").forEach(t => t.addEventListener("click", e => { e.preventDefault(); containerEl.querySelector(".statpress-chart-tab.active").classList.remove("active"); e.currentTarget.classList.add("active"); renderChart(); })); containerEl.querySelectorAll(\'input[name="xaxis-\' + uniqueId + \'"]\').forEach(r => r.addEventListener("change", renderChart)); if (containerEl.querySelector(".statpress-chart-tab")) renderChart(); }); })();'; wp_add_inline_script( 'statpress-shortcode-loader-' . $activity->id, $js_script ); } ?>

title ); ?>

date ) ) ); ?>

distance, 2, ',', ' ' ), 'km' ); ?> duration ); ?> avg_speed, 1, ',', ' ' ), 'km/h' ); ?> total_elevation_gain, 'm' ); ?> category_name ); ?> equipment_name ); ?> strava_url ) ) : ?>
$label ) : ?>
Oś X: