Conditions | 6 |
Paths | 13 |
Total Lines | 137 |
Code Lines | 48 |
Lines | 0 |
Ratio | 0 % |
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 |
||
136 | public function bulk_install( $plugins, $args = array() ) { |
||
137 | // [TGMPA + ] Hook auto-activation in. |
||
138 | add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
||
139 | |||
140 | $defaults = array( |
||
141 | 'clear_update_cache' => true, |
||
142 | ); |
||
143 | $parsed_args = wp_parse_args( $args, $defaults ); |
||
144 | |||
145 | $this->init(); |
||
146 | $this->bulk = true; |
||
147 | |||
148 | $this->install_strings(); // [TGMPA + ] adjusted. |
||
149 | |||
150 | /* [TGMPA - ] $current = get_site_transient( 'update_plugins' ); */ |
||
151 | |||
152 | /* [TGMPA - ] add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); */ |
||
153 | |||
154 | $this->skin->header(); |
||
155 | |||
156 | // Connect to the Filesystem first. |
||
157 | $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); |
||
158 | if ( ! $res ) { |
||
159 | $this->skin->footer(); |
||
160 | return false; |
||
161 | } |
||
162 | |||
163 | $this->skin->bulk_header(); |
||
164 | |||
165 | /* |
||
166 | * Only start maintenance mode if: |
||
167 | * - running Multisite and there are one or more plugins specified, OR |
||
168 | * - a plugin with an update available is currently active. |
||
169 | * @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible. |
||
170 | */ |
||
171 | $maintenance = ( is_multisite() && ! empty( $plugins ) ); |
||
172 | |||
173 | /* |
||
174 | [TGMPA - ] |
||
175 | foreach ( $plugins as $plugin ) |
||
176 | $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) ); |
||
177 | */ |
||
178 | if ( $maintenance ) { |
||
179 | $this->maintenance_mode( true ); |
||
180 | } |
||
181 | |||
182 | $results = array(); |
||
183 | |||
184 | $this->update_count = count( $plugins ); |
||
185 | $this->update_current = 0; |
||
186 | foreach ( $plugins as $plugin ) { |
||
187 | $this->update_current++; |
||
188 | |||
189 | /* |
||
190 | [TGMPA - ] |
||
191 | $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true); |
||
192 | |||
193 | if ( !isset( $current->response[ $plugin ] ) ) { |
||
194 | $this->skin->set_result('up_to_date'); |
||
195 | $this->skin->before(); |
||
196 | $this->skin->feedback('up_to_date'); |
||
197 | $this->skin->after(); |
||
198 | $results[$plugin] = true; |
||
199 | continue; |
||
200 | } |
||
201 | |||
202 | // Get the URL to the zip file. |
||
203 | $r = $current->response[ $plugin ]; |
||
204 | |||
205 | $this->skin->plugin_active = is_plugin_active($plugin); |
||
206 | */ |
||
207 | |||
208 | $result = $this->run( |
||
209 | array( |
||
210 | 'package' => $plugin, // [TGMPA + ] adjusted. |
||
211 | 'destination' => WP_PLUGIN_DIR, |
||
212 | 'clear_destination' => false, // [TGMPA + ] adjusted. |
||
213 | 'clear_working' => true, |
||
214 | 'is_multi' => true, |
||
215 | 'hook_extra' => array( |
||
216 | 'plugin' => $plugin, |
||
217 | ), |
||
218 | ) |
||
219 | ); |
||
220 | |||
221 | $results[ $plugin ] = $this->result; |
||
222 | |||
223 | // Prevent credentials auth screen from displaying multiple times. |
||
224 | if ( false === $result ) { |
||
225 | break; |
||
226 | } |
||
227 | } |
||
228 | |||
229 | $this->maintenance_mode( false ); |
||
230 | |||
231 | /** |
||
232 | * Fires when the bulk upgrader process is complete. |
||
233 | * |
||
234 | * @since WP 3.6.0 / TGMPA 2.5.0 |
||
235 | * |
||
236 | * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might |
||
237 | * be a Theme_Upgrader or Core_Upgrade instance. |
||
238 | * @param array $data { |
||
239 | * Array of bulk item update data. |
||
240 | * |
||
241 | * @type string $action Type of action. Default 'update'. |
||
242 | * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'. |
||
243 | * @type bool $bulk Whether the update process is a bulk update. Default true. |
||
244 | * @type array $packages Array of plugin, theme, or core packages to update. |
||
245 | * } |
||
246 | */ |
||
247 | do_action( // WPCS: prefix OK. |
||
248 | 'upgrader_process_complete', |
||
249 | $this, |
||
250 | array( |
||
251 | 'action' => 'install', // [TGMPA + ] adjusted. |
||
252 | 'type' => 'plugin', |
||
253 | 'bulk' => true, |
||
254 | 'plugins' => $plugins, |
||
255 | ) |
||
256 | ); |
||
257 | |||
258 | $this->skin->bulk_footer(); |
||
259 | |||
260 | $this->skin->footer(); |
||
261 | |||
262 | // Cleanup our hooks, in case something else does a upgrade on this connection. |
||
263 | /* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); */ |
||
264 | |||
265 | // [TGMPA + ] Remove our auto-activation hook. |
||
266 | remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
||
267 | |||
268 | // Force refresh of plugin update information. |
||
269 | wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
||
270 | |||
271 | return $results; |
||
272 | } |
||
273 | |||
334 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.