Conditions | 35 |
Paths | > 20000 |
Total Lines | 184 |
Lines | 3 |
Ratio | 1.63 % |
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 |
||
29 | function wsl_update_compatibilities() |
||
30 | { |
||
31 | delete_option( 'wsl_settings_development_mode_enabled' ); |
||
32 | delete_option( 'wsl_settings_migration_notice_is_read' ); |
||
33 | delete_option( 'wsl_settings_debug_mode_enabled' ); |
||
34 | |||
35 | update_option( 'wsl_settings_welcome_panel_enabled', 1 ); |
||
36 | |||
37 | if( ! get_option( 'wsl_settings_redirect_url' ) ) |
||
38 | { |
||
39 | update_option( 'wsl_settings_redirect_url', home_url() ); |
||
40 | } |
||
41 | |||
42 | if( ! get_option( 'wsl_settings_force_redirect_url' ) ) |
||
43 | { |
||
44 | update_option( 'wsl_settings_force_redirect_url', 2 ); |
||
45 | } |
||
46 | |||
47 | if( ! get_option( 'wsl_settings_connect_with_label' ) ) |
||
48 | { |
||
49 | update_option( 'wsl_settings_connect_with_label', _wsl__("Connect with:", 'wordpress-social-login') ); |
||
50 | } |
||
51 | |||
52 | if( ! get_option( 'wsl_settings_users_avatars' ) ) |
||
53 | { |
||
54 | update_option( 'wsl_settings_users_avatars', 1 ); |
||
55 | } |
||
56 | |||
57 | if( ! get_option( 'wsl_settings_use_popup' ) ) |
||
58 | { |
||
59 | update_option( 'wsl_settings_use_popup', 2 ); |
||
60 | } |
||
61 | |||
62 | if( ! get_option( 'wsl_settings_widget_display' ) ) |
||
63 | { |
||
64 | update_option( 'wsl_settings_widget_display', 1 ); |
||
65 | } |
||
66 | |||
67 | if( ! get_option( 'wsl_settings_authentication_widget_css' ) ) |
||
68 | { |
||
69 | update_option( 'wsl_settings_authentication_widget_css', ".wp-social-login-connect-with {}\n.wp-social-login-provider-list {}\n.wp-social-login-provider-list a {}\n.wp-social-login-provider-list img {}\n.wsl_connect_with_provider {}" ); |
||
70 | } |
||
71 | |||
72 | # bouncer settings |
||
73 | if( ! get_option( 'wsl_settings_bouncer_registration_enabled' ) ) |
||
74 | { |
||
75 | update_option( 'wsl_settings_bouncer_registration_enabled', 1 ); |
||
76 | } |
||
77 | |||
78 | if( ! get_option( 'wsl_settings_bouncer_authentication_enabled' ) ) |
||
79 | { |
||
80 | update_option( 'wsl_settings_bouncer_authentication_enabled', 1 ); |
||
81 | } |
||
82 | |||
83 | if( ! get_option( 'wsl_settings_bouncer_accounts_linking_enabled' ) ) |
||
84 | { |
||
85 | update_option( 'wsl_settings_bouncer_accounts_linking_enabled', 1 ); |
||
86 | } |
||
87 | |||
88 | if( ! get_option( 'wsl_settings_bouncer_profile_completion_require_email' ) ) |
||
89 | { |
||
90 | update_option( 'wsl_settings_bouncer_profile_completion_require_email', 2 ); |
||
91 | } |
||
92 | |||
93 | if( ! get_option( 'wsl_settings_bouncer_profile_completion_change_username' ) ) |
||
94 | { |
||
95 | update_option( 'wsl_settings_bouncer_profile_completion_change_username', 2 ); |
||
96 | } |
||
97 | |||
98 | if( ! get_option( 'wsl_settings_bouncer_profile_completion_hook_extra_fields' ) ) |
||
99 | { |
||
100 | update_option( 'wsl_settings_bouncer_profile_completion_hook_extra_fields', 2 ); |
||
101 | } |
||
102 | |||
103 | if( ! get_option( 'wsl_settings_bouncer_new_users_moderation_level' ) ) |
||
104 | { |
||
105 | update_option( 'wsl_settings_bouncer_new_users_moderation_level', 1 ); |
||
106 | } |
||
107 | |||
108 | if( ! get_option( 'wsl_settings_bouncer_new_users_membership_default_role' ) ) |
||
109 | { |
||
110 | update_option( 'wsl_settings_bouncer_new_users_membership_default_role', "default" ); |
||
111 | } |
||
112 | |||
113 | if( ! get_option( 'wsl_settings_bouncer_new_users_restrict_domain_enabled' ) ) |
||
114 | { |
||
115 | update_option( 'wsl_settings_bouncer_new_users_restrict_domain_enabled', 2 ); |
||
116 | } |
||
117 | |||
118 | if( ! get_option( 'wsl_settings_bouncer_new_users_restrict_domain_text_bounce' ) ) |
||
119 | { |
||
120 | update_option( 'wsl_settings_bouncer_new_users_restrict_domain_text_bounce', _wsl__("<strong>This website is restricted to invited readers only.</strong><p>It doesn't look like you have been invited to access this site. If you think this is a mistake, you might want to contact the website owner and request an invitation.<p>", 'wordpress-social-login') ); |
||
121 | } |
||
122 | |||
123 | if( ! get_option( 'wsl_settings_bouncer_new_users_restrict_email_enabled' ) ) |
||
124 | { |
||
125 | update_option( 'wsl_settings_bouncer_new_users_restrict_email_enabled', 2 ); |
||
126 | } |
||
127 | |||
128 | if( ! get_option( 'wsl_settings_bouncer_new_users_restrict_email_text_bounce' ) ) |
||
129 | { |
||
130 | update_option( 'wsl_settings_bouncer_new_users_restrict_email_text_bounce', _wsl__("<strong>This website is restricted to invited readers only.</strong><p>It doesn't look like you have been invited to access this site. If you think this is a mistake, you might want to contact the website owner and request an invitation.<p>", 'wordpress-social-login') ); |
||
131 | } |
||
132 | |||
133 | if( ! get_option( 'wsl_settings_bouncer_new_users_restrict_profile_enabled' ) ) |
||
134 | { |
||
135 | update_option( 'wsl_settings_bouncer_new_users_restrict_profile_enabled', 2 ); |
||
136 | } |
||
137 | |||
138 | if( ! get_option( 'wsl_settings_bouncer_new_users_restrict_profile_text_bounce' ) ) |
||
139 | { |
||
140 | update_option( 'wsl_settings_bouncer_new_users_restrict_profile_text_bounce', _wsl__("<strong>This website is restricted to invited readers only.</strong><p>It doesn't look like you have been invited to access this site. If you think this is a mistake, you might want to contact the website owner and request an invitation.<p>", 'wordpress-social-login') ); |
||
141 | } |
||
142 | |||
143 | # contacts import |
||
144 | if( ! get_option( 'wsl_settings_contacts_import_facebook' ) ) |
||
145 | { |
||
146 | update_option( 'wsl_settings_contacts_import_facebook', 2 ); |
||
147 | } |
||
148 | |||
149 | if( ! get_option( 'wsl_settings_contacts_import_google' ) ) |
||
150 | { |
||
151 | update_option( 'wsl_settings_contacts_import_google', 2 ); |
||
152 | } |
||
153 | |||
154 | if( ! get_option( 'wsl_settings_contacts_import_twitter' ) ) |
||
155 | { |
||
156 | update_option( 'wsl_settings_contacts_import_twitter', 2 ); |
||
157 | } |
||
158 | |||
159 | if( ! get_option( 'wsl_settings_contacts_import_live' ) ) |
||
160 | { |
||
161 | update_option( 'wsl_settings_contacts_import_live', 2 ); |
||
162 | } |
||
163 | |||
164 | if( ! get_option( 'wsl_settings_contacts_import_linkedin' ) ) |
||
165 | { |
||
166 | update_option( 'wsl_settings_contacts_import_linkedin', 2 ); |
||
167 | } |
||
168 | |||
169 | if( ! get_option( 'wsl_settings_buddypress_enable_mapping' ) ) |
||
170 | { |
||
171 | update_option( 'wsl_settings_buddypress_enable_mapping', 2 ); |
||
172 | } |
||
173 | |||
174 | # buddypress profile mapping |
||
175 | if( ! get_option( 'wsl_settings_buddypress_xprofile_map' ) ) |
||
176 | { |
||
177 | update_option( 'wsl_settings_buddypress_xprofile_map', '' ); |
||
178 | } |
||
179 | |||
180 | # if no idp is enabled then we enable the default providers (facebook, google, twitter) |
||
181 | global $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG; |
||
182 | $nok = true; |
||
183 | foreach( $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG AS $item ) |
||
184 | { |
||
185 | $provider_id = $item["provider_id"]; |
||
186 | |||
187 | if( get_option( 'wsl_settings_' . $provider_id . '_enabled' ) ) |
||
188 | { |
||
189 | $nok = false; |
||
190 | } |
||
191 | } |
||
192 | |||
193 | if( $nok ) |
||
194 | { |
||
195 | foreach( $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG AS $item ) |
||
196 | { |
||
197 | $provider_id = $item["provider_id"]; |
||
198 | |||
199 | View Code Duplication | if( isset( $item["default_network"] ) && $item["default_network"] ){ |
|
|
|||
200 | update_option( 'wsl_settings_' . $provider_id . '_enabled', 1 ); |
||
201 | } |
||
202 | } |
||
203 | } |
||
204 | |||
205 | global $wpdb; |
||
206 | |||
207 | # migrate steam users id to id64. Prior to 2.2 |
||
208 | $sql = "UPDATE {$wpdb->prefix}wslusersprofiles |
||
209 | SET identifier = REPLACE( identifier, 'http://steamcommunity.com/openid/id/', '' ) |
||
210 | WHERE provider = 'Steam' AND identifier like 'http://steamcommunity.com/openid/id/%' "; |
||
211 | $wpdb->query( $sql ); |
||
212 | } |
||
213 | |||
255 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.