<?php

$onesignal_wp_settings = OneSignal::get_onesignal_settings();
if (array_key_exists('app_id', $_POST)) {
    $onesignal_wp_settings = OneSignal_Admin::save_config_page($_POST);
}
?>

<header class="onesignal">
  <a href="https://onesignal.com" target="_blank">
    <div class="onesignal logo" id="logo-onesignal" style="width: 250px; height: 52px; margin: 0 auto;">&nbsp;</div>
  </a>
</header>
<div class="outer site onesignal container">
  <div class="ui site onesignal container" id="content-container">
    <div class="ui pointing stackable menu">
      <a class="item" data-tab="setup">Setup</a>
      <a class="active item" data-tab="configuration">Configuration</a>
    </div>
    <div class="ui tab borderless shadowless segment" data-tab="setup" style="padding-top: 0; padding-bottom: 0;">
      <div class="ui special padded segment" style="padding-top: 0 !important;">
      <div class="ui top secondary pointing menu">
      <div class="ui grid" style="margin: 0 !important; padding: 0 !important;">
        <a class="item" data-tab="setup/0">Overview</a>
        <a class="item" data-tab="setup/1">Google Keys</a>
        <a class="item" data-tab="setup/2">Chrome & Firefox Push</a>
        <a class="item" data-tab="setup/3">OneSignal Keys</a>
        <a class="item" data-tab="setup/4">Modify Site</a>
        <a class="item" data-tab="setup/5">Safari Push</a>
        <a class="item" data-tab="setup/7">Results</a>
        </div>
 public static function save_config_page($config)
 {
     if (!current_user_can('update_plugins')) {
         return;
     }
     $sdk_dir = plugin_dir_path(__FILE__) . 'sdk_files/';
     $onesignal_wp_settings = OneSignal::get_onesignal_settings();
     $new_app_id = $config['app_id'];
     // Validate the UUID
     if (preg_match('/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/', $new_app_id, $m)) {
         $onesignal_wp_settings['app_id'] = $new_app_id;
     }
     if (is_numeric($config['gcm_sender_id'])) {
         $onesignal_wp_settings['gcm_sender_id'] = $config['gcm_sender_id'];
     }
     if (array_key_exists('subdomain', $config)) {
         $onesignal_wp_settings['subdomain'] = $config['subdomain'];
     } else {
         $onesignal_wp_settings['subdomain'] = "";
     }
     $onesignal_wp_settings['is_site_https_firsttime'] = 'set';
     $booleanSettings = array('is_site_https', 'prompt_auto_register', 'use_modal_prompt', 'send_welcome_notification', 'notification_on_post', 'notification_on_post_from_plugin', 'showNotificationIconFromPostThumbnail', 'chrome_auto_dismiss_notifications', 'prompt_customize_enable', 'prompt_showcredit', 'notifyButton_enable', 'notifyButton_prenotify', 'notifyButton_showcredit', 'notifyButton_customize_enable', 'notifyButton_customize_colors_enable', 'notifyButton_customize_offset_enable');
     OneSignal_Admin::saveBooleanSettings($onesignal_wp_settings, $config, $booleanSettings);
     $stringSettings = array('app_rest_api_key', 'safari_web_id', 'prompt_action_message', 'prompt_example_notification_title_desktop', 'prompt_example_notification_message_desktop', 'prompt_example_notification_title_mobile', 'prompt_example_notification_message_mobile', 'prompt_example_notification_caption', 'prompt_cancel_button_text', 'prompt_accept_button_text', 'welcome_notification_title', 'welcome_notification_message', 'welcome_notification_url', 'subscriberTags', 'includedSegments', 'notifyButton_size', 'notifyButton_theme', 'notifyButton_position', 'notifyButton_color_background', 'notifyButton_color_foreground', 'notifyButton_color_badge_background', 'notifyButton_color_badge_foreground', 'notifyButton_color_badge_border', 'notifyButton_color_pulse', 'notifyButton_color_popup_button_background', 'notifyButton_color_popup_button_background_hover', 'notifyButton_color_popup_button_background_active', 'notifyButton_color_popup_button_color', 'notifyButton_offset_bottom', 'notifyButton_offset_left', 'notifyButton_offset_right', 'notifyButton_message_prenotify', 'notifyButton_tip_state_unsubscribed', 'notifyButton_tip_state_subscribed', 'notifyButton_tip_state_blocked', 'notifyButton_message_action_subscribed', 'notifyButton_message_action_resubscribed', 'notifyButton_message_action_unsubscribed', 'notifyButton_dialog_main_title', 'notifyButton_dialog_main_button_subscribe', 'notifyButton_dialog_main_button_unsubscribe', 'notifyButton_dialog_blocked_title', 'notifyButton_dialog_blocked_message');
     OneSignal_Admin::saveStringSettings($onesignal_wp_settings, $config, $stringSettings);
     OneSignal::save_onesignal_settings($onesignal_wp_settings);
     return $onesignal_wp_settings;
 }