function sportsbook_admin_edit_page() {
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
global $wpdb;
$table = $wpdb->prefix . 'sportsbook_bookmakers';
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$bookmaker = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE id = %d", $id));
if (!$bookmaker) {
echo '
Bookmaker Not Found
';
return;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['bookmaker_name'])) {
$data = [
'name' => sanitize_text_field($_POST['bookmaker_name']),
'rating' => floatval($_POST['rating']),
'bonus_text' => sanitize_textarea_field($_POST['bonus_text']),
'offer_link' => esc_url_raw($_POST['offer_link']),
'description' => sanitize_textarea_field($_POST['description']),
'terms' => sanitize_textarea_field($_POST['terms']),
'payment_methods' => sanitize_text_field($_POST['payment_methods']),
'countries' => sanitize_text_field($_POST['countries']),
'logo_url' => esc_url_raw($_POST['logo_url']),
'large_image_url' => esc_url_raw($_POST['large_image_url']),
'app' => isset($_POST['app']) ? 1 : 0,
'cashout' => isset($_POST['cashout']) ? 1 : 0,
'in_play' => isset($_POST['in_play']) ? 1 : 0,
'signup' => isset($_POST['signup']) ? 1 : 0,
'streaming' => isset($_POST['streaming']) ? 1 : 0,
];
$wpdb->update($table, $data, ['id' => $id]);
echo 'Bookmaker updated successfully.
';
$bookmaker = (object) array_merge((array) $bookmaker, $data);
}
echo '';
}
function sportsbook_admin_edit_page() {
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
global $wpdb;
$table = $wpdb->prefix . 'sportsbook_bookmakers';
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$bookmaker = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE id = %d", $id));
if (!$bookmaker) {
echo 'Bookmaker Not Found
';
return;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['bookmaker_name'])) {
$data = [
'name' => sanitize_text_field($_POST['bookmaker_name']),
'rating' => floatval($_POST['rating']),
'bonus_text' => sanitize_textarea_field($_POST['bonus_text']),
'offer_link' => esc_url_raw($_POST['offer_link']),
'description' => sanitize_textarea_field($_POST['description']),
'terms' => sanitize_textarea_field($_POST['terms']),
'payment_methods' => sanitize_text_field($_POST['payment_methods']),
'countries' => sanitize_text_field($_POST['countries']),
'logo_url' => esc_url_raw($_POST['logo_url']),
'large_image_url' => esc_url_raw($_POST['large_image_url']),
'app' => isset($_POST['app']) ? 1 : 0,
'cashout' => isset($_POST['cashout']) ? 1 : 0,
'in_play' => isset($_POST['in_play']) ? 1 : 0,
'signup' => isset($_POST['signup']) ? 1 : 0,
'streaming' => isset($_POST['streaming']) ? 1 : 0,
];
$wpdb->update($table, $data, ['id' => $id]);
echo 'Bookmaker updated successfully.
';
$bookmaker = (object) array_merge((array) $bookmaker, $data);
}
echo 'Edit Bookmaker
';
}