These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Uninstall page for Email Log Plugin to clean up db. |
||
4 | */ |
||
5 | |||
6 | // exit if WordPress is not uninstalling the plugin. |
||
7 | if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
||
8 | exit(); |
||
9 | } |
||
10 | |||
11 | if ( is_multisite() ) { |
||
12 | global $wpdb; |
||
13 | |||
14 | $original_blog_id = get_current_blog_id(); |
||
15 | |||
16 | $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
||
1 ignored issue
–
show
|
|||
17 | |||
18 | foreach ( $blog_ids as $blog_id ) { |
||
19 | switch_to_blog( $blog_id ); |
||
20 | email_log_delete_table(); |
||
21 | } |
||
22 | |||
23 | switch_to_blog( $original_blog_id ); |
||
24 | |||
25 | } else { |
||
26 | email_log_delete_table(); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Delete email log table and db option |
||
31 | * |
||
32 | * @since 1.7 |
||
33 | * |
||
34 | * @global object $wpdb |
||
35 | */ |
||
36 | function email_log_delete_table() { |
||
37 | global $wpdb; |
||
38 | $table_name = $wpdb->prefix . 'email_log'; // This is hardcoded on purpose |
||
39 | |||
40 | if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name ) { |
||
41 | // If table is present, drop it |
||
42 | $wpdb->query( "DROP TABLE $table_name" ); |
||
43 | } |
||
44 | |||
45 | // Delete the option |
||
46 | delete_option( 'email-log-db' ); |
||
47 | } |
||
48 |
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.