-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.php
More file actions
29 lines (22 loc) · 973 Bytes
/
init.php
File metadata and controls
29 lines (22 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
require_once '../../../wp-load.php';
if (!current_user_can('administrator')) {
wp_safe_redirect(home_url());
die;
}
if (empty($_GET['app_id']) || empty($_GET['secret'])) {
wp_safe_redirect(admin_url('options-general.php?page=justauthme&auto_error'));
die;
}
$settings = JustAuthMe::get()->fetchSettings();
if ($settings['app_id'] !== '' && $settings['secret'] !== '') {
wp_safe_redirect(admin_url('options-general.php?page=justauthme&auto_error_setup'));
die;
}
global $wpdb;
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
$sql = $wpdb->prepare("UPDATE " . JustAuthMe::get()->getSettingTableName() . " SET value=%s WHERE name='app_id'", $_GET['app_id']);
dbDelta($sql);
$sql = $wpdb->prepare("UPDATE " . JustAuthMe::get()->getSettingTableName() . " SET value=%s WHERE name='secret'", $_GET['secret']);
dbDelta($sql);
wp_safe_redirect(admin_url('options-general.php?page=justauthme&auto_success'));