| Conditions | 9 |
| Paths | 17 |
| Total Lines | 64 |
| 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 |
||
| 124 | static function admin_page_load() { |
||
| 125 | if ( isset( $_GET['action'] ) ) { |
||
| 126 | if ( isset( $_GET['service'] ) ) { |
||
| 127 | $service_name = $_GET['service']; |
||
| 128 | } |
||
| 129 | |||
| 130 | switch ( $_GET['action'] ) { |
||
| 131 | |||
| 132 | case 'request': |
||
| 133 | check_admin_referer( 'keyring-request', 'kr_nonce' ); |
||
| 134 | check_admin_referer( "keyring-request-$service_name", 'nonce' ); |
||
| 135 | |||
| 136 | $verification = Jetpack::generate_secrets( 'publicize' ); |
||
| 137 | if ( ! $verification ) { |
||
| 138 | $url = Jetpack::admin_url( 'jetpack#/settings' ); |
||
| 139 | wp_die( sprintf( __( "Jetpack is not connected. Please connect Jetpack by visiting <a href='%s'>Settings</a>.", 'jetpack' ), $url ) ); |
||
| 140 | |||
| 141 | } |
||
| 142 | $stats_options = get_option( 'stats_options' ); |
||
| 143 | $wpcom_blog_id = Jetpack_Options::get_option( 'id' ); |
||
| 144 | $wpcom_blog_id = ! empty( $wpcom_blog_id ) ? $wpcom_blog_id : $stats_options['blog_id']; |
||
| 145 | |||
| 146 | $user = wp_get_current_user(); |
||
| 147 | $redirect = Jetpack_Keyring_Service_Helper::api_url( $service_name, urlencode_deep( array( |
||
| 148 | 'action' => 'request', |
||
| 149 | 'redirect_uri' => add_query_arg( array( 'action' => 'done' ), menu_page_url( 'sharing', false ) ), |
||
| 150 | 'for' => 'publicize', |
||
| 151 | // required flag that says this connection is intended for publicize |
||
| 152 | 'siteurl' => site_url(), |
||
| 153 | 'state' => $user->ID, |
||
| 154 | 'blog_id' => $wpcom_blog_id, |
||
| 155 | 'secret_1' => $verification['secret_1'], |
||
| 156 | 'secret_2' => $verification['secret_2'], |
||
| 157 | 'eol' => $verification['exp'], |
||
| 158 | ) ) ); |
||
| 159 | wp_redirect( $redirect ); |
||
| 160 | exit; |
||
| 161 | break; |
||
| 162 | |||
| 163 | case 'completed': |
||
| 164 | Jetpack::load_xml_rpc_client(); |
||
| 165 | $xml = new Jetpack_IXR_Client(); |
||
| 166 | $xml->query( 'jetpack.fetchPublicizeConnections' ); |
||
| 167 | |||
| 168 | if ( ! $xml->isError() ) { |
||
| 169 | $response = $xml->getResponse(); |
||
| 170 | Jetpack_Options::update_option( 'publicize_connections', $response ); |
||
| 171 | } |
||
| 172 | |||
| 173 | break; |
||
| 174 | |||
| 175 | case 'delete': |
||
| 176 | $id = $_GET['id']; |
||
| 177 | |||
| 178 | check_admin_referer( 'keyring-request', 'kr_nonce' ); |
||
| 179 | check_admin_referer( "keyring-request-$service_name", 'nonce' ); |
||
| 180 | |||
| 181 | Jetpack_Keyring_Service_Helper::disconnect( $service_name, $id ); |
||
| 182 | |||
| 183 | do_action( 'connection_disconnected', $service_name ); |
||
| 184 | break; |
||
| 185 | } |
||
| 186 | } |
||
| 187 | } |
||
| 188 | |||
| 205 |
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.