| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 25 |
| 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 |
||
| 23 | public static function output( $post ) { |
||
| 24 | ?> |
||
| 25 | <div id="wpinv-form-builder" class="bsui"> |
||
| 26 | <div class="row"> |
||
| 27 | <div class="col-sm-4"> |
||
| 28 | |||
| 29 | <!-- Builder tabs --> |
||
| 30 | <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e( 'Go Back', 'invoicing' ); ?></button> |
||
| 31 | |||
| 32 | <!-- Builder tab content --> |
||
| 33 | <div class="mt-4"> |
||
| 34 | |||
| 35 | <!-- Available builder elements --> |
||
| 36 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'"> |
||
| 37 | <div class="wpinv-form-builder-add-field-types"> |
||
| 38 | <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small> |
||
| 39 | <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable"> |
||
| 40 | <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }"> |
||
| 41 | <button class="button btn"> |
||
| 42 | <span v-if="element.icon" class="dashicons dashicon-" :class="'dashicon-' + element.icon"></span> |
||
| 43 | {{element.name}} |
||
| 44 | </button> |
||
| 45 | </li> |
||
| 46 | </draggable> |
||
| 47 | </div> |
||
| 48 | </div> |
||
| 49 | |||
| 50 | <!-- Edit an element --> |
||
| 51 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 16px;"> |
||
| 52 | <div class="wpinv-form-builder-edit-field-wrapper"> |
||
| 53 | <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?> |
||
| 54 | <div> |
||
| 55 | <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e( 'Delete Element', 'invoicing' ); ?></button> |
||
| 56 | </div> |
||
| 57 | </div> |
||
| 58 | </div> |
||
| 59 | |||
| 60 | </div> |
||
| 61 | |||
| 62 | </div> |
||
| 63 | <div class="col-sm-8 border-left"> |
||
| 64 | <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small> |
||
| 65 | <p class='form-text text-muted' v-if='! form_elements.length'><?php _e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p> |
||
| 66 | |||
| 67 | <draggable class="section bsui" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 16px;"> |
||
| 68 | <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="{ active: active_form_element==form_element && active_tab=='edit_item' }" @click="active_tab = 'edit_item'; active_form_element = form_element"> |
||
| 69 | <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?> |
||
| 70 | </div> |
||
| 71 | </draggable> |
||
| 72 | |||
| 73 | <textarea style="display:none;" name="wpinv_form_elements" v-model="elementString"></textarea> |
||
| 74 | <textarea style="display:none;" name="wpinv_form_items" v-model="itemString"></textarea> |
||
| 75 | </div> |
||
| 76 | |||
| 77 | </div> |
||
| 78 | </div> |
||
| 79 | <?php |
||
| 80 | |||
| 81 | wp_nonce_field( 'wpinv_save_payment_form', 'wpinv_save_payment_form' ) ; |
||
| 82 | } |
||
| 181 |