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
+14 -14
View File
@@ -9,9 +9,9 @@ if ( ! defined( 'ABSPATH' ) ) {
* @param object $goal The goal object from the database.
* @return array An array containing 'current_value' and 'percentage'.
*/
function mystat_get_goal_progress( $goal ) {
function statpress_get_goal_progress( $goal ) {
global $wpdb;
$table_activities = $wpdb->prefix . 'mystat_activities';
$table_activities = $wpdb->prefix . 'statpress_activities';
$sql_select = '';
switch ( $goal->goal_type ) {
@@ -52,15 +52,15 @@ function mystat_get_goal_progress( $goal ) {
);
}
function mystat_goals_page() {
function statpress_goals_page() {
global $wpdb;
$table_goals = $wpdb->prefix . 'mystat_goals';
$table_categories = $wpdb->prefix . 'mystat_categories';
$table_goals = $wpdb->prefix . 'statpress_goals';
$table_categories = $wpdb->prefix . 'statpress_categories';
$message = '';
$notice_class = '';
// 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;
// Convert hours to seconds for duration goal type before saving
@@ -96,7 +96,7 @@ function mystat_goals_page() {
// Handle GET requests (delete)
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'] ) ) );
$message = 'Cel usunięty.';
$notice_class = 'notice-success';
@@ -125,7 +125,7 @@ function mystat_goals_page() {
<h2><?php echo $item_to_edit ? 'Edytuj cel' : 'Dodaj nowy cel'; ?></h2>
<form method="post">
<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_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>
@@ -147,7 +147,7 @@ function mystat_goals_page() {
<?php else : ?>
<?php foreach ( $goals as $goal ) : ?>
<?php
$progress = mystat_get_goal_progress( $goal );
$progress = statpress_get_goal_progress( $goal );
$percentage = min( 100, $progress['percentage'] );
$target_formatted = '';
@@ -173,14 +173,14 @@ function mystat_goals_page() {
</small>
</td>
<td>
<div class="mystat-progress-bar-container">
<div class="mystat-progress-bar" style="width: <?php echo esc_attr( $percentage ); ?>%;"></div>
<div class="statpress-progress-bar-container">
<div class="statpress-progress-bar" style="width: <?php echo esc_attr( $percentage ); ?>%;"></div>
</div>
<small><?php echo $current_formatted; ?> z <?php echo $target_formatted; ?> (<?php echo round( $percentage, 1 ); ?>%)</small>
</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( 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>
</tr>
<?php endforeach; ?>
@@ -192,8 +192,8 @@ function mystat_goals_page() {
</div>
</div>
<style>
.mystat-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-container { background: #eee; border-radius: 4px; height: 12px; width: 100%; overflow: hidden; margin-bottom: 4px; }
.statpress-progress-bar { background: #3498db; height: 100%; border-radius: 4px; transition: width 0.5s ease-in-out; }
</style>
<?php
}