diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2023-01-20 20:22:06 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2023-01-20 20:22:06 +0100 |
commit | 277fedffc624f55c6ecc8bd80ed8db370134e47e (patch) | |
tree | ac22560f978c3789a63c80284fbd314e11d0b396 /includes/view-helpers/class-giglogadmin-venueform.php | |
parent | f499d9e657fe79e4413eec9e20ae13d616fac6f5 (diff) | |
download | gigologadmin-277fedffc624f55c6ecc8bd80ed8db370134e47e.tar.gz gigologadmin-277fedffc624f55c6ecc8bd80ed8db370134e47e.tar.bz2 gigologadmin-277fedffc624f55c6ecc8bd80ed8db370134e47e.zip |
Rename and reorganize more source files.
Diffstat (limited to 'includes/view-helpers/class-giglogadmin-venueform.php')
-rw-r--r-- | includes/view-helpers/class-giglogadmin-venueform.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/includes/view-helpers/class-giglogadmin-venueform.php b/includes/view-helpers/class-giglogadmin-venueform.php new file mode 100644 index 0000000..f837d73 --- /dev/null +++ b/includes/view-helpers/class-giglogadmin-venueform.php @@ -0,0 +1,52 @@ +<?php +/** + * Class to handle the form for adding venues. + * + * @package giglogadmin + * + * SPDX-FileCopyrightText: 2021 Andrea Chirulescu <andrea.chirulescu@gmail.com> + * SPDX-FileCopyrightText: 2021 Harald Eilertsen <haraldei@anduin.net> + * + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +if ( ! class_exists( 'GiglogAdmin_VenueForm' ) ) { + class GiglogAdmin_VenueForm { + + public function render() : string { + return '<div class="venueform">' + . '<p><strong>VENUE DETAILS</strong></p>' + . '<form method="POST" action="" class="venue">' + . ' <fieldset>' + . wp_nonce_field( 'edit-venue', 'nonce' ) + . ' <div class="field venue_name_field">' + . ' <label for="venue">Venue Name:</label>' + . ' <input type="text" id="venuename" name="venuename">' + . ' </div>' + . ' <div class="field venue_city_field">' + . ' <label for="venuecity">Venue City:</label>' + . ' <input type="text" id="venuecity" name="venuecity">' + . ' </div>' + . ' <div class="actions">' + . ' <input type="submit" name="newvenue" value="Create New Venue">' + . ' </div>' + . ' <fieldset>' + . '</form>' + . '</div>'; + } + + static function update() : void { + if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'edit-venue' ) ) { + header( "{$_SERVER['SERVER_PROTOCOL']} 403 Forbidden" ); + wp_die( 'CSRF validation failed.', 403 ); + } + + if ( empty( $_POST['venuename'] ) || empty( $_POST['venuecity'] ) ) { + echo '<script language="javascript">alert("You are missing a value, venue was not created"); </script>'; + } else { + GiglogAdmin_Venue::create( $_POST['venuename'], $_POST['venuecity'] ); + echo '<script language="javascript">alert("Yey, venue created"); </script>'; + } + } + } +} |