Conditions | 8 |
Paths | 128 |
Total Lines | 86 |
Code Lines | 38 |
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 |
||
125 | public static function output_options( $post ) { |
||
126 | |||
127 | $post_id = ! empty( $post->ID ) ? $post->ID : 0; |
||
128 | $success_page = get_post_meta( $post->ID, 'wpinv_success_page', true ); |
||
129 | $button_text = get_post_meta( $post->ID, 'wpinv_button_text', true ); |
||
130 | $processing_text = get_post_meta( $post->ID, 'wpinv_processing_text', true ); |
||
131 | $supports_quantities = (int) get_post_meta( $post->ID, 'wpinv_form_supports_quantities', true ); |
||
132 | $supports_discounts = (int) get_post_meta( $post->ID, 'wpinv_form_supports_discounts', true ); |
||
133 | $enable_taxes = (int) get_post_meta( $post->ID, 'wpinv_form_supports_quantities', true ); |
||
134 | |||
135 | $values = array( |
||
136 | 'success_page' => empty( $success_page ) ? wpinv_get_success_page_uri() : $success_page, |
||
137 | 'button_text' => empty( $button_text ) ? __( 'Pay Now', 'invoicing' ) : $button_text, |
||
138 | 'processing_text' => empty( $processing_text ) ? __( 'Processing', 'invoicing' ) : $processing_text, |
||
139 | 'supports_quantities' => empty( $supports_quantities ) ? 0 : 1, |
||
140 | 'enable_taxes' => empty( $enable_taxes ) ? 0 : 1, |
||
141 | 'supports_discounts' => empty( $supports_discounts ) ? 0 : 1, |
||
142 | ); |
||
143 | |||
144 | ?> |
||
145 | |||
146 | <div class="wpinv-items-wrap-pending" id="wpinv_options_wrap"> |
||
147 | <table class="form-table"> |
||
148 | <tbody> |
||
149 | |||
150 | <tr class="form-field-success_page"> |
||
151 | <th scope="row"><label for="field_success_page"><?php _e( 'Success Page', 'invoicing' ); ?></label></th> |
||
152 | <td> |
||
153 | <div> |
||
154 | <input type="text" class="regular-text" name="success_page" id="field_success_page" value="<?php echo esc_attr( $values['success_page'] ); ?>"> |
||
155 | <p class="description"><?php _e( 'Where should we redirect users after successfuly completing their payment?', 'invoicing' ); ?></p> |
||
156 | </div> |
||
157 | </td> |
||
158 | </tr> |
||
159 | |||
160 | <tr class="form-field-button_text"> |
||
161 | <th scope="row"><label for="field_button_text"><?php _e( 'Button Text', 'invoicing' ); ?></label></th> |
||
162 | <td> |
||
163 | <div> |
||
164 | <input type="text" class="regular-text" name="button_text" id="field_button_text" value="<?php echo esc_attr( $values['button_text'] ); ?>"> |
||
165 | <p class="description"><?php _e( 'Payment button text', 'invoicing' ); ?></p> |
||
166 | </div> |
||
167 | </td> |
||
168 | </tr> |
||
169 | |||
170 | <tr class="form-field-processing_text"> |
||
171 | <th scope="row"><label for="field_processing_text"><?php _e( 'Processing Text', 'invoicing' ); ?></label></th> |
||
172 | <td> |
||
173 | <div> |
||
174 | <input type="text" class="regular-text" name="processing_text" id="field_processing_text" value="<?php echo esc_attr( $values['processing_text'] ); ?>"> |
||
175 | <p class="description"><?php _e( 'Processing payment button text', 'invoicing' ); ?></p> |
||
176 | </div> |
||
177 | </td> |
||
178 | </tr> |
||
179 | |||
180 | <tr class="form-field-supports_quantities"> |
||
181 | <th scope="row"></th> |
||
182 | <td> |
||
183 | <div> |
||
184 | <label> |
||
185 | <input type="checkbox" name="supports_quantities" id="field_supports_quantities" value="1" <?php checked( $values['supports_quantities'], 1 ); ?>> |
||
186 | <span><?php _e( 'Let users set custom item quantities', 'invoicing' ); ?></span> |
||
187 | </label> |
||
188 | </div> |
||
189 | </td> |
||
190 | </tr> |
||
191 | |||
192 | <tr class="form-field-enable_taxes"> |
||
193 | <th scope="row"></th> |
||
194 | <td> |
||
195 | <div> |
||
196 | <label> |
||
197 | <input type="checkbox" name="enable_taxes" id="field_enable_taxes" value="1" <?php checked( $values['enable_taxes'], 1 ); ?>> |
||
198 | <span><?php _e( 'Enable tax calculations', 'invoicing' ); ?></span> |
||
199 | </label> |
||
200 | </div> |
||
201 | </td> |
||
202 | </tr> |
||
203 | |||
204 | <tr class="form-field-supports_discounts"> |
||
205 | <th scope="row"></th> |
||
206 | <td> |
||
207 | <div> |
||
208 | <label> |
||
209 | <input type="checkbox" name="supports_discounts" id="field_supports_discounts" value="1" <?php checked( $values['supports_discounts'], 1 ); ?>> |
||
210 | <span><?php _e( 'Enable coupon codes', 'invoicing' ); ?></span> |
||
211 | </label> |
||
280 |