| @@ -963,16 +963,26 @@ | ||
| 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']; | |
| 970 | 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 | + | |
| 971 | 981 | wp_remote_post(BerqWPCloud::$endpoint."free-user", [ |
| 972 | 982 | 'timeout' => 30, |
| 973 | 983 | 'body' => [ |
| 974 | - 'site_id' => $berqconfigs->get_configs()['site_id'], | |
| 984 | + 'site_id' => $site_id, | |
| 975 | 985 | 'site_url' => get_option('home'), |
| 976 | 986 | ] |
| 977 | 987 | ]); |
| 978 | 988 | |