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