PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.12
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.12
2.12.8 2.12.7 2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 All 98 releases
sureforms / inc / activator.php

activator.php in SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz 0.0.12, at inc/activator.php

78 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Sureforms flush rewrite rules.
4 *
5 * @package sureforms.
6 * @since 0.0.1
7 */
8
9 namespace SRFM\Inc;
10
11 use SRFM\Inc\Database\Tables\Entries;
12 use SRFM\Inc\Traits\Get_Instance;
13 use SRFM\Inc\Global_Settings\Email_Summary;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Activation Class.
21 *
22 * @since 0.0.1
23 */
24 class Activator {
25 use Get_Instance;
26
27 /**
28 * Activation handler function.
29 *
30 * @since 0.0.1
31 * @return void
32 */
33 public static function activate() {
34 self::create_tables();
35
36 $email_summary_options = get_option( 'srfm_email_summary_settings_options' );
37 $enable_email_summary = is_array( $email_summary_options ) ? $email_summary_options['srfm_email_summary'] : '';
38
39 if ( $enable_email_summary ) {
40 Email_Summary::schedule_weekly_entries_email();
41 }
42
43 /**
44 * Reset rewrite rules to avoid go to permalinks page
45 * through deleting the database options to force WP to do it
46 * because of on activation not work well flush_rewrite_rules()
47 */
48 delete_option( 'rewrite_rules' );
49
50 update_option( '__srfm_do_redirect', true );
51
52 }
53
54 /**
55 * Create necessary table tables on plugin activation.
56 *
57 * @since 0.0.10
58 * @return void
59 */
60 protected static function create_tables() {
61 Entries::get_instance()->create(
62 [
63 'ID BIGINT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY',
64 'form_id BIGINT(20) UNSIGNED',
65 'user_data LONGTEXT',
66 'logs LONGTEXT',
67 'notes LONGTEXT',
68 'submission_info LONGTEXT',
69 'status VARCHAR(10)',
70 'created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP',
71 'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
72 'INDEX idx_form_id (form_id)', // Indexing for the performance improvements.
73 'INDEX idx_form_id_created_at_status (form_id, created_at, status)', // Composite index for performance improvements.
74 ]
75 );
76 }
77 }
78