'ids' ) ); foreach ( $blog_ids as $blog_id ) { switch_to_blog( $blog_id ); $this->activate_site(); restore_current_blog(); } } else { $this->activate_site(); } if ( false === get_option( 'nsc3ppm_data_retention' ) ) { update_option( 'nsc3ppm_data_retention', 'never' ); } // Default sample percentage is 100%. if ( false === get_option( 'nsc3ppm_sample_percentage' ) ) { update_option( 'nsc3ppm_sample_percentage', 100 ); } // Default notification frequency is "Do not notify". if ( false === get_option( 'nsc3ppm_notify_frequency' ) ) { update_option( 'nsc3ppm_notify_frequency', 'do_not_notify' ); } if ( false === get_option( 'nsc3ppm_notify_email' ) ) { update_option( 'nsc3ppm_notify_email', get_option( 'admin_email' ) ); } if ( false === get_option( 'nsc3ppm_notified_hostnames' ) ) { update_option( 'nsc3ppm_notified_hostnames', array() ); } if ( false === get_option( 'nsc3ppm_new_hostnames' ) ) { update_option( 'nsc3ppm_new_hostnames', array() ); } } public function new_multisite_added( $blog_id ) { switch_to_blog( $blog_id ); $this->activate_site(); restore_current_blog(); } public function activate_site() { $this->create_table(); $this->schedule_cleanup(); $this->schedule_domain_notification(); } public function create_table() { global $wpdb; $table_name = $wpdb->prefix . 'nsc3ppm_intercepts'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, original_url TEXT NOT NULL, hostname TEXT NOT NULL, second_level_domain TEXT NOT NULL, page_url TEXT NOT NULL, method VARCHAR(10) NOT NULL, type VARCHAR(20) NOT NULL, intercepted_at DATETIME DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id) ) $charset_collate;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta( $sql ); } public function schedule_cleanup() { if ( ! wp_next_scheduled( 'nsc3ppm_daily_cleanup' ) ) { wp_schedule_event( time(), 'daily', 'nsc3ppm_daily_cleanup' ); } } public function schedule_domain_notification() { if ( ! wp_next_scheduled( 'nsc3ppm_daily_domain_notification' ) ) { wp_schedule_event( time(), 'daily', 'nsc3ppm_daily_domain_notification' ); } } }