Conditions | 9 |
Paths | 17 |
Total Lines | 63 |
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 |
||
143 | static function admin_page_load() { |
||
144 | if ( isset( $_GET['action'] ) ) { |
||
145 | if ( isset( $_GET['service'] ) ) { |
||
146 | $service_name = $_GET['service']; |
||
147 | } |
||
148 | |||
149 | switch ( $_GET['action'] ) { |
||
150 | |||
151 | case 'request': |
||
152 | check_admin_referer( 'keyring-request', 'kr_nonce' ); |
||
153 | check_admin_referer( "keyring-request-$service_name", 'nonce' ); |
||
154 | |||
155 | $verification = Jetpack::generate_secrets( 'publicize' ); |
||
156 | if ( ! $verification ) { |
||
157 | $url = Jetpack::admin_url( 'jetpack#/settings' ); |
||
158 | wp_die( sprintf( __( "Jetpack is not connected. Please connect Jetpack by visiting <a href='%s'>Settings</a>.", 'jetpack' ), $url ) ); |
||
159 | |||
160 | } |
||
161 | $stats_options = get_option( 'stats_options' ); |
||
162 | $wpcom_blog_id = Jetpack_Options::get_option( 'id' ); |
||
163 | $wpcom_blog_id = ! empty( $wpcom_blog_id ) ? $wpcom_blog_id : $stats_options['blog_id']; |
||
164 | |||
165 | $user = wp_get_current_user(); |
||
166 | $redirect = Jetpack_Keyring_Service_Helper::api_url( $service_name, urlencode_deep( array( |
||
167 | 'action' => 'request', |
||
168 | 'redirect_uri' => add_query_arg( array( 'action' => 'done' ), menu_page_url( 'sharing', false ) ), |
||
169 | 'for' => 'publicize', |
||
170 | // required flag that says this connection is intended for publicize |
||
171 | 'siteurl' => site_url(), |
||
172 | 'state' => $user->ID, |
||
173 | 'blog_id' => $wpcom_blog_id, |
||
174 | 'secret_1' => $verification['secret_1'], |
||
175 | 'secret_2' => $verification['secret_2'], |
||
176 | 'eol' => $verification['exp'], |
||
177 | ) ) ); |
||
178 | wp_redirect( $redirect ); |
||
179 | exit; |
||
180 | break; |
||
181 | |||
182 | case 'completed': |
||
183 | $xml = new Jetpack_IXR_Client(); |
||
184 | $xml->query( 'jetpack.fetchPublicizeConnections' ); |
||
185 | |||
186 | if ( ! $xml->isError() ) { |
||
187 | $response = $xml->getResponse(); |
||
188 | Jetpack_Options::update_option( 'publicize_connections', $response ); |
||
189 | } |
||
190 | |||
191 | break; |
||
192 | |||
193 | case 'delete': |
||
194 | $id = $_GET['id']; |
||
195 | |||
196 | check_admin_referer( 'keyring-request', 'kr_nonce' ); |
||
197 | check_admin_referer( "keyring-request-$service_name", 'nonce' ); |
||
198 | |||
199 | Jetpack_Keyring_Service_Helper::disconnect( $service_name, $id ); |
||
200 | |||
201 | do_action( 'connection_disconnected', $service_name ); |
||
202 | break; |
||
203 | } |
||
204 | } |
||
205 | } |
||
206 | |||
222 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.