# sureforms/0.0.12/inc/activator.php

SureForms – Contact Form Builder, AI Forms, Payment Form, Survey &amp; Quiz, version 0.0.12. 78 lines.

- Page: https://pluginprobe.com/plugins/sureforms/0.0.12/code/inc/activator.php
- Raw: https://pluginprobe.com/plugins/sureforms/0.0.12/raw/inc/activator.php
- Modified: 2024-09-18T15:56:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/sureforms/0.0.12/code/inc/activator.php#L10-L20`.

```php
<?php
/**
 * Sureforms flush rewrite rules.
 *
 * @package sureforms.
 * @since 0.0.1
 */

namespace SRFM\Inc;

use SRFM\Inc\Database\Tables\Entries;
use SRFM\Inc\Traits\Get_Instance;
use SRFM\Inc\Global_Settings\Email_Summary;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Activation Class.
 *
 * @since 0.0.1
 */
class Activator {
	use Get_Instance;

	/**
	 * Activation handler function.
	 *
	 * @since 0.0.1
	 * @return void
	 */
	public static function activate() {
		self::create_tables();

		$email_summary_options = get_option( 'srfm_email_summary_settings_options' );
		$enable_email_summary  = is_array( $email_summary_options ) ? $email_summary_options['srfm_email_summary'] : '';

		if ( $enable_email_summary ) {
			Email_Summary::schedule_weekly_entries_email();
		}

		/**
		 * Reset rewrite rules to avoid go to permalinks page
		 * through deleting the database options to force WP to do it
		 * because of on activation not work well flush_rewrite_rules()
		 */
		delete_option( 'rewrite_rules' );

		update_option( '__srfm_do_redirect', true );

	}

	/**
	 * Create necessary table tables on plugin activation.
	 *
	 * @since 0.0.10
	 * @return void
	 */
	protected static function create_tables() {
		Entries::get_instance()->create(
			[
				'ID BIGINT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY',
				'form_id BIGINT(20) UNSIGNED',
				'user_data LONGTEXT',
				'logs LONGTEXT',
				'notes LONGTEXT',
				'submission_info LONGTEXT',
				'status VARCHAR(10)',
				'created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP',
				'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
				'INDEX idx_form_id (form_id)', // Indexing for the performance improvements.
				'INDEX idx_form_id_created_at_status (form_id, created_at, status)', // Composite index for performance improvements.
			]
		);
	}
}

```
