| Conditions | 8 |
| Paths | 128 |
| Total Lines | 87 |
| Code Lines | 42 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 152 | public static function output_options( $post ) { |
||
| 153 | |||
| 154 | $post_id = ! empty( $post->ID ) ? $post->ID : 0; |
||
| 155 | $success_page = get_post_meta( $post->ID, 'wpinv_success_page', true ); |
||
| 156 | $button_text = get_post_meta( $post->ID, 'wpinv_button_text', true ); |
||
| 157 | $processing_text = get_post_meta( $post->ID, 'wpinv_processing_text', true ); |
||
| 158 | $supports_quantities = (int) get_post_meta( $post->ID, 'wpinv_form_supports_quantities', true ); |
||
| 159 | $supports_discounts = (int) get_post_meta( $post->ID, 'wpinv_form_supports_discounts', true ); |
||
| 160 | $enable_taxes = (int) get_post_meta( $post->ID, 'wpinv_form_supports_quantities', true ); |
||
| 161 | |||
| 162 | $values = array( |
||
| 163 | 'success_page' => empty( $success_page ) ? wpinv_get_success_page_uri() : $success_page, |
||
| 164 | 'button_text' => empty( $button_text ) ? __( 'Pay Now', 'invoicing' ) : $button_text, |
||
| 165 | 'processing_text' => empty( $processing_text ) ? __( 'Processing', 'invoicing' ) : $processing_text, |
||
| 166 | 'supports_quantities' => empty( $supports_quantities ) ? 0 : 1, |
||
| 167 | 'enable_taxes' => empty( $enable_taxes ) ? 0 : 1, |
||
| 168 | 'supports_discounts' => empty( $supports_discounts ) ? 0 : 1, |
||
| 169 | ); |
||
| 170 | |||
| 171 | ?> |
||
| 172 | |||
| 173 | <div class="wpinv-items-wrap-pending" id="wpinv_items_wrap"> |
||
| 174 | <table class="form-table"> |
||
| 175 | <tbody> |
||
| 176 | |||
| 177 | <tr class="form-field-supports_quantities"> |
||
| 178 | <th scope="row"></th> |
||
| 179 | <td> |
||
| 180 | <div> |
||
| 181 | <label> |
||
| 182 | <input type="checkbox" name="supports_quantities" id="field_supports_quantities" value="1" <?php checked( $values['supports_quantities'], 1 ); ?>> |
||
| 183 | <span><?php _e( 'Let users set custom item quantities', 'invoicing' ); ?></span> |
||
| 184 | </label> |
||
| 185 | </div> |
||
| 186 | </td> |
||
| 187 | </tr> |
||
| 188 | |||
| 189 | <tr class="form-field-enable_taxes"> |
||
| 190 | <th scope="row"></th> |
||
| 191 | <td> |
||
| 192 | <div> |
||
| 193 | <label> |
||
| 194 | <input type="checkbox" name="enable_taxes" id="field_enable_taxes" value="1" <?php checked( $values['enable_taxes'], 1 ); ?>> |
||
| 195 | <span><?php _e( 'Enable tax calculations', 'invoicing' ); ?></span> |
||
| 196 | </label> |
||
| 197 | </div> |
||
| 198 | </td> |
||
| 199 | </tr> |
||
| 200 | |||
| 201 | <tr class="form-field-supports_discounts"> |
||
| 202 | <th scope="row"></th> |
||
| 203 | <td> |
||
| 204 | <div> |
||
| 205 | <label> |
||
| 206 | <input type="checkbox" name="supports_discounts" id="field_supports_discounts" value="1" <?php checked( $values['supports_discounts'], 1 ); ?>> |
||
| 207 | <span><?php _e( 'Enable coupon codes', 'invoicing' ); ?></span> |
||
| 208 | </label> |
||
| 209 | </div> |
||
| 210 | </td> |
||
| 211 | </tr> |
||
| 212 | |||
| 213 | <tr class="form-field-success_page"> |
||
| 214 | <th scope="row"><label for="field_success_page"><?php _e( 'Success Page', 'invoicing' ); ?></label></th> |
||
| 215 | <td> |
||
| 216 | <div> |
||
| 217 | <input type="text" class="regular-text" name="success_page" id="field_success_page" value="<?php echo esc_attr( $values['success_page'] ); ?>"> |
||
| 218 | <p class="description"><?php _e( 'Where should we redirect users after successfuly completing their payment?', 'invoicing' ); ?></p> |
||
| 219 | </div> |
||
| 220 | </td> |
||
| 221 | </tr> |
||
| 222 | |||
| 223 | <tr class="form-field-button_text"> |
||
| 224 | <th scope="row"><label for="field_button_text"><?php _e( 'Button Text', 'invoicing' ); ?></label></th> |
||
| 225 | <td> |
||
| 226 | <div> |
||
| 227 | <input type="text" class="regular-text" name="button_text" id="field_button_text" value="<?php echo esc_attr( $values['button_text'] ); ?>"> |
||
| 228 | <p class="description"><?php _e( 'Payment button text', 'invoicing' ); ?></p> |
||
| 229 | </div> |
||
| 230 | </td> |
||
| 231 | </tr> |
||
| 232 | |||
| 233 | <tr class="form-field-processing_text"> |
||
| 234 | <th scope="row"><label for="field_processing_text"><?php _e( 'Processing Text', 'invoicing' ); ?></label></th> |
||
| 235 | <td> |
||
| 236 | <div> |
||
| 237 | <input type="text" class="regular-text" name="processing_text" id="field_processing_text" value="<?php echo esc_attr( $values['processing_text'] ); ?>"> |
||
| 238 | <p class="description"><?php _e( 'Processing payment button text', 'invoicing' ); ?></p> |
||
| 239 | </div> |
||
| 253 |