| @@ -963,11 +963,29 @@ | ||
| 963 | 963 | |
| 964 | 964 | function save_settings() |
| 965 | 965 | { |
| 966 | 966 | |
| 967 | - if (!empty($_GET['page']) && $_GET['page'] == 'berqwp' && isset($_GET['activate-free'])) { | |
| 967 | + if (current_user_can('manage_options') && !empty($_GET['page']) && $_GET['page'] == 'berqwp' && isset($_GET['activate-free'])) { | |
| 968 | 968 | $berqconfigs = berqConfigs::getInstance(); |
| 969 | - $berqconfigs->update_configs(['optimization_method' => 'local']); | |
| 969 | + $configs = $berqconfigs->get_configs(); | |
| 970 | + $site_id = $configs['site_id']; | |
| 971 | + | |
| 972 | + if (empty($site_id)) { | |
| 973 | + $site_id = berqwp_generate_site_id(); | |
| 974 | + } | |
| 975 | + | |
| 976 | + $berqconfigs->update_configs([ | |
| 977 | + 'site_id' => $site_id, | |
| 978 | + 'optimization_method' => 'local' | |
| 979 | + ]); | |
| 980 | + | |
| 981 | + wp_remote_post(BerqWPCloud::$endpoint."free-user", [ | |
| 982 | + 'timeout' => 30, | |
| 983 | + 'body' => [ | |
| 984 | + 'site_id' => $site_id, | |
| 985 | + 'site_url' => get_option('home'), | |
| 986 | + ] | |
| 987 | + ]); | |
| 970 | 988 | |
| 971 | 989 | $location = get_admin_url() . 'admin.php?page=berqwp'; |
| 972 | 990 | wp_safe_redirect($location); |
| 973 | 991 | exit; |