settings['write_files'] && ! $old_settings['write_files'] ) { ITSEC_Response::regenerate_server_config(); ITSEC_Response::regenerate_wp_config(); } if ( $this->settings['use_cron'] !== $old_settings['use_cron'] ) { $this->handle_cron_change( $this->settings['use_cron'] ); } if ( $this->settings['enable_grade_report'] && ! $old_settings['enable_grade_report'] ) { update_site_option( 'itsec-enable-grade-report', true ); ITSEC_Modules::load_module_file( 'activate.php', 'grade-report' ); ITSEC_Response::flag_new_notifications_available(); ITSEC_Response::refresh_page(); } elseif ( ! $this->settings['enable_grade_report'] && $old_settings['enable_grade_report'] ) { update_site_option( 'itsec-enable-grade-report', false ); ITSEC_Modules::load_module_file( 'deactivate.php', 'grade-report' ); ITSEC_Response::refresh_page(); } } private function handle_cron_change( $new_use_cron ) { $class = $new_use_cron ? 'ITSEC_Scheduler_Cron' : 'ITSEC_Scheduler_Page_Load'; $this->handle_scheduler_change( $class ); } private function handle_scheduler_change( $new_class ) { $choices = array( 'ITSEC_Scheduler_Cron' => ITSEC_Core::get_core_dir() . 'lib/class-itsec-scheduler-cron.php', 'ITSEC_Scheduler_Page_Load' => ITSEC_Core::get_core_dir() . 'lib/class-itsec-scheduler-page-load.php', ); require_once( $choices[ $new_class ] ); /** @var ITSEC_Scheduler $new */ $new = new $new_class(); $current = ITSEC_Core::get_scheduler(); $new->uninstall(); foreach ( $current->get_custom_schedules() as $slug => $interval ) { $new->register_custom_schedule( $slug, $interval ); } $new->run(); foreach ( $current->get_recurring_events() as $event ) { $new->schedule( $event['schedule'], $event['id'], $event['data'], array( 'fire_at' => $event['fire_at'], ) ); } foreach ( $current->get_single_events() as $event ) { $new->schedule_once( $event['fire_at'], $event['id'], $event['data'] ); } $new->run(); ITSEC_Core::set_scheduler( $new ); $current->uninstall(); } } ITSEC_Modules::register_settings( new ITSEC_Global_Settings( ITSEC_Modules::get_config( 'global' ) ) ); class_alias( ITSEC_Global_Settings::class, 'ITSEC_Global_Settings_New' );