Passed
Push — master ( 4dd773...1df2cc )
by Brian
05:04
created
includes/admin/meta-boxes/class-getpaid-meta-box-payment-form.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit; // Exit if accessed directly
11 11
 }
12 12
 
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param WP_Post $post
22 22
 	 */
23
-    public static function output( $post ) {
23
+    public static function output($post) {
24 24
         ?>
25 25
         <div id="wpinv-form-builder" class="bsui">
26 26
             <div class="row">
27 27
                 <div class="col-sm-4">
28 28
 
29 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>
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 31
 
32 32
                     <!-- Builder tab content -->
33 33
                     <div class="mt-4">
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                         <!-- Available builder elements -->
36 36
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'">
37 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>
38
+                                <small class='form-text text-muted'><?php _e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small>
39 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 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 41
                                         <button class="button btn text-dark">
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
                         <!-- Edit an element -->
51 51
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 14px;">
52 52
                             <div class="wpinv-form-builder-edit-field-wrapper">
53
-                                <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?>
54
-                                <?php do_action( 'getpaid_payment_form_edit_element_template', $post ); ?>
53
+                                <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?>
54
+                                <?php do_action('getpaid_payment_form_edit_element_template', $post); ?>
55 55
                                 <div class='form-group'>
56
-                                    <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e( 'Width', 'invoicing' ) ?></label>
56
+                                    <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e('Width', 'invoicing') ?></label>
57 57
                                     <select class='form-control custom-select' :id="active_form_element.id + '_grid_width'" v-model='gridWidth'>
58
-                                        <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option>
59
-                                        <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option>
60
-                                        <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option>
58
+                                        <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option>
59
+                                        <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option>
60
+                                        <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option>
61 61
                                     </select>
62 62
                                 </div>
63 63
                                 <div>
64
-                                    <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>
64
+                                    <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>
65 65
                                 </div>
66 66
                             </div>
67 67
                         </div>
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
 
71 71
                 </div>
72 72
                 <div class="col-sm-8 border-left">
73
-                    <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small>
74
-                    <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>
73
+                    <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small>
74
+                    <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>
75 75
 
76 76
                     <div class="container-fluid">
77 77
                         <draggable class="section row" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;">
78 78
                             <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' }, form_element.type, grid_class( form_element ) ]" @click="active_tab = 'edit_item'; active_form_element = form_element">
79 79
                                 <div class="wpinv-form-builder-element-preview-inner">
80 80
                                     <div class="wpinv-payment-form-field-preview-overlay"></div>
81
-                                    <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?>
81
+                                    <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?>
82 82
                                 </div>
83 83
                             </div>
84 84
                         </draggable>
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         </div>
93 93
         <?php
94 94
 
95
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
95
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
96 96
     }
97 97
 
98 98
     /**
@@ -100,33 +100,33 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @param int $post_id
102 102
 	 */
103
-	public static function save( $post_id ) {
103
+	public static function save($post_id) {
104 104
 
105 105
         // Prepare the form.
106
-        $form = new GetPaid_Payment_Form( $post_id );
106
+        $form = new GetPaid_Payment_Form($post_id);
107 107
 
108 108
         // Fetch form items.
109
-        $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true );
109
+        $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true);
110 110
 
111 111
         // Ensure that we have an array...
112
-        if ( empty( $form_items ) ) {
112
+        if (empty($form_items)) {
113 113
             $form_items = array();
114 114
         }
115 115
 
116 116
         // Add it to the form.
117
-        $form->set_items( self::item_to_objects( $form_items ) );
117
+        $form->set_items(self::item_to_objects($form_items));
118 118
 
119 119
         // Save form elements.
120
-        $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true );
121
-        if ( empty( $form_elements ) ) {
120
+        $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true);
121
+        if (empty($form_elements)) {
122 122
             $form_elements = array();
123 123
         }
124 124
 
125
-        $form->set_elements( $form_elements );
125
+        $form->set_elements($form_elements);
126 126
 
127 127
         // Persist data to the datastore.
128 128
         $form->save();
129
-        do_action( 'getpaid_payment_form_metabox_save', $post_id, $form );
129
+        do_action('getpaid_payment_form_metabox_save', $post_id, $form);
130 130
 
131 131
     }
132 132
 
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $items
137 137
 	 */
138
-	public static function item_to_objects( $items ) {
138
+	public static function item_to_objects($items) {
139 139
 
140 140
         $objects = array();
141 141
 
142
-        foreach ( $items as $item ) {
143
-            $_item = new GetPaid_Form_Item( $item['id'] );
144
-            $_item->set_allow_quantities( (bool) $item['allow_quantities'] );
145
-            $_item->set_is_required( (bool) $item['required'] );
142
+        foreach ($items as $item) {
143
+            $_item = new GetPaid_Form_Item($item['id']);
144
+            $_item->set_allow_quantities((bool) $item['allow_quantities']);
145
+            $_item->set_is_required((bool) $item['required']);
146 146
             $objects[] = $_item;
147 147
         }
148 148
 
Please login to merge, or discard this patch.