| Conditions | 3 |
| Paths | 2 |
| Total Lines | 75 |
| 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 |
||
| 36 | function AtD_display_options_form() { |
||
| 37 | |||
| 38 | /* grab our user and validate their existence */ |
||
| 39 | $user = wp_get_current_user(); |
||
| 40 | if ( ! $user || $user->ID == 0 ) { |
||
| 41 | return; |
||
| 42 | } |
||
| 43 | |||
| 44 | $options_show_types = AtD_get_options( $user->ID, 'AtD_options' ); |
||
| 45 | $options_check_when = AtD_get_options( $user->ID, 'AtD_check_when' ); |
||
| 46 | $options_guess_lang = AtD_get_options( $user->ID, 'AtD_guess_lang' ); |
||
| 47 | ?> |
||
| 48 | <table class="form-table"> |
||
| 49 | <tr valign="top"> |
||
| 50 | <th scope="row"> <a id="atd"></a> <?php _e( 'Proofreading', 'jetpack' ); ?></th> |
||
| 51 | <td> |
||
| 52 | <p><?php _e( 'Automatically proofread content when:', 'jetpack' ); ?> |
||
| 53 | |||
| 54 | <p> |
||
| 55 | <?php |
||
| 56 | AtD_print_option( 'onpublish', __( 'a post or page is first published', 'jetpack' ), $options_check_when ); |
||
| 57 | echo '<br />'; |
||
| 58 | AtD_print_option( 'onupdate', __( 'a post or page is updated', 'jetpack' ), $options_check_when ); |
||
| 59 | ?> |
||
| 60 | </p> |
||
| 61 | |||
| 62 | <p style="font-weight: bold"><?php _e( 'English Options', 'jetpack' ); ?></p> |
||
| 63 | |||
| 64 | <p><?php _e( 'Enable proofreading for the following grammar and style rules when writing posts and pages:', 'jetpack' ); ?></p> |
||
| 65 | |||
| 66 | <p> |
||
| 67 | <?php |
||
| 68 | AtD_print_option( 'Bias Language', __( 'Bias Language', 'jetpack' ), $options_show_types ); |
||
| 69 | echo '<br />'; |
||
| 70 | AtD_print_option( 'Cliches', __( 'Clichés', 'jetpack' ), $options_show_types ); |
||
| 71 | echo '<br />'; |
||
| 72 | AtD_print_option( 'Complex Expression', __( 'Complex Phrases', 'jetpack' ), $options_show_types ); |
||
| 73 | echo '<br />'; |
||
| 74 | AtD_print_option( 'Diacritical Marks', __( 'Diacritical Marks', 'jetpack' ), $options_show_types ); |
||
| 75 | echo '<br />'; |
||
| 76 | AtD_print_option( 'Double Negative', __( 'Double Negatives', 'jetpack' ), $options_show_types ); |
||
| 77 | echo '<br />'; |
||
| 78 | AtD_print_option( 'Hidden Verbs', __( 'Hidden Verbs', 'jetpack' ), $options_show_types ); |
||
| 79 | echo '<br />'; |
||
| 80 | AtD_print_option( 'Jargon Language', __( 'Jargon', 'jetpack' ), $options_show_types ); |
||
| 81 | echo '<br />'; |
||
| 82 | AtD_print_option( 'Passive voice', __( 'Passive Voice', 'jetpack' ), $options_show_types ); |
||
| 83 | echo '<br />'; |
||
| 84 | AtD_print_option( 'Phrases to Avoid', __( 'Phrases to Avoid', 'jetpack' ), $options_show_types ); |
||
| 85 | echo '<br />'; |
||
| 86 | AtD_print_option( 'Redundant Expression', __( 'Redundant Phrases', 'jetpack' ), $options_show_types ); |
||
| 87 | ?> |
||
| 88 | </p> |
||
| 89 | <p> |
||
| 90 | <?php |
||
| 91 | printf( __( '<a href="%s" rel="noopener noreferrer" target="_blank">Learn more</a> about these options.', 'jetpack' ), 'http://support.wordpress.com/proofreading/' ); |
||
| 92 | ?> |
||
| 93 | </p> |
||
| 94 | |||
| 95 | <p style="font-weight: bold"><?php _e( 'Language', 'jetpack' ); ?></p> |
||
| 96 | |||
| 97 | <p> |
||
| 98 | <?php |
||
| 99 | _e( 'The proofreader supports English, French, German, Portuguese, and Spanish. Your user interface language (see above) is the default proofreading language.', 'jetpack' ); |
||
| 100 | ?> |
||
| 101 | </p> |
||
| 102 | |||
| 103 | <p> |
||
| 104 | <?php |
||
| 105 | AtD_print_option( 'true', __( 'Use automatically detected language to proofread posts and pages', 'jetpack' ), $options_guess_lang ); |
||
| 106 | ?> |
||
| 107 | </p> |
||
| 108 | |||
| 109 | <?php |
||
| 110 | } |
||
| 111 | |||
| 144 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: