Conditions | 14 |
Paths | 434 |
Total Lines | 112 |
Lines | 8 |
Ratio | 7.14 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
18 | function wsl_component_components_setup() |
||
19 | { |
||
20 | // HOOKABLE: |
||
21 | do_action( "wsl_component_components_setup_start" ); |
||
22 | |||
23 | GLOBAL $WORDPRESS_SOCIAL_LOGIN_COMPONENTS; |
||
24 | ?> |
||
25 | <div style="padding: 15px; margin-bottom: 8px; border: 1px solid #ddd; background-color: #fff;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);"> |
||
26 | <?php _wsl_e( "By default, only the three WSL core components are enabled. You can selectively enable or disable any of the non-core components by using the form below. Your WSL installation will continue to function. However, the features of the disabled components will no longer be accessible", 'wordpress-social-login' ) ?>. |
||
27 | </div> |
||
28 | |||
29 | <form action="" method="post"> |
||
30 | <table class="widefat fixed plugins" cellspacing="0"> |
||
31 | <thead> |
||
32 | <tr> |
||
33 | <th scope="col" class="manage-column column-label" style="width: 190px;"><?php _wsl_e( "Component", 'wordpress-social-login' ) ?></th> |
||
34 | <th scope="col" class="manage-column column-description"><?php _wsl_e( "Description", 'wordpress-social-login' ) ?></th> |
||
35 | <th scope="col" class="manage-column column-action" style="width: 140px;"> </th> |
||
36 | </tr> |
||
37 | </thead> |
||
38 | |||
39 | <tfoot> |
||
40 | <tr> |
||
41 | <th scope="col" class="manage-column column-label" style="width: 190px;"><?php _wsl_e( "Component", 'wordpress-social-login' ) ?></th> |
||
42 | <th scope="col" class="manage-column column-description"><?php _wsl_e( "Description", 'wordpress-social-login' ) ?></th> |
||
43 | <th scope="col" class="manage-column column-action" style="width: 140px;"> </th> |
||
44 | </tr> |
||
45 | </tfoot> |
||
46 | |||
47 | <tbody id="the-list"> |
||
48 | <?php |
||
49 | foreach( $WORDPRESS_SOCIAL_LOGIN_COMPONENTS as $name => $settings ) |
||
50 | { |
||
51 | $plugin_tr_class = ''; |
||
|
|||
52 | $plugin_notices = ''; |
||
53 | $plugin_enablable = true; |
||
54 | |||
55 | if( $name == "core" ) |
||
56 | { |
||
57 | continue; |
||
58 | } |
||
59 | |||
60 | $plugin_tr_class = $settings["enabled"] ? "active" : "inactive"; |
||
61 | ?> |
||
62 | <tr id="<?php echo $name ?>" class="<?php echo $name ?> <?php echo $plugin_tr_class ?>"> |
||
63 | <td class="component-label" style="width: 190px;"> |
||
64 | <?php if( $settings["type"] == "core" ): ?> |
||
65 | <div class="icon16 icon-generic"></div> |
||
66 | <?php elseif( $settings["type"] == "addon" ): ?> |
||
67 | <div class="icon16 icon-plugins"></div> |
||
68 | <?php else: ?> |
||
69 | <div class="icon16 icon-appearance"></div> |
||
70 | <?php endif; ?> |
||
71 | |||
72 | <strong><?php _wsl_e( $settings["label"], 'wordpress-social-login' ) ?></strong> |
||
73 | </td> |
||
74 | <td class="column-description"> |
||
75 | <p><?php _wsl_e( $settings["description"], 'wordpress-social-login' ) ?></p> |
||
76 | <?php |
||
77 | $meta = array(); |
||
78 | |||
79 | View Code Duplication | if( isset( $settings["version"] ) ) |
|
80 | { |
||
81 | $meta[] = sprintf( _wsl__( "Version %s", 'wordpress-social-login' ), $settings["version"] ); |
||
82 | } |
||
83 | |||
84 | if( isset( $settings["author"] ) ) |
||
85 | { |
||
86 | if( isset( $settings["author_url"] ) ) |
||
87 | { |
||
88 | $meta[] = sprintf( _wsl__( 'By <a href="%s" target="_blank">%s</a>', 'wordpress-social-login' ), $settings["author_url"], $settings["author"] ); |
||
89 | } |
||
90 | else |
||
91 | { |
||
92 | $meta[] = sprintf( _wsl__( 'By %s', 'wordpress-social-login' ), $settings["author"] ); |
||
93 | } |
||
94 | } |
||
95 | |||
96 | View Code Duplication | if( isset( $settings["component_url"] ) ) |
|
97 | { |
||
98 | $meta[] = sprintf( _wsl__( '<a href="%s" target="_blank">Visit component site</a>', 'wordpress-social-login' ), $settings["component_url"] ); |
||
99 | } |
||
100 | |||
101 | if( ! empty($meta) ) |
||
102 | { |
||
103 | ?><p><?php echo implode( ' | ', $meta ); ?></p><?php |
||
104 | } |
||
105 | ?> |
||
106 | </td> |
||
107 | <td class="column-action" align="right" style="width: 120px;"> |
||
108 | <p> |
||
109 | <?php if( $plugin_enablable && $settings["type"] != "core" ): ?> |
||
110 | <?php if( $settings["enabled"] ): ?> |
||
111 | <a class="button-secondary" href="options-general.php?page=wordpress-social-login&wslp=components&disable=<?php echo $name ?>"><?php _wsl_e( "Disable", 'wordpress-social-login' ) ?></a> |
||
112 | <?php else: ?> |
||
113 | <a class="button-primary" style="color:#ffffff" href="options-general.php?page=wordpress-social-login&wslp=components&enable=<?php echo $name ?>"><?php _wsl_e( "Enable", 'wordpress-social-login' ) ?> </a> |
||
114 | <?php endif; ?> |
||
115 | <?php endif; ?> |
||
116 | |
||
117 | </p> |
||
118 | </td> |
||
119 | </tr> |
||
120 | <?php |
||
121 | } |
||
122 | ?> |
||
123 | </tbody> |
||
124 | </table> |
||
125 | </form> |
||
126 | <?php |
||
127 | // HOOKABLE: |
||
128 | do_action( "wsl_component_components_setup_end" ); |
||
129 | } |
||
130 | |||
132 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.