PluginProbe ʕ •ᴥ•ʔ
Check & Log Email – Easy Email Testing & Mail logging / 1.0.4
Check & Log Email – Easy Email Testing & Mail logging v1.0.4
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 4 years ago Util 4 years ago class-check-email-header-parser.php 4 years ago class-check-email-log-autoloader.php 4 years ago install.php 4 years ago
install.php
80 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 // store the current blog id
15 $current_blog = $wpdb->blogid;
16
17 // Get all blogs in the network and activate plugin on each one
18 $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
19 foreach ( $blog_ids as $blog_id ) {
20 switch_to_blog( $blog_id );
21 self::create_checkemaillog_table();
22 restore_current_blog();
23 }
24 } else {
25 self::create_checkemaillog_table();
26 }
27 }
28
29 public static function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
30 if ( is_plugin_active_for_network( 'check-email-log/check-email.php' ) ) {
31 switch_to_blog( $blog_id );
32 self::create_checkemaillog_table();
33 restore_current_blog();
34 }
35 }
36
37
38 public static function on_delete_blog( $tables ) {
39 global $wpdb;
40 $tables[] = $wpdb->prefix . Check_Email_Log::TABLE_NAME;
41 return $tables;
42 }
43
44 private static function create_checkemaillog_table() {
45 global $wpdb;
46
47 $table_name = $wpdb->prefix . Check_Email_Log::TABLE_NAME;
48 $charset_collate = $wpdb->get_charset_collate();
49
50 if ( $wpdb->get_var( "show tables like '{$table_name}'" ) != $table_name ) {
51
52 $sql = 'CREATE TABLE ' . $table_name . ' (
53 id mediumint(9) NOT NULL AUTO_INCREMENT,
54 to_email VARCHAR(100) NOT NULL,
55 subject VARCHAR(250) NOT NULL,
56 message TEXT NOT NULL,
57 headers TEXT NOT NULL,
58 attachments TEXT NOT NULL,
59 sent_date timestamp NOT NULL,
60 PRIMARY KEY (id)
61 ) ' . $charset_collate . ' ;';
62
63 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
64 dbDelta( $sql );
65
66 add_option( Check_Email_Log::DB_OPTION_NAME, Check_Email_Log::DB_VERSION );
67 }
68 }
69 }
70
71 // When the Plugin installed
72 register_activation_hook( EMAIL_LOG_PLUGIN_FILE, array( 'Check_Email_Log_Init', 'on_activate' ) );
73
74 // when a new blog is created in multisite
75 add_action( 'wpmu_new_blog', array( 'Check_Email_Log_Init', 'on_create_blog' ), 10, 6 );
76
77 // when a blog is deleted in multisite
78 add_filter( 'wpmu_drop_tables', array( 'Check_Email_Log_Init', 'on_delete_blog' ) );
79 ?>
80