| Conditions | 2 |
| Paths | 2 |
| Total Lines | 71 |
| Code Lines | 47 |
| 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 |
||
| 24 | public static function output( $post ) { |
||
| 25 | |||
| 26 | // Prepare the item. |
||
| 27 | $item = new WPInv_Item( $post ); |
||
| 28 | |||
| 29 | ?> |
||
| 30 | |||
| 31 | <div class='bsui' style='padding-top: 10px;'> |
||
| 32 | <?php do_action( 'wpinv_item_before_info_metabox', $item ); ?> |
||
| 33 | |||
| 34 | <div class="wpinv_item_type form-group row"> |
||
| 35 | <label for="wpinv_item_type" class="col-sm-12 col-form-label"> |
||
| 36 | <?php _e( 'Item Type', 'invoicing' );?> |
||
| 37 | <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( self::get_tooltip( $post ) ); ?>"></span> |
||
| 38 | </label> |
||
| 39 | |||
| 40 | <div class="col-sm-12"> |
||
| 41 | |||
| 42 | <?php |
||
| 43 | echo aui()->select( |
||
| 44 | array( |
||
| 45 | 'id' => 'wpinv_item_type', |
||
| 46 | 'name' => 'wpinv_item_type', |
||
| 47 | 'placeholder' => __( 'Select item type', 'invoicing' ), |
||
| 48 | 'value' => $item->get_type( 'edit' ), |
||
| 49 | 'select2' => true, |
||
| 50 | 'data-allow-clear' => 'false', |
||
| 51 | 'no_wrap' => true, |
||
| 52 | 'options' => wpinv_get_item_types(), |
||
| 53 | ) |
||
| 54 | ); |
||
| 55 | ?> |
||
| 56 | |||
| 57 | </div> |
||
| 58 | </div> |
||
| 59 | |||
| 60 | <div class="wpinv_item_shortcode form-group row"> |
||
| 61 | <label for="wpinv_item_shortcode" class="col-sm-12 col-form-label"> |
||
| 62 | <?php _e( 'Payment Form Shortcode', 'invoicing' );?> |
||
| 63 | <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span> |
||
| 64 | </label> |
||
| 65 | |||
| 66 | <div class="col-sm-12"> |
||
| 67 | <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?>]" style="width: 100%;" /> |
||
| 68 | </div> |
||
| 69 | </div> |
||
| 70 | |||
| 71 | <div class="wpinv_item_buy_shortcode form-group row"> |
||
| 72 | <label for="wpinv_item_button_shortcode" class="col-sm-12 col-form-label"> |
||
| 73 | <?php _e( 'Payment Button Shortcode', 'invoicing' );?> |
||
| 74 | <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span> |
||
| 75 | </label> |
||
| 76 | |||
| 77 | <div class="col-sm-12"> |
||
| 78 | <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?> button='Buy Now']" style="width: 100%;" /> |
||
| 79 | </div> |
||
| 80 | </div> |
||
| 81 | |||
| 82 | <div class="wpinv_item_custom_id form-group"> |
||
| 83 | <?php _e( 'Custom ID', 'invoicing' );?> — <?php echo sanitize_text_field( $item->get_custom_id() ) ?> |
||
| 84 | </div> |
||
| 85 | |||
| 86 | <?php do_action( 'wpinv_meta_values_metabox_before', $post ); ?> |
||
| 87 | <?php foreach ( apply_filters( 'wpinv_show_meta_values_for_keys', array() ) as $meta_key ) : ?> |
||
| 88 | <div class="wpinv_item_custom_id form-group"> |
||
| 89 | <?php sanitize_text_field( $meta_key );?> — <?php echo sanitize_text_field( get_post_meta( $item->get_id(), '_wpinv_' . $meta_key, true ) ); ?> |
||
|
|
|||
| 90 | </div> |
||
| 91 | <?php endforeach; ?> |
||
| 92 | <?php do_action( 'wpinv_meta_values_metabox_after', $post ); ?> |
||
| 93 | <?php do_action( 'wpinv_item_info_metabox', $item ); ?> |
||
| 94 | </div> |
||
| 95 | <?php |
||
| 119 |