Plugin rename
This commit is contained in:
@@ -3,16 +3,16 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function mystat_add_new_page() {
|
||||
function statpress_add_new_page() {
|
||||
echo '<div class="wrap"><h1>Dodaj Nowy Trening</h1>';
|
||||
// Obsługa zapisu formularza (musi być przed renderowaniem, aby wyświetlić komunikat)
|
||||
mystat_handle_activity_form_submission();
|
||||
statpress_handle_activity_form_submission();
|
||||
// Formularz dodawania
|
||||
mystat_render_add_form();
|
||||
statpress_render_add_form();
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function mystat_edit_activity_page() {
|
||||
function statpress_edit_activity_page() {
|
||||
global $wpdb;
|
||||
$activity_id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0;
|
||||
|
||||
@@ -22,9 +22,9 @@ function mystat_edit_activity_page() {
|
||||
}
|
||||
|
||||
// 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 ) );
|
||||
|
||||
if ( ! $activity ) {
|
||||
@@ -33,23 +33,23 @@ function mystat_edit_activity_page() {
|
||||
}
|
||||
|
||||
echo '<div class="wrap"><h1>Edytuj Trening</h1>';
|
||||
mystat_render_add_form( $activity );
|
||||
statpress_render_add_form( $activity );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Obsługa zapisu nowego lub edytowanego wpisu do bazy danych
|
||||
*/
|
||||
function mystat_handle_activity_form_submission() {
|
||||
function statpress_handle_activity_form_submission() {
|
||||
global $wpdb;
|
||||
|
||||
// Sprawdź czy formularz został wysłany
|
||||
if ( ! isset( $_POST['mystat_submit_activity'] ) ) {
|
||||
if ( ! isset( $_POST['statpress_submit_activity'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$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)
|
||||
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.
|
||||
// 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 ) {
|
||||
$message = 'Trening zaktualizowany pomyślnie!';
|
||||
@@ -77,20 +77,20 @@ function mystat_handle_activity_form_submission() {
|
||||
/**
|
||||
* Renderowanie formularza HTML
|
||||
*/
|
||||
function mystat_render_add_form( $activity = null ) {
|
||||
function statpress_render_add_form( $activity = null ) {
|
||||
// Enqueue media scripts for the uploader
|
||||
wp_enqueue_media();
|
||||
|
||||
global $wpdb;
|
||||
$table_categories = $wpdb->prefix . 'mystat_categories';
|
||||
$table_event_types = $wpdb->prefix . 'mystat_event_types';
|
||||
$table_equipment = $wpdb->prefix . 'mystat_equipment';
|
||||
$table_categories = $wpdb->prefix . 'statpress_categories';
|
||||
$table_event_types = $wpdb->prefix . 'statpress_event_types';
|
||||
$table_equipment = $wpdb->prefix . 'statpress_equipment';
|
||||
$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" );
|
||||
$equipment_list = $wpdb->get_results( "SELECT * FROM $table_equipment ORDER BY name ASC" );
|
||||
|
||||
$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ść';
|
||||
$button_text = $is_edit_mode ? 'Zaktualizuj Trening' : 'Zapisz Trening';
|
||||
|
||||
@@ -218,7 +218,7 @@ function mystat_render_add_form( $activity = null ) {
|
||||
</tr>
|
||||
</table>
|
||||
<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>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
Reference in New Issue
Block a user