| Server IP : 146.59.209.152 / Your IP : 216.73.216.46 Web Server : Apache System : Linux webm005.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : infrafs ( 43850) PHP Version : 8.2.29 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/infrafs/www/wp-content/plugins/store-locator-widget/ |
Upload File : |
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// Create the row to store the keys
function storelocatorwidget_create_first_row(){
global $wpdb;
$table_name = storelocatorwidget_get_table_name();
$wpdb->insert( $table_name, array('storelocatorwidget_api' => '', 'google_api' => ''), array());
}
// Save the storelocatorwidget API key
function storelocatorwidget_save_storelocatorwidget_api($api){
global $wpdb;
$table_id = 1;
$table_name = storelocatorwidget_get_table_name();
$wpdb->query($wpdb->prepare("UPDATE ".$table_name." SET storelocatorwidget_api='$api' WHERE id = %d", $table_id));
}
// Save the Google API key
function storelocatorwidget_save_google_api($gapi){
global $wpdb;
$table_id = 1;
$table_name = storelocatorwidget_get_table_name();
$wpdb->query($wpdb->prepare("UPDATE ".$table_name." SET google_api='$gapi' WHERE id = %d", $table_id));
}
// Get the storelocatorwidget api from the db
function storelocatorwidget_get_storelocatorwidget_api(){
global $wpdb;
$table_id = 1;
$table_name = storelocatorwidget_get_table_name();
$api = $wpdb->get_row( $wpdb->prepare( "SELECT storelocatorwidget_api FROM " .$table_name. " WHERE ID = %d", $table_id));
return $api->storelocatorwidget_api;
}
// Get the google API from the db
function storelocatorwidget_get_google_api(){
global $wpdb;
$table_id = 1;
$table_name = storelocatorwidget_get_table_name();
$gapi = $wpdb->get_row( $wpdb->prepare( "SELECT google_api FROM " .$table_name. " WHERE ID = %d", $table_id));
return $gapi->google_api;
}
// Process the form data
function storelocatorwidget_process_storelocatorwidget_keys(){
if ($_POST){
// Check for the google api key
if (isset($_POST['google_api_key'])){
storelocatorwidget_save_google_api(sanitize_text_field($_POST['google_api_key']));
}
// Check for the apply api key
if (isset($_POST['storelocatorwidget_api_key'])){
storelocatorwidget_save_storelocatorwidget_api(sanitize_text_field($_POST['storelocatorwidget_api_key']));
}
// redirect
wp_redirect(admin_url( 'admin.php?page=store-locator-widget/store-locator-widget.php&settings-saved'));
exit;
}
}