Plugin rename
This commit is contained in:
@@ -3,7 +3,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function mystat_view_activity_page() {
|
||||
function statpress_view_activity_page() {
|
||||
global $wpdb;
|
||||
|
||||
$activity_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0;
|
||||
@@ -13,10 +13,10 @@ function mystat_view_activity_page() {
|
||||
return;
|
||||
}
|
||||
|
||||
$table_activities = $wpdb->prefix . 'mystat_activities';
|
||||
$table_categories = $wpdb->prefix . 'mystat_categories';
|
||||
$table_event_types = $wpdb->prefix . 'mystat_event_types';
|
||||
$table_equipment = $wpdb->prefix . 'mystat_equipment';
|
||||
$table_activities = $wpdb->prefix . 'statpress_activities';
|
||||
$table_categories = $wpdb->prefix . 'statpress_categories';
|
||||
$table_event_types = $wpdb->prefix . 'statpress_event_types';
|
||||
$table_equipment = $wpdb->prefix . 'statpress_equipment';
|
||||
|
||||
$sql = $wpdb->prepare(
|
||||
"
|
||||
@@ -51,7 +51,7 @@ function mystat_view_activity_page() {
|
||||
$gpx_data = array();
|
||||
$has_gpx_data = false;
|
||||
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'] );
|
||||
}
|
||||
|
||||
@@ -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( 'chart-js', 'https://cdn.jsdelivr.net/npm/chart.js', array(), null, true );
|
||||
|
||||
wp_register_script( 'mystat-details-loader', false );
|
||||
wp_enqueue_script( 'mystat-details-loader' );
|
||||
wp_register_script( 'statpress-details-loader', false );
|
||||
wp_enqueue_script( 'statpress-details-loader' );
|
||||
|
||||
// Check which profiles have data
|
||||
$available_profiles = array();
|
||||
@@ -82,7 +82,7 @@ function mystat_view_activity_page() {
|
||||
let activeChart = null;
|
||||
|
||||
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: \'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>\' }).addTo(map);
|
||||
const polyline = L.polyline(track_points, {color: "' . esc_js( $activity->color ) . '"}).addTo(map);
|
||||
map.fitBounds(polyline.getBounds().pad(0.1));
|
||||
@@ -106,8 +106,8 @@ function mystat_view_activity_page() {
|
||||
|
||||
function renderChart() {
|
||||
if (activeChart) activeChart.destroy();
|
||||
const chartType = document.querySelector(".mystat-chart-tabs .nav-tab-active").getAttribute("href").substring(1);
|
||||
const xAxisType = document.querySelector(\'input[name="mystat_xaxis"]:checked\').value;
|
||||
const chartType = document.querySelector(".statpress-chart-tabs .nav-tab-active").getAttribute("href").substring(1);
|
||||
const xAxisType = document.querySelector(\'input[name="statpress_xaxis"]:checked\').value;
|
||||
|
||||
const yData = profiles[chartType], xData = xAxisConfigs[xAxisType].data;
|
||||
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, {
|
||||
type: "line",
|
||||
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();
|
||||
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");
|
||||
renderChart();
|
||||
}));
|
||||
document.querySelectorAll(\'input[name="mystat_xaxis"]\').forEach(r => r.addEventListener("change", renderChart));
|
||||
if (document.querySelector(".mystat-chart-tabs .nav-tab")) renderChart();
|
||||
document.querySelectorAll(\'input[name="statpress_xaxis"]\').forEach(r => r.addEventListener("change", 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">
|
||||
<h1>
|
||||
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
|
||||
</a>
|
||||
</h1>
|
||||
|
||||
<p><a href="<?php echo esc_url( admin_url( 'admin.php?page=moje-statystyki' ) ); ?>">← Powrót do listy aktywności</a></p>
|
||||
<p><a href="<?php echo esc_url( admin_url( 'admin.php?page=statpress-dashboard' ) ); ?>">← Powrót do listy aktywności</a></p>
|
||||
|
||||
<div class="postbox" style="margin-top: 20px;">
|
||||
<div class="postbox-header"><h2 class="hndle">Podsumowanie</h2></div>
|
||||
<div class="inside">
|
||||
<div id="mystat-details-container">
|
||||
<div class="mystat-details-col">
|
||||
<div id="statpress-details-container">
|
||||
<div class="statpress-details-col">
|
||||
<h3>Główne dane</h3>
|
||||
<table class="form-table">
|
||||
<?php $render_row( 'Kategoria', $activity->category_name ); ?>
|
||||
@@ -182,7 +182,7 @@ function mystat_view_activity_page() {
|
||||
<?php $render_row( 'Sprzęt', $activity->equipment_name ); ?>
|
||||
</table>
|
||||
</div>
|
||||
<div class="mystat-details-col">
|
||||
<div class="statpress-details-col">
|
||||
<h3>Dane szczegółowe</h3>
|
||||
<table class="form-table">
|
||||
<?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 ) : ?>
|
||||
<hr>
|
||||
<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 ) ) : ?>
|
||||
<h3>Wykresy</h3>
|
||||
<div class="mystat-charts-container">
|
||||
<div class="mystat-chart-controls">
|
||||
<nav class="nav-tab-wrapper mystat-chart-tabs">
|
||||
<div class="statpress-charts-container">
|
||||
<div class="statpress-chart-controls">
|
||||
<nav class="nav-tab-wrapper statpress-chart-tabs">
|
||||
<?php
|
||||
$is_first = true;
|
||||
foreach ( $available_profiles as $key => $label ) :
|
||||
@@ -233,18 +233,18 @@ function mystat_view_activity_page() {
|
||||
<?php endforeach; ?>
|
||||
</nav>
|
||||
<?php if ( $has_time_data ) : ?>
|
||||
<div class="mystat-xaxis-switcher">
|
||||
<div class="statpress-xaxis-switcher">
|
||||
<strong>Oś X:</strong>
|
||||
<label><input type="radio" name="mystat_xaxis" value="distance" checked> Dystans</label>
|
||||
<label><input type="radio" name="statpress_xaxis" value="distance" checked> Dystans</label>
|
||||
|
||||
<label><input type="radio" name="mystat_xaxis" value="time"> Czas</label>
|
||||
<label><input type="radio" name="statpress_xaxis" value="time"> Czas</label>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<input type="hidden" name="mystat_xaxis" value="distance" checked>
|
||||
<input type="hidden" name="statpress_xaxis" value="distance" checked>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div style="position: relative; height:250px; width:100%;">
|
||||
<canvas id="mystat-details-chart"></canvas>
|
||||
<canvas id="statpress-details-chart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user