Compare commits
4 Commits
572604300a
...
v0.04
| Author | SHA1 | Date | |
|---|---|---|---|
| 04d625110d | |||
| 8031e2ffc4 | |||
| 1f141fac7d | |||
| 768f7467e3 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,3 @@
|
||||
/database
|
||||
/html
|
||||
scripts/database/*
|
||||
scripts/html/*
|
||||
*.zip
|
||||
@@ -112,4 +112,4 @@ Both tables are automatically removed when the plugin is uninstalled.
|
||||
|
||||
## Author
|
||||
|
||||
Nikola Petrov
|
||||
Nikola Petrov nikola@petrovv.com
|
||||
|
||||
@@ -21,7 +21,7 @@ fwrite($output, $mcmahonfirst);
|
||||
|
||||
foreach ($entries as $i => $e) {
|
||||
$rank = $ranks[$e->rank];
|
||||
$id = $e->i + 1;
|
||||
$id = $i + 1;
|
||||
$egd = (strlen($e->egd_number) == 0) ? '0' : $e->egd_number;
|
||||
$out = " <IndividualParticipant typeversion=\"1\">
|
||||
<Id>$id</Id>
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Go Form Plugin
|
||||
* Description: Form plugin for Go players
|
||||
* Version: 0.03
|
||||
* Author: Nikola Petrov
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH'))
|
||||
exit;
|
||||
@@ -37,18 +31,11 @@ function go_form_activate()
|
||||
email varchar(255) DEFAULT NULL,
|
||||
egd_number varchar(20) DEFAULT NULL,
|
||||
comment text DEFAULT NULL,
|
||||
created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
created_at date DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY form_id (form_id)
|
||||
FOREIGN KEY (form_id) REFERENCES $forms(id) ON DELETE CASCADE
|
||||
) $charset;");
|
||||
|
||||
// Add default form if none exist
|
||||
$existing_forms = $wpdb->get_var("SELECT COUNT(*) FROM $forms");
|
||||
if ($existing_forms == 0) {
|
||||
$wpdb->insert($forms, ['name' => 'Default Form']);
|
||||
}
|
||||
}
|
||||
register_activation_hook(__FILE__, 'go_form_activate');
|
||||
|
||||
function go_form_uninstall()
|
||||
{
|
||||
@@ -56,8 +43,6 @@ function go_form_uninstall()
|
||||
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_entries");
|
||||
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_forms");
|
||||
}
|
||||
register_uninstall_hook(__FILE__, 'go_form_uninstall');
|
||||
//register_deactivation_hook(__FILE__, 'go_form_uninstall');
|
||||
// ========== Helpers ==========
|
||||
$ranks = [
|
||||
0 => '30k', 1 => '29k', 2 => '28k', 3 => '27k', 4 => '26k',
|
||||
@@ -107,15 +92,11 @@ function go_form_handle_submission()
|
||||
wp_die('Security check failed');
|
||||
|
||||
global $wpdb;
|
||||
$form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : 1;
|
||||
|
||||
// Check if form exists
|
||||
$form_exists = $wpdb->get_var($wpdb->prepare(
|
||||
"SELECT COUNT(*) FROM {$wpdb->prefix}go_form_forms WHERE id = %d",
|
||||
$form_id
|
||||
));
|
||||
if (!$form_exists) {
|
||||
$form_id = 1; // Fallback to default form
|
||||
if (isset($_POST['form_id'])) {
|
||||
$form_id = intval($_POST['form_id']);
|
||||
} else {
|
||||
wp_redirect($_SERVER['HTTP_REFERER']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rating = intval($_POST['rating']);
|
||||
@@ -218,11 +199,8 @@ function go_form_delete_form()
|
||||
if (isset($_POST['value_one'])) {
|
||||
global $wpdb;
|
||||
$id = intval($_POST['value_one']);
|
||||
if ($id > 1) {
|
||||
$wpdb->delete("{$wpdb->prefix}go_form_entries", ['form_id' => $id]);
|
||||
$wpdb->delete("{$wpdb->prefix}go_form_forms", ['id' => $id]);
|
||||
}
|
||||
}
|
||||
$redirect_url = add_query_arg(array('page' => 'go-form-settings', 'deleted' => 1), admin_url('admin.php'));
|
||||
wp_redirect($redirect_url);
|
||||
exit;
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
<th>Club</th>
|
||||
<th>Rank</th>
|
||||
<th>EGD Number</th>
|
||||
<th>Date Added</th>
|
||||
<?php if ($show_admin): ?>
|
||||
<th>Rating</th>
|
||||
<th>Email</th>
|
||||
<th>Date Added</th>
|
||||
<th>Action</th>
|
||||
<th>Comment</th>
|
||||
<?php endif; ?>
|
||||
@@ -27,12 +27,12 @@
|
||||
<td> <?= esc_html($e->club) ?> </td>
|
||||
<td> <?= esc_html($ranks[$e->rank]) ?> </td>
|
||||
<td> <?= esc_html($e->egd_number) ?> </td>
|
||||
<td> <?= esc_html($e->created_at) ?> </td>
|
||||
|
||||
<?php if ($show_admin): ?>
|
||||
|
||||
<td> <?= esc_html($e->rating) ?> </td>
|
||||
<td> <?= esc_html($e->email) ?> </td>
|
||||
<td> <?= esc_html($e->created_at) ?> </td>
|
||||
<td>
|
||||
<?php action_button('go_form_delete_entry', 'Delete', 'Delete this entry?', $e->id); ?>
|
||||
</td>
|
||||
|
||||
18
main.php
Normal file
18
main.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Go Form Plugin
|
||||
* Description: Form plugin for Go players
|
||||
* Version: 0.04
|
||||
* Author: Nikola Petrov
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH'))
|
||||
exit;
|
||||
|
||||
// Load plugin code
|
||||
require_once plugin_dir_path(__FILE__) . 'go-form-plugin/go-form-plugin.php';
|
||||
|
||||
register_activation_hook(__FILE__, 'go_form_activate');
|
||||
|
||||
register_uninstall_hook(__FILE__, 'go_form_uninstall');
|
||||
//register_deactivation_hook(__FILE__, 'go_form_uninstall');
|
||||
@@ -7,10 +7,10 @@ CONTAINER_NAME_DB='wordpress_db'
|
||||
CONTAINER_NAME_WP='wordpress'
|
||||
|
||||
# Stop and remove containers
|
||||
podman stop $CONTAINER_NAME_DB $CONTAINER_NAME_WP 2>/dev/null || true
|
||||
podman rm $CONTAINER_NAME_DB $CONTAINER_NAME_WP 2>/dev/null || true
|
||||
podman stop $CONTAINER_NAME_DB $CONTAINER_NAME_WP || true
|
||||
podman rm $CONTAINER_NAME_DB $CONTAINER_NAME_WP || true
|
||||
|
||||
# Remove pod
|
||||
podman pod rm -f $POD_NAME 2>/dev/null || true
|
||||
podman pod rm -f $POD_NAME || true
|
||||
|
||||
echo "removed pods"
|
||||
@@ -9,17 +9,18 @@ CONTAINER_NAME_DB='wordpress_db'
|
||||
CONTAINER_NAME_WP='wordpress'
|
||||
|
||||
# Stop and remove containers
|
||||
podman stop $CONTAINER_NAME_DB $CONTAINER_NAME_WP 2>/dev/null || true
|
||||
podman rm $CONTAINER_NAME_DB $CONTAINER_NAME_WP 2>/dev/null || true
|
||||
podman stop $CONTAINER_NAME_DB $CONTAINER_NAME_WP || true
|
||||
podman rm $CONTAINER_NAME_DB $CONTAINER_NAME_WP || true
|
||||
|
||||
# Remove pod
|
||||
podman pod rm -f $POD_NAME 2>/dev/null || true
|
||||
podman pod rm -f $POD_NAME || true
|
||||
|
||||
echo "removed pods"
|
||||
#exit 0
|
||||
|
||||
# Recreate pod
|
||||
podman pod create -n $POD_NAME -p 8090:80
|
||||
podman pod create -n $POD_NAME -p 8090:80 -p 3306:3306
|
||||
|
||||
|
||||
# Start MariaDB
|
||||
podman run --detach --pod $POD_NAME \
|
||||
@@ -25,7 +25,7 @@ podman pull docker.io/wordpress
|
||||
|
||||
# Create a pod instead of --link.
|
||||
# So both containers are able to reach each others.
|
||||
podman pod create -n $POD_NAME -p 8090:80
|
||||
podman pod create -n $POD_NAME -p 8090:80 -p 3306:3306
|
||||
|
||||
podman run --detach --pod $POD_NAME \
|
||||
-e MYSQL_ROOT_PASSWORD=$DB_PASS \
|
||||
3
scripts/zip.sh
Executable file
3
scripts/zip.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
cd ..
|
||||
rm go-form-plugin.zip
|
||||
zip -r go-form-plugin.zip go-form-plugin/* main.php
|
||||
Reference in New Issue
Block a user