| Conditions | 13 |
| Paths | 12 |
| Total Lines | 35 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 24 | function wpbo_mc_save_list( $post_id ) { |
||
| 25 | |||
| 26 | if ( ! isset( $_POST['wpbo_display'] ) || isset( $_POST['wpbo_display'] ) && ! wp_verify_nonce( $_POST['wpbo_display'], 'add_display' ) ) { |
||
| 27 | return; |
||
| 28 | } |
||
| 29 | |||
| 30 | if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
||
| 31 | return; |
||
| 32 | } |
||
| 33 | |||
| 34 | if ( ! isset( $_POST['post_type'] ) || isset( $_POST['post_type'] ) && 'wpbo-popup' != $_POST['post_type'] ) { |
||
| 35 | return; |
||
| 36 | } |
||
| 37 | |||
| 38 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
||
| 39 | return; |
||
| 40 | } |
||
| 41 | |||
| 42 | $list = isset( $_POST['wpbo_mc_list'] ) ? $_POST['wpbo_mc_list'] : false; |
||
| 43 | |||
| 44 | /* Save custom list ID */ |
||
| 45 | if ( false === $list ) { |
||
| 46 | delete_post_meta( $post_id, 'wpbo_mc_list' ); |
||
| 47 | } else { |
||
| 48 | update_post_meta( $post_id, 'wpbo_mc_list', $list ); |
||
| 49 | } |
||
| 50 | |||
| 51 | /* Save the list groups */ |
||
| 52 | if ( isset( $_POST['wpbo_mc_list_groups'] ) ) { |
||
| 53 | update_post_meta( $post_id, 'wpbo_mc_list_groups', $_POST['wpbo_mc_list_groups'] ); |
||
| 54 | } else { |
||
| 55 | delete_post_meta( $post_id, 'wpbo_mc_list_groups' ); |
||
| 56 | } |
||
| 57 | |||
| 58 | } |
||
| 59 | |||
| 79 | } |