Skip to content

Commit

Permalink
Update onesignal-admin.php
Browse files Browse the repository at this point in the history
Fix- Undefined array key "REQUEST_METHOD"
  • Loading branch information
isrgrajan authored Dec 26, 2024
1 parent 42b4ba6 commit 194de2b
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions v3/onesignal-admin/onesignal-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,23 @@ function admin_files()
wp_enqueue_style('style', plugins_url('onesignal-admin.css', __FILE__), array(), time());
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST["submit"])) {
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST["submit"])) {
$onesignal_settings = get_option('OneSignalWPSetting', array());

$onesignal_settings = get_option('OneSignalWPSetting', array());

if (isset($_POST['onesignal_app_id']) && !empty($_POST['onesignal_app_id'])) {
$onesignal_settings['app_id'] = sanitize_text_field($_POST['onesignal_app_id']);
}
if (isset($_POST['onesignal_app_id']) && !empty($_POST['onesignal_app_id'])) {
$onesignal_settings['app_id'] = sanitize_text_field($_POST['onesignal_app_id']);
}

if (isset($_POST['onesignal_rest_api_key']) && !empty($_POST['onesignal_rest_api_key'])) {
$onesignal_settings['app_rest_api_key'] = sanitize_text_field($_POST['onesignal_rest_api_key']);
}
if (isset($_POST['onesignal_rest_api_key']) && !empty($_POST['onesignal_rest_api_key'])) {
$onesignal_settings['app_rest_api_key'] = sanitize_text_field($_POST['onesignal_rest_api_key']);
}

$send_to_mobile = isset($_POST['onesignal_send_to_mobile']) ? 1 : 0;
$onesignal_settings['send_to_mobile_platforms'] = $send_to_mobile;
$send_to_mobile = isset($_POST['onesignal_send_to_mobile']) ? 1 : 0;
$onesignal_settings['send_to_mobile_platforms'] = $send_to_mobile;

update_option('OneSignalWPSetting', $onesignal_settings);
}
update_option('OneSignalWPSetting', $onesignal_settings);
}
}

// Content for WP Admin Page
Expand Down

0 comments on commit 194de2b

Please sign in to comment.