PluginProbe ʕ •ᴥ•ʔ
Check & Log Email – Easy Email Testing & Mail logging / 2.0.2
Check & Log Email – Easy Email Testing & Mail logging v2.0.2
1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 2.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.13.1 2.0.13.2 2.0.14 2.0.2 2.0.3 2.0.4 2.0.5 2.0.5.1 2.0.6 2.0.7 2.0.8 2.0.9 trunk 0.5.7 0.6.0 0.6.1 0.6.2 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.12.1 1.0.13 1.0.13.1 1.0.2 1.0.3
check-email / include / install.php
check-email / include Last commit date
Core 1 year ago Util 1 year ago Check_Email_Encode_Tab.php 1 year ago Check_Email_SMTP_Tab.php 1 year ago class-check-email-header-parser.php 1 year ago class-check-email-log-autoloader.php 1 year ago class-check-email-newsletter.php 1 year ago deactivate-feedback.php 1 year ago helper-function.php 1 year ago install.php 1 year ago
install.php
77 lines
1 <?php
2 /**
3 * Handle installation and db table creation
4 */
5
6 defined( 'ABSPATH' ) || exit; // Exit if accessed directly
7
8 class Check_Email_Log_Init {
9
10 public static function on_activate( $network_wide ) {
11 global $wpdb;
12
13 if ( is_multisite() && $network_wide ) {
14 foreach ( get_sites() as $site ) {
15 switch_to_blog( $site->blog_id );
16 self::create_checkemaillog_table();
17 restore_current_blog();
18 }
19 } else {
20 self::create_checkemaillog_table();
21 }
22 }
23
24 public static function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
25 if ( is_plugin_active_for_network( 'check-email-log/check-email.php' ) ) {
26 switch_to_blog( $blog_id );
27 self::create_checkemaillog_table();
28 restore_current_blog();
29 }
30 }
31
32
33 public static function on_delete_blog( $tables ) {
34 global $wpdb;
35 $tables[] = $wpdb->prefix . Check_Email_Log::TABLE_NAME;
36 return $tables;
37 }
38
39 private static function create_checkemaillog_table() {
40 global $wpdb;
41
42 $table_name = $wpdb->prefix . Check_Email_Log::TABLE_NAME;
43 $charset_collate = $wpdb->get_charset_collate();
44 // phpcs:disable.
45 if ( $wpdb->get_var( $wpdb->prepare( "show tables like %s",$wpdb->esc_like( $table_name )) ) != $table_name ) {
46
47 $sql = 'CREATE TABLE ' . $table_name . ' (
48 id mediumint(9) NOT NULL AUTO_INCREMENT,
49 to_email VARCHAR(100) NOT NULL,
50 subject VARCHAR(250) NOT NULL,
51 message TEXT NOT NULL,
52 backtrace_segment TEXT NOT NULL,
53 headers TEXT NOT NULL,
54 attachments TEXT NOT NULL,
55 sent_date timestamp NOT NULL,
56 PRIMARY KEY (id)
57 ) ' . $charset_collate . ' ;';
58
59 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
60 dbDelta( $sql );
61
62 add_option( Check_Email_Log::DB_OPTION_NAME, Check_Email_Log::DB_VERSION );
63 }
64 // phpcs:enable.
65 }
66 }
67
68 // When the Plugin installed
69 register_activation_hook( EMAIL_LOG_PLUGIN_FILE, array( 'Check_Email_Log_Init', 'on_activate' ) );
70
71 // when a new blog is created in multisite
72 add_action( 'wpmu_new_blog', array( 'Check_Email_Log_Init', 'on_create_blog' ), 10, 6 );
73
74 // when a blog is deleted in multisite
75 add_filter( 'wpmu_drop_tables', array( 'Check_Email_Log_Init', 'on_delete_blog' ) );
76 ?>
77