| 1 | <?php |
||||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||||
| 2 | /** |
||||
|
0 ignored issues
–
show
|
|||||
| 3 | * @author Podlove <[email protected]> |
||||
| 4 | * @copyright Copyright (c) 2014-2018, Podlove |
||||
| 5 | * @license https://github.com/podlove/podlove-subscribe-button-wp-plugin/blob/master/LICENSE MIT |
||||
| 6 | * @package Podlove\PodloveSubscribeButton |
||||
| 7 | */ |
||||
| 8 | |||||
| 9 | namespace PodloveSubscribeButton; |
||||
| 10 | |||||
| 11 | class Setup { |
||||
|
0 ignored issues
–
show
|
|||||
| 12 | |||||
| 13 | public static function activation( $network_wide ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 14 | |||||
| 15 | global $wpdb; |
||||
| 16 | |||||
| 17 | if ( $network_wide ) { |
||||
| 18 | Model\NetworkButton::build(); |
||||
| 19 | set_time_limit(0); // may take a while, depending on network size |
||||
|
0 ignored issues
–
show
|
|||||
| 20 | $blogids = $wpdb->get_col( "SELECT blog_id FROM " . $wpdb->blogs ); |
||||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
SELECT blog_id FROM 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. Loading history...
|
|||||
| 21 | foreach ( $blogids as $blog_id ) { |
||||
| 22 | switch_to_blog( $blog_id ); |
||||
| 23 | self::activate_for_current_blog(); |
||||
| 24 | } |
||||
| 25 | } else { |
||||
| 26 | self::activate_for_current_blog(); |
||||
| 27 | } |
||||
| 28 | |||||
| 29 | } |
||||
| 30 | |||||
| 31 | public static function activate_for_current_blog() { |
||||
|
0 ignored issues
–
show
|
|||||
| 32 | |||||
| 33 | // Build Databases |
||||
|
0 ignored issues
–
show
|
|||||
| 34 | Model\Button::build(); |
||||
| 35 | |||||
| 36 | $default_values = Defaults::options(); |
||||
| 37 | |||||
| 38 | // add_option( 'podlove_psb_defaults', $default_values ); |
||||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||||
| 39 | |||||
| 40 | foreach ( $default_values as $option => $default_value ) { |
||||
| 41 | if ( ! get_option( 'podlove_subscribe_button_default_' . $option ) ) { |
||||
| 42 | update_option( 'podlove_subscribe_button_default_' . $option, $default_value ); |
||||
| 43 | } |
||||
| 44 | } |
||||
| 45 | |||||
| 46 | } |
||||
| 47 | |||||
| 48 | public static function deactivation( $network_wide ) { |
||||
|
0 ignored issues
–
show
The parameter
$network_wide is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 49 | |||||
| 50 | } |
||||
| 51 | |||||
| 52 | public static function uninstall() { |
||||
|
0 ignored issues
–
show
|
|||||
| 53 | if ( is_multisite() ) { |
||||
| 54 | self::uninstall_for_network(); |
||||
| 55 | } else { |
||||
| 56 | self::uninstall_for_current_blog(); |
||||
| 57 | } |
||||
| 58 | } |
||||
|
0 ignored issues
–
show
|
|||||
| 59 | |||||
| 60 | public static function uninstall_for_network() { |
||||
|
0 ignored issues
–
show
|
|||||
| 61 | |||||
| 62 | global $wpdb; |
||||
| 63 | |||||
| 64 | Model\NetworkButton::destroy(); |
||||
| 65 | |||||
| 66 | $current_blog = $wpdb->blogid; |
||||
| 67 | $blogids = $wpdb->get_col( "SELECT blog_id FROM " . $wpdb->blogs ); |
||||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
SELECT blog_id FROM 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. Loading history...
|
|||||
| 68 | |||||
| 69 | foreach ( $blogids as $blog_id ) { |
||||
| 70 | switch_to_blog( $blog_id ); |
||||
| 71 | self::uninstall_for_current_blog(); |
||||
| 72 | } |
||||
| 73 | |||||
| 74 | switch_to_blog( $current_blog ); |
||||
| 75 | |||||
| 76 | // $options = array( |
||||
|
0 ignored issues
–
show
|
|||||
| 77 | // /** 1.4+ */ |
||||
|
0 ignored issues
–
show
|
|||||
| 78 | // 'podlove_subscribe_button_defaults', |
||||
|
0 ignored issues
–
show
|
|||||
| 79 | // ); |
||||
|
0 ignored issues
–
show
|
|||||
| 80 | // |
||||
| 81 | // foreach ( $options as $option ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 82 | // delete_site_option( $option ); |
||||
|
0 ignored issues
–
show
|
|||||
| 83 | // } |
||||
|
0 ignored issues
–
show
|
|||||
| 84 | |||||
| 85 | } |
||||
| 86 | |||||
| 87 | public static function uninstall_for_current_blog() { |
||||
|
0 ignored issues
–
show
|
|||||
| 88 | |||||
| 89 | // remove DB tables |
||||
|
0 ignored issues
–
show
|
|||||
| 90 | Model\Button::destroy(); |
||||
| 91 | |||||
| 92 | $options = array( |
||||
| 93 | /** 1.4+ */ |
||||
| 94 | 'podlove_subscribe_button_defaults', |
||||
| 95 | 'widget_podlove_subscribe_button_wp_plugin_widget', |
||||
| 96 | /** 1.3.x */ |
||||
| 97 | 'podlove_subscribe_button_default_size', |
||||
| 98 | 'podlove_subscribe_button_default_autowidth', |
||||
| 99 | 'podlove_subscribe_button_default_color', |
||||
| 100 | 'podlove_subscribe_button_default_style', |
||||
| 101 | 'podlove_subscribe_button_default_format', |
||||
| 102 | 'podlove_subscribe_button_default_language', |
||||
| 103 | 'podlove_subscribe_button_plugin_database_version', |
||||
| 104 | ); |
||||
| 105 | |||||
| 106 | foreach ( $options as $option ) { |
||||
| 107 | delete_option( $option ); |
||||
| 108 | } |
||||
| 109 | |||||
| 110 | } |
||||
| 111 | |||||
| 112 | } // END class |
||||
| 113 |