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 Email Log plugin |
||
4 | * |
||
5 | * @package Email Log |
||
6 | * @subpackage Uninstall |
||
7 | * @author Sudar |
||
8 | */ |
||
9 | // uninstall page for Email Log Plugin to clean up db. |
||
10 | if( !defined( 'ABSPATH' ) && !defined( 'WP_UNINSTALL_PLUGIN' ) ) |
||
11 | exit(); |
||
12 | |||
13 | if ( is_multisite() ) { |
||
14 | global $wpdb; |
||
15 | |||
16 | $original_blog_id = get_current_blog_id(); |
||
17 | |||
18 | $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
||
1 ignored issue
–
show
|
|||
19 | |||
20 | foreach ( $blog_ids as $blog_id ) { |
||
21 | switch_to_blog( $blog_id ); |
||
22 | email_log_delete_table(); |
||
23 | } |
||
24 | |||
25 | switch_to_blog( $original_blog_id ); |
||
26 | |||
27 | } else { |
||
28 | email_log_delete_table(); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Delete email log table and db option |
||
33 | * |
||
34 | * @since 1.7 |
||
35 | * |
||
36 | * @global object $wpdb |
||
37 | */ |
||
38 | function email_log_delete_table() { |
||
39 | global $wpdb; |
||
40 | $table_name = $wpdb->prefix . "email_log"; // This is hardcoded on purpose |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
email_log does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
41 | |||
42 | if( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name ) { |
||
1 ignored issue
–
show
As per coding-style, please use concatenation or
sprintf for the variable $table_name instead of interpolation.
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings. // Instead of
$x = "foo $bar $baz";
// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
![]() |
|||
43 | // If table is present, drop it |
||
44 | $wpdb->query( "DROP TABLE $table_name" ); |
||
1 ignored issue
–
show
As per coding-style, please use concatenation or
sprintf for the variable $table_name instead of interpolation.
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings. // Instead of
$x = "foo $bar $baz";
// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
![]() |
|||
45 | } |
||
46 | |||
47 | // Delete the option |
||
48 | delete_option('email-log-db'); |
||
49 | } |
||
50 | ?> |
||
51 |
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.