Conditions | 4 |
Paths | 4 |
Total Lines | 90 |
Code Lines | 57 |
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 |
||
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 echo strip_tags( 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 | <?php if ( 'fee' === $item->get_type( 'edit' ) || 'custom' === $item->get_type( 'edit' ) ) : ?> |
||
61 | |||
62 | <div class="wpinv_item_shortcode form-group row"> |
||
63 | <label for="wpinv_item_shortcode" class="col-sm-12 col-form-label"> |
||
64 | <?php _e( 'Payment Form Shortcode', 'invoicing' );?> |
||
65 | <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span> |
||
66 | </label> |
||
67 | |||
68 | <div class="col-sm-12"> |
||
69 | <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?>]" style="width: 100%;" readonly/> |
||
70 | </div> |
||
71 | </div> |
||
72 | |||
73 | <div class="wpinv_item_buy_shortcode form-group row"> |
||
74 | <label for="wpinv_item_button_shortcode" class="col-sm-12 col-form-label"> |
||
75 | <?php _e( 'Payment Button Shortcode', 'invoicing' );?> |
||
76 | <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span> |
||
77 | </label> |
||
78 | |||
79 | <div class="col-sm-12"> |
||
80 | <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%;" readonly/> |
||
81 | <small class="form-text text-muted"> |
||
82 | <?php _e( 'Or use the following URL in a link:', 'invoicing' );?> |
||
83 | <code>#getpaid-item-<?php echo intval( $item->get_id() ); ?>|0</code> |
||
84 | </small> |
||
85 | </div> |
||
86 | </div> |
||
87 | |||
88 | <div class="wpinv_item_buy_url form-group row"> |
||
89 | <label for="wpinv_item_buy_url" class="col-sm-12 col-form-label"> |
||
90 | <?php _e( 'Direct Payment URL', 'invoicing' );?> |
||
91 | <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'You can use this in an iFrame to embed the payment form on another website', 'invoicing' ); ?>"></span> |
||
92 | </label> |
||
93 | |||
94 | <div class="col-sm-12"> |
||
95 | <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url( getpaid_embed_url( false, $item->get_id() . '|0' ) ); ?>" style="width: 100%;" readonly/> |
||
|
|||
96 | </div> |
||
97 | </div> |
||
98 | |||
99 | <?php endif; ?> |
||
100 | |||
101 | <div class="wpinv_item_custom_id form-group"> |
||
102 | <?php _e( 'Custom ID', 'invoicing' );?> — <?php echo esc_html( $item->get_custom_id() ) ?> |
||
103 | </div> |
||
104 | |||
105 | <?php do_action( 'wpinv_meta_values_metabox_before', $post ); ?> |
||
106 | <?php foreach ( apply_filters( 'wpinv_show_meta_values_for_keys', array() ) as $meta_key ) : ?> |
||
107 | <div class="wpinv_item_custom_id form-group"> |
||
108 | <?php echo esc_html( $meta_key );?> — <?php echo esc_html( get_post_meta( $item->get_id(), '_wpinv_' . $meta_key, true ) ); ?> |
||
109 | </div> |
||
110 | <?php endforeach; ?> |
||
111 | <?php do_action( 'wpinv_meta_values_metabox_after', $post ); ?> |
||
112 | <?php do_action( 'wpinv_item_info_metabox', $item ); ?> |
||
113 | </div> |
||
114 | <?php |
||
138 |