| @@ -11,9 +11,10 @@ | ||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | $plugin_name = defined('BERQWP_PLUGIN_NAME') ? BERQWP_PLUGIN_NAME : 'BerqWP'; |
| 14 | 14 | |
| 15 | - if (!empty($_POST['berqwp_intro_page']) && !berqwp_is_license_managed_by_network()) { | |
| 15 | + // if (!empty($_POST['berqwp_intro_page']) && !berqwp_is_license_managed_by_network()) { | |
| 16 | + if (!berqwp_is_license_managed_by_network() && !empty($_POST['berqwp_optimization_method'])) { | |
| 16 | 17 | $optimization_method = sanitize_text_field($_POST['berqwp_optimization_method']); |
| 17 | 18 | |
| 18 | 19 | if ($optimization_method == 'local') { |
| 19 | 20 | $email = sanitize_email($_POST['berqwp_local_user_email']); |
| @@ -36,9 +37,10 @@ | ||
| 36 | 37 | <?php |
| 37 | 38 | exit(); |
| 38 | 39 | } |
| 39 | 40 | |
| 40 | - if ($optimization_method == 'cloud' && !empty($_POST['berqwp_license_key'])) { | |
| 41 | + // if ($optimization_method == 'cloud' && !empty($_POST['berqwp_license_key'])) { | |
| 42 | + if (!empty($_POST['berqwp_license_key'])) { | |
| 41 | 43 | $license_key = sanitize_text_field($_POST['berqwp_license_key']); |
| 42 | 44 | $berqconfigs = berqConfigs::getInstance(); |
| 43 | 45 | $berqwp_configs = $berqconfigs->get_configs(); |
| 44 | 46 | $site_id = $berqwp_configs['site_id']; |
| @@ -43,13 +45,9 @@ | ||
| 43 | 45 | $berqwp_configs = $berqconfigs->get_configs(); |
| 44 | 46 | $site_id = $berqwp_configs['site_id']; |
| 45 | 47 | |
| 46 | 48 | if (empty($site_id)) { |
| 47 | - $blog_id = get_current_blog_id(); | |
| 48 | - $network_id = function_exists('get_current_network_id') ? get_current_network_id() : 1; | |
| 49 | - $siteurl = get_option('siteurl'); | |
| 50 | - $site_id = md5("berqwp|$network_id|$blog_id|$siteurl"); | |
| 51 | - | |
| 49 | + $site_id = berqwp_generate_site_id(); | |
| 52 | 50 | $berqconfigs->update_configs(['site_id' => $site_id]); |
| 53 | 51 | } |
| 54 | 52 | |
| 55 | 53 | // $lic_response = wp_remote_post(BerqWP::$endpoint."authenticate", [ |
| @@ -241,8 +239,10 @@ | ||
| 241 | 239 | $key_response = $this->verify_license_key($license_key, 'slm_deactivate'); |
| 242 | 240 | |
| 243 | 241 | delete_transient('berq_lic_response_cache'); |
| 244 | 242 | delete_transient('berqwp_lic_response_cache'); |
| 243 | + berqwp_delete_network_option('berqwp_license_cache'); | |
| 244 | + | |
| 245 | 245 | berqwp_delete_license_key(); |
| 246 | 246 | berqwp_clear_cache_queue(); |
| 247 | 247 | |
| 248 | 248 | global $berqNotifications; |
| @@ -457,8 +457,52 @@ | ||
| 457 | 457 | } else { |
| 458 | 458 | update_option('berqwp_disable_emojis', 0); |
| 459 | 459 | } |
| 460 | 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'); | |
| 504 | + | |
| 461 | 505 | // If the option is changed require flush cache |
| 462 | 506 | if (bwp_is_option_updated('berqwp_lazyload_youtube_embed')) { |
| 463 | 507 | $berq_log->info('Updated berqwp_lazyload_youtube_embed'); |
| 464 | 508 | update_option('bwp_require_flush_cache', 1); |
| @@ -481,8 +525,14 @@ | ||
| 481 | 525 | } else { |
| 482 | 526 | update_option('berqwp_preload_yt_poster', 0); |
| 483 | 527 | } |
| 484 | 528 | |
| 529 | + // If the option is changed require flush cache | |
| 530 | + if (bwp_is_option_updated('berqwp_enable_critical_css')) { | |
| 531 | + $berq_log->info('Updated berqwp_enable_critical_css'); | |
| 532 | + update_option('bwp_require_flush_cache', 1); | |
| 533 | + } | |
| 534 | + | |
| 485 | 535 | if (isset($_POST['berqwp_enable_critical_css'])) { |
| 486 | 536 | update_option('berqwp_enable_critical_css', 1); |
| 487 | 537 | } else { |
| 488 | 538 | update_option('berqwp_enable_critical_css', 0); |
| @@ -487,8 +537,14 @@ | ||
| 487 | 537 | } else { |
| 488 | 538 | update_option('berqwp_enable_critical_css', 0); |
| 489 | 539 | } |
| 490 | 540 | |
| 541 | + // If the option is changed require flush cache | |
| 542 | + if (bwp_is_option_updated('berqwp_enable_used_css')) { | |
| 543 | + $berq_log->info('Updated berqwp_enable_used_css'); | |
| 544 | + update_option('bwp_require_flush_cache', 1); | |
| 545 | + } | |
| 546 | + | |
| 491 | 547 | if (isset($_POST['berqwp_enable_used_css'])) { |
| 492 | 548 | update_option('berqwp_enable_used_css', 1); |
| 493 | 549 | } else { |
| 494 | 550 | update_option('berqwp_enable_used_css', 0); |
| @@ -499,13 +555,13 @@ | ||
| 499 | 555 | } else { |
| 500 | 556 | update_option('berqwp_async_excluded_styles', 0); |
| 501 | 557 | } |
| 502 | 558 | |
| 503 | - // if (isset($_POST['berqwp_defer_excluded_styles'])) { | |
| 504 | - // update_option('berqwp_defer_excluded_styles', 1); | |
| 505 | - // } else { | |
| 506 | - // update_option('berqwp_defer_excluded_styles', 0); | |
| 507 | - // } | |
| 559 | + if (isset($_POST['berqwp_defer_excluded_js'])) { | |
| 560 | + update_option('berqwp_defer_excluded_js', 1); | |
| 561 | + } else { | |
| 562 | + update_option('berqwp_defer_excluded_js', 0); | |
| 563 | + } | |
| 508 | 564 | |
| 509 | 565 | if (isset($_POST['berqwp_delay_third_party_scripts'])) { |
| 510 | 566 | update_option('berqwp_delay_third_party_scripts', 1); |
| 511 | 567 | } else { |