Conditions | 14 |
Paths | 13 |
Total Lines | 63 |
Code Lines | 25 |
Lines | 7 |
Ratio | 11.11 % |
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 |
||
33 | public function check_upgrader( $upgrader, $details) { |
||
34 | /* |
||
35 | * Handle plugin update errors |
||
36 | */ |
||
37 | if ( |
||
38 | 'Plugin_Upgrader' == get_class( $upgrader ) && |
||
39 | isset( $details['type'] ) && |
||
40 | 'plugin' == $details['type'] && |
||
41 | ( |
||
42 | 'WP_Ajax_Upgrader_Skin' == get_class( $upgrader->skin ) || |
||
43 | 'Bulk_Plugin_Upgrader_Skin' == get_class( $upgrader->skin ) |
||
44 | ) |
||
45 | ) { |
||
46 | if ( 'WP_Ajax_Upgrader_Skin' == get_class( $upgrader->skin ) ) { |
||
47 | $errors = $upgrader->skin->get_errors(); |
||
48 | } else { |
||
49 | $errors = $upgrader->skin->result; |
||
50 | } |
||
51 | |||
52 | if ( is_wp_error( $errors) ) { |
||
53 | foreach ( $details['plugins'] as $slug ) { |
||
54 | /** |
||
55 | * Sync that a plugin update failed |
||
56 | * |
||
57 | * @since 5.8.0 |
||
58 | * |
||
59 | * @module sync |
||
60 | * |
||
61 | * @param string $plugin, Plugin slug |
||
62 | * @param string Error code |
||
63 | * @param string Error message |
||
64 | */ |
||
65 | do_action( 'jetpack_plugin_update_failed', $slug, $errors->get_error_code(), $errors->get_error_message() ); |
||
66 | } |
||
67 | return; |
||
68 | } |
||
69 | } |
||
70 | |||
71 | View Code Duplication | if ( ! isset( $details['type'] ) || |
|
72 | 'plugin' !== $details['type'] || |
||
73 | is_wp_error( $upgrader->skin->result ) || |
||
74 | ! method_exists( $upgrader, 'plugin_info' ) |
||
75 | ) { |
||
76 | return; |
||
77 | } |
||
78 | |||
79 | if ( 'install' === $details['action'] ) { |
||
80 | $plugin_path = $upgrader->plugin_info(); |
||
81 | $plugins = get_plugins(); |
||
82 | $plugin_info = $plugins[ $plugin_path ]; |
||
83 | |||
84 | /** |
||
85 | * Signals to the sync listener that a plugin was installed and a sync action |
||
86 | * reflecting the installation and the plugin info should be sent |
||
87 | * |
||
88 | * @since 4.9.0 |
||
89 | * |
||
90 | * @param string $plugin_path Path of plugin installed |
||
91 | * @param mixed $plugin_info Array of info describing plugin installed |
||
92 | */ |
||
93 | do_action( 'jetpack_installed_plugin', $plugin_path, $plugin_info ); |
||
94 | } |
||
95 | } |
||
96 | |||
227 |