Passed
Push — master ( f8ba18...48d7e6 )
by Brian
08:22 queued 04:03
created
templates/payment-forms-admin/previews/heading.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  */
9 9
 
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 ?>
14 14
 <component :is='form_element.level' v-html='form_element.text'></component>
15 15
\ No newline at end of file
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/price_input.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Set the currency position.
13 13
 $position = wpinv_currency_position();
14 14
 
15
-if ( $position == 'left_space' ) {
15
+if ($position == 'left_space') {
16 16
     $position = 'left';
17 17
 }
18 18
 
19
-if ( $position == 'right_space' ) {
19
+if ($position == 'right_space') {
20 20
     $position = 'right';
21 21
 }
22 22
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 <div class="input-group">
28 28
 
29
-    <?php if ( $position == 'left' ) : ?>
29
+    <?php if ($position == 'left') : ?>
30 30
         <div class="input-group-prepend">
31 31
             <span class="input-group-text"><?php echo wpinv_currency_symbol() ?></span>
32 32
         </div>
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     <input :placeholder='form_element.placeholder' class='form-control' type='text'>
36 36
 
37
-    <?php if ( $position == 'right' ) : ?>
37
+    <?php if ($position == 'right') : ?>
38 38
         <div class="input-group-append">
39 39
             <span class="input-group-text"><?php echo wpinv_currency_symbol() ?></span>
40 40
         </div>
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/checkbox.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 <div class='form-check'>
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/items.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14 14
 <div v-if='!is_default'>
15
-    <div v-if='! canCheckoutSeveralSubscriptions(form_element)' class='alert alert-info' role='alert'><?php _e( 'Item totals will appear here. Click to set items.', 'invoicing' ) ?></div>
16
-    <div v-if='canCheckoutSeveralSubscriptions(form_element)' class='alert alert-danger' role='alert'><?php _e( 'Your form allows customers to buy several recurring items. This is not supported and might lead to unexpected behaviour.', 'invoicing' ); ?></div>
15
+    <div v-if='! canCheckoutSeveralSubscriptions(form_element)' class='alert alert-info' role='alert'><?php _e('Item totals will appear here. Click to set items.', 'invoicing') ?></div>
16
+    <div v-if='canCheckoutSeveralSubscriptions(form_element)' class='alert alert-danger' role='alert'><?php _e('Your form allows customers to buy several recurring items. This is not supported and might lead to unexpected behaviour.', 'invoicing'); ?></div>
17 17
 </div>
18 18
 
19 19
 <div v-if='is_default'>
20
-    <div class='alert alert-info' role='alert'><?php _e( 'Item totals will appear here.', 'invoicing' ) ?></div>
20
+    <div class='alert alert-info' role='alert'><?php _e('Item totals will appear here.', 'invoicing') ?></div>
21 21
 </div>
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/total_payable.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 echo aui()->alert(
13 13
     array(
14
-        'content'     => esc_html__( 'The total payable amount will appear here', 'invoicing' ),
14
+        'content'     => esc_html__('The total payable amount will appear here', 'invoicing'),
15 15
         'type'        => 'info',
16 16
     )
17 17
 );
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/ip_address.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 <span>{{form_element.text}}</span>
14 14
 <a target='_blank' href="#">
15
-    <?php echo sanitize_text_field( wpinv_get_ip() ); ?>&nbsp;&nbsp;<i class='fa fa-external-link-square' aria-hidden='true'></i>
15
+    <?php echo sanitize_text_field(wpinv_get_ip()); ?>&nbsp;&nbsp;<i class='fa fa-external-link-square' aria-hidden='true'></i>
16 16
 </a>
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/gateway_select.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 echo aui()->alert(
13 13
     array(
14
-        'content'     => esc_html__( 'The gateway select box will appear here', 'invoicing' ),
14
+        'content'     => esc_html__('The gateway select box will appear here', 'invoicing'),
15 15
         'type'        => 'info',
16 16
     )
17 17
 );
Please login to merge, or discard this patch.
includes/class-wpinv-payment-form-elements.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
     exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function __construct() {
15 15
 
16
-        foreach( $this->get_elements() as $element ) {
16
+        foreach ($this->get_elements() as $element) {
17 17
             $element = $element['type'];
18 18
 
19
-            if ( method_exists( $this, "render_{$element}_template" ) ) {
20
-                add_action( 'wpinv_payment_form_render_element_template', array( $this, "render_{$element}_template" ), 10, 2 );
19
+            if (method_exists($this, "render_{$element}_template")) {
20
+                add_action('wpinv_payment_form_render_element_template', array($this, "render_{$element}_template"), 10, 2);
21 21
             }
22 22
 
23 23
         }
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public function get_elements() {
31 31
 
32
-        if ( ! empty( $this->elements ) ) {
32
+        if (!empty($this->elements)) {
33 33
             return $this->elements;
34 34
         }
35 35
 
36
-        $this->elements = wpinv_get_data( 'payment-form-elements' );
36
+        $this->elements = wpinv_get_data('payment-form-elements');
37 37
 
38
-        $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements );
38
+        $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements);
39 39
         return $this->elements;
40 40
     }
41 41
 
42 42
     /**
43 43
      * Returns the restrict markup.
44 44
      */
45
-    public function get_restrict_markup( $field, $field_type ) {
45
+    public function get_restrict_markup($field, $field_type) {
46 46
         $restrict = "$field.type=='$field_type'";
47 47
         return "v-if=\"$restrict\"";
48 48
     }
@@ -50,39 +50,39 @@  discard block
 block discarded – undo
50 50
     /**
51 51
      * Returns an array of items for the currently being edited form.
52 52
      */
53
-    public function get_form_items( $id = false ) {
54
-        $form = new GetPaid_Payment_Form( $id );
53
+    public function get_form_items($id = false) {
54
+        $form = new GetPaid_Payment_Form($id);
55 55
 
56 56
         // Is this a default form?
57
-        if ( $form->is_default() ) {
57
+        if ($form->is_default()) {
58 58
             return array();
59 59
         }
60 60
 
61
-        return $form->get_items( 'view', 'arrays' );
61
+        return $form->get_items('view', 'arrays');
62 62
     }
63 63
 
64 64
     /**
65 65
      * Converts form items for use.
66 66
      */
67
-    public function convert_checkout_items( $items, $invoice ) {
67
+    public function convert_checkout_items($items, $invoice) {
68 68
 
69 69
         $converted = array();
70
-        foreach ( $items as $item ) {
70
+        foreach ($items as $item) {
71 71
 
72 72
             $item_id = $item['id'];
73
-            $_item   = new WPInv_Item( $item_id );
73
+            $_item   = new WPInv_Item($item_id);
74 74
 
75
-            if( ! $_item ) {
75
+            if (!$_item) {
76 76
                 continue;
77 77
             }
78 78
 
79 79
             $converted[] = array(
80
-                'title'            => esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $_item ),
80
+                'title'            => esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($_item),
81 81
                 'id'               => $item['id'],
82 82
                 'price'            => $item['subtotal'],
83 83
                 'custom_price'     => $_item->get_is_dynamic_pricing(),
84 84
                 'recurring'        => $_item->is_recurring(),
85
-                'description'      => apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $_item, $invoice ),
85
+                'description'      => apply_filters('wpinv_checkout_cart_line_item_summary', '', $item, $_item, $invoice),
86 86
                 'minimum_price'    => $_item->get_minimum_price(),
87 87
                 'allow_quantities' => false,
88 88
                 'quantity'         => $item['quantity'],
@@ -96,27 +96,27 @@  discard block
 block discarded – undo
96 96
     /**
97 97
      * Converts an array of id => quantity for use.
98 98
      */
99
-    public function convert_normal_items( $items ) {
99
+    public function convert_normal_items($items) {
100 100
 
101 101
         $converted = array();
102
-        foreach ( $items as $item_id => $quantity ) {
102
+        foreach ($items as $item_id => $quantity) {
103 103
 
104
-            $item   = new WPInv_Item( $item_id );
104
+            $item = new WPInv_Item($item_id);
105 105
 
106
-            if( ! $item ) {
106
+            if (!$item) {
107 107
                 continue;
108 108
             }
109 109
 
110 110
             $converted[] = array(
111
-                'title'            => esc_html( $item->get_name() ) . wpinv_get_item_suffix( $item ),
111
+                'title'            => esc_html($item->get_name()) . wpinv_get_item_suffix($item),
112 112
                 'id'               => $item_id,
113 113
                 'price'            => $item->get_price(),
114 114
                 'custom_price'     => $item->get_is_dynamic_pricing(),
115 115
                 'recurring'        => $item->is_recurring(),
116 116
                 'description'      => $item->get_summary(),
117 117
                 'minimum_price'    => $item->get_minimum_price(),
118
-                'allow_quantities' => ! empty( $quantity ),
119
-                'quantity'         => empty( $quantity ) ? 1 : $quantity,
118
+                'allow_quantities' => !empty($quantity),
119
+                'quantity'         => empty($quantity) ? 1 : $quantity,
120 120
                 'required'         => true,
121 121
             );
122 122
 
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
     /**
130 130
      * Returns an array of elements for the currently being edited form.
131 131
      */
132
-    public function get_form_elements( $id = false ) {
132
+    public function get_form_elements($id = false) {
133 133
 
134
-        if ( empty( $id ) ) {
135
-            return wpinv_get_data( 'sample-payment-form' );
134
+        if (empty($id)) {
135
+            return wpinv_get_data('sample-payment-form');
136 136
         }
137 137
         
138
-        $form_elements = get_post_meta( $id, 'wpinv_form_elements', true );
138
+        $form_elements = get_post_meta($id, 'wpinv_form_elements', true);
139 139
 
140
-        if ( is_array( $form_elements ) ) {
140
+        if (is_array($form_elements)) {
141 141
             return $form_elements;
142 142
         }
143 143
 
144
-        return wpinv_get_data( 'sample-payment-form' );
144
+        return wpinv_get_data('sample-payment-form');
145 145
     }
146 146
 
147 147
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-payment-form.php 1 patch
Spacing   +37 added lines, -37 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">
@@ -50,10 +50,10 @@  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>
56
-                                    <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
+                                    <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>
57 57
                                 </div>
58 58
                             </div>
59 59
                         </div>
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
 
63 63
                 </div>
64 64
                 <div class="col-sm-8 border-left">
65
-                    <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small>
66
-                    <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>
65
+                    <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small>
66
+                    <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>
67 67
 
68 68
                     <draggable class="section bsui" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;">
69 69
                         <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]" @click="active_tab = 'edit_item'; active_form_element = form_element">
70 70
                             <div class="wpinv-form-builder-element-preview-inner">
71 71
                                 <div class="wpinv-payment-form-field-preview-overlay"></div>
72
-                                <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?>
72
+                                <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?>
73 73
                             </div>
74 74
                         </div>
75 75
                     </draggable>
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         </div>
83 83
         <?php
84 84
 
85
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
85
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
86 86
     }
87 87
 
88 88
     /**
@@ -90,49 +90,49 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @param int $post_id
92 92
 	 */
93
-	public static function save( $post_id ) {
93
+	public static function save($post_id) {
94 94
 
95 95
         // Prepare the form.
96
-        $form = new GetPaid_Payment_Form( $post_id );
96
+        $form = new GetPaid_Payment_Form($post_id);
97 97
 
98 98
         // Fetch form items.
99
-        $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true );
99
+        $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true);
100 100
 
101 101
         // Ensure that we have an array...
102
-        if ( empty( $form_items ) ) {
102
+        if (empty($form_items)) {
103 103
             $form_items = array();
104 104
         }
105 105
 
106 106
         // ... and that new items are saved to the db.
107
-        $form_items = self::maybe_save_items( $form_items );
107
+        $form_items = self::maybe_save_items($form_items);
108 108
 
109 109
         // Add it to the form.
110
-        $form->set_items( $form_items );
110
+        $form->set_items($form_items);
111 111
 
112 112
         // Save form elements.
113
-        $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true );
114
-        if ( empty( $form_elements ) ) {
113
+        $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true);
114
+        if (empty($form_elements)) {
115 115
             $form_elements = array();
116 116
         }
117 117
 
118
-        $form->set_elements( $form_elements );
118
+        $form->set_elements($form_elements);
119 119
 
120 120
         // Persist data to the datastore.
121 121
         $form->save();
122
-        do_action( 'getpaid_payment_form_metabox_save', $post_id, $form );
122
+        do_action('getpaid_payment_form_metabox_save', $post_id, $form);
123 123
 
124 124
     }
125 125
 
126 126
     /**
127 127
      * Saves unsaved form items.
128 128
      */
129
-    public static function maybe_save_items( $items ) {
129
+    public static function maybe_save_items($items) {
130 130
 
131 131
         $saved = array();
132 132
 
133
-        foreach( $items as $item ) {
133
+        foreach ($items as $item) {
134 134
 
135
-            if ( is_numeric( $item['id'] ) ) {
135
+            if (is_numeric($item['id'])) {
136 136
                 $saved[] = $item;
137 137
                 continue;
138 138
             }
@@ -142,32 +142,32 @@  discard block
 block discarded – undo
142 142
             // Save post data.
143 143
             $new_item->set_props(
144 144
                 array(
145
-                    'name'               => sanitize_text_field( $item['title'] ),
146
-                    'description'        => wp_kses_post( $item['description'] ),
145
+                    'name'               => sanitize_text_field($item['title']),
146
+                    'description'        => wp_kses_post($item['description']),
147 147
                     'status'             => 'publish',
148
-                    'type'               => empty( $item['type'] ) ? 'custom' : $item['type'],
149
-                    'price'              => wpinv_sanitize_amount( $item['price'] ),
150
-                    'vat_rule'           => empty( $item['rule'] ) ? 'digital' : $item['rule'],
151
-                    'vat_class'          => empty( $item['class'] ) ? '_standard' : $item['class'],
152
-                    'is_dynamic_pricing' => empty( $item['custom_price'] ) ? 0 : (int) $item['custom_price'],
153
-                    'minimum_price'      => empty( $item['minimum_price'] ) ? 0 : (float) $item['minimum_price'],
148
+                    'type'               => empty($item['type']) ? 'custom' : $item['type'],
149
+                    'price'              => wpinv_sanitize_amount($item['price']),
150
+                    'vat_rule'           => empty($item['rule']) ? 'digital' : $item['rule'],
151
+                    'vat_class'          => empty($item['class']) ? '_standard' : $item['class'],
152
+                    'is_dynamic_pricing' => empty($item['custom_price']) ? 0 : (int) $item['custom_price'],
153
+                    'minimum_price'      => empty($item['minimum_price']) ? 0 : (float) $item['minimum_price'],
154 154
                 )
155 155
             );
156 156
 
157 157
             // Save the item.
158 158
             $new_item->save();
159 159
 
160
-            if ( $new_item->get_id() ) {
160
+            if ($new_item->get_id()) {
161 161
                 $item['id'] = $new_item->get_id();
162 162
                 $saved[] = $item;
163 163
             }
164 164
 
165 165
         }
166 166
 
167
-        foreach ( $saved as $i => $item ) {
168
-            foreach ( array( 'new', 'type', 'class', 'rule', 'price', 'title', 'custom_price', 'minimum_price', 'recurring' ) as $key ) {
169
-                if ( isset( $item[ $key ] ) ) {
170
-                    unset( $saved[ $i ][ $key ] );
167
+        foreach ($saved as $i => $item) {
168
+            foreach (array('new', 'type', 'class', 'rule', 'price', 'title', 'custom_price', 'minimum_price', 'recurring') as $key) {
169
+                if (isset($item[$key])) {
170
+                    unset($saved[$i][$key]);
171 171
                 }
172 172
             }
173 173
         }
Please login to merge, or discard this patch.