| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 78 | 
| Code Lines | 33 | 
| 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  | 
            ||
| 60 |     public static function output ( $post ) { | 
            ||
| 61 | $success_page = get_post_meta( $post->ID, 'wpinv_success_page', true );  | 
            ||
| 62 | $success_page = empty( $success_page ) ? wpinv_get_success_page_uri() : $success_page  | 
            ||
| 63 | ?>  | 
            ||
| 64 | |||
| 65 | <div id="wpinv-form-builder" style="display: flex; flex-flow: wrap;">  | 
            ||
| 66 | |||
| 67 | <div class="wpinv-form-builder-left bsui" style="flex: 0 0 320px;">  | 
            ||
| 68 | <ul class="wpinv-form-builder-tabs nav nav-tabs">  | 
            ||
| 69 | <li class='nav-item' v-if="active_tab!='new_item'">  | 
            ||
| 70 |                         <a @click.prevent="active_tab='new_item'" class="nav-link p-3" :class="{ 'active': active_tab=='new_item' }" href="#"><?php _e( 'Add new element', 'invoicing' ); ?></a> | 
            ||
| 71 | </li>  | 
            ||
| 72 | <li class='nav-item' v-if='false'>  | 
            ||
| 73 |                         <a @click.prevent="active_tab='edit_item'" class="nav-link p-3" :class="{ 'active': active_tab=='edit_item' }" href="#"><?php _e( 'Edit element', 'invoicing' ); ?></a> | 
            ||
| 74 | </li>  | 
            ||
| 75 | <li class='nav-item' v-if='false'>  | 
            ||
| 76 |                         <a @click.prevent="active_tab='settings'" class="nav-link p-3" :class="{ 'active': active_tab=='settings' }" href="#"><?php _e( 'Settings', 'invoicing' ); ?></a> | 
            ||
| 77 | </li>  | 
            ||
| 78 | </ul>  | 
            ||
| 79 | |||
| 80 | <div class="wpinv-form-builder-tab-content bsui" style="margin-top: 16px;">  | 
            ||
| 81 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'">  | 
            ||
| 82 | <div class="wpinv-form-builder-add-field-types">  | 
            ||
| 83 | <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small>  | 
            ||
| 84 |                             <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"> | 
            ||
| 85 |                                 <li v-for="element in elements" style="width: 49%; background-color: #fafafa; margin-bottom: 9px; cursor: move; border: 1px solid #eeeeee;" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }"> | 
            ||
| 86 | <button class="button btn" style="width: 100%; cursor: move;">  | 
            ||
| 87 | <span v-if="element.icon" class="dashicons dashicon-" :class="'dashicon-' + element.icon"></span>  | 
            ||
| 88 |                                         {{element.name}} | 
            ||
| 89 | </button>  | 
            ||
| 90 | </li>  | 
            ||
| 91 | </draggable>  | 
            ||
| 92 | |||
| 93 | </div>  | 
            ||
| 94 | </div>  | 
            ||
| 95 | |||
| 96 | <div class="wpinv-form-builder-tab-pane bsui" v-if="active_tab=='edit_item'" style="font-size: 16px;">  | 
            ||
| 97 | <div class="wpinv-form-builder-edit-field-wrapper">  | 
            ||
| 98 | <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?>  | 
            ||
| 99 | <div>  | 
            ||
| 100 | <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 Field', 'invoicing' ); ?></button>  | 
            ||
| 101 | </div>  | 
            ||
| 102 | </div>  | 
            ||
| 103 | </div>  | 
            ||
| 104 | |||
| 105 | <div class="wpinv-form-builder-tab-pane bsui" v-if="active_tab=='settings'">  | 
            ||
| 106 | <div class="wpinv-form-builder-settings-wrapper">  | 
            ||
| 107 | |||
| 108 | <div class='form-group'>  | 
            ||
| 109 | <label for="wpi-success-page"><?php _e( 'Success Page', 'invoicing' ); ?></label>  | 
            ||
| 110 | <input placeholder="https://" id='wpi-success-page' value="<?php echo esc_url( $success_page ); ?>" class='form-control' type='text'>  | 
            ||
| 111 | <small class='form-text text-muted'><?php _e( 'Where should we redirect users after successfuly completing their payment?', 'invoicing' ); ?></small>  | 
            ||
| 112 | </div>  | 
            ||
| 113 | |||
| 114 | </div>  | 
            ||
| 115 | </div>  | 
            ||
| 116 | |||
| 117 | </div>  | 
            ||
| 118 | </div>  | 
            ||
| 119 | |||
| 120 | <div class="wpinv-form-builder-right" style="flex: 1; padding-top: 40px;border-left: 1px solid #ddd;padding-left: 20px;min-height: 520px;margin-left: 10px;">  | 
            ||
| 121 | |||
| 122 | <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small>  | 
            ||
| 123 | <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>  | 
            ||
| 124 | |||
| 125 | <draggable class="section bsui" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 16px;">  | 
            ||
| 126 |                     <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"> | 
            ||
| 127 | <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?>  | 
            ||
| 128 | </div>  | 
            ||
| 129 | </draggable>  | 
            ||
| 130 | </div>  | 
            ||
| 131 | |||
| 132 | <textarea style="display:none;" name="wpinv_form_elements" v-model="elementString"></textarea>  | 
            ||
| 133 | <textarea style="display:none;" name="wpinv_form_items" v-model="itemString"></textarea>  | 
            ||
| 134 | </div>  | 
            ||
| 135 | |||
| 136 | <?php wp_nonce_field( 'wpinv_save_payment_form', 'wpinv_save_payment_form' ) ;?>  | 
            ||
| 137 | |||
| 138 | <?php  | 
            ||
| 235 |