| @@ -12,9 +12,9 @@ | ||
| 12 | 12 | |
| 13 | 13 | $plugin_name = defined('BERQWP_PLUGIN_NAME') ? BERQWP_PLUGIN_NAME : 'BerqWP'; |
| 14 | 14 | |
| 15 | 15 | // if (!empty($_POST['berqwp_intro_page']) && !berqwp_is_license_managed_by_network()) { |
| 16 | - if (!berqwp_is_license_managed_by_network()) { | |
| 16 | + if (!berqwp_is_license_managed_by_network() && !empty($_POST['berqwp_optimization_method'])) { | |
| 17 | 17 | $optimization_method = sanitize_text_field($_POST['berqwp_optimization_method']); |
| 18 | 18 | |
| 19 | 19 | if ($optimization_method == 'local') { |
| 20 | 20 | $email = sanitize_email($_POST['berqwp_local_user_email']); |
| @@ -45,13 +45,9 @@ | ||
| 45 | 45 | $berqwp_configs = $berqconfigs->get_configs(); |
| 46 | 46 | $site_id = $berqwp_configs['site_id']; |
| 47 | 47 | |
| 48 | 48 | if (empty($site_id)) { |
| 49 | - $blog_id = get_current_blog_id(); | |
| 50 | - $network_id = function_exists('get_current_network_id') ? get_current_network_id() : 1; | |
| 51 | - $siteurl = get_option('siteurl'); | |
| 52 | - $site_id = md5("berqwp|$network_id|$blog_id|$siteurl"); | |
| 53 | - | |
| 49 | + $site_id = berqwp_generate_site_id(); | |
| 54 | 50 | $berqconfigs->update_configs(['site_id' => $site_id]); |
| 55 | 51 | } |
| 56 | 52 | |
| 57 | 53 | // $lic_response = wp_remote_post(BerqWP::$endpoint."authenticate", [ |
| @@ -460,8 +456,52 @@ | ||
| 460 | 456 | update_option('berqwp_disable_emojis', 1); |
| 461 | 457 | } else { |
| 462 | 458 | update_option('berqwp_disable_emojis', 0); |
| 463 | 459 | } |
| 460 | + | |
| 461 | + if (isset($_POST['berqwp_heartbeat_mode'])) { | |
| 462 | + $heartbeat_mode = sanitize_text_field($_POST['berqwp_heartbeat_mode']); | |
| 463 | + if (!in_array($heartbeat_mode, ['default', 'restrict', 'throttle', 'disable'], true)) { | |
| 464 | + $heartbeat_mode = 'default'; | |
| 465 | + } | |
| 466 | + update_option('berqwp_heartbeat_mode', $heartbeat_mode); | |
| 467 | + } | |
| 468 | + | |
| 469 | + if (isset($_POST['berqwp_heartbeat_interval'])) { | |
| 470 | + $heartbeat_interval = max(15, min(300, (int) sanitize_text_field($_POST['berqwp_heartbeat_interval']))); | |
| 471 | + update_option('berqwp_heartbeat_interval', $heartbeat_interval); | |
| 472 | + } | |
| 473 | + | |
| 474 | + foreach ([ | |
| 475 | + 'berqwp_disable_embeds', | |
| 476 | + 'berqwp_disable_xmlrpc', | |
| 477 | + 'berqwp_remove_rest_head_links', | |
| 478 | + 'berqwp_remove_head_meta', | |
| 479 | + 'berqwp_disable_self_pingbacks', | |
| 480 | + ] as $bwp_debloat_option) { | |
| 481 | + update_option($bwp_debloat_option, isset($_POST[$bwp_debloat_option]) ? 1 : 0); | |
| 482 | + } | |
| 483 | + | |
| 484 | + if (isset($_POST['berqwp_db_schedule_frequency'])) { | |
| 485 | + $db_schedule_frequency = sanitize_text_field($_POST['berqwp_db_schedule_frequency']); | |
| 486 | + if (!in_array($db_schedule_frequency, ['daily', 'weekly', 'monthly'], true)) { | |
| 487 | + $db_schedule_frequency = 'weekly'; | |
| 488 | + } | |
| 489 | + update_option('berqwp_db_schedule_frequency', $db_schedule_frequency); | |
| 490 | + } | |
| 491 | + | |
| 492 | + if (isset($_POST['berqwp_db_revision_limit'])) { | |
| 493 | + update_option('berqwp_db_revision_limit', max(0, (int) sanitize_text_field($_POST['berqwp_db_revision_limit']))); | |
| 494 | + } | |
| 495 | + | |
| 496 | + $_POST['berqwp_db_scheduled_tasks'] = $_POST['berqwp_db_scheduled_tasks'] ?? []; | |
| 497 | + if (is_array($_POST['berqwp_db_scheduled_tasks'])) { | |
| 498 | + update_option('berqwp_db_scheduled_tasks', array_map('sanitize_text_field', wp_unslash($_POST['berqwp_db_scheduled_tasks']))); | |
| 499 | + } | |
| 500 | + | |
| 501 | + update_option('berqwp_db_schedule_enabled', isset($_POST['berqwp_db_schedule_enabled']) ? 1 : 0); | |
| 502 | + | |
| 503 | + do_action('berqwp_reschedule_db_cron'); | |
| 464 | 504 | |
| 465 | 505 | // If the option is changed require flush cache |
| 466 | 506 | if (bwp_is_option_updated('berqwp_lazyload_youtube_embed')) { |
| 467 | 507 | $berq_log->info('Updated berqwp_lazyload_youtube_embed'); |