Passed
Push — master ( afad5e...c5d98b )
by Stiofan
05:31
created
includes/data/tax-rates.php 2 patches
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -12,265 +12,265 @@
 block discarded – undo
12 12
 
13 13
 return array(
14 14
 
15
-	array(
16
-		'country'      => 'AT', // Austria
17
-		'state'        => '',
18
-		'global'       => true,
19
-		'rate'         => 20,
20
-		'reduced_rate' => 13,
21
-		'name'         => __( 'VAT', 'invoicing' ),
22
-	),
23
-
24
-	array(
25
-		'country'      => 'BE', // Belgium
26
-		'state'        => '',
27
-		'global'       => true,
28
-		'rate'         => 21,
29
-		'reduced_rate' => 12,
30
-		'name'         => __( 'VAT', 'invoicing' ),
31
-	),
32
-
33
-	array(
34
-		'country'      => 'BG', // Bulgaria
35
-		'state'        => '',
36
-		'global'       => true,
37
-		'rate'         => 20,
38
-		'reduced_rate' => 9,
39
-		'name'         => __( 'VAT', 'invoicing' ),
40
-	),
41
-
42
-	array(
43
-		'country'      => 'HR', // Croatia
44
-		'state'        => '',
45
-		'global'       => true,
46
-		'rate'         => 25,
47
-		'reduced_rate' => 13,
48
-		'name'         => __( 'VAT', 'invoicing' ),
49
-	),
50
-
51
-	array(
52
-		'country'      => 'CY', // Cyprus
53
-		'state'        => '',
54
-		'global'       => true,
55
-		'rate'         => 19,
56
-		'reduced_rate' => 9,
57
-		'name'         => __( 'VAT', 'invoicing' ),
58
-	),
59
-
60
-	array(
61
-		'country'      => 'CZ', // Czech Republic
62
-		'state'        => '',
63
-		'global'       => true,
64
-		'rate'         => 21,
65
-		'reduced_rate' => 15,
66
-		'name'         => __( 'VAT', 'invoicing' ),
67
-	),
68
-
69
-	array(
70
-		'country'      => 'DK', // Denmark
71
-		'state'        => '',
72
-		'global'       => true,
73
-		'rate'         => 25,
74
-		'reduced_rate' => 0,
75
-		'name'         => __( 'VAT', 'invoicing' ),
76
-	),
77
-
78
-	array(
79
-		'country'      => 'EE', // Estonia
80
-		'state'        => '',
81
-		'global'       => true,
82
-		'rate'         => 20,
83
-		'reduced_rate' => 9,
84
-		'name'         => __( 'VAT', 'invoicing' ),
85
-	),
86
-
87
-	array(
88
-		'country'      => 'FI', // Finland
89
-		'state'        => '',
90
-		'global'       => true,
91
-		'rate'         => 24,
92
-		'reduced_rate' => 14,
93
-		'name'         => __( 'VAT', 'invoicing' ),
94
-	),
95
-
96
-	array(
97
-		'country'      => 'FR', // France
98
-		'state'        => '',
99
-		'global'       => true,
100
-		'rate'         => 20,
101
-		'reduced_rate' => 5.5,
102
-		'name'         => __( 'VAT', 'invoicing' ),
103
-	),
104
-
105
-	array(
106
-		'country'      => 'DE', // Germany
107
-		'state'        => '',
108
-		'global'       => true,
109
-		'rate'         => 19,
110
-		'reduced_rate' => 7,
111
-		'name'         => __( 'VAT', 'invoicing' ),
112
-	),
113
-
114
-	array(
115
-		'country'      => 'GR', // Greece
116
-		'state'        => '',
117
-		'global'       => true,
118
-		'rate'         => 24,
119
-		'reduced_rate' => 13,
120
-		'name'         => __( 'VAT', 'invoicing' ),
121
-	),
122
-
123
-	array(
124
-		'country'      => 'HU', // Hungary
125
-		'state'        => '',
126
-		'global'       => true,
127
-		'rate'         => 27,
128
-		'reduced_rate' => 18,
129
-		'name'         => __( 'VAT', 'invoicing' ),
130
-	),
131
-
132
-	array(
133
-		'country'      => 'IE', // Ireland
134
-		'state'        => '',
135
-		'global'       => true,
136
-		'rate'         => 23,
137
-		'reduced_rate' => 13.5,
138
-		'name'         => __( 'VAT', 'invoicing' ),
139
-	),
140
-
141
-	array(
142
-		'country'      => 'IT', // Italy
143
-		'state'        => '',
144
-		'global'       => true,
145
-		'rate'         => 22,
146
-		'reduced_rate' => 10,
147
-		'name'         => __( 'VAT', 'invoicing' ),
148
-	),
149
-
150
-	array(
151
-		'country'      => 'LV', // Latvia
152
-		'state'        => '',
153
-		'global'       => true,
154
-		'rate'         => 21,
155
-		'reduced_rate' => 12,
156
-		'name'         => __( 'VAT', 'invoicing' ),
157
-	),
158
-
159
-	array(
160
-		'country'      => 'LT', // Lithuania
161
-		'state'        => '',
162
-		'global'       => true,
163
-		'rate'         => 21,
164
-		'reduced_rate' => 9,
165
-		'name'         => __( 'VAT', 'invoicing' ),
166
-	),
167
-
168
-	array(
169
-		'country'      => 'LU', // Luxembourg
170
-		'state'        => '',
171
-		'global'       => true,
172
-		'rate'         => 17,
173
-		'reduced_rate' => 14,
174
-		'name'         => __( 'VAT', 'invoicing' ),
175
-	),
176
-
177
-	array(
178
-		'country'      => 'MT', // Malta
179
-		'state'        => '',
180
-		'global'       => true,
181
-		'rate'         => 18,
182
-		'reduced_rate' => 7,
183
-		'name'         => __( 'VAT', 'invoicing' ),
184
-	),
185
-
186
-	array(
187
-		'country'      => 'MC', // Monaco
188
-		'state'        => '',
189
-		'global'       => true,
190
-		'rate'         => 20,
191
-		'reduced_rate' => 10,
192
-		'name'         => __( 'VAT', 'invoicing' ),
193
-	),
194
-
195
-	array(
196
-		'country'      => 'NL', // Netherlands
197
-		'state'        => '',
198
-		'global'       => true,
199
-		'rate'         => 21,
200
-		'reduced_rate' => 9,
201
-		'name'         => __( 'VAT', 'invoicing' ),
202
-	),
203
-
204
-	array(
205
-		'country'      => 'PL', // Poland
206
-		'state'        => '',
207
-		'global'       => true,
208
-		'rate'         => 23,
209
-		'reduced_rate' => 8,
210
-		'name'         => __( 'VAT', 'invoicing' ),
211
-	),
212
-
213
-	array(
214
-		'country'      => 'PT', // Portugal
215
-		'state'        => '',
216
-		'global'       => true,
217
-		'rate'         => 23,
218
-		'reduced_rate' => 13,
219
-		'name'         => __( 'VAT', 'invoicing' ),
220
-	),
221
-
222
-	array(
223
-		'country'      => 'RO', // Romania
224
-		'state'        => '',
225
-		'global'       => true,
226
-		'rate'         => 19,
227
-		'reduced_rate' => 9,
228
-		'name'         => __( 'VAT', 'invoicing' ),
229
-	),
230
-
231
-	array(
232
-		'country'      => 'SK', // Slovakia
233
-		'state'        => '',
234
-		'global'       => true,
235
-		'rate'         => 20,
236
-		'reduced_rate' => 10,
237
-		'name'         => __( 'VAT', 'invoicing' ),
238
-	),
239
-
240
-	array(
241
-		'country'      => 'SI', // Slovenia
242
-		'state'        => '',
243
-		'global'       => true,
244
-		'rate'         => 22,
245
-		'reduced_rate' => 9.5,
246
-		'name'         => __( 'VAT', 'invoicing' ),
247
-	),
248
-
249
-	array(
250
-		'country'      => 'ES', // Spain
251
-		'state'        => '',
252
-		'global'       => true,
253
-		'rate'         => 21,
254
-		'reduced_rate' => 10,
255
-		'name'         => __( 'VAT', 'invoicing' ),
256
-	),
257
-
258
-	array(
259
-		'country'      => 'SE', // Sweden
260
-		'state'        => '',
261
-		'global'       => true,
262
-		'rate'         => 25,
263
-		'reduced_rate' => 12,
264
-		'name'         => __( 'VAT', 'invoicing' ),
265
-	),
266
-
267
-	array(
268
-		'country'      => 'GB', // UK
269
-		'state'        => '',
270
-		'global'       => true,
271
-		'rate'         => 20,
272
-		'reduced_rate' => 5,
273
-		'name'         => __( 'VAT', 'invoicing' ),
274
-	)
15
+    array(
16
+        'country'      => 'AT', // Austria
17
+        'state'        => '',
18
+        'global'       => true,
19
+        'rate'         => 20,
20
+        'reduced_rate' => 13,
21
+        'name'         => __( 'VAT', 'invoicing' ),
22
+    ),
23
+
24
+    array(
25
+        'country'      => 'BE', // Belgium
26
+        'state'        => '',
27
+        'global'       => true,
28
+        'rate'         => 21,
29
+        'reduced_rate' => 12,
30
+        'name'         => __( 'VAT', 'invoicing' ),
31
+    ),
32
+
33
+    array(
34
+        'country'      => 'BG', // Bulgaria
35
+        'state'        => '',
36
+        'global'       => true,
37
+        'rate'         => 20,
38
+        'reduced_rate' => 9,
39
+        'name'         => __( 'VAT', 'invoicing' ),
40
+    ),
41
+
42
+    array(
43
+        'country'      => 'HR', // Croatia
44
+        'state'        => '',
45
+        'global'       => true,
46
+        'rate'         => 25,
47
+        'reduced_rate' => 13,
48
+        'name'         => __( 'VAT', 'invoicing' ),
49
+    ),
50
+
51
+    array(
52
+        'country'      => 'CY', // Cyprus
53
+        'state'        => '',
54
+        'global'       => true,
55
+        'rate'         => 19,
56
+        'reduced_rate' => 9,
57
+        'name'         => __( 'VAT', 'invoicing' ),
58
+    ),
59
+
60
+    array(
61
+        'country'      => 'CZ', // Czech Republic
62
+        'state'        => '',
63
+        'global'       => true,
64
+        'rate'         => 21,
65
+        'reduced_rate' => 15,
66
+        'name'         => __( 'VAT', 'invoicing' ),
67
+    ),
68
+
69
+    array(
70
+        'country'      => 'DK', // Denmark
71
+        'state'        => '',
72
+        'global'       => true,
73
+        'rate'         => 25,
74
+        'reduced_rate' => 0,
75
+        'name'         => __( 'VAT', 'invoicing' ),
76
+    ),
77
+
78
+    array(
79
+        'country'      => 'EE', // Estonia
80
+        'state'        => '',
81
+        'global'       => true,
82
+        'rate'         => 20,
83
+        'reduced_rate' => 9,
84
+        'name'         => __( 'VAT', 'invoicing' ),
85
+    ),
86
+
87
+    array(
88
+        'country'      => 'FI', // Finland
89
+        'state'        => '',
90
+        'global'       => true,
91
+        'rate'         => 24,
92
+        'reduced_rate' => 14,
93
+        'name'         => __( 'VAT', 'invoicing' ),
94
+    ),
95
+
96
+    array(
97
+        'country'      => 'FR', // France
98
+        'state'        => '',
99
+        'global'       => true,
100
+        'rate'         => 20,
101
+        'reduced_rate' => 5.5,
102
+        'name'         => __( 'VAT', 'invoicing' ),
103
+    ),
104
+
105
+    array(
106
+        'country'      => 'DE', // Germany
107
+        'state'        => '',
108
+        'global'       => true,
109
+        'rate'         => 19,
110
+        'reduced_rate' => 7,
111
+        'name'         => __( 'VAT', 'invoicing' ),
112
+    ),
113
+
114
+    array(
115
+        'country'      => 'GR', // Greece
116
+        'state'        => '',
117
+        'global'       => true,
118
+        'rate'         => 24,
119
+        'reduced_rate' => 13,
120
+        'name'         => __( 'VAT', 'invoicing' ),
121
+    ),
122
+
123
+    array(
124
+        'country'      => 'HU', // Hungary
125
+        'state'        => '',
126
+        'global'       => true,
127
+        'rate'         => 27,
128
+        'reduced_rate' => 18,
129
+        'name'         => __( 'VAT', 'invoicing' ),
130
+    ),
131
+
132
+    array(
133
+        'country'      => 'IE', // Ireland
134
+        'state'        => '',
135
+        'global'       => true,
136
+        'rate'         => 23,
137
+        'reduced_rate' => 13.5,
138
+        'name'         => __( 'VAT', 'invoicing' ),
139
+    ),
140
+
141
+    array(
142
+        'country'      => 'IT', // Italy
143
+        'state'        => '',
144
+        'global'       => true,
145
+        'rate'         => 22,
146
+        'reduced_rate' => 10,
147
+        'name'         => __( 'VAT', 'invoicing' ),
148
+    ),
149
+
150
+    array(
151
+        'country'      => 'LV', // Latvia
152
+        'state'        => '',
153
+        'global'       => true,
154
+        'rate'         => 21,
155
+        'reduced_rate' => 12,
156
+        'name'         => __( 'VAT', 'invoicing' ),
157
+    ),
158
+
159
+    array(
160
+        'country'      => 'LT', // Lithuania
161
+        'state'        => '',
162
+        'global'       => true,
163
+        'rate'         => 21,
164
+        'reduced_rate' => 9,
165
+        'name'         => __( 'VAT', 'invoicing' ),
166
+    ),
167
+
168
+    array(
169
+        'country'      => 'LU', // Luxembourg
170
+        'state'        => '',
171
+        'global'       => true,
172
+        'rate'         => 17,
173
+        'reduced_rate' => 14,
174
+        'name'         => __( 'VAT', 'invoicing' ),
175
+    ),
176
+
177
+    array(
178
+        'country'      => 'MT', // Malta
179
+        'state'        => '',
180
+        'global'       => true,
181
+        'rate'         => 18,
182
+        'reduced_rate' => 7,
183
+        'name'         => __( 'VAT', 'invoicing' ),
184
+    ),
185
+
186
+    array(
187
+        'country'      => 'MC', // Monaco
188
+        'state'        => '',
189
+        'global'       => true,
190
+        'rate'         => 20,
191
+        'reduced_rate' => 10,
192
+        'name'         => __( 'VAT', 'invoicing' ),
193
+    ),
194
+
195
+    array(
196
+        'country'      => 'NL', // Netherlands
197
+        'state'        => '',
198
+        'global'       => true,
199
+        'rate'         => 21,
200
+        'reduced_rate' => 9,
201
+        'name'         => __( 'VAT', 'invoicing' ),
202
+    ),
203
+
204
+    array(
205
+        'country'      => 'PL', // Poland
206
+        'state'        => '',
207
+        'global'       => true,
208
+        'rate'         => 23,
209
+        'reduced_rate' => 8,
210
+        'name'         => __( 'VAT', 'invoicing' ),
211
+    ),
212
+
213
+    array(
214
+        'country'      => 'PT', // Portugal
215
+        'state'        => '',
216
+        'global'       => true,
217
+        'rate'         => 23,
218
+        'reduced_rate' => 13,
219
+        'name'         => __( 'VAT', 'invoicing' ),
220
+    ),
221
+
222
+    array(
223
+        'country'      => 'RO', // Romania
224
+        'state'        => '',
225
+        'global'       => true,
226
+        'rate'         => 19,
227
+        'reduced_rate' => 9,
228
+        'name'         => __( 'VAT', 'invoicing' ),
229
+    ),
230
+
231
+    array(
232
+        'country'      => 'SK', // Slovakia
233
+        'state'        => '',
234
+        'global'       => true,
235
+        'rate'         => 20,
236
+        'reduced_rate' => 10,
237
+        'name'         => __( 'VAT', 'invoicing' ),
238
+    ),
239
+
240
+    array(
241
+        'country'      => 'SI', // Slovenia
242
+        'state'        => '',
243
+        'global'       => true,
244
+        'rate'         => 22,
245
+        'reduced_rate' => 9.5,
246
+        'name'         => __( 'VAT', 'invoicing' ),
247
+    ),
248
+
249
+    array(
250
+        'country'      => 'ES', // Spain
251
+        'state'        => '',
252
+        'global'       => true,
253
+        'rate'         => 21,
254
+        'reduced_rate' => 10,
255
+        'name'         => __( 'VAT', 'invoicing' ),
256
+    ),
257
+
258
+    array(
259
+        'country'      => 'SE', // Sweden
260
+        'state'        => '',
261
+        'global'       => true,
262
+        'rate'         => 25,
263
+        'reduced_rate' => 12,
264
+        'name'         => __( 'VAT', 'invoicing' ),
265
+    ),
266
+
267
+    array(
268
+        'country'      => 'GB', // UK
269
+        'state'        => '',
270
+        'global'       => true,
271
+        'rate'         => 20,
272
+        'reduced_rate' => 5,
273
+        'name'         => __( 'VAT', 'invoicing' ),
274
+    )
275 275
 
276 276
 );
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 return array(
14 14
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 		'global'       => true,
19 19
 		'rate'         => 20,
20 20
 		'reduced_rate' => 13,
21
-		'name'         => __( 'VAT', 'invoicing' ),
21
+		'name'         => __('VAT', 'invoicing'),
22 22
 	),
23 23
 
24 24
 	array(
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		'global'       => true,
28 28
 		'rate'         => 21,
29 29
 		'reduced_rate' => 12,
30
-		'name'         => __( 'VAT', 'invoicing' ),
30
+		'name'         => __('VAT', 'invoicing'),
31 31
 	),
32 32
 
33 33
 	array(
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		'global'       => true,
37 37
 		'rate'         => 20,
38 38
 		'reduced_rate' => 9,
39
-		'name'         => __( 'VAT', 'invoicing' ),
39
+		'name'         => __('VAT', 'invoicing'),
40 40
 	),
41 41
 
42 42
 	array(
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		'global'       => true,
46 46
 		'rate'         => 25,
47 47
 		'reduced_rate' => 13,
48
-		'name'         => __( 'VAT', 'invoicing' ),
48
+		'name'         => __('VAT', 'invoicing'),
49 49
 	),
50 50
 
51 51
 	array(
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		'global'       => true,
55 55
 		'rate'         => 19,
56 56
 		'reduced_rate' => 9,
57
-		'name'         => __( 'VAT', 'invoicing' ),
57
+		'name'         => __('VAT', 'invoicing'),
58 58
 	),
59 59
 
60 60
 	array(
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		'global'       => true,
64 64
 		'rate'         => 21,
65 65
 		'reduced_rate' => 15,
66
-		'name'         => __( 'VAT', 'invoicing' ),
66
+		'name'         => __('VAT', 'invoicing'),
67 67
 	),
68 68
 
69 69
 	array(
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		'global'       => true,
73 73
 		'rate'         => 25,
74 74
 		'reduced_rate' => 0,
75
-		'name'         => __( 'VAT', 'invoicing' ),
75
+		'name'         => __('VAT', 'invoicing'),
76 76
 	),
77 77
 
78 78
 	array(
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		'global'       => true,
82 82
 		'rate'         => 20,
83 83
 		'reduced_rate' => 9,
84
-		'name'         => __( 'VAT', 'invoicing' ),
84
+		'name'         => __('VAT', 'invoicing'),
85 85
 	),
86 86
 
87 87
 	array(
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		'global'       => true,
91 91
 		'rate'         => 24,
92 92
 		'reduced_rate' => 14,
93
-		'name'         => __( 'VAT', 'invoicing' ),
93
+		'name'         => __('VAT', 'invoicing'),
94 94
 	),
95 95
 
96 96
 	array(
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		'global'       => true,
100 100
 		'rate'         => 20,
101 101
 		'reduced_rate' => 5.5,
102
-		'name'         => __( 'VAT', 'invoicing' ),
102
+		'name'         => __('VAT', 'invoicing'),
103 103
 	),
104 104
 
105 105
 	array(
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		'global'       => true,
109 109
 		'rate'         => 19,
110 110
 		'reduced_rate' => 7,
111
-		'name'         => __( 'VAT', 'invoicing' ),
111
+		'name'         => __('VAT', 'invoicing'),
112 112
 	),
113 113
 
114 114
 	array(
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		'global'       => true,
118 118
 		'rate'         => 24,
119 119
 		'reduced_rate' => 13,
120
-		'name'         => __( 'VAT', 'invoicing' ),
120
+		'name'         => __('VAT', 'invoicing'),
121 121
 	),
122 122
 
123 123
 	array(
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		'global'       => true,
127 127
 		'rate'         => 27,
128 128
 		'reduced_rate' => 18,
129
-		'name'         => __( 'VAT', 'invoicing' ),
129
+		'name'         => __('VAT', 'invoicing'),
130 130
 	),
131 131
 
132 132
 	array(
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		'global'       => true,
136 136
 		'rate'         => 23,
137 137
 		'reduced_rate' => 13.5,
138
-		'name'         => __( 'VAT', 'invoicing' ),
138
+		'name'         => __('VAT', 'invoicing'),
139 139
 	),
140 140
 
141 141
 	array(
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		'global'       => true,
145 145
 		'rate'         => 22,
146 146
 		'reduced_rate' => 10,
147
-		'name'         => __( 'VAT', 'invoicing' ),
147
+		'name'         => __('VAT', 'invoicing'),
148 148
 	),
149 149
 
150 150
 	array(
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		'global'       => true,
154 154
 		'rate'         => 21,
155 155
 		'reduced_rate' => 12,
156
-		'name'         => __( 'VAT', 'invoicing' ),
156
+		'name'         => __('VAT', 'invoicing'),
157 157
 	),
158 158
 
159 159
 	array(
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		'global'       => true,
163 163
 		'rate'         => 21,
164 164
 		'reduced_rate' => 9,
165
-		'name'         => __( 'VAT', 'invoicing' ),
165
+		'name'         => __('VAT', 'invoicing'),
166 166
 	),
167 167
 
168 168
 	array(
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		'global'       => true,
172 172
 		'rate'         => 17,
173 173
 		'reduced_rate' => 14,
174
-		'name'         => __( 'VAT', 'invoicing' ),
174
+		'name'         => __('VAT', 'invoicing'),
175 175
 	),
176 176
 
177 177
 	array(
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		'global'       => true,
181 181
 		'rate'         => 18,
182 182
 		'reduced_rate' => 7,
183
-		'name'         => __( 'VAT', 'invoicing' ),
183
+		'name'         => __('VAT', 'invoicing'),
184 184
 	),
185 185
 
186 186
 	array(
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		'global'       => true,
190 190
 		'rate'         => 20,
191 191
 		'reduced_rate' => 10,
192
-		'name'         => __( 'VAT', 'invoicing' ),
192
+		'name'         => __('VAT', 'invoicing'),
193 193
 	),
194 194
 
195 195
 	array(
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 		'global'       => true,
199 199
 		'rate'         => 21,
200 200
 		'reduced_rate' => 9,
201
-		'name'         => __( 'VAT', 'invoicing' ),
201
+		'name'         => __('VAT', 'invoicing'),
202 202
 	),
203 203
 
204 204
 	array(
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		'global'       => true,
208 208
 		'rate'         => 23,
209 209
 		'reduced_rate' => 8,
210
-		'name'         => __( 'VAT', 'invoicing' ),
210
+		'name'         => __('VAT', 'invoicing'),
211 211
 	),
212 212
 
213 213
 	array(
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		'global'       => true,
217 217
 		'rate'         => 23,
218 218
 		'reduced_rate' => 13,
219
-		'name'         => __( 'VAT', 'invoicing' ),
219
+		'name'         => __('VAT', 'invoicing'),
220 220
 	),
221 221
 
222 222
 	array(
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		'global'       => true,
226 226
 		'rate'         => 19,
227 227
 		'reduced_rate' => 9,
228
-		'name'         => __( 'VAT', 'invoicing' ),
228
+		'name'         => __('VAT', 'invoicing'),
229 229
 	),
230 230
 
231 231
 	array(
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		'global'       => true,
235 235
 		'rate'         => 20,
236 236
 		'reduced_rate' => 10,
237
-		'name'         => __( 'VAT', 'invoicing' ),
237
+		'name'         => __('VAT', 'invoicing'),
238 238
 	),
239 239
 
240 240
 	array(
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 		'global'       => true,
244 244
 		'rate'         => 22,
245 245
 		'reduced_rate' => 9.5,
246
-		'name'         => __( 'VAT', 'invoicing' ),
246
+		'name'         => __('VAT', 'invoicing'),
247 247
 	),
248 248
 
249 249
 	array(
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 		'global'       => true,
253 253
 		'rate'         => 21,
254 254
 		'reduced_rate' => 10,
255
-		'name'         => __( 'VAT', 'invoicing' ),
255
+		'name'         => __('VAT', 'invoicing'),
256 256
 	),
257 257
 
258 258
 	array(
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 		'global'       => true,
262 262
 		'rate'         => 25,
263 263
 		'reduced_rate' => 12,
264
-		'name'         => __( 'VAT', 'invoicing' ),
264
+		'name'         => __('VAT', 'invoicing'),
265 265
 	),
266 266
 
267 267
 	array(
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 		'global'       => true,
271 271
 		'rate'         => 20,
272 272
 		'reduced_rate' => 5,
273
-		'name'         => __( 'VAT', 'invoicing' ),
273
+		'name'         => __('VAT', 'invoicing'),
274 274
 	)
275 275
 
276 276
 );
Please login to merge, or discard this patch.
includes/class-wpinv-item.php 2 patches
Indentation   +732 added lines, -732 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,30 +10,30 @@  discard block
 block discarded – undo
10 10
 class WPInv_Item  extends GetPaid_Data {
11 11
 
12 12
     /**
13
-	 * Which data store to load.
14
-	 *
15
-	 * @var string
16
-	 */
13
+     * Which data store to load.
14
+     *
15
+     * @var string
16
+     */
17 17
     protected $data_store_name = 'item';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'item';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'item';
25 25
 
26 26
     /**
27
-	 * Item Data array. This is the core item data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'parent_id'            => 0,
34
-		'status'               => 'draft',
35
-		'version'              => '',
36
-		'date_created'         => null,
27
+     * Item Data array. This is the core item data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'parent_id'            => 0,
34
+        'status'               => 'draft',
35
+        'version'              => '',
36
+        'date_created'         => null,
37 37
         'date_modified'        => null,
38 38
         'name'                 => '',
39 39
         'description'          => '',
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
     );
59 59
 
60 60
     /**
61
-	 * Stores meta in cache for future reads.
62
-	 *
63
-	 * A group must be set to to enable caching.
64
-	 *
65
-	 * @var string
66
-	 */
67
-	protected $cache_group = 'getpaid_items';
61
+     * Stores meta in cache for future reads.
62
+     *
63
+     * A group must be set to to enable caching.
64
+     *
65
+     * @var string
66
+     */
67
+    protected $cache_group = 'getpaid_items';
68 68
 
69 69
     /**
70 70
      * Stores a reference to the original WP_Post object
@@ -74,37 +74,37 @@  discard block
 block discarded – undo
74 74
     protected $post = null;
75 75
 
76 76
     /**
77
-	 * Get the item if ID is passed, otherwise the item is new and empty.
78
-	 *
79
-	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
-	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
94
-		} else {
95
-			$this->set_object_read( true );
96
-		}
77
+     * Get the item if ID is passed, otherwise the item is new and empty.
78
+     *
79
+     * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
+     */
81
+    public function __construct( $item = 0 ) {
82
+        parent::__construct( $item );
83
+
84
+        if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
+            $this->set_id( $item );
86
+        } elseif ( $item instanceof self ) {
87
+            $this->set_id( $item->get_id() );
88
+        } elseif ( ! empty( $item->ID ) ) {
89
+            $this->set_id( $item->ID );
90
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
+            $this->set_id( $item_id );
92
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
+            $this->set_id( $item_id );
94
+        } else {
95
+            $this->set_object_read( true );
96
+        }
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
100 100
 
101
-		if ( $this->get_id() > 0 ) {
101
+        if ( $this->get_id() > 0 ) {
102 102
             $this->post = get_post( $this->get_id() );
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+            $this->data_store->read( $this );
105 105
         }
106 106
 
107
-	}
107
+    }
108 108
 
109 109
     /*
110 110
 	|--------------------------------------------------------------------------
@@ -122,401 +122,401 @@  discard block
 block discarded – undo
122 122
     */
123 123
 
124 124
     /**
125
-	 * Get parent item ID.
126
-	 *
127
-	 * @since 1.0.19
128
-	 * @param  string $context View or edit context.
129
-	 * @return int
130
-	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
125
+     * Get parent item ID.
126
+     *
127
+     * @since 1.0.19
128
+     * @param  string $context View or edit context.
129
+     * @return int
130
+     */
131
+    public function get_parent_id( $context = 'view' ) {
132
+        return (int) $this->get_prop( 'parent_id', $context );
133 133
     }
134 134
 
135 135
     /**
136
-	 * Get item status.
137
-	 *
138
-	 * @since 1.0.19
139
-	 * @param  string $context View or edit context.
140
-	 * @return string
141
-	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
136
+     * Get item status.
137
+     *
138
+     * @since 1.0.19
139
+     * @param  string $context View or edit context.
140
+     * @return string
141
+     */
142
+    public function get_status( $context = 'view' ) {
143
+        return $this->get_prop( 'status', $context );
144 144
     }
145 145
 
146 146
     /**
147
-	 * Get plugin version when the item was created.
148
-	 *
149
-	 * @since 1.0.19
150
-	 * @param  string $context View or edit context.
151
-	 * @return string
152
-	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
147
+     * Get plugin version when the item was created.
148
+     *
149
+     * @since 1.0.19
150
+     * @param  string $context View or edit context.
151
+     * @return string
152
+     */
153
+    public function get_version( $context = 'view' ) {
154
+        return $this->get_prop( 'version', $context );
155 155
     }
156 156
 
157 157
     /**
158
-	 * Get date when the item was created.
159
-	 *
160
-	 * @since 1.0.19
161
-	 * @param  string $context View or edit context.
162
-	 * @return string
163
-	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
158
+     * Get date when the item was created.
159
+     *
160
+     * @since 1.0.19
161
+     * @param  string $context View or edit context.
162
+     * @return string
163
+     */
164
+    public function get_date_created( $context = 'view' ) {
165
+        return $this->get_prop( 'date_created', $context );
166 166
     }
167 167
 
168 168
     /**
169
-	 * Get GMT date when the item was created.
170
-	 *
171
-	 * @since 1.0.19
172
-	 * @param  string $context View or edit context.
173
-	 * @return string
174
-	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
169
+     * Get GMT date when the item was created.
170
+     *
171
+     * @since 1.0.19
172
+     * @param  string $context View or edit context.
173
+     * @return string
174
+     */
175
+    public function get_date_created_gmt( $context = 'view' ) {
176 176
         $date = $this->get_date_created( $context );
177 177
 
178 178
         if ( $date ) {
179 179
             $date = get_gmt_from_date( $date );
180 180
         }
181
-		return $date;
181
+        return $date;
182 182
     }
183 183
 
184 184
     /**
185
-	 * Get date when the item was last modified.
186
-	 *
187
-	 * @since 1.0.19
188
-	 * @param  string $context View or edit context.
189
-	 * @return string
190
-	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
185
+     * Get date when the item was last modified.
186
+     *
187
+     * @since 1.0.19
188
+     * @param  string $context View or edit context.
189
+     * @return string
190
+     */
191
+    public function get_date_modified( $context = 'view' ) {
192
+        return $this->get_prop( 'date_modified', $context );
193 193
     }
194 194
 
195 195
     /**
196
-	 * Get GMT date when the item was last modified.
197
-	 *
198
-	 * @since 1.0.19
199
-	 * @param  string $context View or edit context.
200
-	 * @return string
201
-	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
196
+     * Get GMT date when the item was last modified.
197
+     *
198
+     * @since 1.0.19
199
+     * @param  string $context View or edit context.
200
+     * @return string
201
+     */
202
+    public function get_date_modified_gmt( $context = 'view' ) {
203 203
         $date = $this->get_date_modified( $context );
204 204
 
205 205
         if ( $date ) {
206 206
             $date = get_gmt_from_date( $date );
207 207
         }
208
-		return $date;
208
+        return $date;
209 209
     }
210 210
 
211 211
     /**
212
-	 * Get the item name.
213
-	 *
214
-	 * @since 1.0.19
215
-	 * @param  string $context View or edit context.
216
-	 * @return string
217
-	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
212
+     * Get the item name.
213
+     *
214
+     * @since 1.0.19
215
+     * @param  string $context View or edit context.
216
+     * @return string
217
+     */
218
+    public function get_name( $context = 'view' ) {
219
+        return $this->get_prop( 'name', $context );
220 220
     }
221 221
 
222 222
     /**
223
-	 * Alias of self::get_name().
224
-	 *
225
-	 * @since 1.0.19
226
-	 * @param  string $context View or edit context.
227
-	 * @return string
228
-	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
223
+     * Alias of self::get_name().
224
+     *
225
+     * @since 1.0.19
226
+     * @param  string $context View or edit context.
227
+     * @return string
228
+     */
229
+    public function get_title( $context = 'view' ) {
230
+        return $this->get_name( $context );
231 231
     }
232 232
 
233 233
     /**
234
-	 * Get the item description.
235
-	 *
236
-	 * @since 1.0.19
237
-	 * @param  string $context View or edit context.
238
-	 * @return string
239
-	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
234
+     * Get the item description.
235
+     *
236
+     * @since 1.0.19
237
+     * @param  string $context View or edit context.
238
+     * @return string
239
+     */
240
+    public function get_description( $context = 'view' ) {
241
+        return $this->get_prop( 'description', $context );
242 242
     }
243 243
 
244 244
     /**
245
-	 * Alias of self::get_description().
246
-	 *
247
-	 * @since 1.0.19
248
-	 * @param  string $context View or edit context.
249
-	 * @return string
250
-	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
245
+     * Alias of self::get_description().
246
+     *
247
+     * @since 1.0.19
248
+     * @param  string $context View or edit context.
249
+     * @return string
250
+     */
251
+    public function get_excerpt( $context = 'view' ) {
252
+        return $this->get_description( $context );
253 253
     }
254 254
 
255 255
     /**
256
-	 * Alias of self::get_description().
257
-	 *
258
-	 * @since 1.0.19
259
-	 * @param  string $context View or edit context.
260
-	 * @return string
261
-	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
256
+     * Alias of self::get_description().
257
+     *
258
+     * @since 1.0.19
259
+     * @param  string $context View or edit context.
260
+     * @return string
261
+     */
262
+    public function get_summary( $context = 'view' ) {
263
+        return $this->get_description( $context );
264 264
     }
265 265
 
266 266
     /**
267
-	 * Get the owner of the item.
268
-	 *
269
-	 * @since 1.0.19
270
-	 * @param  string $context View or edit context.
271
-	 * @return int
272
-	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
275
-	}
267
+     * Get the owner of the item.
268
+     *
269
+     * @since 1.0.19
270
+     * @param  string $context View or edit context.
271
+     * @return int
272
+     */
273
+    public function get_author( $context = 'view' ) {
274
+        return (int) $this->get_prop( 'author', $context );
275
+    }
276 276
 	
277
-	/**
278
-	 * Alias of self::get_author().
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @param  string $context View or edit context.
282
-	 * @return int
283
-	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
286
-    }
287
-
288
-    /**
289
-	 * Get the price of the item.
290
-	 *
291
-	 * @since 1.0.19
292
-	 * @param  string $context View or edit context.
293
-	 * @return float
294
-	 */
295
-	public function get_price( $context = 'view' ) {
277
+    /**
278
+     * Alias of self::get_author().
279
+     *
280
+     * @since 1.0.19
281
+     * @param  string $context View or edit context.
282
+     * @return int
283
+     */
284
+    public function get_owner( $context = 'view' ) {
285
+        return $this->get_author( $context );
286
+    }
287
+
288
+    /**
289
+     * Get the price of the item.
290
+     *
291
+     * @since 1.0.19
292
+     * @param  string $context View or edit context.
293
+     * @return float
294
+     */
295
+    public function get_price( $context = 'view' ) {
296 296
         return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
297
-	}
297
+    }
298 298
 
299
-	/**
300
-	 * Get the inital price of the item.
301
-	 *
302
-	 * @since 1.0.19
303
-	 * @param  string $context View or edit context.
304
-	 * @return float
305
-	 */
306
-	public function get_initial_price( $context = 'view' ) {
299
+    /**
300
+     * Get the inital price of the item.
301
+     *
302
+     * @since 1.0.19
303
+     * @param  string $context View or edit context.
304
+     * @return float
305
+     */
306
+    public function get_initial_price( $context = 'view' ) {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+        $price = (float) $this->get_price( $context );
309 309
 
310
-		if ( $this->has_free_trial() ) {
311
-			$price = 0;
312
-		}
310
+        if ( $this->has_free_trial() ) {
311
+            $price = 0;
312
+        }
313 313
 
314 314
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
315 315
     }
316 316
 
317 317
     /**
318
-	 * Returns a formated price.
319
-	 *
320
-	 * @since 1.0.19
321
-	 * @param  string $context View or edit context.
322
-	 * @return string
323
-	 */
318
+     * Returns a formated price.
319
+     *
320
+     * @since 1.0.19
321
+     * @param  string $context View or edit context.
322
+     * @return string
323
+     */
324 324
     public function get_the_price() {
325 325
         return wpinv_price( $this->get_price() );
326
-	}
327
-
328
-	/**
329
-	 * Returns the formated initial price.
330
-	 *
331
-	 * @since 1.0.19
332
-	 * @param  string $context View or edit context.
333
-	 * @return string
334
-	 */
326
+    }
327
+
328
+    /**
329
+     * Returns the formated initial price.
330
+     *
331
+     * @since 1.0.19
332
+     * @param  string $context View or edit context.
333
+     * @return string
334
+     */
335 335
     public function get_the_initial_price() {
336 336
         return wpinv_price( $this->get_initial_price() );
337 337
     }
338 338
 
339 339
     /**
340
-	 * Get the VAT rule of the item.
341
-	 *
342
-	 * @since 1.0.19
343
-	 * @param  string $context View or edit context.
344
-	 * @return string
345
-	 */
346
-	public function get_vat_rule( $context = 'view' ) {
340
+     * Get the VAT rule of the item.
341
+     *
342
+     * @since 1.0.19
343
+     * @param  string $context View or edit context.
344
+     * @return string
345
+     */
346
+    public function get_vat_rule( $context = 'view' ) {
347 347
         return $this->get_prop( 'vat_rule', $context );
348 348
     }
349 349
 
350 350
     /**
351
-	 * Get the VAT class of the item.
352
-	 *
353
-	 * @since 1.0.19
354
-	 * @param  string $context View or edit context.
355
-	 * @return string
356
-	 */
357
-	public function get_vat_class( $context = 'view' ) {
351
+     * Get the VAT class of the item.
352
+     *
353
+     * @since 1.0.19
354
+     * @param  string $context View or edit context.
355
+     * @return string
356
+     */
357
+    public function get_vat_class( $context = 'view' ) {
358 358
         return $this->get_prop( 'vat_class', $context );
359 359
     }
360 360
 
361 361
     /**
362
-	 * Get the type of the item.
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $context View or edit context.
366
-	 * @return string
367
-	 */
368
-	public function get_type( $context = 'view' ) {
362
+     * Get the type of the item.
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $context View or edit context.
366
+     * @return string
367
+     */
368
+    public function get_type( $context = 'view' ) {
369 369
         return $this->get_prop( 'type', $context );
370 370
     }
371 371
 
372 372
     /**
373
-	 * Get the custom id of the item.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_custom_id( $context = 'view' ) {
373
+     * Get the custom id of the item.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_custom_id( $context = 'view' ) {
380 380
         return $this->get_prop( 'custom_id', $context );
381 381
     }
382 382
 
383 383
     /**
384
-	 * Get the custom name of the item.
385
-	 *
386
-	 * @since 1.0.19
387
-	 * @param  string $context View or edit context.
388
-	 * @return string
389
-	 */
390
-	public function get_custom_name( $context = 'view' ) {
384
+     * Get the custom name of the item.
385
+     *
386
+     * @since 1.0.19
387
+     * @param  string $context View or edit context.
388
+     * @return string
389
+     */
390
+    public function get_custom_name( $context = 'view' ) {
391 391
         return $this->get_prop( 'custom_name', $context );
392 392
     }
393 393
 
394 394
     /**
395
-	 * Get the custom singular name of the item.
396
-	 *
397
-	 * @since 1.0.19
398
-	 * @param  string $context View or edit context.
399
-	 * @return string
400
-	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
395
+     * Get the custom singular name of the item.
396
+     *
397
+     * @since 1.0.19
398
+     * @param  string $context View or edit context.
399
+     * @return string
400
+     */
401
+    public function get_custom_singular_name( $context = 'view' ) {
402 402
         return $this->get_prop( 'custom_singular_name', $context );
403 403
     }
404 404
 
405 405
     /**
406
-	 * Checks if an item is editable..
407
-	 *
408
-	 * @since 1.0.19
409
-	 * @param  string $context View or edit context.
410
-	 * @return int
411
-	 */
412
-	public function get_is_editable( $context = 'view' ) {
406
+     * Checks if an item is editable..
407
+     *
408
+     * @since 1.0.19
409
+     * @param  string $context View or edit context.
410
+     * @return int
411
+     */
412
+    public function get_is_editable( $context = 'view' ) {
413 413
         return (int) $this->get_prop( 'is_editable', $context );
414 414
     }
415 415
 
416 416
     /**
417
-	 * Alias of self::get_is_editable().
418
-	 *
419
-	 * @since 1.0.19
420
-	 * @param  string $context View or edit context.
421
-	 * @return int
422
-	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
417
+     * Alias of self::get_is_editable().
418
+     *
419
+     * @since 1.0.19
420
+     * @param  string $context View or edit context.
421
+     * @return int
422
+     */
423
+    public function get_editable( $context = 'view' ) {
424
+        return $this->get_is_editable( $context );
425 425
     }
426 426
 
427 427
     /**
428
-	 * Checks if dynamic pricing is enabled.
429
-	 *
430
-	 * @since 1.0.19
431
-	 * @param  string $context View or edit context.
432
-	 * @return int
433
-	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
428
+     * Checks if dynamic pricing is enabled.
429
+     *
430
+     * @since 1.0.19
431
+     * @param  string $context View or edit context.
432
+     * @return int
433
+     */
434
+    public function get_is_dynamic_pricing( $context = 'view' ) {
435 435
         return (int) $this->get_prop( 'is_dynamic_pricing', $context );
436 436
     }
437 437
 
438 438
     /**
439
-	 * Returns the minimum price if dynamic pricing is enabled.
440
-	 *
441
-	 * @since 1.0.19
442
-	 * @param  string $context View or edit context.
443
-	 * @return float
444
-	 */
445
-	public function get_minimum_price( $context = 'view' ) {
439
+     * Returns the minimum price if dynamic pricing is enabled.
440
+     *
441
+     * @since 1.0.19
442
+     * @param  string $context View or edit context.
443
+     * @return float
444
+     */
445
+    public function get_minimum_price( $context = 'view' ) {
446 446
         return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
447 447
     }
448 448
 
449 449
     /**
450
-	 * Checks if this is a recurring item.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return int
455
-	 */
456
-	public function get_is_recurring( $context = 'view' ) {
450
+     * Checks if this is a recurring item.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return int
455
+     */
456
+    public function get_is_recurring( $context = 'view' ) {
457 457
         return (int) $this->get_prop( 'is_recurring', $context );
458
-	}
458
+    }
459 459
 	
460
-	/**
461
-	 * Get the recurring price of the item.
462
-	 *
463
-	 * @since 1.0.19
464
-	 * @param  string $context View or edit context.
465
-	 * @return float
466
-	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
460
+    /**
461
+     * Get the recurring price of the item.
462
+     *
463
+     * @since 1.0.19
464
+     * @param  string $context View or edit context.
465
+     * @return float
466
+     */
467
+    public function get_recurring_price( $context = 'view' ) {
468
+        $price = $this->get_price( $context );
469 469
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
470
-	}
471
-
472
-	/**
473
-	 * Get the formatted recurring price of the item.
474
-	 *
475
-	 * @since 1.0.19
476
-	 * @param  string $context View or edit context.
477
-	 * @return string
478
-	 */
470
+    }
471
+
472
+    /**
473
+     * Get the formatted recurring price of the item.
474
+     *
475
+     * @since 1.0.19
476
+     * @param  string $context View or edit context.
477
+     * @return string
478
+     */
479 479
     public function get_the_recurring_price() {
480 480
         return wpinv_price( $this->get_recurring_price() );
481
-	}
482
-
483
-	/**
484
-	 * Get the first renewal date (in timestamps) of the item.
485
-	 *
486
-	 * @since 1.0.19
487
-	 * @return int
488
-	 */
489
-	public function get_first_renewal_date() {
490
-
491
-		$periods = array(
492
-			'D' => 'days',
493
-			'W' => 'weeks',
494
-			'M' => 'months',
495
-			'Y' => 'years',
496
-		);
497
-
498
-		$period   = $this->get_recurring_period();
499
-		$interval = $this->get_recurring_interval();
500
-
501
-		if ( $this->has_free_trial() ) {
502
-			$period   = $this->get_trial_period();
503
-			$interval = $this->get_trial_interval();
504
-		}
505
-
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
481
+    }
482
+
483
+    /**
484
+     * Get the first renewal date (in timestamps) of the item.
485
+     *
486
+     * @since 1.0.19
487
+     * @return int
488
+     */
489
+    public function get_first_renewal_date() {
490
+
491
+        $periods = array(
492
+            'D' => 'days',
493
+            'W' => 'weeks',
494
+            'M' => 'months',
495
+            'Y' => 'years',
496
+        );
497
+
498
+        $period   = $this->get_recurring_period();
499
+        $interval = $this->get_recurring_interval();
500
+
501
+        if ( $this->has_free_trial() ) {
502
+            $period   = $this->get_trial_period();
503
+            $interval = $this->get_trial_interval();
504
+        }
505
+
506
+        $period       = $periods[ $period ];
507
+        $interval     = empty( $interval ) ? 1 : $interval;
508
+        $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509 509
         return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
510 510
     }
511 511
 
512 512
     /**
513
-	 * Get the recurring period.
514
-	 *
515
-	 * @since 1.0.19
516
-	 * @param  bool $full Return abbreviation or in full.
517
-	 * @return string
518
-	 */
519
-	public function get_recurring_period( $full = false ) {
513
+     * Get the recurring period.
514
+     *
515
+     * @since 1.0.19
516
+     * @param  bool $full Return abbreviation or in full.
517
+     * @return string
518
+     */
519
+    public function get_recurring_period( $full = false ) {
520 520
         $period = $this->get_prop( 'recurring_period', 'view' );
521 521
 
522 522
         if ( $full && ! is_bool( $full ) ) {
@@ -527,58 +527,58 @@  discard block
 block discarded – undo
527 527
     }
528 528
 
529 529
     /**
530
-	 * Get the recurring interval.
531
-	 *
532
-	 * @since 1.0.19
533
-	 * @param  string $context View or edit context.
534
-	 * @return int
535
-	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
538
-		return max( 1, $interval );
530
+     * Get the recurring interval.
531
+     *
532
+     * @since 1.0.19
533
+     * @param  string $context View or edit context.
534
+     * @return int
535
+     */
536
+    public function get_recurring_interval( $context = 'view' ) {
537
+        $interval = absint( $this->get_prop( 'recurring_interval', $context ) );
538
+        return max( 1, $interval );
539 539
     }
540 540
 
541 541
     /**
542
-	 * Get the recurring limit.
543
-	 *
544
-	 * @since 1.0.19
545
-	 * @param  string $context View or edit context.
546
-	 * @return int
547
-	 */
548
-	public function get_recurring_limit( $context = 'view' ) {
542
+     * Get the recurring limit.
543
+     *
544
+     * @since 1.0.19
545
+     * @param  string $context View or edit context.
546
+     * @return int
547
+     */
548
+    public function get_recurring_limit( $context = 'view' ) {
549 549
         return (int) $this->get_prop( 'recurring_limit', $context );
550 550
     }
551 551
 
552 552
     /**
553
-	 * Checks if we have a free trial.
554
-	 *
555
-	 * @since 1.0.19
556
-	 * @param  string $context View or edit context.
557
-	 * @return int
558
-	 */
559
-	public function get_is_free_trial( $context = 'view' ) {
553
+     * Checks if we have a free trial.
554
+     *
555
+     * @since 1.0.19
556
+     * @param  string $context View or edit context.
557
+     * @return int
558
+     */
559
+    public function get_is_free_trial( $context = 'view' ) {
560 560
         return (int) $this->get_prop( 'is_free_trial', $context );
561 561
     }
562 562
 
563 563
     /**
564
-	 * Alias for self::get_is_free_trial().
565
-	 *
566
-	 * @since 1.0.19
567
-	 * @param  string $context View or edit context.
568
-	 * @return int
569
-	 */
570
-	public function get_free_trial( $context = 'view' ) {
564
+     * Alias for self::get_is_free_trial().
565
+     *
566
+     * @since 1.0.19
567
+     * @param  string $context View or edit context.
568
+     * @return int
569
+     */
570
+    public function get_free_trial( $context = 'view' ) {
571 571
         return $this->get_is_free_trial( $context );
572 572
     }
573 573
 
574 574
     /**
575
-	 * Get the trial period.
576
-	 *
577
-	 * @since 1.0.19
578
-	 * @param  bool $full Return abbreviation or in full.
579
-	 * @return string
580
-	 */
581
-	public function get_trial_period( $full = false ) {
575
+     * Get the trial period.
576
+     *
577
+     * @since 1.0.19
578
+     * @param  bool $full Return abbreviation or in full.
579
+     * @return string
580
+     */
581
+    public function get_trial_period( $full = false ) {
582 582
         $period = $this->get_prop( 'trial_period', 'view' );
583 583
 
584 584
         if ( $full && ! is_bool( $full ) ) {
@@ -589,104 +589,104 @@  discard block
 block discarded – undo
589 589
     }
590 590
 
591 591
     /**
592
-	 * Get the trial interval.
593
-	 *
594
-	 * @since 1.0.19
595
-	 * @param  string $context View or edit context.
596
-	 * @return int
597
-	 */
598
-	public function get_trial_interval( $context = 'view' ) {
592
+     * Get the trial interval.
593
+     *
594
+     * @since 1.0.19
595
+     * @param  string $context View or edit context.
596
+     * @return int
597
+     */
598
+    public function get_trial_interval( $context = 'view' ) {
599 599
         return (int) $this->get_prop( 'trial_interval', $context );
600
-	}
600
+    }
601 601
 	
602
-	/**
603
-	 * Get the item's edit url.
604
-	 *
605
-	 * @since 1.0.19
606
-	 * @return string
607
-	 */
608
-	public function get_edit_url() {
602
+    /**
603
+     * Get the item's edit url.
604
+     *
605
+     * @since 1.0.19
606
+     * @return string
607
+     */
608
+    public function get_edit_url() {
609 609
         return get_edit_post_link( $this->get_id(), 'edit' );
610
-	}
611
-
612
-	/**
613
-	 * Given an item's name/custom id, it returns its id.
614
-	 *
615
-	 *
616
-	 * @static
617
-	 * @param string $value The item name or custom id.
618
-	 * @param string $field Either name or custom_id.
619
-	 * @param string $type in case you need to search for a given type.
620
-	 * @since 1.0.15
621
-	 * @return int
622
-	 */
623
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
624
-
625
-		// Trim the value.
626
-		$value = sanitize_text_field( $value );
627
-		if ( empty( $value ) ) {
628
-			return 0;
629
-		}
610
+    }
611
+
612
+    /**
613
+     * Given an item's name/custom id, it returns its id.
614
+     *
615
+     *
616
+     * @static
617
+     * @param string $value The item name or custom id.
618
+     * @param string $field Either name or custom_id.
619
+     * @param string $type in case you need to search for a given type.
620
+     * @since 1.0.15
621
+     * @return int
622
+     */
623
+    public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
624
+
625
+        // Trim the value.
626
+        $value = sanitize_text_field( $value );
627
+        if ( empty( $value ) ) {
628
+            return 0;
629
+        }
630 630
 
631 631
         // Valid fields.
632 632
         $fields = array( 'custom_id', 'name', 'slug' );
633 633
 
634
-		// Ensure a field has been passed.
635
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
636
-			return 0;
637
-		}
638
-
639
-		if ( $field == 'name' ) {
640
-			$field = 'slug';
641
-		}
642
-
643
-		// Maybe retrieve from the cache.
644
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
645
-		if ( ! empty( $item_id ) ) {
646
-			return $item_id;
647
-		}
648
-
649
-		// Fetch from the db.
650
-		$items = array();
651
-		if ( $field == 'slug' ) {
652
-			$items = get_posts(
653
-				array(
654
-					'post_type'      => 'wpi_item',
655
-					'name'           => $value,
656
-					'posts_per_page' => 1,
657
-					'post_status'    => 'any',
658
-				)
659
-			);
660
-		}
661
-
662
-		if ( $field =='custom_id' ) {
663
-			$items = get_posts(
664
-				array(
665
-					'post_type'      => 'wpi_item',
666
-					'posts_per_page' => 1,
667
-					'post_status'    => 'any',
668
-					'meta_query'     => array(
669
-						array(
670
-							'key'   => '_wpinv_type',
671
-                			'value' => $type,
672
-						),
673
-						array(
674
-							'key'   => '_wpinv_custom_id',
675
-                			'value' => $value,
676
-						)
677
-					)
678
-				)
679
-			);
680
-		}
681
-
682
-		if ( empty( $items ) ) {
683
-			return 0;
684
-		}
685
-
686
-		// Update the cache with our data
687
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
688
-
689
-		return $items[0]->ID;
634
+        // Ensure a field has been passed.
635
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
636
+            return 0;
637
+        }
638
+
639
+        if ( $field == 'name' ) {
640
+            $field = 'slug';
641
+        }
642
+
643
+        // Maybe retrieve from the cache.
644
+        $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
645
+        if ( ! empty( $item_id ) ) {
646
+            return $item_id;
647
+        }
648
+
649
+        // Fetch from the db.
650
+        $items = array();
651
+        if ( $field == 'slug' ) {
652
+            $items = get_posts(
653
+                array(
654
+                    'post_type'      => 'wpi_item',
655
+                    'name'           => $value,
656
+                    'posts_per_page' => 1,
657
+                    'post_status'    => 'any',
658
+                )
659
+            );
660
+        }
661
+
662
+        if ( $field =='custom_id' ) {
663
+            $items = get_posts(
664
+                array(
665
+                    'post_type'      => 'wpi_item',
666
+                    'posts_per_page' => 1,
667
+                    'post_status'    => 'any',
668
+                    'meta_query'     => array(
669
+                        array(
670
+                            'key'   => '_wpinv_type',
671
+                            'value' => $type,
672
+                        ),
673
+                        array(
674
+                            'key'   => '_wpinv_custom_id',
675
+                            'value' => $value,
676
+                        )
677
+                    )
678
+                )
679
+            );
680
+        }
681
+
682
+        if ( empty( $items ) ) {
683
+            return 0;
684
+        }
685
+
686
+        // Update the cache with our data
687
+        wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
688
+
689
+        return $items[0]->ID;
690 690
     }
691 691
 
692 692
     /**
@@ -719,52 +719,52 @@  discard block
 block discarded – undo
719 719
     */
720 720
 
721 721
     /**
722
-	 * Set parent order ID.
723
-	 *
724
-	 * @since 1.0.19
725
-	 */
726
-	public function set_parent_id( $value ) {
727
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
728
-			return;
729
-		}
730
-		$this->set_prop( 'parent_id', absint( $value ) );
731
-	}
732
-
733
-    /**
734
-	 * Sets item status.
735
-	 *
736
-	 * @since 1.0.19
737
-	 * @param  string $status New status.
738
-	 * @return array details of change.
739
-	 */
740
-	public function set_status( $status ) {
722
+     * Set parent order ID.
723
+     *
724
+     * @since 1.0.19
725
+     */
726
+    public function set_parent_id( $value ) {
727
+        if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
728
+            return;
729
+        }
730
+        $this->set_prop( 'parent_id', absint( $value ) );
731
+    }
732
+
733
+    /**
734
+     * Sets item status.
735
+     *
736
+     * @since 1.0.19
737
+     * @param  string $status New status.
738
+     * @return array details of change.
739
+     */
740
+    public function set_status( $status ) {
741 741
         $old_status = $this->get_status();
742 742
 
743 743
         $this->set_prop( 'status', $status );
744 744
 
745
-		return array(
746
-			'from' => $old_status,
747
-			'to'   => $status,
748
-		);
745
+        return array(
746
+            'from' => $old_status,
747
+            'to'   => $status,
748
+        );
749 749
     }
750 750
 
751 751
     /**
752
-	 * Set plugin version when the item was created.
753
-	 *
754
-	 * @since 1.0.19
755
-	 */
756
-	public function set_version( $value ) {
757
-		$this->set_prop( 'version', $value );
752
+     * Set plugin version when the item was created.
753
+     *
754
+     * @since 1.0.19
755
+     */
756
+    public function set_version( $value ) {
757
+        $this->set_prop( 'version', $value );
758 758
     }
759 759
 
760 760
     /**
761
-	 * Set date when the item was created.
762
-	 *
763
-	 * @since 1.0.19
764
-	 * @param string $value Value to set.
761
+     * Set date when the item was created.
762
+     *
763
+     * @since 1.0.19
764
+     * @param string $value Value to set.
765 765
      * @return bool Whether or not the date was set.
766
-	 */
767
-	public function set_date_created( $value ) {
766
+     */
767
+    public function set_date_created( $value ) {
768 768
         $date = strtotime( $value );
769 769
 
770 770
         if ( $date ) {
@@ -777,13 +777,13 @@  discard block
 block discarded – undo
777 777
     }
778 778
 
779 779
     /**
780
-	 * Set date when the item was last modified.
781
-	 *
782
-	 * @since 1.0.19
783
-	 * @param string $value Value to set.
780
+     * Set date when the item was last modified.
781
+     *
782
+     * @since 1.0.19
783
+     * @param string $value Value to set.
784 784
      * @return bool Whether or not the date was set.
785
-	 */
786
-	public function set_date_modified( $value ) {
785
+     */
786
+    public function set_date_modified( $value ) {
787 787
         $date = strtotime( $value );
788 788
 
789 789
         if ( $date ) {
@@ -796,115 +796,115 @@  discard block
 block discarded – undo
796 796
     }
797 797
 
798 798
     /**
799
-	 * Set the item name.
800
-	 *
801
-	 * @since 1.0.19
802
-	 * @param  string $value New name.
803
-	 */
804
-	public function set_name( $value ) {
799
+     * Set the item name.
800
+     *
801
+     * @since 1.0.19
802
+     * @param  string $value New name.
803
+     */
804
+    public function set_name( $value ) {
805 805
         $name = sanitize_text_field( $value );
806
-		$this->set_prop( 'name', $name );
806
+        $this->set_prop( 'name', $name );
807 807
     }
808 808
 
809 809
     /**
810
-	 * Alias of self::set_name().
811
-	 *
812
-	 * @since 1.0.19
813
-	 * @param  string $value New name.
814
-	 */
815
-	public function set_title( $value ) {
816
-		$this->set_name( $value );
810
+     * Alias of self::set_name().
811
+     *
812
+     * @since 1.0.19
813
+     * @param  string $value New name.
814
+     */
815
+    public function set_title( $value ) {
816
+        $this->set_name( $value );
817 817
     }
818 818
 
819 819
     /**
820
-	 * Set the item description.
821
-	 *
822
-	 * @since 1.0.19
823
-	 * @param  string $value New description.
824
-	 */
825
-	public function set_description( $value ) {
826
-		$description = wp_kses_post( wp_unslash( $value ) );
827
-		return $this->set_prop( 'description', $description );
820
+     * Set the item description.
821
+     *
822
+     * @since 1.0.19
823
+     * @param  string $value New description.
824
+     */
825
+    public function set_description( $value ) {
826
+        $description = wp_kses_post( wp_unslash( $value ) );
827
+        return $this->set_prop( 'description', $description );
828 828
     }
829 829
 
830 830
     /**
831
-	 * Alias of self::set_description().
832
-	 *
833
-	 * @since 1.0.19
834
-	 * @param  string $value New description.
835
-	 */
836
-	public function set_excerpt( $value ) {
837
-		$this->set_description( $value );
831
+     * Alias of self::set_description().
832
+     *
833
+     * @since 1.0.19
834
+     * @param  string $value New description.
835
+     */
836
+    public function set_excerpt( $value ) {
837
+        $this->set_description( $value );
838 838
     }
839 839
 
840 840
     /**
841
-	 * Alias of self::set_description().
842
-	 *
843
-	 * @since 1.0.19
844
-	 * @param  string $value New description.
845
-	 */
846
-	public function set_summary( $value ) {
847
-		$this->set_description( $value );
841
+     * Alias of self::set_description().
842
+     *
843
+     * @since 1.0.19
844
+     * @param  string $value New description.
845
+     */
846
+    public function set_summary( $value ) {
847
+        $this->set_description( $value );
848 848
     }
849 849
 
850 850
     /**
851
-	 * Set the owner of the item.
852
-	 *
853
-	 * @since 1.0.19
854
-	 * @param  int $value New author.
855
-	 */
856
-	public function set_author( $value ) {
857
-		$this->set_prop( 'author', (int) $value );
858
-	}
851
+     * Set the owner of the item.
852
+     *
853
+     * @since 1.0.19
854
+     * @param  int $value New author.
855
+     */
856
+    public function set_author( $value ) {
857
+        $this->set_prop( 'author', (int) $value );
858
+    }
859 859
 	
860
-	/**
861
-	 * Alias of self::set_author().
862
-	 *
863
-	 * @since 1.0.19
864
-	 * @param  int $value New author.
865
-	 */
866
-	public function set_owner( $value ) {
867
-		$this->set_author( $value );
868
-    }
869
-
870
-    /**
871
-	 * Set the price of the item.
872
-	 *
873
-	 * @since 1.0.19
874
-	 * @param  float $value New price.
875
-	 */
876
-	public function set_price( $value ) {
860
+    /**
861
+     * Alias of self::set_author().
862
+     *
863
+     * @since 1.0.19
864
+     * @param  int $value New author.
865
+     */
866
+    public function set_owner( $value ) {
867
+        $this->set_author( $value );
868
+    }
869
+
870
+    /**
871
+     * Set the price of the item.
872
+     *
873
+     * @since 1.0.19
874
+     * @param  float $value New price.
875
+     */
876
+    public function set_price( $value ) {
877 877
         $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
878 878
     }
879 879
 
880 880
     /**
881
-	 * Set the VAT rule of the item.
882
-	 *
883
-	 * @since 1.0.19
884
-	 * @param  string $value new rule.
885
-	 */
886
-	public function set_vat_rule( $value ) {
881
+     * Set the VAT rule of the item.
882
+     *
883
+     * @since 1.0.19
884
+     * @param  string $value new rule.
885
+     */
886
+    public function set_vat_rule( $value ) {
887 887
         $this->set_prop( 'vat_rule', $value );
888 888
     }
889 889
 
890 890
     /**
891
-	 * Set the VAT class of the item.
892
-	 *
893
-	 * @since 1.0.19
894
-	 * @param  string $value new class.
895
-	 */
896
-	public function set_vat_class( $value ) {
891
+     * Set the VAT class of the item.
892
+     *
893
+     * @since 1.0.19
894
+     * @param  string $value new class.
895
+     */
896
+    public function set_vat_class( $value ) {
897 897
         $this->set_prop( 'vat_class', $value );
898 898
     }
899 899
 
900 900
     /**
901
-	 * Set the type of the item.
902
-	 *
903
-	 * @since 1.0.19
904
-	 * @param  string $value new item type.
905
-	 * @return string
906
-	 */
907
-	public function set_type( $value ) {
901
+     * Set the type of the item.
902
+     *
903
+     * @since 1.0.19
904
+     * @param  string $value new item type.
905
+     * @return string
906
+     */
907
+    public function set_type( $value ) {
908 908
 
909 909
         if ( empty( $value ) ) {
910 910
             $value = 'custom';
@@ -914,132 +914,132 @@  discard block
 block discarded – undo
914 914
     }
915 915
 
916 916
     /**
917
-	 * Set the custom id of the item.
918
-	 *
919
-	 * @since 1.0.19
920
-	 * @param  string $value new custom id.
921
-	 */
922
-	public function set_custom_id( $value ) {
917
+     * Set the custom id of the item.
918
+     *
919
+     * @since 1.0.19
920
+     * @param  string $value new custom id.
921
+     */
922
+    public function set_custom_id( $value ) {
923 923
         $this->set_prop( 'custom_id', $value );
924 924
     }
925 925
 
926 926
     /**
927
-	 * Set the custom name of the item.
928
-	 *
929
-	 * @since 1.0.19
930
-	 * @param  string $value new custom name.
931
-	 */
932
-	public function set_custom_name( $value ) {
927
+     * Set the custom name of the item.
928
+     *
929
+     * @since 1.0.19
930
+     * @param  string $value new custom name.
931
+     */
932
+    public function set_custom_name( $value ) {
933 933
         $this->set_prop( 'custom_name', $value );
934 934
     }
935 935
 
936 936
     /**
937
-	 * Set the custom singular name of the item.
938
-	 *
939
-	 * @since 1.0.19
940
-	 * @param  string $value new custom singular name.
941
-	 */
942
-	public function set_custom_singular_name( $value ) {
937
+     * Set the custom singular name of the item.
938
+     *
939
+     * @since 1.0.19
940
+     * @param  string $value new custom singular name.
941
+     */
942
+    public function set_custom_singular_name( $value ) {
943 943
         $this->set_prop( 'custom_singular_name', $value );
944 944
     }
945 945
 
946 946
     /**
947
-	 * Sets if an item is editable..
948
-	 *
949
-	 * @since 1.0.19
950
-	 * @param  int|bool $value whether or not the item is editable.
951
-	 */
952
-	public function set_is_editable( $value ) {
953
-		$this->set_prop( 'is_editable', (int) $value );
947
+     * Sets if an item is editable..
948
+     *
949
+     * @since 1.0.19
950
+     * @param  int|bool $value whether or not the item is editable.
951
+     */
952
+    public function set_is_editable( $value ) {
953
+        $this->set_prop( 'is_editable', (int) $value );
954 954
     }
955 955
 
956 956
     /**
957
-	 * Sets if dynamic pricing is enabled.
958
-	 *
959
-	 * @since 1.0.19
960
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
961
-	 */
962
-	public function set_is_dynamic_pricing( $value ) {
957
+     * Sets if dynamic pricing is enabled.
958
+     *
959
+     * @since 1.0.19
960
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
961
+     */
962
+    public function set_is_dynamic_pricing( $value ) {
963 963
         $this->set_prop( 'is_dynamic_pricing', (int) $value );
964 964
     }
965 965
 
966 966
     /**
967
-	 * Sets the minimum price if dynamic pricing is enabled.
968
-	 *
969
-	 * @since 1.0.19
970
-	 * @param  float $value minimum price.
971
-	 */
972
-	public function set_minimum_price( $value ) {
967
+     * Sets the minimum price if dynamic pricing is enabled.
968
+     *
969
+     * @since 1.0.19
970
+     * @param  float $value minimum price.
971
+     */
972
+    public function set_minimum_price( $value ) {
973 973
         $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
974 974
     }
975 975
 
976 976
     /**
977
-	 * Sets if this is a recurring item.
978
-	 *
979
-	 * @since 1.0.19
980
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
981
-	 */
982
-	public function set_is_recurring( $value ) {
977
+     * Sets if this is a recurring item.
978
+     *
979
+     * @since 1.0.19
980
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
981
+     */
982
+    public function set_is_recurring( $value ) {
983 983
         $this->set_prop( 'is_recurring', (int) $value );
984 984
     }
985 985
 
986 986
     /**
987
-	 * Set the recurring period.
988
-	 *
989
-	 * @since 1.0.19
990
-	 * @param  string $value new period.
991
-	 */
992
-	public function set_recurring_period( $value ) {
987
+     * Set the recurring period.
988
+     *
989
+     * @since 1.0.19
990
+     * @param  string $value new period.
991
+     */
992
+    public function set_recurring_period( $value ) {
993 993
         $this->set_prop( 'recurring_period', $value );
994 994
     }
995 995
 
996 996
     /**
997
-	 * Set the recurring interval.
998
-	 *
999
-	 * @since 1.0.19
1000
-	 * @param  int $value recurring interval.
1001
-	 */
1002
-	public function set_recurring_interval( $value ) {
997
+     * Set the recurring interval.
998
+     *
999
+     * @since 1.0.19
1000
+     * @param  int $value recurring interval.
1001
+     */
1002
+    public function set_recurring_interval( $value ) {
1003 1003
         return $this->set_prop( 'recurring_interval', (int) $value );
1004 1004
     }
1005 1005
 
1006 1006
     /**
1007
-	 * Get the recurring limit.
1008
-	 * @since 1.0.19
1009
-	 * @param  int $value The recurring limit.
1010
-	 * @return int
1011
-	 */
1012
-	public function set_recurring_limit( $value ) {
1007
+     * Get the recurring limit.
1008
+     * @since 1.0.19
1009
+     * @param  int $value The recurring limit.
1010
+     * @return int
1011
+     */
1012
+    public function set_recurring_limit( $value ) {
1013 1013
         $this->set_prop( 'recurring_limit', (int) $value );
1014 1014
     }
1015 1015
 
1016 1016
     /**
1017
-	 * Checks if we have a free trial.
1018
-	 *
1019
-	 * @since 1.0.19
1020
-	 * @param  int|bool $value whether or not it has a free trial.
1021
-	 */
1022
-	public function set_is_free_trial( $value ) {
1017
+     * Checks if we have a free trial.
1018
+     *
1019
+     * @since 1.0.19
1020
+     * @param  int|bool $value whether or not it has a free trial.
1021
+     */
1022
+    public function set_is_free_trial( $value ) {
1023 1023
         $this->set_prop( 'is_free_trial', (int) $value );
1024 1024
     }
1025 1025
 
1026 1026
     /**
1027
-	 * Set the trial period.
1028
-	 *
1029
-	 * @since 1.0.19
1030
-	 * @param  string $value trial period.
1031
-	 */
1032
-	public function set_trial_period( $value ) {
1027
+     * Set the trial period.
1028
+     *
1029
+     * @since 1.0.19
1030
+     * @param  string $value trial period.
1031
+     */
1032
+    public function set_trial_period( $value ) {
1033 1033
         $this->set_prop( 'trial_period', $value );
1034 1034
     }
1035 1035
 
1036 1036
     /**
1037
-	 * Set the trial interval.
1038
-	 *
1039
-	 * @since 1.0.19
1040
-	 * @param  int $value trial interval.
1041
-	 */
1042
-	public function set_trial_interval( $value ) {
1037
+     * Set the trial interval.
1038
+     *
1039
+     * @since 1.0.19
1040
+     * @param  int $value trial interval.
1041
+     */
1042
+    public function set_trial_interval( $value ) {
1043 1043
         $this->set_prop( 'trial_interval', $value );
1044 1044
     }
1045 1045
 
@@ -1047,17 +1047,17 @@  discard block
 block discarded – undo
1047 1047
      * Create an item. For backwards compatibilty.
1048 1048
      * 
1049 1049
      * @deprecated
1050
-	 * @return int item id
1050
+     * @return int item id
1051 1051
      */
1052 1052
     public function create( $data = array() ) {
1053 1053
 
1054
-		// Set the properties.
1055
-		if ( is_array( $data ) ) {
1056
-			$this->set_props( $data );
1057
-		}
1054
+        // Set the properties.
1055
+        if ( is_array( $data ) ) {
1056
+            $this->set_props( $data );
1057
+        }
1058 1058
 
1059
-		// Save the item.
1060
-		return $this->save();
1059
+        // Save the item.
1060
+        return $this->save();
1061 1061
 
1062 1062
     }
1063 1063
 
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
      * Updates an item. For backwards compatibilty.
1066 1066
      * 
1067 1067
      * @deprecated
1068
-	 * @return int item id
1068
+     * @return int item id
1069 1069
      */
1070 1070
     public function update( $data = array() ) {
1071 1071
         return $this->create( $data );
@@ -1081,93 +1081,93 @@  discard block
 block discarded – undo
1081 1081
 	*/
1082 1082
 
1083 1083
     /**
1084
-	 * Checks whether the item has enabled dynamic pricing.
1085
-	 *
1086
-	 * @since 1.0.19
1087
-	 * @return bool
1088
-	 */
1089
-	public function user_can_set_their_price() {
1084
+     * Checks whether the item has enabled dynamic pricing.
1085
+     *
1086
+     * @since 1.0.19
1087
+     * @return bool
1088
+     */
1089
+    public function user_can_set_their_price() {
1090 1090
         return (bool) $this->get_is_dynamic_pricing();
1091
-	}
1091
+    }
1092 1092
 	
1093
-	/**
1094
-	 * Checks whether the item is recurring.
1095
-	 *
1096
-	 * @since 1.0.19
1097
-	 * @return bool
1098
-	 */
1099
-	public function is_recurring() {
1093
+    /**
1094
+     * Checks whether the item is recurring.
1095
+     *
1096
+     * @since 1.0.19
1097
+     * @return bool
1098
+     */
1099
+    public function is_recurring() {
1100 1100
         return (bool) $this->get_is_recurring();
1101 1101
     }
1102 1102
 
1103 1103
     /**
1104
-	 * Checks whether the item has a free trial.
1105
-	 *
1106
-	 * @since 1.0.19
1107
-	 * @return bool
1108
-	 */
1104
+     * Checks whether the item has a free trial.
1105
+     *
1106
+     * @since 1.0.19
1107
+     * @return bool
1108
+     */
1109 1109
     public function has_free_trial() {
1110 1110
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1111 1111
         return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1112 1112
     }
1113 1113
 
1114 1114
     /**
1115
-	 * Checks whether the item is free.
1116
-	 *
1117
-	 * @since 1.0.19
1118
-	 * @return bool
1119
-	 */
1115
+     * Checks whether the item is free.
1116
+     *
1117
+     * @since 1.0.19
1118
+     * @return bool
1119
+     */
1120 1120
     public function is_free() {
1121 1121
         $is_free   = $this->get_price() == 0;
1122 1122
         return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1123 1123
     }
1124 1124
 
1125 1125
     /**
1126
-	 * Checks the item status against a passed in status.
1127
-	 *
1128
-	 * @param array|string $status Status to check.
1129
-	 * @return bool
1130
-	 */
1131
-	public function has_status( $status ) {
1132
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1133
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1126
+     * Checks the item status against a passed in status.
1127
+     *
1128
+     * @param array|string $status Status to check.
1129
+     * @return bool
1130
+     */
1131
+    public function has_status( $status ) {
1132
+        $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1133
+        return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1134 1134
     }
1135 1135
 
1136 1136
     /**
1137
-	 * Checks the item type against a passed in types.
1138
-	 *
1139
-	 * @param array|string $type Type to check.
1140
-	 * @return bool
1141
-	 */
1142
-	public function is_type( $type ) {
1143
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1144
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1145
-	}
1137
+     * Checks the item type against a passed in types.
1138
+     *
1139
+     * @param array|string $type Type to check.
1140
+     * @return bool
1141
+     */
1142
+    public function is_type( $type ) {
1143
+        $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1144
+        return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1145
+    }
1146 1146
 
1147 1147
     /**
1148
-	 * Checks whether the item is editable.
1149
-	 *
1150
-	 * @since 1.0.19
1151
-	 * @return bool
1152
-	 */
1148
+     * Checks whether the item is editable.
1149
+     *
1150
+     * @since 1.0.19
1151
+     * @return bool
1152
+     */
1153 1153
     public function is_editable() {
1154 1154
         $is_editable = $this->get_is_editable();
1155 1155
         return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1156
-	}
1156
+    }
1157 1157
 
1158
-	/**
1159
-	 * Returns an array of cart fees.
1160
-	 */
1161
-	public function get_fees() {
1158
+    /**
1159
+     * Returns an array of cart fees.
1160
+     */
1161
+    public function get_fees() {
1162 1162
         return array();
1163 1163
     }
1164 1164
 
1165 1165
     /**
1166
-	 * Checks whether the item is purchasable.
1167
-	 *
1168
-	 * @since 1.0.19
1169
-	 * @return bool
1170
-	 */
1166
+     * Checks whether the item is purchasable.
1167
+     *
1168
+     * @since 1.0.19
1169
+     * @return bool
1170
+     */
1171 1171
     public function can_purchase() {
1172 1172
         $can_purchase = $this->exists();
1173 1173
 
@@ -1179,11 +1179,11 @@  discard block
 block discarded – undo
1179 1179
     }
1180 1180
 
1181 1181
     /**
1182
-	 * Checks whether the item supports dynamic pricing.
1183
-	 *
1184
-	 * @since 1.0.19
1185
-	 * @return bool
1186
-	 */
1182
+     * Checks whether the item supports dynamic pricing.
1183
+     *
1184
+     * @since 1.0.19
1185
+     * @return bool
1186
+     */
1187 1187
     public function supports_dynamic_pricing() {
1188 1188
         return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1189 1189
     }
Please login to merge, or discard this patch.
Spacing   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -78,30 +78,30 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80 80
 	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
81
+	public function __construct($item = 0) {
82
+		parent::__construct($item);
83
+
84
+		if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) {
85
+			$this->set_id($item);
86
+		} elseif ($item instanceof self) {
87
+			$this->set_id($item->get_id());
88
+		} elseif (!empty($item->ID)) {
89
+			$this->set_id($item->ID);
90
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) {
91
+			$this->set_id($item_id);
92
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) {
93
+			$this->set_id($item_id);
94 94
 		} else {
95
-			$this->set_object_read( true );
95
+			$this->set_object_read(true);
96 96
 		}
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
100 100
 
101
-		if ( $this->get_id() > 0 ) {
102
-            $this->post = get_post( $this->get_id() );
101
+		if ($this->get_id() > 0) {
102
+            $this->post = get_post($this->get_id());
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+			$this->data_store->read($this);
105 105
         }
106 106
 
107 107
 	}
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 * @param  string $context View or edit context.
129 129
 	 * @return int
130 130
 	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
131
+	public function get_parent_id($context = 'view') {
132
+		return (int) $this->get_prop('parent_id', $context);
133 133
     }
134 134
 
135 135
     /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 * @param  string $context View or edit context.
140 140
 	 * @return string
141 141
 	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
142
+	public function get_status($context = 'view') {
143
+		return $this->get_prop('status', $context);
144 144
     }
145 145
 
146 146
     /**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @param  string $context View or edit context.
151 151
 	 * @return string
152 152
 	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
153
+	public function get_version($context = 'view') {
154
+		return $this->get_prop('version', $context);
155 155
     }
156 156
 
157 157
     /**
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @param  string $context View or edit context.
162 162
 	 * @return string
163 163
 	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
164
+	public function get_date_created($context = 'view') {
165
+		return $this->get_prop('date_created', $context);
166 166
     }
167 167
 
168 168
     /**
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	 * @param  string $context View or edit context.
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
176
-        $date = $this->get_date_created( $context );
175
+	public function get_date_created_gmt($context = 'view') {
176
+        $date = $this->get_date_created($context);
177 177
 
178
-        if ( $date ) {
179
-            $date = get_gmt_from_date( $date );
178
+        if ($date) {
179
+            $date = get_gmt_from_date($date);
180 180
         }
181 181
 		return $date;
182 182
     }
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @param  string $context View or edit context.
189 189
 	 * @return string
190 190
 	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
191
+	public function get_date_modified($context = 'view') {
192
+		return $this->get_prop('date_modified', $context);
193 193
     }
194 194
 
195 195
     /**
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
203
-        $date = $this->get_date_modified( $context );
202
+	public function get_date_modified_gmt($context = 'view') {
203
+        $date = $this->get_date_modified($context);
204 204
 
205
-        if ( $date ) {
206
-            $date = get_gmt_from_date( $date );
205
+        if ($date) {
206
+            $date = get_gmt_from_date($date);
207 207
         }
208 208
 		return $date;
209 209
     }
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 * @param  string $context View or edit context.
216 216
 	 * @return string
217 217
 	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
218
+	public function get_name($context = 'view') {
219
+		return $this->get_prop('name', $context);
220 220
     }
221 221
 
222 222
     /**
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param  string $context View or edit context.
227 227
 	 * @return string
228 228
 	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
229
+	public function get_title($context = 'view') {
230
+		return $this->get_name($context);
231 231
     }
232 232
 
233 233
     /**
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @param  string $context View or edit context.
238 238
 	 * @return string
239 239
 	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
240
+	public function get_description($context = 'view') {
241
+		return $this->get_prop('description', $context);
242 242
     }
243 243
 
244 244
     /**
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param  string $context View or edit context.
249 249
 	 * @return string
250 250
 	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
251
+	public function get_excerpt($context = 'view') {
252
+		return $this->get_description($context);
253 253
     }
254 254
 
255 255
     /**
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @param  string $context View or edit context.
260 260
 	 * @return string
261 261
 	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
262
+	public function get_summary($context = 'view') {
263
+		return $this->get_description($context);
264 264
     }
265 265
 
266 266
     /**
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 * @param  string $context View or edit context.
271 271
 	 * @return int
272 272
 	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
273
+	public function get_author($context = 'view') {
274
+		return (int) $this->get_prop('author', $context);
275 275
 	}
276 276
 	
277 277
 	/**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param  string $context View or edit context.
282 282
 	 * @return int
283 283
 	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
284
+	public function get_owner($context = 'view') {
285
+		return $this->get_author($context);
286 286
     }
287 287
 
288 288
     /**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param  string $context View or edit context.
293 293
 	 * @return float
294 294
 	 */
295
-	public function get_price( $context = 'view' ) {
296
-        return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
295
+	public function get_price($context = 'view') {
296
+        return wpinv_sanitize_amount($this->get_prop('price', $context));
297 297
 	}
298 298
 
299 299
 	/**
@@ -303,15 +303,15 @@  discard block
 block discarded – undo
303 303
 	 * @param  string $context View or edit context.
304 304
 	 * @return float
305 305
 	 */
306
-	public function get_initial_price( $context = 'view' ) {
306
+	public function get_initial_price($context = 'view') {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+		$price = (float) $this->get_price($context);
309 309
 
310
-		if ( $this->has_free_trial() ) {
310
+		if ($this->has_free_trial()) {
311 311
 			$price = 0;
312 312
 		}
313 313
 
314
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
314
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this));
315 315
     }
316 316
 
317 317
     /**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return string
323 323
 	 */
324 324
     public function get_the_price() {
325
-        return wpinv_price( $this->get_price() );
325
+        return wpinv_price($this->get_price());
326 326
 	}
327 327
 
328 328
 	/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @return string
334 334
 	 */
335 335
     public function get_the_initial_price() {
336
-        return wpinv_price( $this->get_initial_price() );
336
+        return wpinv_price($this->get_initial_price());
337 337
     }
338 338
 
339 339
     /**
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	 * @param  string $context View or edit context.
344 344
 	 * @return string
345 345
 	 */
346
-	public function get_vat_rule( $context = 'view' ) {
347
-        return $this->get_prop( 'vat_rule', $context );
346
+	public function get_vat_rule($context = 'view') {
347
+        return $this->get_prop('vat_rule', $context);
348 348
     }
349 349
 
350 350
     /**
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @param  string $context View or edit context.
355 355
 	 * @return string
356 356
 	 */
357
-	public function get_vat_class( $context = 'view' ) {
358
-        return $this->get_prop( 'vat_class', $context );
357
+	public function get_vat_class($context = 'view') {
358
+        return $this->get_prop('vat_class', $context);
359 359
     }
360 360
 
361 361
     /**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $context View or edit context.
366 366
 	 * @return string
367 367
 	 */
368
-	public function get_type( $context = 'view' ) {
369
-        return $this->get_prop( 'type', $context );
368
+	public function get_type($context = 'view') {
369
+        return $this->get_prop('type', $context);
370 370
     }
371 371
 
372 372
     /**
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_custom_id( $context = 'view' ) {
380
-        return $this->get_prop( 'custom_id', $context );
379
+	public function get_custom_id($context = 'view') {
380
+        return $this->get_prop('custom_id', $context);
381 381
     }
382 382
 
383 383
     /**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 	 * @param  string $context View or edit context.
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_custom_name( $context = 'view' ) {
391
-        return $this->get_prop( 'custom_name', $context );
390
+	public function get_custom_name($context = 'view') {
391
+        return $this->get_prop('custom_name', $context);
392 392
     }
393 393
 
394 394
     /**
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 * @param  string $context View or edit context.
399 399
 	 * @return string
400 400
 	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
402
-        return $this->get_prop( 'custom_singular_name', $context );
401
+	public function get_custom_singular_name($context = 'view') {
402
+        return $this->get_prop('custom_singular_name', $context);
403 403
     }
404 404
 
405 405
     /**
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 * @param  string $context View or edit context.
410 410
 	 * @return int
411 411
 	 */
412
-	public function get_is_editable( $context = 'view' ) {
413
-        return (int) $this->get_prop( 'is_editable', $context );
412
+	public function get_is_editable($context = 'view') {
413
+        return (int) $this->get_prop('is_editable', $context);
414 414
     }
415 415
 
416 416
     /**
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param  string $context View or edit context.
421 421
 	 * @return int
422 422
 	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
423
+	public function get_editable($context = 'view') {
424
+		return $this->get_is_editable($context);
425 425
     }
426 426
 
427 427
     /**
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param  string $context View or edit context.
432 432
 	 * @return int
433 433
 	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
435
-        return (int) $this->get_prop( 'is_dynamic_pricing', $context );
434
+	public function get_is_dynamic_pricing($context = 'view') {
435
+        return (int) $this->get_prop('is_dynamic_pricing', $context);
436 436
     }
437 437
 
438 438
     /**
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @param  string $context View or edit context.
443 443
 	 * @return float
444 444
 	 */
445
-	public function get_minimum_price( $context = 'view' ) {
446
-        return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
445
+	public function get_minimum_price($context = 'view') {
446
+        return wpinv_sanitize_amount($this->get_prop('minimum_price', $context));
447 447
     }
448 448
 
449 449
     /**
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return int
455 455
 	 */
456
-	public function get_is_recurring( $context = 'view' ) {
457
-        return (int) $this->get_prop( 'is_recurring', $context );
456
+	public function get_is_recurring($context = 'view') {
457
+        return (int) $this->get_prop('is_recurring', $context);
458 458
 	}
459 459
 	
460 460
 	/**
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 	 * @param  string $context View or edit context.
465 465
 	 * @return float
466 466
 	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
469
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
467
+	public function get_recurring_price($context = 'view') {
468
+		$price = $this->get_price($context);
469
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID));
470 470
 	}
471 471
 
472 472
 	/**
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return string
478 478
 	 */
479 479
     public function get_the_recurring_price() {
480
-        return wpinv_price( $this->get_recurring_price() );
480
+        return wpinv_price($this->get_recurring_price());
481 481
 	}
482 482
 
483 483
 	/**
@@ -498,15 +498,15 @@  discard block
 block discarded – undo
498 498
 		$period   = $this->get_recurring_period();
499 499
 		$interval = $this->get_recurring_interval();
500 500
 
501
-		if ( $this->has_free_trial() ) {
501
+		if ($this->has_free_trial()) {
502 502
 			$period   = $this->get_trial_period();
503 503
 			$interval = $this->get_trial_interval();
504 504
 		}
505 505
 
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509
-        return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
506
+		$period       = $periods[$period];
507
+		$interval     = empty($interval) ? 1 : $interval;
508
+		$next_renewal = strtotime("+$interval $period", current_time('timestamp'));
509
+        return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this);
510 510
     }
511 511
 
512 512
     /**
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
 	 * @param  bool $full Return abbreviation or in full.
517 517
 	 * @return string
518 518
 	 */
519
-	public function get_recurring_period( $full = false ) {
520
-        $period = $this->get_prop( 'recurring_period', 'view' );
519
+	public function get_recurring_period($full = false) {
520
+        $period = $this->get_prop('recurring_period', 'view');
521 521
 
522
-        if ( $full && ! is_bool( $full ) ) {
522
+        if ($full && !is_bool($full)) {
523 523
             $full = false;
524 524
         }
525 525
 
526
-        return getpaid_sanitize_recurring_period( $period, $full );
526
+        return getpaid_sanitize_recurring_period($period, $full);
527 527
     }
528 528
 
529 529
     /**
@@ -533,9 +533,9 @@  discard block
 block discarded – undo
533 533
 	 * @param  string $context View or edit context.
534 534
 	 * @return int
535 535
 	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
538
-		return max( 1, $interval );
536
+	public function get_recurring_interval($context = 'view') {
537
+		$interval = absint($this->get_prop('recurring_interval', $context));
538
+		return max(1, $interval);
539 539
     }
540 540
 
541 541
     /**
@@ -545,8 +545,8 @@  discard block
 block discarded – undo
545 545
 	 * @param  string $context View or edit context.
546 546
 	 * @return int
547 547
 	 */
548
-	public function get_recurring_limit( $context = 'view' ) {
549
-        return (int) $this->get_prop( 'recurring_limit', $context );
548
+	public function get_recurring_limit($context = 'view') {
549
+        return (int) $this->get_prop('recurring_limit', $context);
550 550
     }
551 551
 
552 552
     /**
@@ -556,8 +556,8 @@  discard block
 block discarded – undo
556 556
 	 * @param  string $context View or edit context.
557 557
 	 * @return int
558 558
 	 */
559
-	public function get_is_free_trial( $context = 'view' ) {
560
-        return (int) $this->get_prop( 'is_free_trial', $context );
559
+	public function get_is_free_trial($context = 'view') {
560
+        return (int) $this->get_prop('is_free_trial', $context);
561 561
     }
562 562
 
563 563
     /**
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
 	 * @param  string $context View or edit context.
568 568
 	 * @return int
569 569
 	 */
570
-	public function get_free_trial( $context = 'view' ) {
571
-        return $this->get_is_free_trial( $context );
570
+	public function get_free_trial($context = 'view') {
571
+        return $this->get_is_free_trial($context);
572 572
     }
573 573
 
574 574
     /**
@@ -578,14 +578,14 @@  discard block
 block discarded – undo
578 578
 	 * @param  bool $full Return abbreviation or in full.
579 579
 	 * @return string
580 580
 	 */
581
-	public function get_trial_period( $full = false ) {
582
-        $period = $this->get_prop( 'trial_period', 'view' );
581
+	public function get_trial_period($full = false) {
582
+        $period = $this->get_prop('trial_period', 'view');
583 583
 
584
-        if ( $full && ! is_bool( $full ) ) {
584
+        if ($full && !is_bool($full)) {
585 585
             $full = false;
586 586
         }
587 587
 
588
-        return getpaid_sanitize_recurring_period( $period, $full );
588
+        return getpaid_sanitize_recurring_period($period, $full);
589 589
     }
590 590
 
591 591
     /**
@@ -595,8 +595,8 @@  discard block
 block discarded – undo
595 595
 	 * @param  string $context View or edit context.
596 596
 	 * @return int
597 597
 	 */
598
-	public function get_trial_interval( $context = 'view' ) {
599
-        return (int) $this->get_prop( 'trial_interval', $context );
598
+	public function get_trial_interval($context = 'view') {
599
+        return (int) $this->get_prop('trial_interval', $context);
600 600
 	}
601 601
 	
602 602
 	/**
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 	 * @return string
607 607
 	 */
608 608
 	public function get_edit_url() {
609
-        return get_edit_post_link( $this->get_id(), 'edit' );
609
+        return get_edit_post_link($this->get_id(), 'edit');
610 610
 	}
611 611
 
612 612
 	/**
@@ -620,35 +620,35 @@  discard block
 block discarded – undo
620 620
 	 * @since 1.0.15
621 621
 	 * @return int
622 622
 	 */
623
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
623
+	public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') {
624 624
 
625 625
 		// Trim the value.
626
-		$value = sanitize_text_field( $value );
627
-		if ( empty( $value ) ) {
626
+		$value = sanitize_text_field($value);
627
+		if (empty($value)) {
628 628
 			return 0;
629 629
 		}
630 630
 
631 631
         // Valid fields.
632
-        $fields = array( 'custom_id', 'name', 'slug' );
632
+        $fields = array('custom_id', 'name', 'slug');
633 633
 
634 634
 		// Ensure a field has been passed.
635
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
635
+		if (empty($field) || !in_array($field, $fields)) {
636 636
 			return 0;
637 637
 		}
638 638
 
639
-		if ( $field == 'name' ) {
639
+		if ($field == 'name') {
640 640
 			$field = 'slug';
641 641
 		}
642 642
 
643 643
 		// Maybe retrieve from the cache.
644
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
645
-		if ( ! empty( $item_id ) ) {
644
+		$item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids");
645
+		if (!empty($item_id)) {
646 646
 			return $item_id;
647 647
 		}
648 648
 
649 649
 		// Fetch from the db.
650 650
 		$items = array();
651
-		if ( $field == 'slug' ) {
651
+		if ($field == 'slug') {
652 652
 			$items = get_posts(
653 653
 				array(
654 654
 					'post_type'      => 'wpi_item',
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 			);
660 660
 		}
661 661
 
662
-		if ( $field =='custom_id' ) {
662
+		if ($field == 'custom_id') {
663 663
 			$items = get_posts(
664 664
 				array(
665 665
 					'post_type'      => 'wpi_item',
@@ -679,12 +679,12 @@  discard block
 block discarded – undo
679 679
 			);
680 680
 		}
681 681
 
682
-		if ( empty( $items ) ) {
682
+		if (empty($items)) {
683 683
 			return 0;
684 684
 		}
685 685
 
686 686
 		// Update the cache with our data
687
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
687
+		wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids");
688 688
 
689 689
 		return $items[0]->ID;
690 690
     }
@@ -692,19 +692,19 @@  discard block
 block discarded – undo
692 692
     /**
693 693
      * Margic method for retrieving a property.
694 694
      */
695
-    public function __get( $key ) {
695
+    public function __get($key) {
696 696
 
697 697
         // Check if we have a helper method for that.
698
-        if ( method_exists( $this, 'get_' . $key ) ) {
699
-            return call_user_func( array( $this, 'get_' . $key ) );
698
+        if (method_exists($this, 'get_' . $key)) {
699
+            return call_user_func(array($this, 'get_' . $key));
700 700
         }
701 701
 
702 702
         // Check if the key is in the associated $post object.
703
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
703
+        if (!empty($this->post) && isset($this->post->$key)) {
704 704
             return $this->post->$key;
705 705
         }
706 706
 
707
-        return $this->get_prop( $key );
707
+        return $this->get_prop($key);
708 708
 
709 709
     }
710 710
 
@@ -723,11 +723,11 @@  discard block
 block discarded – undo
723 723
 	 *
724 724
 	 * @since 1.0.19
725 725
 	 */
726
-	public function set_parent_id( $value ) {
727
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
726
+	public function set_parent_id($value) {
727
+		if ($value && ($value === $this->get_id() || !get_post($value))) {
728 728
 			return;
729 729
 		}
730
-		$this->set_prop( 'parent_id', absint( $value ) );
730
+		$this->set_prop('parent_id', absint($value));
731 731
 	}
732 732
 
733 733
     /**
@@ -737,10 +737,10 @@  discard block
 block discarded – undo
737 737
 	 * @param  string $status New status.
738 738
 	 * @return array details of change.
739 739
 	 */
740
-	public function set_status( $status ) {
740
+	public function set_status($status) {
741 741
         $old_status = $this->get_status();
742 742
 
743
-        $this->set_prop( 'status', $status );
743
+        $this->set_prop('status', $status);
744 744
 
745 745
 		return array(
746 746
 			'from' => $old_status,
@@ -753,8 +753,8 @@  discard block
 block discarded – undo
753 753
 	 *
754 754
 	 * @since 1.0.19
755 755
 	 */
756
-	public function set_version( $value ) {
757
-		$this->set_prop( 'version', $value );
756
+	public function set_version($value) {
757
+		$this->set_prop('version', $value);
758 758
     }
759 759
 
760 760
     /**
@@ -764,11 +764,11 @@  discard block
 block discarded – undo
764 764
 	 * @param string $value Value to set.
765 765
      * @return bool Whether or not the date was set.
766 766
 	 */
767
-	public function set_date_created( $value ) {
768
-        $date = strtotime( $value );
767
+	public function set_date_created($value) {
768
+        $date = strtotime($value);
769 769
 
770
-        if ( $date ) {
771
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
770
+        if ($date) {
771
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
772 772
             return true;
773 773
         }
774 774
 
@@ -783,11 +783,11 @@  discard block
 block discarded – undo
783 783
 	 * @param string $value Value to set.
784 784
      * @return bool Whether or not the date was set.
785 785
 	 */
786
-	public function set_date_modified( $value ) {
787
-        $date = strtotime( $value );
786
+	public function set_date_modified($value) {
787
+        $date = strtotime($value);
788 788
 
789
-        if ( $date ) {
790
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
789
+        if ($date) {
790
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
791 791
             return true;
792 792
         }
793 793
 
@@ -801,9 +801,9 @@  discard block
 block discarded – undo
801 801
 	 * @since 1.0.19
802 802
 	 * @param  string $value New name.
803 803
 	 */
804
-	public function set_name( $value ) {
805
-        $name = sanitize_text_field( $value );
806
-		$this->set_prop( 'name', $name );
804
+	public function set_name($value) {
805
+        $name = sanitize_text_field($value);
806
+		$this->set_prop('name', $name);
807 807
     }
808 808
 
809 809
     /**
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 	 * @since 1.0.19
813 813
 	 * @param  string $value New name.
814 814
 	 */
815
-	public function set_title( $value ) {
816
-		$this->set_name( $value );
815
+	public function set_title($value) {
816
+		$this->set_name($value);
817 817
     }
818 818
 
819 819
     /**
@@ -822,9 +822,9 @@  discard block
 block discarded – undo
822 822
 	 * @since 1.0.19
823 823
 	 * @param  string $value New description.
824 824
 	 */
825
-	public function set_description( $value ) {
826
-		$description = wp_kses_post( wp_unslash( $value ) );
827
-		return $this->set_prop( 'description', $description );
825
+	public function set_description($value) {
826
+		$description = wp_kses_post(wp_unslash($value));
827
+		return $this->set_prop('description', $description);
828 828
     }
829 829
 
830 830
     /**
@@ -833,8 +833,8 @@  discard block
 block discarded – undo
833 833
 	 * @since 1.0.19
834 834
 	 * @param  string $value New description.
835 835
 	 */
836
-	public function set_excerpt( $value ) {
837
-		$this->set_description( $value );
836
+	public function set_excerpt($value) {
837
+		$this->set_description($value);
838 838
     }
839 839
 
840 840
     /**
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
 	 * @since 1.0.19
844 844
 	 * @param  string $value New description.
845 845
 	 */
846
-	public function set_summary( $value ) {
847
-		$this->set_description( $value );
846
+	public function set_summary($value) {
847
+		$this->set_description($value);
848 848
     }
849 849
 
850 850
     /**
@@ -853,8 +853,8 @@  discard block
 block discarded – undo
853 853
 	 * @since 1.0.19
854 854
 	 * @param  int $value New author.
855 855
 	 */
856
-	public function set_author( $value ) {
857
-		$this->set_prop( 'author', (int) $value );
856
+	public function set_author($value) {
857
+		$this->set_prop('author', (int) $value);
858 858
 	}
859 859
 	
860 860
 	/**
@@ -863,8 +863,8 @@  discard block
 block discarded – undo
863 863
 	 * @since 1.0.19
864 864
 	 * @param  int $value New author.
865 865
 	 */
866
-	public function set_owner( $value ) {
867
-		$this->set_author( $value );
866
+	public function set_owner($value) {
867
+		$this->set_author($value);
868 868
     }
869 869
 
870 870
     /**
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 	 * @since 1.0.19
874 874
 	 * @param  float $value New price.
875 875
 	 */
876
-	public function set_price( $value ) {
877
-        $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
876
+	public function set_price($value) {
877
+        $this->set_prop('price', (float) wpinv_sanitize_amount($value));
878 878
     }
879 879
 
880 880
     /**
@@ -883,8 +883,8 @@  discard block
 block discarded – undo
883 883
 	 * @since 1.0.19
884 884
 	 * @param  string $value new rule.
885 885
 	 */
886
-	public function set_vat_rule( $value ) {
887
-        $this->set_prop( 'vat_rule', $value );
886
+	public function set_vat_rule($value) {
887
+        $this->set_prop('vat_rule', $value);
888 888
     }
889 889
 
890 890
     /**
@@ -893,8 +893,8 @@  discard block
 block discarded – undo
893 893
 	 * @since 1.0.19
894 894
 	 * @param  string $value new class.
895 895
 	 */
896
-	public function set_vat_class( $value ) {
897
-        $this->set_prop( 'vat_class', $value );
896
+	public function set_vat_class($value) {
897
+        $this->set_prop('vat_class', $value);
898 898
     }
899 899
 
900 900
     /**
@@ -904,13 +904,13 @@  discard block
 block discarded – undo
904 904
 	 * @param  string $value new item type.
905 905
 	 * @return string
906 906
 	 */
907
-	public function set_type( $value ) {
907
+	public function set_type($value) {
908 908
 
909
-        if ( empty( $value ) ) {
909
+        if (empty($value)) {
910 910
             $value = 'custom';
911 911
         }
912 912
 
913
-        $this->set_prop( 'type', $value );
913
+        $this->set_prop('type', $value);
914 914
     }
915 915
 
916 916
     /**
@@ -919,8 +919,8 @@  discard block
 block discarded – undo
919 919
 	 * @since 1.0.19
920 920
 	 * @param  string $value new custom id.
921 921
 	 */
922
-	public function set_custom_id( $value ) {
923
-        $this->set_prop( 'custom_id', $value );
922
+	public function set_custom_id($value) {
923
+        $this->set_prop('custom_id', $value);
924 924
     }
925 925
 
926 926
     /**
@@ -929,8 +929,8 @@  discard block
 block discarded – undo
929 929
 	 * @since 1.0.19
930 930
 	 * @param  string $value new custom name.
931 931
 	 */
932
-	public function set_custom_name( $value ) {
933
-        $this->set_prop( 'custom_name', $value );
932
+	public function set_custom_name($value) {
933
+        $this->set_prop('custom_name', $value);
934 934
     }
935 935
 
936 936
     /**
@@ -939,8 +939,8 @@  discard block
 block discarded – undo
939 939
 	 * @since 1.0.19
940 940
 	 * @param  string $value new custom singular name.
941 941
 	 */
942
-	public function set_custom_singular_name( $value ) {
943
-        $this->set_prop( 'custom_singular_name', $value );
942
+	public function set_custom_singular_name($value) {
943
+        $this->set_prop('custom_singular_name', $value);
944 944
     }
945 945
 
946 946
     /**
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 	 * @since 1.0.19
950 950
 	 * @param  int|bool $value whether or not the item is editable.
951 951
 	 */
952
-	public function set_is_editable( $value ) {
953
-		$this->set_prop( 'is_editable', (int) $value );
952
+	public function set_is_editable($value) {
953
+		$this->set_prop('is_editable', (int) $value);
954 954
     }
955 955
 
956 956
     /**
@@ -959,8 +959,8 @@  discard block
 block discarded – undo
959 959
 	 * @since 1.0.19
960 960
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
961 961
 	 */
962
-	public function set_is_dynamic_pricing( $value ) {
963
-        $this->set_prop( 'is_dynamic_pricing', (int) $value );
962
+	public function set_is_dynamic_pricing($value) {
963
+        $this->set_prop('is_dynamic_pricing', (int) $value);
964 964
     }
965 965
 
966 966
     /**
@@ -969,8 +969,8 @@  discard block
 block discarded – undo
969 969
 	 * @since 1.0.19
970 970
 	 * @param  float $value minimum price.
971 971
 	 */
972
-	public function set_minimum_price( $value ) {
973
-        $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
972
+	public function set_minimum_price($value) {
973
+        $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value));
974 974
     }
975 975
 
976 976
     /**
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
 	 * @since 1.0.19
980 980
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
981 981
 	 */
982
-	public function set_is_recurring( $value ) {
983
-        $this->set_prop( 'is_recurring', (int) $value );
982
+	public function set_is_recurring($value) {
983
+        $this->set_prop('is_recurring', (int) $value);
984 984
     }
985 985
 
986 986
     /**
@@ -989,8 +989,8 @@  discard block
 block discarded – undo
989 989
 	 * @since 1.0.19
990 990
 	 * @param  string $value new period.
991 991
 	 */
992
-	public function set_recurring_period( $value ) {
993
-        $this->set_prop( 'recurring_period', $value );
992
+	public function set_recurring_period($value) {
993
+        $this->set_prop('recurring_period', $value);
994 994
     }
995 995
 
996 996
     /**
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
 	 * @since 1.0.19
1000 1000
 	 * @param  int $value recurring interval.
1001 1001
 	 */
1002
-	public function set_recurring_interval( $value ) {
1003
-        return $this->set_prop( 'recurring_interval', (int) $value );
1002
+	public function set_recurring_interval($value) {
1003
+        return $this->set_prop('recurring_interval', (int) $value);
1004 1004
     }
1005 1005
 
1006 1006
     /**
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 	 * @param  int $value The recurring limit.
1010 1010
 	 * @return int
1011 1011
 	 */
1012
-	public function set_recurring_limit( $value ) {
1013
-        $this->set_prop( 'recurring_limit', (int) $value );
1012
+	public function set_recurring_limit($value) {
1013
+        $this->set_prop('recurring_limit', (int) $value);
1014 1014
     }
1015 1015
 
1016 1016
     /**
@@ -1019,8 +1019,8 @@  discard block
 block discarded – undo
1019 1019
 	 * @since 1.0.19
1020 1020
 	 * @param  int|bool $value whether or not it has a free trial.
1021 1021
 	 */
1022
-	public function set_is_free_trial( $value ) {
1023
-        $this->set_prop( 'is_free_trial', (int) $value );
1022
+	public function set_is_free_trial($value) {
1023
+        $this->set_prop('is_free_trial', (int) $value);
1024 1024
     }
1025 1025
 
1026 1026
     /**
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 	 * @since 1.0.19
1030 1030
 	 * @param  string $value trial period.
1031 1031
 	 */
1032
-	public function set_trial_period( $value ) {
1033
-        $this->set_prop( 'trial_period', $value );
1032
+	public function set_trial_period($value) {
1033
+        $this->set_prop('trial_period', $value);
1034 1034
     }
1035 1035
 
1036 1036
     /**
@@ -1039,8 +1039,8 @@  discard block
 block discarded – undo
1039 1039
 	 * @since 1.0.19
1040 1040
 	 * @param  int $value trial interval.
1041 1041
 	 */
1042
-	public function set_trial_interval( $value ) {
1043
-        $this->set_prop( 'trial_interval', $value );
1042
+	public function set_trial_interval($value) {
1043
+        $this->set_prop('trial_interval', $value);
1044 1044
     }
1045 1045
 
1046 1046
     /**
@@ -1049,11 +1049,11 @@  discard block
 block discarded – undo
1049 1049
      * @deprecated
1050 1050
 	 * @return int item id
1051 1051
      */
1052
-    public function create( $data = array() ) {
1052
+    public function create($data = array()) {
1053 1053
 
1054 1054
 		// Set the properties.
1055
-		if ( is_array( $data ) ) {
1056
-			$this->set_props( $data );
1055
+		if (is_array($data)) {
1056
+			$this->set_props($data);
1057 1057
 		}
1058 1058
 
1059 1059
 		// Save the item.
@@ -1067,8 +1067,8 @@  discard block
 block discarded – undo
1067 1067
      * @deprecated
1068 1068
 	 * @return int item id
1069 1069
      */
1070
-    public function update( $data = array() ) {
1071
-        return $this->create( $data );
1070
+    public function update($data = array()) {
1071
+        return $this->create($data);
1072 1072
     }
1073 1073
 
1074 1074
     /*
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
 	 */
1109 1109
     public function has_free_trial() {
1110 1110
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1111
-        return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1111
+        return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this);
1112 1112
     }
1113 1113
 
1114 1114
     /**
@@ -1118,8 +1118,8 @@  discard block
 block discarded – undo
1118 1118
 	 * @return bool
1119 1119
 	 */
1120 1120
     public function is_free() {
1121
-        $is_free   = $this->get_price() == 0;
1122
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1121
+        $is_free = $this->get_price() == 0;
1122
+        return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this);
1123 1123
     }
1124 1124
 
1125 1125
     /**
@@ -1128,9 +1128,9 @@  discard block
 block discarded – undo
1128 1128
 	 * @param array|string $status Status to check.
1129 1129
 	 * @return bool
1130 1130
 	 */
1131
-	public function has_status( $status ) {
1132
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1133
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1131
+	public function has_status($status) {
1132
+		$has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status;
1133
+		return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status);
1134 1134
     }
1135 1135
 
1136 1136
     /**
@@ -1139,9 +1139,9 @@  discard block
 block discarded – undo
1139 1139
 	 * @param array|string $type Type to check.
1140 1140
 	 * @return bool
1141 1141
 	 */
1142
-	public function is_type( $type ) {
1143
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1144
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1142
+	public function is_type($type) {
1143
+		$is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type;
1144
+		return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type);
1145 1145
 	}
1146 1146
 
1147 1147
     /**
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 	 */
1153 1153
     public function is_editable() {
1154 1154
         $is_editable = $this->get_is_editable();
1155
-        return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1155
+        return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this);
1156 1156
 	}
1157 1157
 
1158 1158
 	/**
@@ -1171,11 +1171,11 @@  discard block
 block discarded – undo
1171 1171
     public function can_purchase() {
1172 1172
         $can_purchase = $this->exists();
1173 1173
 
1174
-        if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
1174
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
1175 1175
             $can_purchase = false;
1176 1176
         }
1177 1177
 
1178
-        return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
1178
+        return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
1179 1179
     }
1180 1180
 
1181 1181
     /**
@@ -1185,6 +1185,6 @@  discard block
 block discarded – undo
1185 1185
 	 * @return bool
1186 1186
 	 */
1187 1187
     public function supports_dynamic_pricing() {
1188
-        return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1188
+        return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this);
1189 1189
     }
1190 1190
 }
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 2 patches
Indentation   +433 added lines, -433 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function wpinv_subscriptions_page() {
16 16
 
17
-	?>
17
+    ?>
18 18
 
19 19
 	<div class="wrap">
20 20
 		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
@@ -22,27 +22,27 @@  discard block
 block discarded – undo
22 22
 
23 23
 			<?php
24 24
 
25
-				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
25
+                // Verify user permissions.
26
+                if ( ! wpinv_current_user_can_manage_invoicing() ) {
27 27
 
28
-					echo aui()->alert(
29
-						array(
30
-							'type'    => 'danger',
31
-							'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
-						)
33
-					);
28
+                    echo aui()->alert(
29
+                        array(
30
+                            'type'    => 'danger',
31
+                            'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
+                        )
33
+                    );
34 34
 
35
-				} else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
35
+                } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
36 36
 
37
-					// Display a single subscription.
38
-					wpinv_recurring_subscription_details();
39
-				} else {
37
+                    // Display a single subscription.
38
+                    wpinv_recurring_subscription_details();
39
+                } else {
40 40
 
41
-					// Display a list of available subscriptions.
42
-					getpaid_print_subscriptions_list();
43
-				}
41
+                    // Display a list of available subscriptions.
42
+                    getpaid_print_subscriptions_list();
43
+                }
44 44
 
45
-			?>
45
+            ?>
46 46
 
47 47
 		</div>
48 48
 	</div>
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function getpaid_print_subscriptions_list() {
61 61
 
62
-	$subscribers_table = new WPInv_Subscriptions_List_Table();
63
-	$subscribers_table->prepare_items();
62
+    $subscribers_table = new WPInv_Subscriptions_List_Table();
63
+    $subscribers_table->prepare_items();
64 64
 
65
-	?>
65
+    ?>
66 66
 	<?php $subscribers_table->views(); ?>
67 67
 	<form id="subscribers-filter" class="bsui" method="get">
68 68
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
@@ -81,41 +81,41 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function wpinv_recurring_subscription_details() {
83 83
 
84
-	// Fetch the subscription.
85
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
86
-	if ( ! $sub->exists() ) {
84
+    // Fetch the subscription.
85
+    $sub = new WPInv_Subscription( (int) $_GET['id'] );
86
+    if ( ! $sub->exists() ) {
87 87
 
88
-		echo aui()->alert(
89
-			array(
90
-				'type'    => 'danger',
91
-				'content' => __( 'Subscription not found.', 'invoicing' ),
92
-			)
93
-		);
88
+        echo aui()->alert(
89
+            array(
90
+                'type'    => 'danger',
91
+                'content' => __( 'Subscription not found.', 'invoicing' ),
92
+            )
93
+        );
94 94
 
95
-		return;
96
-	}
95
+        return;
96
+    }
97 97
 
98
-	// Use metaboxes to display the subscription details.
99
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
100
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
98
+    // Use metaboxes to display the subscription details.
99
+    add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
100
+    add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
101 101
 
102
-	$subscription_id     = $sub->get_id();
103
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
104
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
102
+    $subscription_id     = $sub->get_id();
103
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
104
+    $subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
105 105
 
106
-	if ( 1 < count( $subscription_groups ) ) {
107
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
108
-	}
106
+    if ( 1 < count( $subscription_groups ) ) {
107
+        add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
108
+    }
109 109
 
110
-	if ( ! empty( $subscription_group ) ) {
111
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
112
-	}
110
+    if ( ! empty( $subscription_group ) ) {
111
+        add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
112
+    }
113 113
 
114
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
114
+    add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
115 115
 
116
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
116
+    do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
117 117
 
118
-	?>
118
+    ?>
119 119
 
120 120
 		<form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>">
121 121
 
@@ -155,45 +155,45 @@  discard block
 block discarded – undo
155 155
  */
156 156
 function getpaid_admin_subscription_details_metabox( $sub ) {
157 157
 
158
-	// Subscription items.
159
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
160
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
161
-
162
-	// Prepare subscription detail columns.
163
-	$fields = apply_filters(
164
-		'getpaid_subscription_admin_page_fields',
165
-		array(
166
-			'subscription'   => __( 'Subscription', 'invoicing' ),
167
-			'customer'       => __( 'Customer', 'invoicing' ),
168
-			'amount'         => __( 'Amount', 'invoicing' ),
169
-			'start_date'     => __( 'Start Date', 'invoicing' ),
170
-			'renews_on'      => __( 'Next Payment', 'invoicing' ),
171
-			'renewals'       => __( 'Payments', 'invoicing' ),
172
-			'item'           => _n( 'Item', 'Items', $items_count,  'invoicing' ),
173
-			'gateway'        => __( 'Payment Method', 'invoicing' ),
174
-			'profile_id'     => __( 'Profile ID', 'invoicing' ),
175
-			'status'         => __( 'Status', 'invoicing' ),
176
-		)
177
-	);
178
-
179
-	if ( ! $sub->is_active() ) {
180
-
181
-		if ( isset( $fields['renews_on'] ) ) {
182
-			unset( $fields['renews_on'] );
183
-		}
184
-
185
-		if ( isset( $fields['gateway'] ) ) {
186
-			unset( $fields['gateway'] );
187
-		}
188
-
189
-	}
190
-
191
-	$profile_id = $sub->get_profile_id();
192
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
193
-		unset( $fields['profile_id'] );
194
-	}
195
-
196
-	?>
158
+    // Subscription items.
159
+    $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
160
+    $items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
161
+
162
+    // Prepare subscription detail columns.
163
+    $fields = apply_filters(
164
+        'getpaid_subscription_admin_page_fields',
165
+        array(
166
+            'subscription'   => __( 'Subscription', 'invoicing' ),
167
+            'customer'       => __( 'Customer', 'invoicing' ),
168
+            'amount'         => __( 'Amount', 'invoicing' ),
169
+            'start_date'     => __( 'Start Date', 'invoicing' ),
170
+            'renews_on'      => __( 'Next Payment', 'invoicing' ),
171
+            'renewals'       => __( 'Payments', 'invoicing' ),
172
+            'item'           => _n( 'Item', 'Items', $items_count,  'invoicing' ),
173
+            'gateway'        => __( 'Payment Method', 'invoicing' ),
174
+            'profile_id'     => __( 'Profile ID', 'invoicing' ),
175
+            'status'         => __( 'Status', 'invoicing' ),
176
+        )
177
+    );
178
+
179
+    if ( ! $sub->is_active() ) {
180
+
181
+        if ( isset( $fields['renews_on'] ) ) {
182
+            unset( $fields['renews_on'] );
183
+        }
184
+
185
+        if ( isset( $fields['gateway'] ) ) {
186
+            unset( $fields['gateway'] );
187
+        }
188
+
189
+    }
190
+
191
+    $profile_id = $sub->get_profile_id();
192
+    if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
193
+        unset( $fields['profile_id'] );
194
+    }
195
+
196
+    ?>
197 197
 
198 198
 		<table class="table table-borderless" style="font-size: 14px;">
199 199
 			<tbody>
@@ -227,20 +227,20 @@  discard block
 block discarded – undo
227 227
  */
228 228
 function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
229 229
 
230
-	$username = __( '(Missing User)', 'invoicing' );
230
+    $username = __( '(Missing User)', 'invoicing' );
231 231
 
232
-	$user = get_userdata( $subscription->get_customer_id() );
233
-	if ( $user ) {
232
+    $user = get_userdata( $subscription->get_customer_id() );
233
+    if ( $user ) {
234 234
 
235
-		$username = sprintf(
236
-			'<a href="user-edit.php?user_id=%s">%s</a>',
237
-			absint( $user->ID ),
238
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
239
-		);
235
+        $username = sprintf(
236
+            '<a href="user-edit.php?user_id=%s">%s</a>',
237
+            absint( $user->ID ),
238
+            ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
239
+        );
240 240
 
241
-	}
241
+    }
242 242
 
243
-	echo  $username;
243
+    echo  $username;
244 244
 }
245 245
 add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
246 246
 
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
  * @param WPInv_Subscription $subscription
251 251
  */
252 252
 function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
253
-	$amount    = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) );
254
-	echo "<span>$amount</span>";
253
+    $amount    = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) );
254
+    echo "<span>$amount</span>";
255 255
 }
256 256
 add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
257 257
 
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
  */
263 263
 function getpaid_admin_subscription_metabox_display_id( $subscription ) {
264 264
 
265
-	printf(
266
-		'<a href="%s">#%s</a>',
267
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
268
-		absint( $subscription->get_id() )
269
-	);
265
+    printf(
266
+        '<a href="%s">#%s</a>',
267
+        esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
268
+        absint( $subscription->get_id() )
269
+    );
270 270
 
271 271
 }
272 272
 add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
  * @param WPInv_Subscription $subscription
278 278
  */
279 279
 function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
280
-	echo getpaid_format_date_value( $subscription->get_date_created() );
280
+    echo getpaid_format_date_value( $subscription->get_date_created() );
281 281
 }
282 282
 add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
283 283
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
  * @param WPInv_Subscription $subscription
288 288
  */
289 289
 function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
290
-	echo getpaid_format_date_value( $subscription->get_expiration() );
290
+    echo getpaid_format_date_value( $subscription->get_expiration() );
291 291
 }
292 292
 add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
293 293
 
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
  * @param WPInv_Subscription $subscription
298 298
  */
299 299
 function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
300
-	$max_bills = $subscription->get_bill_times();
301
-	echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
300
+    $max_bills = $subscription->get_bill_times();
301
+    echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
302 302
 }
303 303
 add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
304 304
 /**
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
  */
310 310
 function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
311 311
 
312
-	if ( empty( $subscription_group ) ) {
313
-		echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() );
314
-		return;
315
-	}
312
+    if ( empty( $subscription_group ) ) {
313
+        echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() );
314
+        return;
315
+    }
316 316
 
317
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
318
-	echo implode( ' | ', $markup );
317
+    $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
318
+    echo implode( ' | ', $markup );
319 319
 
320 320
 }
321 321
 add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
@@ -327,13 +327,13 @@  discard block
 block discarded – undo
327 327
  */
328 328
 function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
329 329
 
330
-	$gateway = $subscription->get_gateway();
330
+    $gateway = $subscription->get_gateway();
331 331
 
332
-	if ( ! empty( $gateway ) ) {
333
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
334
-	} else {
335
-		echo "&mdash;";
336
-	}
332
+    if ( ! empty( $gateway ) ) {
333
+        echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
334
+    } else {
335
+        echo "&mdash;";
336
+    }
337 337
 
338 338
 }
339 339
 add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
  * @param WPInv_Subscription $subscription
345 345
  */
346 346
 function getpaid_admin_subscription_metabox_display_status( $subscription ) {
347
-	echo $subscription->get_status_label_html();
347
+    echo $subscription->get_status_label_html();
348 348
 }
349 349
 add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
350 350
 
@@ -355,29 +355,29 @@  discard block
 block discarded – undo
355 355
  */
356 356
 function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
357 357
 
358
-	$profile_id = $subscription->get_profile_id();
359
-
360
-	$input = aui()->input(
361
-		array(
362
-			'type'        => 'text',
363
-			'id'          => 'wpinv_subscription_profile_id',
364
-			'name'        => 'wpinv_subscription_profile_id',
365
-			'label'       => __( 'Profile Id', 'invoicing' ),
366
-			'label_type'  => 'hidden',
367
-			'placeholder' => __( 'Profile Id', 'invoicing' ),
368
-			'value'       => esc_attr( $profile_id ),
369
-			'input_group_right' => '',
370
-			'no_wrap'     => true,
371
-		)
372
-	);
373
-
374
-	echo str_ireplace( 'form-control', 'regular-text', $input );
375
-
376
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
377
-	if ( ! empty( $url ) ) {
378
-		$url = esc_url_raw( $url );
379
-		echo '&nbsp;<a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
380
-	}
358
+    $profile_id = $subscription->get_profile_id();
359
+
360
+    $input = aui()->input(
361
+        array(
362
+            'type'        => 'text',
363
+            'id'          => 'wpinv_subscription_profile_id',
364
+            'name'        => 'wpinv_subscription_profile_id',
365
+            'label'       => __( 'Profile Id', 'invoicing' ),
366
+            'label_type'  => 'hidden',
367
+            'placeholder' => __( 'Profile Id', 'invoicing' ),
368
+            'value'       => esc_attr( $profile_id ),
369
+            'input_group_right' => '',
370
+            'no_wrap'     => true,
371
+        )
372
+    );
373
+
374
+    echo str_ireplace( 'form-control', 'regular-text', $input );
375
+
376
+    $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
377
+    if ( ! empty( $url ) ) {
378
+        $url = esc_url_raw( $url );
379
+        echo '&nbsp;<a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
380
+    }
381 381
 
382 382
 }
383 383
 add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
@@ -389,39 +389,39 @@  discard block
 block discarded – undo
389 389
  */
390 390
 function getpaid_admin_subscription_update_metabox( $subscription ) {
391 391
 
392
-	?>
392
+    ?>
393 393
 	<div class="mt-3">
394 394
 
395 395
 		<?php
396
-			echo aui()->select(
397
-				array(
398
-					'options'          => getpaid_get_subscription_statuses(),
399
-					'name'             => 'subscription_status',
400
-					'id'               => 'subscription_status_update_select',
401
-					'required'         => true,
402
-					'no_wrap'          => false,
403
-					'label'            => __( 'Subscription Status', 'invoicing' ),
404
-					'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
405
-					'select2'          => true,
406
-					'value'            => $subscription->get_status( 'edit' ),
407
-				)
408
-			);
409
-		?>
396
+            echo aui()->select(
397
+                array(
398
+                    'options'          => getpaid_get_subscription_statuses(),
399
+                    'name'             => 'subscription_status',
400
+                    'id'               => 'subscription_status_update_select',
401
+                    'required'         => true,
402
+                    'no_wrap'          => false,
403
+                    'label'            => __( 'Subscription Status', 'invoicing' ),
404
+                    'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
405
+                    'select2'          => true,
406
+                    'value'            => $subscription->get_status( 'edit' ),
407
+                )
408
+            );
409
+        ?>
410 410
 
411 411
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
412 412
 
413 413
 		<?php
414
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
414
+            submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
415 415
 
416
-			$url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
417
-			$anchor = __( 'Renew Subscription', 'invoicing' );
418
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
416
+            $url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
417
+            $anchor = __( 'Renew Subscription', 'invoicing' );
418
+            $title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
419 419
 
420
-			if ( $subscription->is_active() ) {
421
-				echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
422
-			}
420
+            if ( $subscription->is_active() ) {
421
+                echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
422
+            }
423 423
 
424
-	echo '</div></div>';
424
+    echo '</div></div>';
425 425
 }
426 426
 
427 427
 /**
@@ -432,33 +432,33 @@  discard block
 block discarded – undo
432 432
  */
433 433
 function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
434 434
 
435
-	$columns = apply_filters(
436
-		'getpaid_subscription_related_invoices_columns',
437
-		array(
438
-			'invoice'      => __( 'Invoice', 'invoicing' ),
439
-			'relationship' => __( 'Relationship', 'invoicing' ),
440
-			'date'         => __( 'Date', 'invoicing' ),
441
-			'status'       => __( 'Status', 'invoicing' ),
442
-			'total'        => __( 'Total', 'invoicing' ),
443
-		),
444
-		$subscription
445
-	);
446
-
447
-	// Prepare the invoices.
448
-	$payments = $subscription->get_child_payments( ! is_admin() );
449
-	$parent   = $subscription->get_parent_invoice();
450
-
451
-	if ( $parent->exists() ) {
452
-		$payments = array_merge( array( $parent ), $payments );
453
-	}
454
-
455
-	$table_class = 'w-100 bg-white';
456
-
457
-	if ( ! is_admin() ) {
458
-		$table_class = 'table table-bordered';
459
-	}
460
-
461
-	?>
435
+    $columns = apply_filters(
436
+        'getpaid_subscription_related_invoices_columns',
437
+        array(
438
+            'invoice'      => __( 'Invoice', 'invoicing' ),
439
+            'relationship' => __( 'Relationship', 'invoicing' ),
440
+            'date'         => __( 'Date', 'invoicing' ),
441
+            'status'       => __( 'Status', 'invoicing' ),
442
+            'total'        => __( 'Total', 'invoicing' ),
443
+        ),
444
+        $subscription
445
+    );
446
+
447
+    // Prepare the invoices.
448
+    $payments = $subscription->get_child_payments( ! is_admin() );
449
+    $parent   = $subscription->get_parent_invoice();
450
+
451
+    if ( $parent->exists() ) {
452
+        $payments = array_merge( array( $parent ), $payments );
453
+    }
454
+
455
+    $table_class = 'w-100 bg-white';
456
+
457
+    if ( ! is_admin() ) {
458
+        $table_class = 'table table-bordered';
459
+    }
460
+
461
+    ?>
462 462
 		<div class="m-0" style="overflow: auto;">
463 463
 
464 464
 			<table class="<?php echo $table_class; ?>">
@@ -466,14 +466,14 @@  discard block
 block discarded – undo
466 466
 				<thead>
467 467
 					<tr>
468 468
 						<?php
469
-							foreach ( $columns as $key => $label ) {
470
-								$key   = esc_attr( $key );
471
-								$label = esc_html( $label );
472
-								$class = 'text-left';
473
-
474
-								echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
475
-							}
476
-						?>
469
+                            foreach ( $columns as $key => $label ) {
470
+                                $key   = esc_attr( $key );
471
+                                $label = esc_html( $label );
472
+                                $class = 'text-left';
473
+
474
+                                echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
475
+                            }
476
+                        ?>
477 477
 					</tr>
478 478
 				</thead>
479 479
 
@@ -489,73 +489,73 @@  discard block
 block discarded – undo
489 489
 
490 490
 					<?php
491 491
 
492
-						foreach( $payments as $payment ) :
492
+                        foreach( $payments as $payment ) :
493 493
 
494
-							// Ensure that we have an invoice.
495
-							$payment = new WPInv_Invoice( $payment );
494
+                            // Ensure that we have an invoice.
495
+                            $payment = new WPInv_Invoice( $payment );
496 496
 
497
-							// Abort if the invoice is invalid...
498
-							if ( ! $payment->exists() ) {
499
-								continue;
500
-							}
497
+                            // Abort if the invoice is invalid...
498
+                            if ( ! $payment->exists() ) {
499
+                                continue;
500
+                            }
501 501
 
502
-							// ... or belongs to a different subscription.
503
-							if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
504
-								continue;
505
-							}
502
+                            // ... or belongs to a different subscription.
503
+                            if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
504
+                                continue;
505
+                            }
506 506
 
507
-							echo '<tr>';
507
+                            echo '<tr>';
508 508
 
509
-								foreach ( array_keys( $columns ) as $key ) {
509
+                                foreach ( array_keys( $columns ) as $key ) {
510 510
 
511
-									$class = 'text-left';
511
+                                    $class = 'text-left';
512 512
 
513
-									echo "<td class='p-2 $class'>";
513
+                                    echo "<td class='p-2 $class'>";
514 514
 
515
-										switch( $key ) {
515
+                                        switch( $key ) {
516 516
 
517
-											case 'total':
518
-												echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>';
519
-												break;
517
+                                            case 'total':
518
+                                                echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>';
519
+                                                break;
520 520
 
521
-											case 'relationship':
522
-												echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
523
-												break;
521
+                                            case 'relationship':
522
+                                                echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
523
+                                                break;
524 524
 
525
-											case 'date':
526
-												echo getpaid_format_date_value( $payment->get_date_created() );
527
-												break;
525
+                                            case 'date':
526
+                                                echo getpaid_format_date_value( $payment->get_date_created() );
527
+                                                break;
528 528
 
529
-											case 'status':
529
+                                            case 'status':
530 530
 
531
-												$status = $payment->get_status_nicename();
532
-												if ( is_admin() ) {
533
-													$status = $payment->get_status_label_html();
534
-												}
531
+                                                $status = $payment->get_status_nicename();
532
+                                                if ( is_admin() ) {
533
+                                                    $status = $payment->get_status_label_html();
534
+                                                }
535 535
 
536
-												echo $status;
537
-												break;
536
+                                                echo $status;
537
+                                                break;
538 538
 
539
-											case 'invoice':
540
-												$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
539
+                                            case 'invoice':
540
+                                                $link    = esc_url( get_edit_post_link( $payment->get_id() ) );
541 541
 
542
-												if ( ! is_admin() ) {
543
-													$link = esc_url( $payment->get_view_url() );
544
-												}
542
+                                                if ( ! is_admin() ) {
543
+                                                    $link = esc_url( $payment->get_view_url() );
544
+                                                }
545 545
 
546
-												$invoice = esc_html( $payment->get_number() );
547
-												echo "<a href='$link'>$invoice</a>";
548
-												break;
549
-										}
546
+                                                $invoice = esc_html( $payment->get_number() );
547
+                                                echo "<a href='$link'>$invoice</a>";
548
+                                                break;
549
+                                        }
550 550
 
551
-									echo '</td>';
551
+                                    echo '</td>';
552 552
 
553
-								}
553
+                                }
554 554
 
555
-							echo '</tr>';
555
+                            echo '</tr>';
556 556
 
557
-						endforeach;
558
-					?>
557
+                        endforeach;
558
+                    ?>
559 559
 
560 560
 				</tbody>
561 561
 
@@ -573,42 +573,42 @@  discard block
 block discarded – undo
573 573
  */
574 574
 function getpaid_admin_subscription_item_details_metabox( $subscription ) {
575 575
 
576
-	// Fetch the subscription group.
577
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
576
+    // Fetch the subscription group.
577
+    $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
578 578
 
579
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
580
-		return;
581
-	}
579
+    if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
580
+        return;
581
+    }
582 582
 
583
-	// Prepare table columns.
584
-	$columns = apply_filters(
585
-		'getpaid_subscription_item_details_columns',
586
-		array(
587
-			'item_name'    => __( 'Item', 'invoicing' ),
588
-			'price'        => __( 'Price', 'invoicing' ),
589
-			'tax'          => __( 'Tax', 'invoicing' ),
590
-			'discount'     => __( 'Discount', 'invoicing' ),
591
-			//'initial'      => __( 'Initial Amount', 'invoicing' ),
592
-			'recurring'    => __( 'Subtotal', 'invoicing' ),
593
-		),
594
-		$subscription
595
-	);
583
+    // Prepare table columns.
584
+    $columns = apply_filters(
585
+        'getpaid_subscription_item_details_columns',
586
+        array(
587
+            'item_name'    => __( 'Item', 'invoicing' ),
588
+            'price'        => __( 'Price', 'invoicing' ),
589
+            'tax'          => __( 'Tax', 'invoicing' ),
590
+            'discount'     => __( 'Discount', 'invoicing' ),
591
+            //'initial'      => __( 'Initial Amount', 'invoicing' ),
592
+            'recurring'    => __( 'Subtotal', 'invoicing' ),
593
+        ),
594
+        $subscription
595
+    );
596 596
 
597
-	// Prepare the invoices.
597
+    // Prepare the invoices.
598 598
 
599
-	$invoice = $subscription->get_parent_invoice();
599
+    $invoice = $subscription->get_parent_invoice();
600 600
 
601
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
602
-		unset( $columns['tax'] );
603
-	}
601
+    if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
602
+        unset( $columns['tax'] );
603
+    }
604 604
 
605
-	$table_class = 'w-100 bg-white';
605
+    $table_class = 'w-100 bg-white';
606 606
 
607
-	if ( ! is_admin() ) {
608
-		$table_class = 'table table-bordered';
609
-	}
607
+    if ( ! is_admin() ) {
608
+        $table_class = 'table table-bordered';
609
+    }
610 610
 
611
-	?>
611
+    ?>
612 612
 		<div class="m-0" style="overflow: auto;">
613 613
 
614 614
 			<table class="<?php echo $table_class; ?>">
@@ -617,14 +617,14 @@  discard block
 block discarded – undo
617 617
 					<tr>
618 618
 						<?php
619 619
 
620
-							foreach ( $columns as $key => $label ) {
621
-								$key   = esc_attr( $key );
622
-								$label = esc_html( $label );
623
-								$class = 'text-left';
620
+                            foreach ( $columns as $key => $label ) {
621
+                                $key   = esc_attr( $key );
622
+                                $label = esc_html( $label );
623
+                                $class = 'text-left';
624 624
 
625
-								echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
626
-							}
627
-						?>
625
+                                echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
626
+                            }
627
+                        ?>
628 628
 					</tr>
629 629
 				</thead>
630 630
 
@@ -632,106 +632,106 @@  discard block
 block discarded – undo
632 632
 
633 633
 					<?php
634 634
 
635
-						foreach( $subscription_group['items'] as $subscription_group_item ) :
635
+                        foreach( $subscription_group['items'] as $subscription_group_item ) :
636 636
 
637
-							echo '<tr>';
637
+                            echo '<tr>';
638 638
 
639
-								foreach ( array_keys( $columns ) as $key ) {
639
+                                foreach ( array_keys( $columns ) as $key ) {
640 640
 
641
-									$class = 'text-left';
641
+                                    $class = 'text-left';
642 642
 
643
-									echo "<td class='p-2 $class'>";
643
+                                    echo "<td class='p-2 $class'>";
644 644
 
645
-										switch( $key ) {
645
+                                        switch( $key ) {
646 646
 
647
-											case 'item_name':
648
-												$item_name = get_the_title( $subscription_group_item['item_id'] );
649
-												$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
647
+                                            case 'item_name':
648
+                                                $item_name = get_the_title( $subscription_group_item['item_id'] );
649
+                                                $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
650 650
 
651
-												if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
652
-													echo esc_html( $item_name );
653
-												} else {
654
-													printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
655
-												}
651
+                                                if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
652
+                                                    echo esc_html( $item_name );
653
+                                                } else {
654
+                                                    printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
655
+                                                }
656 656
 
657
-												break;
657
+                                                break;
658 658
 
659
-											case 'price':
660
-												echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() );
661
-												break;
659
+                                            case 'price':
660
+                                                echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() );
661
+                                                break;
662 662
 
663
-											case 'tax':
664
-												echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() );
665
-												break;
663
+                                            case 'tax':
664
+                                                echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() );
665
+                                                break;
666 666
 
667
-											case 'discount':
668
-												echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() );
669
-												break;
667
+                                            case 'discount':
668
+                                                echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() );
669
+                                                break;
670 670
 
671
-											case 'initial':
672
-												echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
673
-												break;
671
+                                            case 'initial':
672
+                                                echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
673
+                                                break;
674 674
 
675
-											case 'recurring':
676
-												echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>';
677
-												break;
675
+                                            case 'recurring':
676
+                                                echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>';
677
+                                                break;
678 678
 
679
-										}
679
+                                        }
680 680
 
681
-									echo '</td>';
681
+                                    echo '</td>';
682 682
 
683
-								}
683
+                                }
684 684
 
685
-							echo '</tr>';
685
+                            echo '</tr>';
686 686
 
687
-						endforeach;
687
+                        endforeach;
688 688
 
689
-						foreach( $subscription_group['fees'] as $subscription_group_fee ) :
689
+                        foreach( $subscription_group['fees'] as $subscription_group_fee ) :
690 690
 
691
-							echo '<tr>';
691
+                            echo '<tr>';
692 692
 
693
-								foreach ( array_keys( $columns ) as $key ) {
693
+                                foreach ( array_keys( $columns ) as $key ) {
694 694
 
695
-									$class = 'text-left';
695
+                                    $class = 'text-left';
696 696
 
697
-									echo "<td class='p-2 $class'>";
697
+                                    echo "<td class='p-2 $class'>";
698 698
 
699
-										switch( $key ) {
699
+                                        switch( $key ) {
700 700
 
701
-											case 'item_name':
702
-												echo esc_html( $subscription_group_fee['name'] );
703
-												break;
701
+                                            case 'item_name':
702
+                                                echo esc_html( $subscription_group_fee['name'] );
703
+                                                break;
704 704
 
705
-											case 'price':
706
-												echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
707
-												break;
705
+                                            case 'price':
706
+                                                echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
707
+                                                break;
708 708
 
709
-											case 'tax':
710
-												echo "&mdash;";
711
-												break;
709
+                                            case 'tax':
710
+                                                echo "&mdash;";
711
+                                                break;
712 712
 
713
-											case 'discount':
714
-												echo "&mdash;";
715
-												break;
713
+                                            case 'discount':
714
+                                                echo "&mdash;";
715
+                                                break;
716 716
 
717
-											case 'initial':
718
-												echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
719
-												break;
717
+                                            case 'initial':
718
+                                                echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
719
+                                                break;
720 720
 
721
-											case 'recurring':
722
-												echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>';
723
-												break;
721
+                                            case 'recurring':
722
+                                                echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>';
723
+                                                break;
724 724
 
725
-										}
725
+                                        }
726 726
 
727
-									echo '</td>';
727
+                                    echo '</td>';
728 728
 
729
-								}
729
+                                }
730 730
 
731
-							echo '</tr>';
731
+                            echo '</tr>';
732 732
 
733
-						endforeach;
734
-					?>
733
+                        endforeach;
734
+                    ?>
735 735
 
736 736
 				</tbody>
737 737
 
@@ -750,38 +750,38 @@  discard block
 block discarded – undo
750 750
  */
751 751
 function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
752 752
 
753
-	// Fetch the subscription groups.
754
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
755
-
756
-	if ( empty( $subscription_groups ) ) {
757
-		return;
758
-	}
759
-
760
-	// Prepare table columns.
761
-	$columns = apply_filters(
762
-		'getpaid_subscription_related_subscriptions_columns',
763
-		array(
764
-			'subscription'      => __( 'Subscription', 'invoicing' ),
765
-			'start_date'        => __( 'Start Date', 'invoicing' ),
766
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
767
-			'renewals'          => __( 'Payments', 'invoicing' ),
768
-			'item'              => __( 'Items', 'invoicing' ),
769
-			'status'            => __( 'Status', 'invoicing' ),
770
-		),
771
-		$subscription
772
-	);
773
-
774
-	if ( $subscription->get_status() == 'pending' ) {
775
-		unset( $columns['start_date'], $columns['renewal_date'] );
776
-	}
777
-
778
-	$table_class = 'w-100 bg-white';
779
-
780
-	if ( ! is_admin() ) {
781
-		$table_class = 'table table-bordered';
782
-	}
783
-
784
-	?>
753
+    // Fetch the subscription groups.
754
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
755
+
756
+    if ( empty( $subscription_groups ) ) {
757
+        return;
758
+    }
759
+
760
+    // Prepare table columns.
761
+    $columns = apply_filters(
762
+        'getpaid_subscription_related_subscriptions_columns',
763
+        array(
764
+            'subscription'      => __( 'Subscription', 'invoicing' ),
765
+            'start_date'        => __( 'Start Date', 'invoicing' ),
766
+            'renewal_date'      => __( 'Next Payment', 'invoicing' ),
767
+            'renewals'          => __( 'Payments', 'invoicing' ),
768
+            'item'              => __( 'Items', 'invoicing' ),
769
+            'status'            => __( 'Status', 'invoicing' ),
770
+        ),
771
+        $subscription
772
+    );
773
+
774
+    if ( $subscription->get_status() == 'pending' ) {
775
+        unset( $columns['start_date'], $columns['renewal_date'] );
776
+    }
777
+
778
+    $table_class = 'w-100 bg-white';
779
+
780
+    if ( ! is_admin() ) {
781
+        $table_class = 'table table-bordered';
782
+    }
783
+
784
+    ?>
785 785
 		<div class="m-0" style="overflow: auto;">
786 786
 
787 787
 			<table class="<?php echo $table_class; ?>">
@@ -790,14 +790,14 @@  discard block
 block discarded – undo
790 790
 					<tr>
791 791
 						<?php
792 792
 
793
-							foreach ( $columns as $key => $label ) {
794
-								$key   = esc_attr( $key );
795
-								$label = esc_html( $label );
796
-								$class = 'text-left';
793
+                            foreach ( $columns as $key => $label ) {
794
+                                $key   = esc_attr( $key );
795
+                                $label = esc_html( $label );
796
+                                $class = 'text-left';
797 797
 
798
-								echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
799
-							}
800
-						?>
798
+                                echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
799
+                            }
800
+                        ?>
801 801
 					</tr>
802 802
 				</thead>
803 803
 
@@ -805,74 +805,74 @@  discard block
 block discarded – undo
805 805
 
806 806
 					<?php
807 807
 
808
-						foreach( $subscription_groups as $subscription_group ) :
808
+                        foreach( $subscription_groups as $subscription_group ) :
809 809
 
810
-							// Do not list current subscription.
811
-							if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
812
-								continue;
813
-							}
810
+                            // Do not list current subscription.
811
+                            if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
812
+                                continue;
813
+                            }
814 814
 
815
-							// Ensure the subscription exists.
816
-							$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
815
+                            // Ensure the subscription exists.
816
+                            $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
817 817
 
818
-							if ( ! $_suscription->exists() ) {
819
-								continue;
820
-							}
818
+                            if ( ! $_suscription->exists() ) {
819
+                                continue;
820
+                            }
821 821
 
822
-							echo '<tr>';
822
+                            echo '<tr>';
823 823
 
824
-								foreach ( array_keys( $columns ) as $key ) {
824
+                                foreach ( array_keys( $columns ) as $key ) {
825 825
 
826
-									$class = 'text-left';
826
+                                    $class = 'text-left';
827 827
 
828
-									echo "<td class='p-2 $class'>";
828
+                                    echo "<td class='p-2 $class'>";
829 829
 
830
-										switch( $key ) {
830
+                                        switch( $key ) {
831 831
 
832
-											case 'status':
833
-												echo $_suscription->get_status_label_html();
834
-												break;
832
+                                            case 'status':
833
+                                                echo $_suscription->get_status_label_html();
834
+                                                break;
835 835
 
836
-											case 'item':
837
-												$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
838
-												echo implode( ' | ', $markup );
839
-												break;
836
+                                            case 'item':
837
+                                                $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
838
+                                                echo implode( ' | ', $markup );
839
+                                                break;
840 840
 
841
-											case 'renewals':
842
-												$max_bills = $_suscription->get_bill_times();
843
-												echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
844
-												break;
841
+                                            case 'renewals':
842
+                                                $max_bills = $_suscription->get_bill_times();
843
+                                                echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
844
+                                                break;
845 845
 
846
-											case 'renewal_date':
847
-												echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "&mdash;";
848
-												break;
846
+                                            case 'renewal_date':
847
+                                                echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "&mdash;";
848
+                                                break;
849 849
 
850
-											case 'start_date':
851
-												echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value( $_suscription->get_date_created() );
852
-												break;
850
+                                            case 'start_date':
851
+                                                echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value( $_suscription->get_date_created() );
852
+                                                break;
853 853
 
854
-											case 'subscription':
855
-												$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
856
-												printf(
857
-													'%1$s#%2$s%3$s',
858
-													'<a href="' . esc_url( $url ) . '">',
859
-													'<strong>' . intval( $_suscription->get_id() ) . '</strong>',
860
-													'</a>'
861
-												);
854
+                                            case 'subscription':
855
+                                                $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
856
+                                                printf(
857
+                                                    '%1$s#%2$s%3$s',
858
+                                                    '<a href="' . esc_url( $url ) . '">',
859
+                                                    '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
860
+                                                    '</a>'
861
+                                                );
862 862
 
863
-												echo WPInv_Subscriptions_List_Table::column_amount( $_suscription );
864
-												break;
863
+                                                echo WPInv_Subscriptions_List_Table::column_amount( $_suscription );
864
+                                                break;
865 865
 
866
-										}
866
+                                        }
867 867
 
868
-									echo '</td>';
868
+                                    echo '</td>';
869 869
 
870
-								}
870
+                                }
871 871
 
872
-							echo '</tr>';
872
+                            echo '</tr>';
873 873
 
874
-						endforeach;
875
-					?>
874
+                        endforeach;
875
+                    ?>
876 876
 
877 877
 				</tbody>
878 878
 
Please login to merge, or discard this patch.
Spacing   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains functions that display the subscriptions admin page.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Render the Subscriptions page
@@ -17,22 +17,22 @@  discard block
 block discarded – undo
17 17
 	?>
18 18
 
19 19
 	<div class="wrap">
20
-		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
20
+		<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
21 21
 		<div class="bsui">
22 22
 
23 23
 			<?php
24 24
 
25 25
 				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
26
+				if (!wpinv_current_user_can_manage_invoicing()) {
27 27
 
28 28
 					echo aui()->alert(
29 29
 						array(
30 30
 							'type'    => 'danger',
31
-							'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
31
+							'content' => __('You are not permitted to view this page.', 'invoicing'),
32 32
 						)
33 33
 					);
34 34
 
35
-				} else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
35
+				} else if (!empty($_GET['id']) && is_numeric($_GET['id'])) {
36 36
 
37 37
 					// Display a single subscription.
38 38
 					wpinv_recurring_subscription_details();
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	<?php $subscribers_table->views(); ?>
67 67
 	<form id="subscribers-filter" class="bsui" method="get">
68 68
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
69
-		<?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?>
69
+		<?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?>
70 70
 		<?php $subscribers_table->display(); ?>
71 71
 	</form>
72 72
 	<?php
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
 function wpinv_recurring_subscription_details() {
83 83
 
84 84
 	// Fetch the subscription.
85
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
86
-	if ( ! $sub->exists() ) {
85
+	$sub = new WPInv_Subscription((int) $_GET['id']);
86
+	if (!$sub->exists()) {
87 87
 
88 88
 		echo aui()->alert(
89 89
 			array(
90 90
 				'type'    => 'danger',
91
-				'content' => __( 'Subscription not found.', 'invoicing' ),
91
+				'content' => __('Subscription not found.', 'invoicing'),
92 92
 			)
93 93
 		);
94 94
 
@@ -96,45 +96,45 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 
98 98
 	// Use metaboxes to display the subscription details.
99
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
100
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
99
+	add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high');
100
+	add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side');
101 101
 
102 102
 	$subscription_id     = $sub->get_id();
103
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
104
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
103
+	$subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id());
104
+	$subscription_group  = wp_list_filter($subscription_groups, compact('subscription_id'));
105 105
 
106
-	if ( 1 < count( $subscription_groups ) ) {
107
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
106
+	if (1 < count($subscription_groups)) {
107
+		add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced');
108 108
 	}
109 109
 
110
-	if ( ! empty( $subscription_group ) ) {
111
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
110
+	if (!empty($subscription_group)) {
111
+		add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low');
112 112
 	}
113 113
 
114
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
114
+	add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced');
115 115
 
116
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
116
+	do_action('getpaid_admin_single_subscription_register_metabox', $sub);
117 117
 
118 118
 	?>
119 119
 
120
-		<form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>">
120
+		<form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>">
121 121
 
122
-			<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
123
-			<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
124
-			<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
122
+			<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
123
+			<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
124
+			<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
125 125
 			<input type="hidden" name="getpaid-admin-action" value="update_single_subscription" />
126
-			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" />
126
+			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" />
127 127
 
128 128
 			<div id="poststuff">
129 129
 				<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
130 130
 
131 131
 					<div id="postbox-container-1" class="postbox-container">
132
-						<?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?>
132
+						<?php do_meta_boxes(get_current_screen(), 'side', $sub); ?>
133 133
 					</div>
134 134
 
135 135
 					<div id="postbox-container-2" class="postbox-container">
136
-						<?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?>
137
-						<?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?>
136
+						<?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?>
137
+						<?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?>
138 138
 					</div>
139 139
 
140 140
 				</div>
@@ -153,44 +153,44 @@  discard block
 block discarded – undo
153 153
  *
154 154
  * @param WPInv_Subscription $sub
155 155
  */
156
-function getpaid_admin_subscription_details_metabox( $sub ) {
156
+function getpaid_admin_subscription_details_metabox($sub) {
157 157
 
158 158
 	// Subscription items.
159
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
160
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
159
+	$subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id());
160
+	$items_count        = empty($subscription_group) ? 1 : count($subscription_group['items']);
161 161
 
162 162
 	// Prepare subscription detail columns.
163 163
 	$fields = apply_filters(
164 164
 		'getpaid_subscription_admin_page_fields',
165 165
 		array(
166
-			'subscription'   => __( 'Subscription', 'invoicing' ),
167
-			'customer'       => __( 'Customer', 'invoicing' ),
168
-			'amount'         => __( 'Amount', 'invoicing' ),
169
-			'start_date'     => __( 'Start Date', 'invoicing' ),
170
-			'renews_on'      => __( 'Next Payment', 'invoicing' ),
171
-			'renewals'       => __( 'Payments', 'invoicing' ),
172
-			'item'           => _n( 'Item', 'Items', $items_count,  'invoicing' ),
173
-			'gateway'        => __( 'Payment Method', 'invoicing' ),
174
-			'profile_id'     => __( 'Profile ID', 'invoicing' ),
175
-			'status'         => __( 'Status', 'invoicing' ),
166
+			'subscription'   => __('Subscription', 'invoicing'),
167
+			'customer'       => __('Customer', 'invoicing'),
168
+			'amount'         => __('Amount', 'invoicing'),
169
+			'start_date'     => __('Start Date', 'invoicing'),
170
+			'renews_on'      => __('Next Payment', 'invoicing'),
171
+			'renewals'       => __('Payments', 'invoicing'),
172
+			'item'           => _n('Item', 'Items', $items_count, 'invoicing'),
173
+			'gateway'        => __('Payment Method', 'invoicing'),
174
+			'profile_id'     => __('Profile ID', 'invoicing'),
175
+			'status'         => __('Status', 'invoicing'),
176 176
 		)
177 177
 	);
178 178
 
179
-	if ( ! $sub->is_active() ) {
179
+	if (!$sub->is_active()) {
180 180
 
181
-		if ( isset( $fields['renews_on'] ) ) {
182
-			unset( $fields['renews_on'] );
181
+		if (isset($fields['renews_on'])) {
182
+			unset($fields['renews_on']);
183 183
 		}
184 184
 
185
-		if ( isset( $fields['gateway'] ) ) {
186
-			unset( $fields['gateway'] );
185
+		if (isset($fields['gateway'])) {
186
+			unset($fields['gateway']);
187 187
 		}
188 188
 
189 189
 	}
190 190
 
191 191
 	$profile_id = $sub->get_profile_id();
192
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
193
-		unset( $fields['profile_id'] );
192
+	if (empty($profile_id) && isset($fields['profile_id'])) {
193
+		unset($fields['profile_id']);
194 194
 	}
195 195
 
196 196
 	?>
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
 		<table class="table table-borderless" style="font-size: 14px;">
199 199
 			<tbody>
200 200
 
201
-				<?php foreach ( $fields as $key => $label ) : ?>
201
+				<?php foreach ($fields as $key => $label) : ?>
202 202
 
203
-					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>">
203
+					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>">
204 204
 
205 205
 						<th class="w-25" style="font-weight: 500;">
206
-							<?php echo esc_html( $label ); ?>
206
+							<?php echo esc_html($label); ?>
207 207
 						</th>
208 208
 
209 209
 						<td class="w-75 text-muted">
210
-							<?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?>
210
+							<?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?>
211 211
 						</td>
212 212
 
213 213
 					</tr>
@@ -225,135 +225,135 @@  discard block
 block discarded – undo
225 225
  *
226 226
  * @param WPInv_Subscription $subscription
227 227
  */
228
-function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
228
+function getpaid_admin_subscription_metabox_display_customer($subscription) {
229 229
 
230
-	$username = __( '(Missing User)', 'invoicing' );
230
+	$username = __('(Missing User)', 'invoicing');
231 231
 
232
-	$user = get_userdata( $subscription->get_customer_id() );
233
-	if ( $user ) {
232
+	$user = get_userdata($subscription->get_customer_id());
233
+	if ($user) {
234 234
 
235 235
 		$username = sprintf(
236 236
 			'<a href="user-edit.php?user_id=%s">%s</a>',
237
-			absint( $user->ID ),
238
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
237
+			absint($user->ID),
238
+			!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
239 239
 		);
240 240
 
241 241
 	}
242 242
 
243 243
 	echo  $username;
244 244
 }
245
-add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
245
+add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer');
246 246
 
247 247
 /**
248 248
  * Displays the subscription amount.
249 249
  *
250 250
  * @param WPInv_Subscription $subscription
251 251
  */
252
-function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
253
-	$amount    = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) );
252
+function getpaid_admin_subscription_metabox_display_amount($subscription) {
253
+	$amount = wp_kses_post(getpaid_get_formatted_subscription_amount($subscription));
254 254
 	echo "<span>$amount</span>";
255 255
 }
256
-add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
256
+add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount');
257 257
 
258 258
 /**
259 259
  * Displays the subscription id.
260 260
  *
261 261
  * @param WPInv_Subscription $subscription
262 262
  */
263
-function getpaid_admin_subscription_metabox_display_id( $subscription ) {
263
+function getpaid_admin_subscription_metabox_display_id($subscription) {
264 264
 
265 265
 	printf(
266 266
 		'<a href="%s">#%s</a>',
267
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
268
-		absint( $subscription->get_id() )
267
+		esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))),
268
+		absint($subscription->get_id())
269 269
 	);
270 270
 
271 271
 }
272
-add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
272
+add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id');
273 273
 
274 274
 /**
275 275
  * Displays the subscription renewal date.
276 276
  *
277 277
  * @param WPInv_Subscription $subscription
278 278
  */
279
-function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
280
-	echo getpaid_format_date_value( $subscription->get_date_created() );
279
+function getpaid_admin_subscription_metabox_display_start_date($subscription) {
280
+	echo getpaid_format_date_value($subscription->get_date_created());
281 281
 }
282
-add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
282
+add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date');
283 283
 
284 284
 /**
285 285
  * Displays the subscription renewal date.
286 286
  *
287 287
  * @param WPInv_Subscription $subscription
288 288
  */
289
-function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
290
-	echo getpaid_format_date_value( $subscription->get_expiration() );
289
+function getpaid_admin_subscription_metabox_display_renews_on($subscription) {
290
+	echo getpaid_format_date_value($subscription->get_expiration());
291 291
 }
292
-add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
292
+add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on');
293 293
 
294 294
 /**
295 295
  * Displays the subscription renewal count.
296 296
  *
297 297
  * @param WPInv_Subscription $subscription
298 298
  */
299
-function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
299
+function getpaid_admin_subscription_metabox_display_renewals($subscription) {
300 300
 	$max_bills = $subscription->get_bill_times();
301
-	echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
301
+	echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
302 302
 }
303
-add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
303
+add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals');
304 304
 /**
305 305
  * Displays the subscription item.
306 306
  *
307 307
  * @param WPInv_Subscription $subscription
308 308
  * @param false|array $subscription_group
309 309
  */
310
-function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
310
+function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) {
311 311
 
312
-	if ( empty( $subscription_group ) ) {
313
-		echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() );
312
+	if (empty($subscription_group)) {
313
+		echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id());
314 314
 		return;
315 315
 	}
316 316
 
317
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
318
-	echo implode( ' | ', $markup );
317
+	$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
318
+	echo implode(' | ', $markup);
319 319
 
320 320
 }
321
-add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
321
+add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2);
322 322
 
323 323
 /**
324 324
  * Displays the subscription gateway.
325 325
  *
326 326
  * @param WPInv_Subscription $subscription
327 327
  */
328
-function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
328
+function getpaid_admin_subscription_metabox_display_gateway($subscription) {
329 329
 
330 330
 	$gateway = $subscription->get_gateway();
331 331
 
332
-	if ( ! empty( $gateway ) ) {
333
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
332
+	if (!empty($gateway)) {
333
+		echo esc_html(wpinv_get_gateway_admin_label($gateway));
334 334
 	} else {
335 335
 		echo "&mdash;";
336 336
 	}
337 337
 
338 338
 }
339
-add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
339
+add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway');
340 340
 
341 341
 /**
342 342
  * Displays the subscription status.
343 343
  *
344 344
  * @param WPInv_Subscription $subscription
345 345
  */
346
-function getpaid_admin_subscription_metabox_display_status( $subscription ) {
346
+function getpaid_admin_subscription_metabox_display_status($subscription) {
347 347
 	echo $subscription->get_status_label_html();
348 348
 }
349
-add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
349
+add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status');
350 350
 
351 351
 /**
352 352
  * Displays the subscription profile id.
353 353
  *
354 354
  * @param WPInv_Subscription $subscription
355 355
  */
356
-function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
356
+function getpaid_admin_subscription_metabox_display_profile_id($subscription) {
357 357
 
358 358
 	$profile_id = $subscription->get_profile_id();
359 359
 
@@ -362,32 +362,32 @@  discard block
 block discarded – undo
362 362
 			'type'        => 'text',
363 363
 			'id'          => 'wpinv_subscription_profile_id',
364 364
 			'name'        => 'wpinv_subscription_profile_id',
365
-			'label'       => __( 'Profile Id', 'invoicing' ),
365
+			'label'       => __('Profile Id', 'invoicing'),
366 366
 			'label_type'  => 'hidden',
367
-			'placeholder' => __( 'Profile Id', 'invoicing' ),
368
-			'value'       => esc_attr( $profile_id ),
367
+			'placeholder' => __('Profile Id', 'invoicing'),
368
+			'value'       => esc_attr($profile_id),
369 369
 			'input_group_right' => '',
370 370
 			'no_wrap'     => true,
371 371
 		)
372 372
 	);
373 373
 
374
-	echo str_ireplace( 'form-control', 'regular-text', $input );
374
+	echo str_ireplace('form-control', 'regular-text', $input);
375 375
 
376
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
377
-	if ( ! empty( $url ) ) {
378
-		$url = esc_url_raw( $url );
379
-		echo '&nbsp;<a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
376
+	$url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription);
377
+	if (!empty($url)) {
378
+		$url = esc_url_raw($url);
379
+		echo '&nbsp;<a href="' . $url . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
380 380
 	}
381 381
 
382 382
 }
383
-add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
383
+add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id');
384 384
 
385 385
 /**
386 386
  * Displays the subscriptions update metabox.
387 387
  *
388 388
  * @param WPInv_Subscription $subscription
389 389
  */
390
-function getpaid_admin_subscription_update_metabox( $subscription ) {
390
+function getpaid_admin_subscription_update_metabox($subscription) {
391 391
 
392 392
 	?>
393 393
 	<div class="mt-3">
@@ -400,10 +400,10 @@  discard block
 block discarded – undo
400 400
 					'id'               => 'subscription_status_update_select',
401 401
 					'required'         => true,
402 402
 					'no_wrap'          => false,
403
-					'label'            => __( 'Subscription Status', 'invoicing' ),
404
-					'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
403
+					'label'            => __('Subscription Status', 'invoicing'),
404
+					'help_text'        => __('Updating the status will trigger related actions and hooks', 'invoicing'),
405 405
 					'select2'          => true,
406
-					'value'            => $subscription->get_status( 'edit' ),
406
+					'value'            => $subscription->get_status('edit'),
407 407
 				)
408 408
 			);
409 409
 		?>
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
412 412
 
413 413
 		<?php
414
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
414
+			submit_button(__('Update', 'invoicing'), 'primary', 'submit', false);
415 415
 
416
-			$url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
417
-			$anchor = __( 'Renew Subscription', 'invoicing' );
418
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
416
+			$url    = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'));
417
+			$anchor = __('Renew Subscription', 'invoicing');
418
+			$title  = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing');
419 419
 
420
-			if ( $subscription->is_active() ) {
420
+			if ($subscription->is_active()) {
421 421
 				echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
422 422
 			}
423 423
 
@@ -430,31 +430,31 @@  discard block
 block discarded – undo
430 430
  * @param WPInv_Subscription $subscription
431 431
  * @param bool $strict Whether or not to skip invoices of sibling subscriptions
432 432
  */
433
-function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
433
+function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) {
434 434
 
435 435
 	$columns = apply_filters(
436 436
 		'getpaid_subscription_related_invoices_columns',
437 437
 		array(
438
-			'invoice'      => __( 'Invoice', 'invoicing' ),
439
-			'relationship' => __( 'Relationship', 'invoicing' ),
440
-			'date'         => __( 'Date', 'invoicing' ),
441
-			'status'       => __( 'Status', 'invoicing' ),
442
-			'total'        => __( 'Total', 'invoicing' ),
438
+			'invoice'      => __('Invoice', 'invoicing'),
439
+			'relationship' => __('Relationship', 'invoicing'),
440
+			'date'         => __('Date', 'invoicing'),
441
+			'status'       => __('Status', 'invoicing'),
442
+			'total'        => __('Total', 'invoicing'),
443 443
 		),
444 444
 		$subscription
445 445
 	);
446 446
 
447 447
 	// Prepare the invoices.
448
-	$payments = $subscription->get_child_payments( ! is_admin() );
448
+	$payments = $subscription->get_child_payments(!is_admin());
449 449
 	$parent   = $subscription->get_parent_invoice();
450 450
 
451
-	if ( $parent->exists() ) {
452
-		$payments = array_merge( array( $parent ), $payments );
451
+	if ($parent->exists()) {
452
+		$payments = array_merge(array($parent), $payments);
453 453
 	}
454 454
 
455 455
 	$table_class = 'w-100 bg-white';
456 456
 
457
-	if ( ! is_admin() ) {
457
+	if (!is_admin()) {
458 458
 		$table_class = 'table table-bordered';
459 459
 	}
460 460
 
@@ -466,9 +466,9 @@  discard block
 block discarded – undo
466 466
 				<thead>
467 467
 					<tr>
468 468
 						<?php
469
-							foreach ( $columns as $key => $label ) {
470
-								$key   = esc_attr( $key );
471
-								$label = esc_html( $label );
469
+							foreach ($columns as $key => $label) {
470
+								$key   = esc_attr($key);
471
+								$label = esc_html($label);
472 472
 								$class = 'text-left';
473 473
 
474 474
 								echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
@@ -479,57 +479,57 @@  discard block
 block discarded – undo
479 479
 
480 480
 				<tbody>
481 481
 
482
-					<?php if ( empty( $payments ) ) : ?>
482
+					<?php if (empty($payments)) : ?>
483 483
 						<tr>
484 484
 							<td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted">
485
-								<?php _e( 'This subscription has no invoices.', 'invoicing' ); ?>
485
+								<?php _e('This subscription has no invoices.', 'invoicing'); ?>
486 486
 							</td>
487 487
 						</tr>
488 488
 					<?php endif; ?>
489 489
 
490 490
 					<?php
491 491
 
492
-						foreach( $payments as $payment ) :
492
+						foreach ($payments as $payment) :
493 493
 
494 494
 							// Ensure that we have an invoice.
495
-							$payment = new WPInv_Invoice( $payment );
495
+							$payment = new WPInv_Invoice($payment);
496 496
 
497 497
 							// Abort if the invoice is invalid...
498
-							if ( ! $payment->exists() ) {
498
+							if (!$payment->exists()) {
499 499
 								continue;
500 500
 							}
501 501
 
502 502
 							// ... or belongs to a different subscription.
503
-							if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
503
+							if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) {
504 504
 								continue;
505 505
 							}
506 506
 
507 507
 							echo '<tr>';
508 508
 
509
-								foreach ( array_keys( $columns ) as $key ) {
509
+								foreach (array_keys($columns) as $key) {
510 510
 
511 511
 									$class = 'text-left';
512 512
 
513 513
 									echo "<td class='p-2 $class'>";
514 514
 
515
-										switch( $key ) {
515
+										switch ($key) {
516 516
 
517 517
 											case 'total':
518
-												echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>';
518
+												echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>';
519 519
 												break;
520 520
 
521 521
 											case 'relationship':
522
-												echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
522
+												echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing');
523 523
 												break;
524 524
 
525 525
 											case 'date':
526
-												echo getpaid_format_date_value( $payment->get_date_created() );
526
+												echo getpaid_format_date_value($payment->get_date_created());
527 527
 												break;
528 528
 
529 529
 											case 'status':
530 530
 
531 531
 												$status = $payment->get_status_nicename();
532
-												if ( is_admin() ) {
532
+												if (is_admin()) {
533 533
 													$status = $payment->get_status_label_html();
534 534
 												}
535 535
 
@@ -537,13 +537,13 @@  discard block
 block discarded – undo
537 537
 												break;
538 538
 
539 539
 											case 'invoice':
540
-												$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
540
+												$link = esc_url(get_edit_post_link($payment->get_id()));
541 541
 
542
-												if ( ! is_admin() ) {
543
-													$link = esc_url( $payment->get_view_url() );
542
+												if (!is_admin()) {
543
+													$link = esc_url($payment->get_view_url());
544 544
 												}
545 545
 
546
-												$invoice = esc_html( $payment->get_number() );
546
+												$invoice = esc_html($payment->get_number());
547 547
 												echo "<a href='$link'>$invoice</a>";
548 548
 												break;
549 549
 										}
@@ -571,12 +571,12 @@  discard block
 block discarded – undo
571 571
  *
572 572
  * @param WPInv_Subscription $subscription
573 573
  */
574
-function getpaid_admin_subscription_item_details_metabox( $subscription ) {
574
+function getpaid_admin_subscription_item_details_metabox($subscription) {
575 575
 
576 576
 	// Fetch the subscription group.
577
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
577
+	$subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id());
578 578
 
579
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
579
+	if (empty($subscription_group) || empty($subscription_group['items'])) {
580 580
 		return;
581 581
 	}
582 582
 
@@ -584,12 +584,12 @@  discard block
 block discarded – undo
584 584
 	$columns = apply_filters(
585 585
 		'getpaid_subscription_item_details_columns',
586 586
 		array(
587
-			'item_name'    => __( 'Item', 'invoicing' ),
588
-			'price'        => __( 'Price', 'invoicing' ),
589
-			'tax'          => __( 'Tax', 'invoicing' ),
590
-			'discount'     => __( 'Discount', 'invoicing' ),
587
+			'item_name'    => __('Item', 'invoicing'),
588
+			'price'        => __('Price', 'invoicing'),
589
+			'tax'          => __('Tax', 'invoicing'),
590
+			'discount'     => __('Discount', 'invoicing'),
591 591
 			//'initial'      => __( 'Initial Amount', 'invoicing' ),
592
-			'recurring'    => __( 'Subtotal', 'invoicing' ),
592
+			'recurring'    => __('Subtotal', 'invoicing'),
593 593
 		),
594 594
 		$subscription
595 595
 	);
@@ -598,13 +598,13 @@  discard block
 block discarded – undo
598 598
 
599 599
 	$invoice = $subscription->get_parent_invoice();
600 600
 
601
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
602
-		unset( $columns['tax'] );
601
+	if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) {
602
+		unset($columns['tax']);
603 603
 	}
604 604
 
605 605
 	$table_class = 'w-100 bg-white';
606 606
 
607
-	if ( ! is_admin() ) {
607
+	if (!is_admin()) {
608 608
 		$table_class = 'table table-bordered';
609 609
 	}
610 610
 
@@ -617,9 +617,9 @@  discard block
 block discarded – undo
617 617
 					<tr>
618 618
 						<?php
619 619
 
620
-							foreach ( $columns as $key => $label ) {
621
-								$key   = esc_attr( $key );
622
-								$label = esc_html( $label );
620
+							foreach ($columns as $key => $label) {
621
+								$key   = esc_attr($key);
622
+								$label = esc_html($label);
623 623
 								$class = 'text-left';
624 624
 
625 625
 								echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
@@ -632,48 +632,48 @@  discard block
 block discarded – undo
632 632
 
633 633
 					<?php
634 634
 
635
-						foreach( $subscription_group['items'] as $subscription_group_item ) :
635
+						foreach ($subscription_group['items'] as $subscription_group_item) :
636 636
 
637 637
 							echo '<tr>';
638 638
 
639
-								foreach ( array_keys( $columns ) as $key ) {
639
+								foreach (array_keys($columns) as $key) {
640 640
 
641 641
 									$class = 'text-left';
642 642
 
643 643
 									echo "<td class='p-2 $class'>";
644 644
 
645
-										switch( $key ) {
645
+										switch ($key) {
646 646
 
647 647
 											case 'item_name':
648
-												$item_name = get_the_title( $subscription_group_item['item_id'] );
649
-												$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
648
+												$item_name = get_the_title($subscription_group_item['item_id']);
649
+												$item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name;
650 650
 
651
-												if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
652
-													echo esc_html( $item_name );
651
+												if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) {
652
+													echo esc_html($item_name);
653 653
 												} else {
654
-													printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
654
+													printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']);
655 655
 												}
656 656
 
657 657
 												break;
658 658
 
659 659
 											case 'price':
660
-												echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() );
660
+												echo wpinv_price($subscription_group_item['item_price'], $invoice->get_currency());
661 661
 												break;
662 662
 
663 663
 											case 'tax':
664
-												echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() );
664
+												echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency());
665 665
 												break;
666 666
 
667 667
 											case 'discount':
668
-												echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() );
668
+												echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency());
669 669
 												break;
670 670
 
671 671
 											case 'initial':
672
-												echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
672
+												echo wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency());
673 673
 												break;
674 674
 
675 675
 											case 'recurring':
676
-												echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>';
676
+												echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>';
677 677
 												break;
678 678
 
679 679
 										}
@@ -686,24 +686,24 @@  discard block
 block discarded – undo
686 686
 
687 687
 						endforeach;
688 688
 
689
-						foreach( $subscription_group['fees'] as $subscription_group_fee ) :
689
+						foreach ($subscription_group['fees'] as $subscription_group_fee) :
690 690
 
691 691
 							echo '<tr>';
692 692
 
693
-								foreach ( array_keys( $columns ) as $key ) {
693
+								foreach (array_keys($columns) as $key) {
694 694
 
695 695
 									$class = 'text-left';
696 696
 
697 697
 									echo "<td class='p-2 $class'>";
698 698
 
699
-										switch( $key ) {
699
+										switch ($key) {
700 700
 
701 701
 											case 'item_name':
702
-												echo esc_html( $subscription_group_fee['name'] );
702
+												echo esc_html($subscription_group_fee['name']);
703 703
 												break;
704 704
 
705 705
 											case 'price':
706
-												echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
706
+												echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
707 707
 												break;
708 708
 
709 709
 											case 'tax':
@@ -715,11 +715,11 @@  discard block
 block discarded – undo
715 715
 												break;
716 716
 
717 717
 											case 'initial':
718
-												echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
718
+												echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
719 719
 												break;
720 720
 
721 721
 											case 'recurring':
722
-												echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>';
722
+												echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>';
723 723
 												break;
724 724
 
725 725
 										}
@@ -748,12 +748,12 @@  discard block
 block discarded – undo
748 748
  * @param WPInv_Subscription $subscription
749 749
  * @param bool $skip_current
750 750
  */
751
-function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
751
+function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) {
752 752
 
753 753
 	// Fetch the subscription groups.
754
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
754
+	$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id());
755 755
 
756
-	if ( empty( $subscription_groups ) ) {
756
+	if (empty($subscription_groups)) {
757 757
 		return;
758 758
 	}
759 759
 
@@ -761,23 +761,23 @@  discard block
 block discarded – undo
761 761
 	$columns = apply_filters(
762 762
 		'getpaid_subscription_related_subscriptions_columns',
763 763
 		array(
764
-			'subscription'      => __( 'Subscription', 'invoicing' ),
765
-			'start_date'        => __( 'Start Date', 'invoicing' ),
766
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
767
-			'renewals'          => __( 'Payments', 'invoicing' ),
768
-			'item'              => __( 'Items', 'invoicing' ),
769
-			'status'            => __( 'Status', 'invoicing' ),
764
+			'subscription'      => __('Subscription', 'invoicing'),
765
+			'start_date'        => __('Start Date', 'invoicing'),
766
+			'renewal_date'      => __('Next Payment', 'invoicing'),
767
+			'renewals'          => __('Payments', 'invoicing'),
768
+			'item'              => __('Items', 'invoicing'),
769
+			'status'            => __('Status', 'invoicing'),
770 770
 		),
771 771
 		$subscription
772 772
 	);
773 773
 
774
-	if ( $subscription->get_status() == 'pending' ) {
775
-		unset( $columns['start_date'], $columns['renewal_date'] );
774
+	if ($subscription->get_status() == 'pending') {
775
+		unset($columns['start_date'], $columns['renewal_date']);
776 776
 	}
777 777
 
778 778
 	$table_class = 'w-100 bg-white';
779 779
 
780
-	if ( ! is_admin() ) {
780
+	if (!is_admin()) {
781 781
 		$table_class = 'table table-bordered';
782 782
 	}
783 783
 
@@ -790,9 +790,9 @@  discard block
 block discarded – undo
790 790
 					<tr>
791 791
 						<?php
792 792
 
793
-							foreach ( $columns as $key => $label ) {
794
-								$key   = esc_attr( $key );
795
-								$label = esc_html( $label );
793
+							foreach ($columns as $key => $label) {
794
+								$key   = esc_attr($key);
795
+								$label = esc_html($label);
796 796
 								$class = 'text-left';
797 797
 
798 798
 								echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
@@ -805,62 +805,62 @@  discard block
 block discarded – undo
805 805
 
806 806
 					<?php
807 807
 
808
-						foreach( $subscription_groups as $subscription_group ) :
808
+						foreach ($subscription_groups as $subscription_group) :
809 809
 
810 810
 							// Do not list current subscription.
811
-							if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
811
+							if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) {
812 812
 								continue;
813 813
 							}
814 814
 
815 815
 							// Ensure the subscription exists.
816
-							$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
816
+							$_suscription = new WPInv_Subscription($subscription_group['subscription_id']);
817 817
 
818
-							if ( ! $_suscription->exists() ) {
818
+							if (!$_suscription->exists()) {
819 819
 								continue;
820 820
 							}
821 821
 
822 822
 							echo '<tr>';
823 823
 
824
-								foreach ( array_keys( $columns ) as $key ) {
824
+								foreach (array_keys($columns) as $key) {
825 825
 
826 826
 									$class = 'text-left';
827 827
 
828 828
 									echo "<td class='p-2 $class'>";
829 829
 
830
-										switch( $key ) {
830
+										switch ($key) {
831 831
 
832 832
 											case 'status':
833 833
 												echo $_suscription->get_status_label_html();
834 834
 												break;
835 835
 
836 836
 											case 'item':
837
-												$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
838
-												echo implode( ' | ', $markup );
837
+												$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
838
+												echo implode(' | ', $markup);
839 839
 												break;
840 840
 
841 841
 											case 'renewals':
842 842
 												$max_bills = $_suscription->get_bill_times();
843
-												echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
843
+												echo $_suscription->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
844 844
 												break;
845 845
 
846 846
 											case 'renewal_date':
847
-												echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "&mdash;";
847
+												echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : "&mdash;";
848 848
 												break;
849 849
 
850 850
 											case 'start_date':
851
-												echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value( $_suscription->get_date_created() );
851
+												echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value($_suscription->get_date_created());
852 852
 												break;
853 853
 
854 854
 											case 'subscription':
855
-												$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
855
+												$url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url();
856 856
 												printf(
857 857
 													'%1$s#%2$s%3$s',
858
-													'<a href="' . esc_url( $url ) . '">',
859
-													'<strong>' . intval( $_suscription->get_id() ) . '</strong>',
858
+													'<a href="' . esc_url($url) . '">',
859
+													'<strong>' . intval($_suscription->get_id()) . '</strong>',
860 860
 													'</a>'
861 861
 												);
862 862
 
863
-												echo WPInv_Subscriptions_List_Table::column_amount( $_suscription );
863
+												echo WPInv_Subscriptions_List_Table::column_amount($_suscription);
864 864
 												break;
865 865
 
866 866
 										}
Please login to merge, or discard this patch.
includes/class-bp-getpaid-component.php 2 patches
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -17,45 +17,45 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class BP_GetPaid_Component extends BP_Component {
19 19
 
20
-	/**
21
-	 * Start the component setup process.
22
-	 *
23
-	 * @since 2.1.5
24
-	 */
25
-	public function __construct() {
26
-		parent::start(
27
-			'getpaid',
28
-			'GetPaid',
29
-			buddypress()->plugin_dir,
30
-			array(
31
-				'adminbar_myaccount_order' => 30,
32
-			)
33
-		);
34
-	}
20
+    /**
21
+     * Start the component setup process.
22
+     *
23
+     * @since 2.1.5
24
+     */
25
+    public function __construct() {
26
+        parent::start(
27
+            'getpaid',
28
+            'GetPaid',
29
+            buddypress()->plugin_dir,
30
+            array(
31
+                'adminbar_myaccount_order' => 30,
32
+            )
33
+        );
34
+    }
35 35
 
36 36
     /**
37
-	 * Set up component global variables.
38
-	 *
39
-	 * @since 2.1.5
40
-	 *
41
-	 *
42
-	 * @param array $args {
43
-	 *     All values are optional.
44
-	 *     @type string   $slug                  The component slug. Used to construct certain URLs, such as 'friends' in
45
-	 *                                           http://example.com/members/joe/friends/. Default: the value of $this->id.
46
-	 *     @type string   $root_slug             The component root slug. Note that this value is generally unused if the
47
-	 *                                           component has a root directory (the slug will be overridden by the
48
-	 *                                           post_name of the directory page). Default: the slug of the directory page
49
-	 *                                           if one is found, otherwise an empty string.
50
-	 *     @type bool     $has_directory         Set to true if the component requires an associated WordPress page.
51
-	 *     @type callable $notification_callback Optional. The callable function that formats the component's notifications.
52
-	 *     @type string   $search_term           Optional. The placeholder text in the component directory search box. Eg,
53
-	 *                                           'Search Groups...'.
54
-	 *     @type array    $global_tables         Optional. An array of database table names.
55
-	 *     @type array    $meta_tables           Optional. An array of metadata table names.
56
-	 * }
57
-	 */
58
-	public function setup_globals( $args = array() ) {
37
+     * Set up component global variables.
38
+     *
39
+     * @since 2.1.5
40
+     *
41
+     *
42
+     * @param array $args {
43
+     *     All values are optional.
44
+     *     @type string   $slug                  The component slug. Used to construct certain URLs, such as 'friends' in
45
+     *                                           http://example.com/members/joe/friends/. Default: the value of $this->id.
46
+     *     @type string   $root_slug             The component root slug. Note that this value is generally unused if the
47
+     *                                           component has a root directory (the slug will be overridden by the
48
+     *                                           post_name of the directory page). Default: the slug of the directory page
49
+     *                                           if one is found, otherwise an empty string.
50
+     *     @type bool     $has_directory         Set to true if the component requires an associated WordPress page.
51
+     *     @type callable $notification_callback Optional. The callable function that formats the component's notifications.
52
+     *     @type string   $search_term           Optional. The placeholder text in the component directory search box. Eg,
53
+     *                                           'Search Groups...'.
54
+     *     @type array    $global_tables         Optional. An array of database table names.
55
+     *     @type array    $meta_tables           Optional. An array of metadata table names.
56
+     * }
57
+     */
58
+    public function setup_globals( $args = array() ) {
59 59
         parent::setup_globals(
60 60
             array(
61 61
                 'id'            => 'getpaid',
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
                 'has_directory' => false
65 65
             )
66 66
         );
67
-	}
68
-
69
-	/**
70
-	 * Set up component navigation.
71
-	 *
72
-	 * @since 2.1.5
73
-	 *
74
-	 * @see BP_Component::setup_nav() for a description of arguments.
75
-	 *
76
-	 * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
77
-	 * @param array $sub_nav  Optional. See BP_Component::setup_nav() for description.
78
-	 */
79
-	public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
80
-
81
-		// Abort if the integration is inactive.
67
+    }
68
+
69
+    /**
70
+     * Set up component navigation.
71
+     *
72
+     * @since 2.1.5
73
+     *
74
+     * @see BP_Component::setup_nav() for a description of arguments.
75
+     *
76
+     * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
77
+     * @param array $sub_nav  Optional. See BP_Component::setup_nav() for description.
78
+     */
79
+    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
80
+
81
+        // Abort if the integration is inactive.
82 82
         if ( ! getpaid_is_buddypress_integration_active() || ! is_user_logged_in() ) {
83 83
             return;
84 84
         }
@@ -88,25 +88,25 @@  discard block
 block discarded – undo
88 88
             return;
89 89
         }
90 90
 
91
-		// Determine user to use.
92
-		$user_domain   = bp_loggedin_user_domain();
93
-		$slug          = 'getpaid';
94
-		$payments_link = trailingslashit( $user_domain . $slug );
95
-
96
-		// Add 'Payments' to the main navigation.
97
-		$main_nav = array(
98
-			'name'                => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ),
99
-			'slug'                => $slug,
100
-			'position'            => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ),
101
-			'screen_function'     => array( $this, 'display_current_tab' ),
102
-			'default_subnav_slug' => apply_filters( 'getpaid_default_tab', 'gp-edit-address' ),
91
+        // Determine user to use.
92
+        $user_domain   = bp_loggedin_user_domain();
93
+        $slug          = 'getpaid';
94
+        $payments_link = trailingslashit( $user_domain . $slug );
95
+
96
+        // Add 'Payments' to the main navigation.
97
+        $main_nav = array(
98
+            'name'                => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ),
99
+            'slug'                => $slug,
100
+            'position'            => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ),
101
+            'screen_function'     => array( $this, 'display_current_tab' ),
102
+            'default_subnav_slug' => apply_filters( 'getpaid_default_tab', 'gp-edit-address' ),
103 103
             'show_for_displayed_user' => false,
104
-			'item_css_id'         => $this->id,
105
-			'parent_url'          => $user_domain,
106
-			'parent_slug'         => buddypress()->slug,
107
-		);
104
+            'item_css_id'         => $this->id,
105
+            'parent_url'          => $user_domain,
106
+            'parent_slug'         => buddypress()->slug,
107
+        );
108 108
 
109
-		// Add the subnav items to the payments nav item if we are using a theme that supports this.
109
+        // Add the subnav items to the payments nav item if we are using a theme that supports this.
110 110
         foreach ( getpaid_get_user_content_tabs() as $_slug => $tab ) {
111 111
 
112 112
             $sub_nav[] = array(
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
                 'parent_slug'     => $slug,
117 117
                 'position' => 10,
118 118
                 'screen_function'        => function() use ( $tab ) {
119
-					$GLOBALS['getpaid_bp_current_tab'] = $tab;
120
-					$this->display_current_tab();
119
+                    $GLOBALS['getpaid_bp_current_tab'] = $tab;
120
+                    $this->display_current_tab();
121 121
                 },
122 122
                 'show_for_displayed_user' => false,
123 123
                 'item_css_id'             => "getpaid-bp-$_slug",
@@ -125,27 +125,27 @@  discard block
 block discarded – undo
125 125
 
126 126
         }
127 127
 
128
-		parent::setup_nav( $main_nav, $sub_nav );
129
-	}
130
-
131
-	/**
132
-	 * Set up the component entries in the WordPress Admin Bar.
133
-	 *
134
-	 * @since 2.1.5
135
-	 *
136
-	 * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
137
-	 *      parameter array.
138
-	 *
139
-	 * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
140
-	 *                            description.
141
-	 */
142
-	public function setup_admin_bar( $wp_admin_nav = array() ) {
143
-
144
-		// Menus for logged in user.
145
-		if ( is_user_logged_in() ) {
128
+        parent::setup_nav( $main_nav, $sub_nav );
129
+    }
146 130
 
147
-			// Setup the logged in user variables.
148
-			$payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' );
131
+    /**
132
+     * Set up the component entries in the WordPress Admin Bar.
133
+     *
134
+     * @since 2.1.5
135
+     *
136
+     * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
137
+     *      parameter array.
138
+     *
139
+     * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
140
+     *                            description.
141
+     */
142
+    public function setup_admin_bar( $wp_admin_nav = array() ) {
143
+
144
+        // Menus for logged in user.
145
+        if ( is_user_logged_in() ) {
146
+
147
+            // Setup the logged in user variables.
148
+            $payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' );
149 149
 
150 150
             // Add the "Payments" sub menu.
151 151
             $wp_admin_nav[] = array(
@@ -167,50 +167,50 @@  discard block
 block discarded – undo
167 167
 
168 168
             }
169 169
 
170
-		}
171
-
172
-		parent::setup_admin_bar( $wp_admin_nav );
173
-	}
170
+        }
174 171
 
175
-	/**
176
-	 * Retrieves the current tab.
177
-	 *
178
-	 * @since 2.1.5
179
-	 */
180
-	public function get_current_tab() {
181
-		global $getpaid_bp_current_tab;
172
+        parent::setup_admin_bar( $wp_admin_nav );
173
+    }
182 174
 
183
-		if ( empty( $getpaid_bp_current_tab ) ) {
184
-			return array(
185
-				'label'     => __( 'Invoices', 'invoicing' ),
186
-				'content'   => '[wpinv_history]',
187
-				'icon'      => 'fas fa-file-invoice',
188
-			);
189
-		}
175
+    /**
176
+     * Retrieves the current tab.
177
+     *
178
+     * @since 2.1.5
179
+     */
180
+    public function get_current_tab() {
181
+        global $getpaid_bp_current_tab;
182
+
183
+        if ( empty( $getpaid_bp_current_tab ) ) {
184
+            return array(
185
+                'label'     => __( 'Invoices', 'invoicing' ),
186
+                'content'   => '[wpinv_history]',
187
+                'icon'      => 'fas fa-file-invoice',
188
+            );
189
+        }
190 190
 
191
-		return $getpaid_bp_current_tab;
192
-	}
191
+        return $getpaid_bp_current_tab;
192
+    }
193 193
 
194
-	/**
195
-	 * Displays the current tab.
196
-	 *
197
-	 * @since 2.1.5
198
-	 */
199
-	public function display_current_tab() {
194
+    /**
195
+     * Displays the current tab.
196
+     *
197
+     * @since 2.1.5
198
+     */
199
+    public function display_current_tab() {
200 200
 
201
-		add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) );
202
-		$template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
201
+        add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) );
202
+        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
203 203
 
204 204
         bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
205
-	}
206
-
207
-	/**
208
-	 * Handles the actual display of the current tab.
209
-	 *
210
-	 * @since 2.1.5
211
-	 */
212
-	public function handle_display_current_tab() {
213
-		echo getpaid_prepare_user_content_tab( $this->get_current_tab() );
214
-	}
205
+    }
206
+
207
+    /**
208
+     * Handles the actual display of the current tab.
209
+     *
210
+     * @since 2.1.5
211
+     */
212
+    public function handle_display_current_tab() {
213
+        echo getpaid_prepare_user_content_tab( $this->get_current_tab() );
214
+    }
215 215
 
216 216
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 // Exit if accessed directly.
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * Main GetPaid Class.
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *     @type array    $meta_tables           Optional. An array of metadata table names.
56 56
 	 * }
57 57
 	 */
58
-	public function setup_globals( $args = array() ) {
58
+	public function setup_globals($args = array()) {
59 59
         parent::setup_globals(
60 60
             array(
61 61
                 'id'            => 'getpaid',
@@ -76,30 +76,30 @@  discard block
 block discarded – undo
76 76
 	 * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
77 77
 	 * @param array $sub_nav  Optional. See BP_Component::setup_nav() for description.
78 78
 	 */
79
-	public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
79
+	public function setup_nav($main_nav = array(), $sub_nav = array()) {
80 80
 
81 81
 		// Abort if the integration is inactive.
82
-        if ( ! getpaid_is_buddypress_integration_active() || ! is_user_logged_in() ) {
82
+        if (!getpaid_is_buddypress_integration_active() || !is_user_logged_in()) {
83 83
             return;
84 84
         }
85 85
     
86 86
         // Or a user is not viewing their profile.
87
-        if ( bp_displayed_user_id() != bp_loggedin_user_id() ) {
87
+        if (bp_displayed_user_id() != bp_loggedin_user_id()) {
88 88
             return;
89 89
         }
90 90
 
91 91
 		// Determine user to use.
92 92
 		$user_domain   = bp_loggedin_user_domain();
93 93
 		$slug          = 'getpaid';
94
-		$payments_link = trailingslashit( $user_domain . $slug );
94
+		$payments_link = trailingslashit($user_domain . $slug);
95 95
 
96 96
 		// Add 'Payments' to the main navigation.
97 97
 		$main_nav = array(
98
-			'name'                => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ),
98
+			'name'                => _x('Billing', 'BuddyPress profile payments screen nav', 'invoicing'),
99 99
 			'slug'                => $slug,
100
-			'position'            => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ),
101
-			'screen_function'     => array( $this, 'display_current_tab' ),
102
-			'default_subnav_slug' => apply_filters( 'getpaid_default_tab', 'gp-edit-address' ),
100
+			'position'            => apply_filters('wpinv_bp_nav_position', wpinv_get_option('wpinv_menu_position', 91), $slug),
101
+			'screen_function'     => array($this, 'display_current_tab'),
102
+			'default_subnav_slug' => apply_filters('getpaid_default_tab', 'gp-edit-address'),
103 103
             'show_for_displayed_user' => false,
104 104
 			'item_css_id'         => $this->id,
105 105
 			'parent_url'          => $user_domain,
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
 		);
108 108
 
109 109
 		// Add the subnav items to the payments nav item if we are using a theme that supports this.
110
-        foreach ( getpaid_get_user_content_tabs() as $_slug => $tab ) {
110
+        foreach (getpaid_get_user_content_tabs() as $_slug => $tab) {
111 111
 
112 112
             $sub_nav[] = array(
113
-                'name'            => $tab[ 'label'],
113
+                'name'            => $tab['label'],
114 114
                 'slug'            => $_slug,
115 115
                 'parent_url'      => $payments_link,
116 116
                 'parent_slug'     => $slug,
117 117
                 'position' => 10,
118
-                'screen_function'        => function() use ( $tab ) {
118
+                'screen_function'        => function() use ($tab) {
119 119
 					$GLOBALS['getpaid_bp_current_tab'] = $tab;
120 120
 					$this->display_current_tab();
121 121
                 },
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
         }
127 127
 
128
-		parent::setup_nav( $main_nav, $sub_nav );
128
+		parent::setup_nav($main_nav, $sub_nav);
129 129
 	}
130 130
 
131 131
 	/**
@@ -139,29 +139,29 @@  discard block
 block discarded – undo
139 139
 	 * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
140 140
 	 *                            description.
141 141
 	 */
142
-	public function setup_admin_bar( $wp_admin_nav = array() ) {
142
+	public function setup_admin_bar($wp_admin_nav = array()) {
143 143
 
144 144
 		// Menus for logged in user.
145
-		if ( is_user_logged_in() ) {
145
+		if (is_user_logged_in()) {
146 146
 
147 147
 			// Setup the logged in user variables.
148
-			$payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' );
148
+			$payments_link = trailingslashit(bp_loggedin_user_domain() . 'getpaid/');
149 149
 
150 150
             // Add the "Payments" sub menu.
151 151
             $wp_admin_nav[] = array(
152 152
                 'parent' => buddypress()->my_account_menu_id,
153 153
                 'id'     => 'my-account-getpaid',
154
-                'title'  => _x( 'Billing', 'BuddyPress my account payments sub nav', 'invoicing' ),
155
-                'href'   => $payments_link . apply_filters( 'getpaid_default_tab', 'gp-edit-address' ),
154
+                'title'  => _x('Billing', 'BuddyPress my account payments sub nav', 'invoicing'),
155
+                'href'   => $payments_link . apply_filters('getpaid_default_tab', 'gp-edit-address'),
156 156
             );
157 157
 
158
-            foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) {
158
+            foreach (getpaid_get_user_content_tabs() as $slug => $tab) {
159 159
 
160 160
                 $wp_admin_nav[] = array(
161 161
                     'parent'   => 'my-account-getpaid',
162 162
                     'id'       => 'my-account-getpaid' . $slug,
163
-                    'title'    => $tab[ 'label'],
164
-                    'href'     => trailingslashit( $payments_link . $slug ),
163
+                    'title'    => $tab['label'],
164
+                    'href'     => trailingslashit($payments_link . $slug),
165 165
                     'position' => 20
166 166
                 );
167 167
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
 		}
171 171
 
172
-		parent::setup_admin_bar( $wp_admin_nav );
172
+		parent::setup_admin_bar($wp_admin_nav);
173 173
 	}
174 174
 
175 175
 	/**
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 	public function get_current_tab() {
181 181
 		global $getpaid_bp_current_tab;
182 182
 
183
-		if ( empty( $getpaid_bp_current_tab ) ) {
183
+		if (empty($getpaid_bp_current_tab)) {
184 184
 			return array(
185
-				'label'     => __( 'Invoices', 'invoicing' ),
185
+				'label'     => __('Invoices', 'invoicing'),
186 186
 				'content'   => '[wpinv_history]',
187 187
 				'icon'      => 'fas fa-file-invoice',
188 188
 			);
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function display_current_tab() {
200 200
 
201
-		add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) );
202
-		$template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
201
+		add_action('bp_template_content', array($this, 'handle_display_current_tab'));
202
+		$template = apply_filters('bp_core_template_plugin', 'members/single/plugins');
203 203
 
204
-        bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
204
+        bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template));
205 205
 	}
206 206
 
207 207
 	/**
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @since 2.1.5
211 211
 	 */
212 212
 	public function handle_display_current_tab() {
213
-		echo getpaid_prepare_user_content_tab( $this->get_current_tab() );
213
+		echo getpaid_prepare_user_content_tab($this->get_current_tab());
214 214
 	}
215 215
 
216 216
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-discount.php 2 patches
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -12,167 +12,167 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Discount {
14 14
 
15
-	/**
16
-	 * Submission discounts.
17
-	 * @var array
18
-	 */
19
-	public $discounts = array();
15
+    /**
16
+     * Submission discounts.
17
+     * @var array
18
+     */
19
+    public $discounts = array();
20
+
21
+    /**
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     * @param float                           $initial_total
26
+     * @param float                           $recurring_total
27
+     */
28
+    public function __construct( $submission, $initial_total, $recurring_total ) {
29
+
30
+        // Process any existing invoice discounts.
31
+        if ( $submission->has_invoice() ) {
32
+            $this->discounts = $submission->get_invoice()->get_discounts();
33
+        }
34
+
35
+        // Do we have a discount?
36
+        $discount = $submission->get_field( 'discount' );
37
+
38
+        if ( empty( $discount ) ) {
39
+
40
+            if ( isset( $this->discounts['discount_code'] ) ) {
41
+                unset( $this->discounts['discount_code'] );
42
+            }
43
+
44
+            return;
45
+        }
46
+
47
+        // Processes the discount code.
48
+        $amount = max( $initial_total, $recurring_total );
49
+        $this->process_discount( $submission, $discount, $amount );
50
+
51
+    }
20 52
 
21 53
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 * @param float                           $initial_total
26
-	 * @param float                           $recurring_total
27
-	 */
28
-	public function __construct( $submission, $initial_total, $recurring_total ) {
29
-
30
-		// Process any existing invoice discounts.
31
-		if ( $submission->has_invoice() ) {
32
-			$this->discounts = $submission->get_invoice()->get_discounts();
33
-		}
34
-
35
-		// Do we have a discount?
36
-		$discount = $submission->get_field( 'discount' );
37
-
38
-		if ( empty( $discount ) ) {
39
-
40
-			if ( isset( $this->discounts['discount_code'] ) ) {
41
-				unset( $this->discounts['discount_code'] );
42
-			}
43
-
44
-			return;
45
-		}
46
-
47
-		// Processes the discount code.
48
-		$amount = max( $initial_total, $recurring_total );
49
-		$this->process_discount( $submission, $discount, $amount );
50
-
51
-	}
52
-
53
-	/**
54
-	 * Processes a submission discount.
55
-	 *
56
-	 * @param GetPaid_Payment_Form_Submission $submission
57
-	 * @param string                          $discount
58
-	 * @param float                           $amount
59
-	 */
60
-	public function process_discount( $submission, $discount, $amount ) {
61
-
62
-		// Fetch the discount.
63
-		$discount = new WPInv_Discount( $discount );
64
-
65
-		// Ensure it is active.
54
+     * Processes a submission discount.
55
+     *
56
+     * @param GetPaid_Payment_Form_Submission $submission
57
+     * @param string                          $discount
58
+     * @param float                           $amount
59
+     */
60
+    public function process_discount( $submission, $discount, $amount ) {
61
+
62
+        // Fetch the discount.
63
+        $discount = new WPInv_Discount( $discount );
64
+
65
+        // Ensure it is active.
66 66
         if ( ! $this->is_discount_active( $discount ) ) {
67
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'Invalid or expired discount code', 'invoicing' ) );
68
-		}
69
-
70
-		// Required items.
71
-		if ( ! $discount->is_required_items_met( array_keys( $submission->get_items() ) ) ) {
72
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'You are not allowed to use this discount code.', 'invoicing' ) );
73
-		}
74
-
75
-		// Exceeded limit.
76
-		if ( $discount->has_exceeded_limit() ) {
77
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'This discount code has been used up', 'invoicing' ) );
78
-		}
79
-
80
-		// Validate usages.
81
-		$this->validate_single_use_discount( $submission, $discount );
82
-
83
-		// Validate amount.
84
-		$this->validate_discount_amount( $submission, $discount, $amount );
85
-
86
-		// Save the discount.
87
-		$this->discounts['discount_code'] = $this->calculate_discount( $submission, $discount );
88
-	}
89
-
90
-	/**
91
-	 * Validates a single use discount.
92
-	 *
93
-	 * @param WPInv_Discount                  $discount
94
-	 * @return bool
95
-	 */
96
-	public function is_discount_active(  $discount ) {
97
-		return $discount->exists() && $discount->is_active() && $discount->has_started() && ! $discount->is_expired();
98
-	}
99
-
100
-	/**
101
-	 * Returns a user's id or email.
102
-	 *
103
-	 * @param string $email
104
-	 * @return int|string|false
105
-	 */
106
-	public function get_user_id_or_email( $email ) {
107
-
108
-		if ( is_user_logged_in() ) {
109
-			return get_current_user_id();
110
-		}
111
-
112
-		return empty( $email ) ? false : sanitize_email( $email );
113
-	}
114
-
115
-	/**
116
-	 * Validates a single use discount.
117
-	 *
118
-	 * @param GetPaid_Payment_Form_Submission $submission
119
-	 * @param WPInv_Discount                  $discount
120
-	 */
121
-	public function validate_single_use_discount( $submission, $discount ) {
122
-
123
-		// Abort if it is not a single use discount.
124
-		if ( ! $discount->is_single_use() ) {
125
-			return;
126
-		}
127
-
128
-		// Ensure there is a valid billing email.
129
-		$user = $this->get_user_id_or_email( $submission->get_billing_email() );
130
-
131
-		if ( empty( $user ) ) {
132
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'You need to either log in or enter your billing email before applying this discount', 'invoicing' ) );
133
-		}
134
-
135
-		// Has the user used this discount code before?
136
-		if ( ! $discount->is_valid_for_user( $user ) ) {
137
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'You have already used this discount', 'invoicing' ) );
138
-		}
139
-
140
-	}
141
-
142
-	/**
143
-	 * Validates the discount's amount.
144
-	 *
145
-	 * @param GetPaid_Payment_Form_Submission $submission
146
-	 * @param WPInv_Discount         $discount
147
-	 * @param float                  $amount
148
-	 */
149
-	public function validate_discount_amount( $submission, $discount, $amount ) {
150
-
151
-		// Validate minimum amount.
152
-		if ( ! $discount->is_minimum_amount_met( $amount ) ) {
153
-			$min = wpinv_price( $discount->get_minimum_total(), $submission->get_currency() );
154
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ) );
155
-		}
156
-
157
-		// Validate the maximum amount.
158
-		if ( ! $discount->is_maximum_amount_met( $amount ) ) {
159
-			$max = wpinv_price( $discount->get_maximum_total(), $submission->get_currency() );
160
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ) );
161
-		}
162
-
163
-	}
164
-
165
-	/**
166
-	 * Calculates the discount code's amount.
167
-	 *
168
-	 * Ensure that the discount exists and has been validated before calling this method.
169
-	 *
170
-	 * @param GetPaid_Payment_Form_Submission $submission
171
-	 * @param WPInv_Discount                  $discount
172
-	 * @return array
173
-	 */
174
-	public function calculate_discount( $submission, $discount ) {
175
-		return getpaid_calculate_invoice_discount( $submission, $discount );
176
-	}
67
+            throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'Invalid or expired discount code', 'invoicing' ) );
68
+        }
69
+
70
+        // Required items.
71
+        if ( ! $discount->is_required_items_met( array_keys( $submission->get_items() ) ) ) {
72
+            throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'You are not allowed to use this discount code.', 'invoicing' ) );
73
+        }
74
+
75
+        // Exceeded limit.
76
+        if ( $discount->has_exceeded_limit() ) {
77
+            throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'This discount code has been used up', 'invoicing' ) );
78
+        }
79
+
80
+        // Validate usages.
81
+        $this->validate_single_use_discount( $submission, $discount );
82
+
83
+        // Validate amount.
84
+        $this->validate_discount_amount( $submission, $discount, $amount );
85
+
86
+        // Save the discount.
87
+        $this->discounts['discount_code'] = $this->calculate_discount( $submission, $discount );
88
+    }
89
+
90
+    /**
91
+     * Validates a single use discount.
92
+     *
93
+     * @param WPInv_Discount                  $discount
94
+     * @return bool
95
+     */
96
+    public function is_discount_active(  $discount ) {
97
+        return $discount->exists() && $discount->is_active() && $discount->has_started() && ! $discount->is_expired();
98
+    }
99
+
100
+    /**
101
+     * Returns a user's id or email.
102
+     *
103
+     * @param string $email
104
+     * @return int|string|false
105
+     */
106
+    public function get_user_id_or_email( $email ) {
107
+
108
+        if ( is_user_logged_in() ) {
109
+            return get_current_user_id();
110
+        }
111
+
112
+        return empty( $email ) ? false : sanitize_email( $email );
113
+    }
114
+
115
+    /**
116
+     * Validates a single use discount.
117
+     *
118
+     * @param GetPaid_Payment_Form_Submission $submission
119
+     * @param WPInv_Discount                  $discount
120
+     */
121
+    public function validate_single_use_discount( $submission, $discount ) {
122
+
123
+        // Abort if it is not a single use discount.
124
+        if ( ! $discount->is_single_use() ) {
125
+            return;
126
+        }
127
+
128
+        // Ensure there is a valid billing email.
129
+        $user = $this->get_user_id_or_email( $submission->get_billing_email() );
130
+
131
+        if ( empty( $user ) ) {
132
+            throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'You need to either log in or enter your billing email before applying this discount', 'invoicing' ) );
133
+        }
134
+
135
+        // Has the user used this discount code before?
136
+        if ( ! $discount->is_valid_for_user( $user ) ) {
137
+            throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'You have already used this discount', 'invoicing' ) );
138
+        }
139
+
140
+    }
141
+
142
+    /**
143
+     * Validates the discount's amount.
144
+     *
145
+     * @param GetPaid_Payment_Form_Submission $submission
146
+     * @param WPInv_Discount         $discount
147
+     * @param float                  $amount
148
+     */
149
+    public function validate_discount_amount( $submission, $discount, $amount ) {
150
+
151
+        // Validate minimum amount.
152
+        if ( ! $discount->is_minimum_amount_met( $amount ) ) {
153
+            $min = wpinv_price( $discount->get_minimum_total(), $submission->get_currency() );
154
+            throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ) );
155
+        }
156
+
157
+        // Validate the maximum amount.
158
+        if ( ! $discount->is_maximum_amount_met( $amount ) ) {
159
+            $max = wpinv_price( $discount->get_maximum_total(), $submission->get_currency() );
160
+            throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ) );
161
+        }
162
+
163
+    }
164
+
165
+    /**
166
+     * Calculates the discount code's amount.
167
+     *
168
+     * Ensure that the discount exists and has been validated before calling this method.
169
+     *
170
+     * @param GetPaid_Payment_Form_Submission $submission
171
+     * @param WPInv_Discount                  $discount
172
+     * @return array
173
+     */
174
+    public function calculate_discount( $submission, $discount ) {
175
+        return getpaid_calculate_invoice_discount( $submission, $discount );
176
+    }
177 177
 
178 178
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission discount class
@@ -25,28 +25,28 @@  discard block
 block discarded – undo
25 25
 	 * @param float                           $initial_total
26 26
 	 * @param float                           $recurring_total
27 27
 	 */
28
-	public function __construct( $submission, $initial_total, $recurring_total ) {
28
+	public function __construct($submission, $initial_total, $recurring_total) {
29 29
 
30 30
 		// Process any existing invoice discounts.
31
-		if ( $submission->has_invoice() ) {
31
+		if ($submission->has_invoice()) {
32 32
 			$this->discounts = $submission->get_invoice()->get_discounts();
33 33
 		}
34 34
 
35 35
 		// Do we have a discount?
36
-		$discount = $submission->get_field( 'discount' );
36
+		$discount = $submission->get_field('discount');
37 37
 
38
-		if ( empty( $discount ) ) {
38
+		if (empty($discount)) {
39 39
 
40
-			if ( isset( $this->discounts['discount_code'] ) ) {
41
-				unset( $this->discounts['discount_code'] );
40
+			if (isset($this->discounts['discount_code'])) {
41
+				unset($this->discounts['discount_code']);
42 42
 			}
43 43
 
44 44
 			return;
45 45
 		}
46 46
 
47 47
 		// Processes the discount code.
48
-		$amount = max( $initial_total, $recurring_total );
49
-		$this->process_discount( $submission, $discount, $amount );
48
+		$amount = max($initial_total, $recurring_total);
49
+		$this->process_discount($submission, $discount, $amount);
50 50
 
51 51
 	}
52 52
 
@@ -57,34 +57,34 @@  discard block
 block discarded – undo
57 57
 	 * @param string                          $discount
58 58
 	 * @param float                           $amount
59 59
 	 */
60
-	public function process_discount( $submission, $discount, $amount ) {
60
+	public function process_discount($submission, $discount, $amount) {
61 61
 
62 62
 		// Fetch the discount.
63
-		$discount = new WPInv_Discount( $discount );
63
+		$discount = new WPInv_Discount($discount);
64 64
 
65 65
 		// Ensure it is active.
66
-        if ( ! $this->is_discount_active( $discount ) ) {
67
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'Invalid or expired discount code', 'invoicing' ) );
66
+        if (!$this->is_discount_active($discount)) {
67
+			throw new GetPaid_Payment_Exception('.getpaid-discount-field .getpaid-custom-payment-form-errors', __('Invalid or expired discount code', 'invoicing'));
68 68
 		}
69 69
 
70 70
 		// Required items.
71
-		if ( ! $discount->is_required_items_met( array_keys( $submission->get_items() ) ) ) {
72
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'You are not allowed to use this discount code.', 'invoicing' ) );
71
+		if (!$discount->is_required_items_met(array_keys($submission->get_items()))) {
72
+			throw new GetPaid_Payment_Exception('.getpaid-discount-field .getpaid-custom-payment-form-errors', __('You are not allowed to use this discount code.', 'invoicing'));
73 73
 		}
74 74
 
75 75
 		// Exceeded limit.
76
-		if ( $discount->has_exceeded_limit() ) {
77
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'This discount code has been used up', 'invoicing' ) );
76
+		if ($discount->has_exceeded_limit()) {
77
+			throw new GetPaid_Payment_Exception('.getpaid-discount-field .getpaid-custom-payment-form-errors', __('This discount code has been used up', 'invoicing'));
78 78
 		}
79 79
 
80 80
 		// Validate usages.
81
-		$this->validate_single_use_discount( $submission, $discount );
81
+		$this->validate_single_use_discount($submission, $discount);
82 82
 
83 83
 		// Validate amount.
84
-		$this->validate_discount_amount( $submission, $discount, $amount );
84
+		$this->validate_discount_amount($submission, $discount, $amount);
85 85
 
86 86
 		// Save the discount.
87
-		$this->discounts['discount_code'] = $this->calculate_discount( $submission, $discount );
87
+		$this->discounts['discount_code'] = $this->calculate_discount($submission, $discount);
88 88
 	}
89 89
 
90 90
 	/**
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 	 * @param WPInv_Discount                  $discount
94 94
 	 * @return bool
95 95
 	 */
96
-	public function is_discount_active(  $discount ) {
97
-		return $discount->exists() && $discount->is_active() && $discount->has_started() && ! $discount->is_expired();
96
+	public function is_discount_active($discount) {
97
+		return $discount->exists() && $discount->is_active() && $discount->has_started() && !$discount->is_expired();
98 98
 	}
99 99
 
100 100
 	/**
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 	 * @param string $email
104 104
 	 * @return int|string|false
105 105
 	 */
106
-	public function get_user_id_or_email( $email ) {
106
+	public function get_user_id_or_email($email) {
107 107
 
108
-		if ( is_user_logged_in() ) {
108
+		if (is_user_logged_in()) {
109 109
 			return get_current_user_id();
110 110
 		}
111 111
 
112
-		return empty( $email ) ? false : sanitize_email( $email );
112
+		return empty($email) ? false : sanitize_email($email);
113 113
 	}
114 114
 
115 115
 	/**
@@ -118,23 +118,23 @@  discard block
 block discarded – undo
118 118
 	 * @param GetPaid_Payment_Form_Submission $submission
119 119
 	 * @param WPInv_Discount                  $discount
120 120
 	 */
121
-	public function validate_single_use_discount( $submission, $discount ) {
121
+	public function validate_single_use_discount($submission, $discount) {
122 122
 
123 123
 		// Abort if it is not a single use discount.
124
-		if ( ! $discount->is_single_use() ) {
124
+		if (!$discount->is_single_use()) {
125 125
 			return;
126 126
 		}
127 127
 
128 128
 		// Ensure there is a valid billing email.
129
-		$user = $this->get_user_id_or_email( $submission->get_billing_email() );
129
+		$user = $this->get_user_id_or_email($submission->get_billing_email());
130 130
 
131
-		if ( empty( $user ) ) {
132
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'You need to either log in or enter your billing email before applying this discount', 'invoicing' ) );
131
+		if (empty($user)) {
132
+			throw new GetPaid_Payment_Exception('.getpaid-discount-field .getpaid-custom-payment-form-errors', __('You need to either log in or enter your billing email before applying this discount', 'invoicing'));
133 133
 		}
134 134
 
135 135
 		// Has the user used this discount code before?
136
-		if ( ! $discount->is_valid_for_user( $user ) ) {
137
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', __( 'You have already used this discount', 'invoicing' ) );
136
+		if (!$discount->is_valid_for_user($user)) {
137
+			throw new GetPaid_Payment_Exception('.getpaid-discount-field .getpaid-custom-payment-form-errors', __('You have already used this discount', 'invoicing'));
138 138
 		}
139 139
 
140 140
 	}
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 	 * @param WPInv_Discount         $discount
147 147
 	 * @param float                  $amount
148 148
 	 */
149
-	public function validate_discount_amount( $submission, $discount, $amount ) {
149
+	public function validate_discount_amount($submission, $discount, $amount) {
150 150
 
151 151
 		// Validate minimum amount.
152
-		if ( ! $discount->is_minimum_amount_met( $amount ) ) {
153
-			$min = wpinv_price( $discount->get_minimum_total(), $submission->get_currency() );
154
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ) );
152
+		if (!$discount->is_minimum_amount_met($amount)) {
153
+			$min = wpinv_price($discount->get_minimum_total(), $submission->get_currency());
154
+			throw new GetPaid_Payment_Exception('.getpaid-discount-field .getpaid-custom-payment-form-errors', sprintf(__('The minimum total for using this discount is %s', 'invoicing'), $min));
155 155
 		}
156 156
 
157 157
 		// Validate the maximum amount.
158
-		if ( ! $discount->is_maximum_amount_met( $amount ) ) {
159
-			$max = wpinv_price( $discount->get_maximum_total(), $submission->get_currency() );
160
-			throw new GetPaid_Payment_Exception( '.getpaid-discount-field .getpaid-custom-payment-form-errors', sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ) );
158
+		if (!$discount->is_maximum_amount_met($amount)) {
159
+			$max = wpinv_price($discount->get_maximum_total(), $submission->get_currency());
160
+			throw new GetPaid_Payment_Exception('.getpaid-discount-field .getpaid-custom-payment-form-errors', sprintf(__('The maximum total for using this discount is %s', 'invoicing'), $max));
161 161
 		}
162 162
 
163 163
 	}
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * @param WPInv_Discount                  $discount
172 172
 	 * @return array
173 173
 	 */
174
-	public function calculate_discount( $submission, $discount ) {
175
-		return getpaid_calculate_invoice_discount( $submission, $discount );
174
+	public function calculate_discount($submission, $discount) {
175
+		return getpaid_calculate_invoice_discount($submission, $discount);
176 176
 	}
177 177
 
178 178
 }
Please login to merge, or discard this patch.
includes/data/discount-schema.php 2 patches
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -13,177 +13,177 @@
 block discarded – undo
13 13
 
14 14
 return array(
15 15
 
16
-	'id'              => array(
17
-		'description' => __( 'Unique identifier for the discount.', 'invoicing' ),
18
-		'type'        => 'integer',
19
-		'context'     => array( 'view', 'edit', 'embed' ),
20
-		'readonly'    => true,
21
-	),
22
-
23
-	'status'          => array(
24
-		'description' => __( 'A named status for the discount.', 'invoicing' ),
25
-		'type'        => 'string',
26
-		'enum'        => array( 'publish', 'pending', 'draft', 'expired' ),
27
-		'default'     => 'draft',
28
-		'context'     => array( 'view', 'edit', 'embed' ),
29
-	),
30
-
31
-	'version'         => array(
32
-		'description' => __( 'Plugin version when the discount was created.', 'invoicing' ),
33
-		'type'        => 'string',
34
-		'context'     => array( 'view', 'edit', 'embed' ),
35
-		'readonly'    => true,
36
-	),
37
-
38
-	'date_created'    => array(
39
-		'description' => __( "The date the discount was created, in the site's timezone.", 'invoicing' ),
40
-		'type'        => 'string',
41
-		'context'     => array( 'view', 'edit', 'embed' ),
42
-	),
43
-
44
-	'date_created_gmt'    => array(
45
-		'description' => __( 'The GMT date the discount was created.', 'invoicing' ),
46
-		'type'        => 'string',
47
-		'context'     => array( 'view', 'edit', 'embed' ),
48
-		'readonly'    => true,
49
-	),
50
-
51
-	'date_modified'   => array(
52
-		'description' => __( "The date the discount was last modified, in the site's timezone.", 'invoicing' ),
53
-		'type'        => 'string',
54
-		'context'     => array( 'view', 'edit', 'embed' ),
55
-		'readonly'    => true,
56
-	),
57
-
58
-	'date_modified_gmt'    => array(
59
-		'description' => __( 'The GMT date the discount was last modified.', 'invoicing' ),
60
-		'type'        => 'string',
61
-		'context'     => array( 'view', 'edit', 'embed' ),
62
-		'readonly'    => true,
63
-	),
64
-
65
-	'name'			  => array(
66
-		'description' => __( 'The discount name.', 'invoicing' ),
67
-		'type'        => 'string',
68
-		'context'     => array( 'view', 'edit', 'embed' ),
69
-	),
70
-
71
-	'description'     => array(
72
-		'description' => __( 'A description of what the discount is all about.', 'invoicing' ),
73
-		'type'        => 'string',
74
-		'context'     => array( 'view', 'edit', 'embed' ),
75
-	),
76
-
77
-	'code'            => array(
78
-		'description' => __( 'The discount code.', 'invoicing' ),
79
-		'type'        => 'string',
80
-		'context'     => array( 'view', 'edit', 'embed' ),
81
-		'required'	  => true,
82
-	),
83
-
84
-	'type'            => array(
85
-		'description' => __( 'The type of discount.', 'invoicing' ),
86
-		'type'        => 'string',
87
-		'enum'        => array_keys( wpinv_get_discount_types() ),
88
-		'context'     => array( 'view', 'edit', 'embed' ),
89
-		'default'	  => 'percent',
90
-	),
91
-
92
-	'amount'        => array(
93
-		'description' => __( 'The discount value.', 'invoicing' ),
94
-		'type'        => 'number',
95
-		'context'     => array( 'view', 'edit', 'embed' ),
96
-		'required'	  => true,
97
-	),
98
-
99
-	'formatted_amount'        => array(
100
-		'description' => __( 'The formatted discount value.', 'invoicing' ),
101
-		'type'        => 'string',
102
-		'context'     => array( 'view', 'edit', 'embed' ),
103
-		'readonly'    => true,
104
-	),
105
-
106
-	'uses'            => array(
107
-		'description' => __( 'The number of times the discount has been used.', 'invoicing' ),
108
-		'type'        => 'integer',
109
-		'context'     => array( 'view', 'embed' ),
110
-		'readonly'    => true,
111
-	),
112
-
113
-	'max_uses'        => array(
114
-		'description' => __( 'The maximum number of times the discount can be used.', 'invoicing' ),
115
-		'type'        => 'integer',
116
-		'context'     => array( 'view', 'edit' ),
117
-	),
118
-
119
-	'usage'           => array(
120
-		'description' => __( "The discount's usage, i.e uses / max uses.", 'invoicing' ),
121
-		'type'        => 'string',
122
-		'context'     => array( 'view', 'embed' ),
123
-		'readonly'    => true,
124
-	),
125
-
126
-	'is_single_use'   => array(
127
-		'description' => __( 'Whether or not the discount can only be used once per user.', 'invoicing' ),
128
-		'type'        => 'boolean',
129
-		'context'     => array( 'view', 'edit' ),
130
-	),
131
-
132
-	'is_recurring'   => array(
133
-		'description' => __( 'Whether or not the discount applies to the initial payment only or all recurring payments.', 'invoicing' ),
134
-		'type'        => 'boolean',
135
-		'context'     => array( 'view', 'edit' ),
136
-	),
137
-
138
-	'start_date'      => array(
139
-		'description' => __( 'The start date for the discount in the format of yyyy-mm-dd hh:mm:ss. If provided, the discount can only be used after or on this date.', 'invoicing' ),
140
-		'type'        => 'string',
141
-		'context'     => array( 'view', 'edit' ),
142
-	),
143
-
144
-	'end_date'        => array(
145
-		'description' => __( 'The expiration date for the discount.', 'invoicing' ),
146
-		'type'        => 'string',
147
-		'context'     => array( 'view', 'edit' ),
148
-	),
149
-
150
-	'allowed_items'   => array(
151
-		'description' => __( 'Items which are allowed to use this discount. Leave blank to enable for all items.', 'invoicing' ),
152
-		'type'        => 'array',
153
-		'context'     => array( 'view', 'edit' ),
154
-		'items'       => array(
155
-			'type'    => 'integer'
156
-		)
157
-	),
158
-
159
-	'excluded_items'  => array(
160
-		'description' => __( 'Items which are NOT allowed to use this discount.', 'invoicing' ),
161
-		'type'        => 'array',
162
-		'context'     => array( 'view', 'edit' ),
163
-		'items'       => array(
164
-			'type'    => 'integer'
165
-		)
166
-	),
167
-
168
-	'required_items'  => array(
169
-		'description' => __( 'Items which are required to be in the cart before using this discount.', 'invoicing' ),
170
-		'type'        => 'array',
171
-		'context'     => array( 'view', 'edit' ),
172
-		'items'       => array(
173
-			'type'    => 'integer'
174
-		)
175
-	),
176
-
177
-	'minimum_total'   => array(
178
-		'description' => __( 'The minimum total needed to use this invoice.', 'invoicing' ),
179
-		'type'        => 'number',
180
-		'context'     => array( 'view', 'edit' ),
181
-	),
182
-
183
-	'maximum_total'   => array(
184
-		'description' => __( 'The maximum total needed to use this invoice.', 'invoicing' ),
185
-		'type'        => 'number',
186
-		'context'     => array( 'view', 'edit' ),
187
-	),
16
+    'id'              => array(
17
+        'description' => __( 'Unique identifier for the discount.', 'invoicing' ),
18
+        'type'        => 'integer',
19
+        'context'     => array( 'view', 'edit', 'embed' ),
20
+        'readonly'    => true,
21
+    ),
22
+
23
+    'status'          => array(
24
+        'description' => __( 'A named status for the discount.', 'invoicing' ),
25
+        'type'        => 'string',
26
+        'enum'        => array( 'publish', 'pending', 'draft', 'expired' ),
27
+        'default'     => 'draft',
28
+        'context'     => array( 'view', 'edit', 'embed' ),
29
+    ),
30
+
31
+    'version'         => array(
32
+        'description' => __( 'Plugin version when the discount was created.', 'invoicing' ),
33
+        'type'        => 'string',
34
+        'context'     => array( 'view', 'edit', 'embed' ),
35
+        'readonly'    => true,
36
+    ),
37
+
38
+    'date_created'    => array(
39
+        'description' => __( "The date the discount was created, in the site's timezone.", 'invoicing' ),
40
+        'type'        => 'string',
41
+        'context'     => array( 'view', 'edit', 'embed' ),
42
+    ),
43
+
44
+    'date_created_gmt'    => array(
45
+        'description' => __( 'The GMT date the discount was created.', 'invoicing' ),
46
+        'type'        => 'string',
47
+        'context'     => array( 'view', 'edit', 'embed' ),
48
+        'readonly'    => true,
49
+    ),
50
+
51
+    'date_modified'   => array(
52
+        'description' => __( "The date the discount was last modified, in the site's timezone.", 'invoicing' ),
53
+        'type'        => 'string',
54
+        'context'     => array( 'view', 'edit', 'embed' ),
55
+        'readonly'    => true,
56
+    ),
57
+
58
+    'date_modified_gmt'    => array(
59
+        'description' => __( 'The GMT date the discount was last modified.', 'invoicing' ),
60
+        'type'        => 'string',
61
+        'context'     => array( 'view', 'edit', 'embed' ),
62
+        'readonly'    => true,
63
+    ),
64
+
65
+    'name'			  => array(
66
+        'description' => __( 'The discount name.', 'invoicing' ),
67
+        'type'        => 'string',
68
+        'context'     => array( 'view', 'edit', 'embed' ),
69
+    ),
70
+
71
+    'description'     => array(
72
+        'description' => __( 'A description of what the discount is all about.', 'invoicing' ),
73
+        'type'        => 'string',
74
+        'context'     => array( 'view', 'edit', 'embed' ),
75
+    ),
76
+
77
+    'code'            => array(
78
+        'description' => __( 'The discount code.', 'invoicing' ),
79
+        'type'        => 'string',
80
+        'context'     => array( 'view', 'edit', 'embed' ),
81
+        'required'	  => true,
82
+    ),
83
+
84
+    'type'            => array(
85
+        'description' => __( 'The type of discount.', 'invoicing' ),
86
+        'type'        => 'string',
87
+        'enum'        => array_keys( wpinv_get_discount_types() ),
88
+        'context'     => array( 'view', 'edit', 'embed' ),
89
+        'default'	  => 'percent',
90
+    ),
91
+
92
+    'amount'        => array(
93
+        'description' => __( 'The discount value.', 'invoicing' ),
94
+        'type'        => 'number',
95
+        'context'     => array( 'view', 'edit', 'embed' ),
96
+        'required'	  => true,
97
+    ),
98
+
99
+    'formatted_amount'        => array(
100
+        'description' => __( 'The formatted discount value.', 'invoicing' ),
101
+        'type'        => 'string',
102
+        'context'     => array( 'view', 'edit', 'embed' ),
103
+        'readonly'    => true,
104
+    ),
105
+
106
+    'uses'            => array(
107
+        'description' => __( 'The number of times the discount has been used.', 'invoicing' ),
108
+        'type'        => 'integer',
109
+        'context'     => array( 'view', 'embed' ),
110
+        'readonly'    => true,
111
+    ),
112
+
113
+    'max_uses'        => array(
114
+        'description' => __( 'The maximum number of times the discount can be used.', 'invoicing' ),
115
+        'type'        => 'integer',
116
+        'context'     => array( 'view', 'edit' ),
117
+    ),
118
+
119
+    'usage'           => array(
120
+        'description' => __( "The discount's usage, i.e uses / max uses.", 'invoicing' ),
121
+        'type'        => 'string',
122
+        'context'     => array( 'view', 'embed' ),
123
+        'readonly'    => true,
124
+    ),
125
+
126
+    'is_single_use'   => array(
127
+        'description' => __( 'Whether or not the discount can only be used once per user.', 'invoicing' ),
128
+        'type'        => 'boolean',
129
+        'context'     => array( 'view', 'edit' ),
130
+    ),
131
+
132
+    'is_recurring'   => array(
133
+        'description' => __( 'Whether or not the discount applies to the initial payment only or all recurring payments.', 'invoicing' ),
134
+        'type'        => 'boolean',
135
+        'context'     => array( 'view', 'edit' ),
136
+    ),
137
+
138
+    'start_date'      => array(
139
+        'description' => __( 'The start date for the discount in the format of yyyy-mm-dd hh:mm:ss. If provided, the discount can only be used after or on this date.', 'invoicing' ),
140
+        'type'        => 'string',
141
+        'context'     => array( 'view', 'edit' ),
142
+    ),
143
+
144
+    'end_date'        => array(
145
+        'description' => __( 'The expiration date for the discount.', 'invoicing' ),
146
+        'type'        => 'string',
147
+        'context'     => array( 'view', 'edit' ),
148
+    ),
149
+
150
+    'allowed_items'   => array(
151
+        'description' => __( 'Items which are allowed to use this discount. Leave blank to enable for all items.', 'invoicing' ),
152
+        'type'        => 'array',
153
+        'context'     => array( 'view', 'edit' ),
154
+        'items'       => array(
155
+            'type'    => 'integer'
156
+        )
157
+    ),
158
+
159
+    'excluded_items'  => array(
160
+        'description' => __( 'Items which are NOT allowed to use this discount.', 'invoicing' ),
161
+        'type'        => 'array',
162
+        'context'     => array( 'view', 'edit' ),
163
+        'items'       => array(
164
+            'type'    => 'integer'
165
+        )
166
+    ),
167
+
168
+    'required_items'  => array(
169
+        'description' => __( 'Items which are required to be in the cart before using this discount.', 'invoicing' ),
170
+        'type'        => 'array',
171
+        'context'     => array( 'view', 'edit' ),
172
+        'items'       => array(
173
+            'type'    => 'integer'
174
+        )
175
+    ),
176
+
177
+    'minimum_total'   => array(
178
+        'description' => __( 'The minimum total needed to use this invoice.', 'invoicing' ),
179
+        'type'        => 'number',
180
+        'context'     => array( 'view', 'edit' ),
181
+    ),
182
+
183
+    'maximum_total'   => array(
184
+        'description' => __( 'The maximum total needed to use this invoice.', 'invoicing' ),
185
+        'type'        => 'number',
186
+        'context'     => array( 'view', 'edit' ),
187
+    ),
188 188
 
189 189
 );
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -9,181 +9,181 @@
 block discarded – undo
9 9
  * @version 1.0.19
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 return array(
15 15
 
16 16
 	'id'              => array(
17
-		'description' => __( 'Unique identifier for the discount.', 'invoicing' ),
17
+		'description' => __('Unique identifier for the discount.', 'invoicing'),
18 18
 		'type'        => 'integer',
19
-		'context'     => array( 'view', 'edit', 'embed' ),
19
+		'context'     => array('view', 'edit', 'embed'),
20 20
 		'readonly'    => true,
21 21
 	),
22 22
 
23 23
 	'status'          => array(
24
-		'description' => __( 'A named status for the discount.', 'invoicing' ),
24
+		'description' => __('A named status for the discount.', 'invoicing'),
25 25
 		'type'        => 'string',
26
-		'enum'        => array( 'publish', 'pending', 'draft', 'expired' ),
26
+		'enum'        => array('publish', 'pending', 'draft', 'expired'),
27 27
 		'default'     => 'draft',
28
-		'context'     => array( 'view', 'edit', 'embed' ),
28
+		'context'     => array('view', 'edit', 'embed'),
29 29
 	),
30 30
 
31 31
 	'version'         => array(
32
-		'description' => __( 'Plugin version when the discount was created.', 'invoicing' ),
32
+		'description' => __('Plugin version when the discount was created.', 'invoicing'),
33 33
 		'type'        => 'string',
34
-		'context'     => array( 'view', 'edit', 'embed' ),
34
+		'context'     => array('view', 'edit', 'embed'),
35 35
 		'readonly'    => true,
36 36
 	),
37 37
 
38 38
 	'date_created'    => array(
39
-		'description' => __( "The date the discount was created, in the site's timezone.", 'invoicing' ),
39
+		'description' => __("The date the discount was created, in the site's timezone.", 'invoicing'),
40 40
 		'type'        => 'string',
41
-		'context'     => array( 'view', 'edit', 'embed' ),
41
+		'context'     => array('view', 'edit', 'embed'),
42 42
 	),
43 43
 
44 44
 	'date_created_gmt'    => array(
45
-		'description' => __( 'The GMT date the discount was created.', 'invoicing' ),
45
+		'description' => __('The GMT date the discount was created.', 'invoicing'),
46 46
 		'type'        => 'string',
47
-		'context'     => array( 'view', 'edit', 'embed' ),
47
+		'context'     => array('view', 'edit', 'embed'),
48 48
 		'readonly'    => true,
49 49
 	),
50 50
 
51 51
 	'date_modified'   => array(
52
-		'description' => __( "The date the discount was last modified, in the site's timezone.", 'invoicing' ),
52
+		'description' => __("The date the discount was last modified, in the site's timezone.", 'invoicing'),
53 53
 		'type'        => 'string',
54
-		'context'     => array( 'view', 'edit', 'embed' ),
54
+		'context'     => array('view', 'edit', 'embed'),
55 55
 		'readonly'    => true,
56 56
 	),
57 57
 
58 58
 	'date_modified_gmt'    => array(
59
-		'description' => __( 'The GMT date the discount was last modified.', 'invoicing' ),
59
+		'description' => __('The GMT date the discount was last modified.', 'invoicing'),
60 60
 		'type'        => 'string',
61
-		'context'     => array( 'view', 'edit', 'embed' ),
61
+		'context'     => array('view', 'edit', 'embed'),
62 62
 		'readonly'    => true,
63 63
 	),
64 64
 
65 65
 	'name'			  => array(
66
-		'description' => __( 'The discount name.', 'invoicing' ),
66
+		'description' => __('The discount name.', 'invoicing'),
67 67
 		'type'        => 'string',
68
-		'context'     => array( 'view', 'edit', 'embed' ),
68
+		'context'     => array('view', 'edit', 'embed'),
69 69
 	),
70 70
 
71 71
 	'description'     => array(
72
-		'description' => __( 'A description of what the discount is all about.', 'invoicing' ),
72
+		'description' => __('A description of what the discount is all about.', 'invoicing'),
73 73
 		'type'        => 'string',
74
-		'context'     => array( 'view', 'edit', 'embed' ),
74
+		'context'     => array('view', 'edit', 'embed'),
75 75
 	),
76 76
 
77 77
 	'code'            => array(
78
-		'description' => __( 'The discount code.', 'invoicing' ),
78
+		'description' => __('The discount code.', 'invoicing'),
79 79
 		'type'        => 'string',
80
-		'context'     => array( 'view', 'edit', 'embed' ),
80
+		'context'     => array('view', 'edit', 'embed'),
81 81
 		'required'	  => true,
82 82
 	),
83 83
 
84 84
 	'type'            => array(
85
-		'description' => __( 'The type of discount.', 'invoicing' ),
85
+		'description' => __('The type of discount.', 'invoicing'),
86 86
 		'type'        => 'string',
87
-		'enum'        => array_keys( wpinv_get_discount_types() ),
88
-		'context'     => array( 'view', 'edit', 'embed' ),
87
+		'enum'        => array_keys(wpinv_get_discount_types()),
88
+		'context'     => array('view', 'edit', 'embed'),
89 89
 		'default'	  => 'percent',
90 90
 	),
91 91
 
92 92
 	'amount'        => array(
93
-		'description' => __( 'The discount value.', 'invoicing' ),
93
+		'description' => __('The discount value.', 'invoicing'),
94 94
 		'type'        => 'number',
95
-		'context'     => array( 'view', 'edit', 'embed' ),
95
+		'context'     => array('view', 'edit', 'embed'),
96 96
 		'required'	  => true,
97 97
 	),
98 98
 
99 99
 	'formatted_amount'        => array(
100
-		'description' => __( 'The formatted discount value.', 'invoicing' ),
100
+		'description' => __('The formatted discount value.', 'invoicing'),
101 101
 		'type'        => 'string',
102
-		'context'     => array( 'view', 'edit', 'embed' ),
102
+		'context'     => array('view', 'edit', 'embed'),
103 103
 		'readonly'    => true,
104 104
 	),
105 105
 
106 106
 	'uses'            => array(
107
-		'description' => __( 'The number of times the discount has been used.', 'invoicing' ),
107
+		'description' => __('The number of times the discount has been used.', 'invoicing'),
108 108
 		'type'        => 'integer',
109
-		'context'     => array( 'view', 'embed' ),
109
+		'context'     => array('view', 'embed'),
110 110
 		'readonly'    => true,
111 111
 	),
112 112
 
113 113
 	'max_uses'        => array(
114
-		'description' => __( 'The maximum number of times the discount can be used.', 'invoicing' ),
114
+		'description' => __('The maximum number of times the discount can be used.', 'invoicing'),
115 115
 		'type'        => 'integer',
116
-		'context'     => array( 'view', 'edit' ),
116
+		'context'     => array('view', 'edit'),
117 117
 	),
118 118
 
119 119
 	'usage'           => array(
120
-		'description' => __( "The discount's usage, i.e uses / max uses.", 'invoicing' ),
120
+		'description' => __("The discount's usage, i.e uses / max uses.", 'invoicing'),
121 121
 		'type'        => 'string',
122
-		'context'     => array( 'view', 'embed' ),
122
+		'context'     => array('view', 'embed'),
123 123
 		'readonly'    => true,
124 124
 	),
125 125
 
126 126
 	'is_single_use'   => array(
127
-		'description' => __( 'Whether or not the discount can only be used once per user.', 'invoicing' ),
127
+		'description' => __('Whether or not the discount can only be used once per user.', 'invoicing'),
128 128
 		'type'        => 'boolean',
129
-		'context'     => array( 'view', 'edit' ),
129
+		'context'     => array('view', 'edit'),
130 130
 	),
131 131
 
132 132
 	'is_recurring'   => array(
133
-		'description' => __( 'Whether or not the discount applies to the initial payment only or all recurring payments.', 'invoicing' ),
133
+		'description' => __('Whether or not the discount applies to the initial payment only or all recurring payments.', 'invoicing'),
134 134
 		'type'        => 'boolean',
135
-		'context'     => array( 'view', 'edit' ),
135
+		'context'     => array('view', 'edit'),
136 136
 	),
137 137
 
138 138
 	'start_date'      => array(
139
-		'description' => __( 'The start date for the discount in the format of yyyy-mm-dd hh:mm:ss. If provided, the discount can only be used after or on this date.', 'invoicing' ),
139
+		'description' => __('The start date for the discount in the format of yyyy-mm-dd hh:mm:ss. If provided, the discount can only be used after or on this date.', 'invoicing'),
140 140
 		'type'        => 'string',
141
-		'context'     => array( 'view', 'edit' ),
141
+		'context'     => array('view', 'edit'),
142 142
 	),
143 143
 
144 144
 	'end_date'        => array(
145
-		'description' => __( 'The expiration date for the discount.', 'invoicing' ),
145
+		'description' => __('The expiration date for the discount.', 'invoicing'),
146 146
 		'type'        => 'string',
147
-		'context'     => array( 'view', 'edit' ),
147
+		'context'     => array('view', 'edit'),
148 148
 	),
149 149
 
150 150
 	'allowed_items'   => array(
151
-		'description' => __( 'Items which are allowed to use this discount. Leave blank to enable for all items.', 'invoicing' ),
151
+		'description' => __('Items which are allowed to use this discount. Leave blank to enable for all items.', 'invoicing'),
152 152
 		'type'        => 'array',
153
-		'context'     => array( 'view', 'edit' ),
153
+		'context'     => array('view', 'edit'),
154 154
 		'items'       => array(
155 155
 			'type'    => 'integer'
156 156
 		)
157 157
 	),
158 158
 
159 159
 	'excluded_items'  => array(
160
-		'description' => __( 'Items which are NOT allowed to use this discount.', 'invoicing' ),
160
+		'description' => __('Items which are NOT allowed to use this discount.', 'invoicing'),
161 161
 		'type'        => 'array',
162
-		'context'     => array( 'view', 'edit' ),
162
+		'context'     => array('view', 'edit'),
163 163
 		'items'       => array(
164 164
 			'type'    => 'integer'
165 165
 		)
166 166
 	),
167 167
 
168 168
 	'required_items'  => array(
169
-		'description' => __( 'Items which are required to be in the cart before using this discount.', 'invoicing' ),
169
+		'description' => __('Items which are required to be in the cart before using this discount.', 'invoicing'),
170 170
 		'type'        => 'array',
171
-		'context'     => array( 'view', 'edit' ),
171
+		'context'     => array('view', 'edit'),
172 172
 		'items'       => array(
173 173
 			'type'    => 'integer'
174 174
 		)
175 175
 	),
176 176
 
177 177
 	'minimum_total'   => array(
178
-		'description' => __( 'The minimum total needed to use this invoice.', 'invoicing' ),
178
+		'description' => __('The minimum total needed to use this invoice.', 'invoicing'),
179 179
 		'type'        => 'number',
180
-		'context'     => array( 'view', 'edit' ),
180
+		'context'     => array('view', 'edit'),
181 181
 	),
182 182
 
183 183
 	'maximum_total'   => array(
184
-		'description' => __( 'The maximum total needed to use this invoice.', 'invoicing' ),
184
+		'description' => __('The maximum total needed to use this invoice.', 'invoicing'),
185 185
 		'type'        => 'number',
186
-		'context'     => array( 'view', 'edit' ),
186
+		'context'     => array('view', 'edit'),
187 187
 	),
188 188
 
189 189
 );
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@
 block discarded – undo
209 209
 						$help_text = '';
210 210
 						//$label_args['class'] .= ' d-inline ';
211 211
 						$args['wrap_class'] .= ' align-items-center ';
212
-					}else{
212
+					} else{
213 213
 
214 214
 					}
215 215
 
Please login to merge, or discard this patch.
Indentation   +1186 added lines, -1186 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,1210 +11,1210 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Input {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function input( $args = array() ) {
22
-		$defaults = array(
23
-			'type'                     => 'text',
24
-			'name'                     => '',
25
-			'class'                    => '',
26
-			'wrap_class'               => '',
27
-			'id'                       => '',
28
-			'placeholder'              => '',
29
-			'title'                    => '',
30
-			'value'                    => '',
31
-			'required'                 => false,
32
-			'label'                    => '',
33
-			'label_after'              => false,
34
-			'label_class'              => '',
35
-			'label_col'                => '2',
36
-			'label_type'               => '',
37
-			'label_force_left'         => false, // used to force checkbox label left when using horizontal
38
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
39
-			'help_text'                => '',
40
-			'validation_text'          => '',
41
-			'validation_pattern'       => '',
42
-			'no_wrap'                  => false,
43
-			'input_group_right'        => '',
44
-			'input_group_left'         => '',
45
-			'input_group_right_inside' => false,
46
-			// forces the input group inside the input
47
-			'input_group_left_inside'  => false,
48
-			// forces the input group inside the input
49
-			'step'                     => '',
50
-			'switch'                   => false,
51
-			// to show checkbox as a switch
52
-			'checked'                  => false,
53
-			// set a checkbox or radio as selected
54
-			'password_toggle'          => true,
55
-			// toggle view/hide password
56
-			'element_require'          => '',
57
-			// [%element_id%] == "1"
58
-			'extra_attributes'         => array(),
59
-			// an array of extra attributes
60
-			'wrap_attributes'          => array()
61
-		);
62
-
63
-		/**
64
-		 * Parse incoming $args into an array and merge it with $defaults
65
-		 */
66
-		$args   = wp_parse_args( $args, $defaults );
67
-		$output = '';
68
-		if ( ! empty( $args['type'] ) ) {
69
-			// hidden label option needs to be empty
70
-			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
71
-
72
-			$type = sanitize_html_class( $args['type'] );
73
-
74
-			$help_text   = '';
75
-			$label       = '';
76
-			$label_after = $args['label_after'];
77
-			$label_args  = array(
78
-				'title'      => $args['label'],
79
-				'for'        => $args['id'],
80
-				'class'      => $args['label_class'] . " ",
81
-				'label_type' => $args['label_type'],
82
-				'label_col'  => $args['label_col']
83
-			);
84
-
85
-			// floating labels need label after
86
-			if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
87
-				$label_after         = true;
88
-				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
89
-			}
90
-
91
-			// Some special sauce for files
92
-			if ( $type == 'file' ) {
93
-				$label_after = true; // if type file we need the label after
94
-				$args['class'] .= ' custom-file-input ';
95
-			} elseif ( $type == 'checkbox' ) {
96
-				$label_after = true; // if type file we need the label after
97
-				$args['class'] .= ' custom-control-input ';
98
-			} elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
99
-				$type = 'text';
100
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
101
-				$args['class'] .= ' bg-initial ';
102
-
103
-				$args['extra_attributes']['data-aui-init'] = 'flatpickr';
104
-				// enqueue the script
105
-				$aui_settings = AyeCode_UI_Settings::instance();
106
-				$aui_settings->enqueue_flatpickr();
107
-			} elseif ( $type == 'iconpicker' ) {
108
-				$type = 'text';
109
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function input( $args = array() ) {
22
+        $defaults = array(
23
+            'type'                     => 'text',
24
+            'name'                     => '',
25
+            'class'                    => '',
26
+            'wrap_class'               => '',
27
+            'id'                       => '',
28
+            'placeholder'              => '',
29
+            'title'                    => '',
30
+            'value'                    => '',
31
+            'required'                 => false,
32
+            'label'                    => '',
33
+            'label_after'              => false,
34
+            'label_class'              => '',
35
+            'label_col'                => '2',
36
+            'label_type'               => '',
37
+            'label_force_left'         => false, // used to force checkbox label left when using horizontal
38
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
39
+            'help_text'                => '',
40
+            'validation_text'          => '',
41
+            'validation_pattern'       => '',
42
+            'no_wrap'                  => false,
43
+            'input_group_right'        => '',
44
+            'input_group_left'         => '',
45
+            'input_group_right_inside' => false,
46
+            // forces the input group inside the input
47
+            'input_group_left_inside'  => false,
48
+            // forces the input group inside the input
49
+            'step'                     => '',
50
+            'switch'                   => false,
51
+            // to show checkbox as a switch
52
+            'checked'                  => false,
53
+            // set a checkbox or radio as selected
54
+            'password_toggle'          => true,
55
+            // toggle view/hide password
56
+            'element_require'          => '',
57
+            // [%element_id%] == "1"
58
+            'extra_attributes'         => array(),
59
+            // an array of extra attributes
60
+            'wrap_attributes'          => array()
61
+        );
62
+
63
+        /**
64
+         * Parse incoming $args into an array and merge it with $defaults
65
+         */
66
+        $args   = wp_parse_args( $args, $defaults );
67
+        $output = '';
68
+        if ( ! empty( $args['type'] ) ) {
69
+            // hidden label option needs to be empty
70
+            $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
71
+
72
+            $type = sanitize_html_class( $args['type'] );
73
+
74
+            $help_text   = '';
75
+            $label       = '';
76
+            $label_after = $args['label_after'];
77
+            $label_args  = array(
78
+                'title'      => $args['label'],
79
+                'for'        => $args['id'],
80
+                'class'      => $args['label_class'] . " ",
81
+                'label_type' => $args['label_type'],
82
+                'label_col'  => $args['label_col']
83
+            );
84
+
85
+            // floating labels need label after
86
+            if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
87
+                $label_after         = true;
88
+                $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
89
+            }
90
+
91
+            // Some special sauce for files
92
+            if ( $type == 'file' ) {
93
+                $label_after = true; // if type file we need the label after
94
+                $args['class'] .= ' custom-file-input ';
95
+            } elseif ( $type == 'checkbox' ) {
96
+                $label_after = true; // if type file we need the label after
97
+                $args['class'] .= ' custom-control-input ';
98
+            } elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
99
+                $type = 'text';
100
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
101
+                $args['class'] .= ' bg-initial ';
102
+
103
+                $args['extra_attributes']['data-aui-init'] = 'flatpickr';
104
+                // enqueue the script
105
+                $aui_settings = AyeCode_UI_Settings::instance();
106
+                $aui_settings->enqueue_flatpickr();
107
+            } elseif ( $type == 'iconpicker' ) {
108
+                $type = 'text';
109
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
110 110
 //				$args['class'] .= ' bg-initial ';
111 111
 
112
-				$args['extra_attributes']['data-aui-init'] = 'iconpicker';
113
-				$args['extra_attributes']['data-placement'] = 'bottomRight';
112
+                $args['extra_attributes']['data-aui-init'] = 'iconpicker';
113
+                $args['extra_attributes']['data-placement'] = 'bottomRight';
114 114
 
115
-				$args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>';
115
+                $args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>';
116 116
 //				$args['input_group_right_inside'] = true;
117
-				// enqueue the script
118
-				$aui_settings = AyeCode_UI_Settings::instance();
119
-				$aui_settings->enqueue_iconpicker();
120
-			}
121
-
122
-			if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) {
123
-				$output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
124
-			}
125
-
126
-
127
-			// open/type
128
-			$output .= '<input type="' . $type . '" ';
129
-
130
-			// name
131
-			if ( ! empty( $args['name'] ) ) {
132
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
133
-			}
134
-
135
-			// id
136
-			if ( ! empty( $args['id'] ) ) {
137
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
138
-			}
139
-
140
-			// placeholder
141
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
142
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
143
-			}
144
-
145
-			// title
146
-			if ( ! empty( $args['title'] ) ) {
147
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
148
-			}
149
-
150
-			// value
151
-			if ( ! empty( $args['value'] ) ) {
152
-				$output .= AUI_Component_Helper::value( $args['value'] );
153
-			}
154
-
155
-			// checked, for radio and checkboxes
156
-			if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
157
-				$output .= ' checked ';
158
-			}
159
-
160
-			// validation text
161
-			if ( ! empty( $args['validation_text'] ) ) {
162
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
163
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
164
-			}
165
-
166
-			// validation_pattern
167
-			if ( ! empty( $args['validation_pattern'] ) ) {
168
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
169
-			}
170
-
171
-			// step (for numbers)
172
-			if ( ! empty( $args['step'] ) ) {
173
-				$output .= ' step="' . $args['step'] . '" ';
174
-			}
175
-
176
-			// required
177
-			if ( ! empty( $args['required'] ) ) {
178
-				$output .= ' required ';
179
-			}
180
-
181
-			// class
182
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
183
-			$output .= ' class="form-control ' . $class . '" ';
184
-
185
-			// data-attributes
186
-			$output .= AUI_Component_Helper::data_attributes( $args );
187
-
188
-			// extra attributes
189
-			if ( ! empty( $args['extra_attributes'] ) ) {
190
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
191
-			}
192
-
193
-			// close
194
-			$output .= ' >';
195
-
196
-			// help text
197
-			if ( ! empty( $args['help_text'] ) ) {
198
-				$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
199
-			}
200
-
201
-			// label
202
-			if ( ! empty( $args['label'] ) ) {
203
-				$label_base_class = '';
204
-				if ( $type == 'file' ) {
205
-					$label_base_class = ' custom-file-label';
206
-				} elseif ( $type == 'checkbox' ) {
207
-					if ( ! empty( $args['label_force_left'] ) ) {
208
-						$label_args['title'] = wp_kses_post( $args['help_text'] );
209
-						$help_text = '';
210
-						//$label_args['class'] .= ' d-inline ';
211
-						$args['wrap_class'] .= ' align-items-center ';
212
-					}else{
213
-
214
-					}
215
-
216
-					$label_base_class = ' custom-control-label';
217
-				}
218
-				$label_args['class'] .= $label_base_class;
219
-				$temp_label_args = $label_args;
220
-				if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
221
-				$label = self::label( $temp_label_args, $type );
222
-			}
223
-
224
-
225
-
226
-
227
-			// set help text in the correct position
228
-			if ( $label_after ) {
229
-				$output .= $label . $help_text;
230
-			}
231
-
232
-			// some input types need a separate wrap
233
-			if ( $type == 'file' ) {
234
-				$output = self::wrap( array(
235
-					'content' => $output,
236
-					'class'   => 'form-group custom-file'
237
-				) );
238
-			} elseif ( $type == 'checkbox' ) {
239
-
240
-				$label_args['title'] = $args['label'];
241
-				$label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
242
-				$label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
243
-				$switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
244
-				$wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox';
245
-				if ( ! empty( $args['label_force_left'] ) ) {
246
-					$wrap_class .= ' d-flex align-content-center';
247
-					$label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) );
248
-				}
249
-				$output     = self::wrap( array(
250
-					'content' => $output,
251
-					'class'   => 'custom-control ' . $wrap_class
252
-				) );
253
-
254
-				if ( $args['label_type'] == 'horizontal' ) {
255
-					$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
256
-					$output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
257
-				}
258
-			} elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
259
-
260
-
261
-				// allow password field to toggle view
262
-				$args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
117
+                // enqueue the script
118
+                $aui_settings = AyeCode_UI_Settings::instance();
119
+                $aui_settings->enqueue_iconpicker();
120
+            }
121
+
122
+            if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) {
123
+                $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
124
+            }
125
+
126
+
127
+            // open/type
128
+            $output .= '<input type="' . $type . '" ';
129
+
130
+            // name
131
+            if ( ! empty( $args['name'] ) ) {
132
+                $output .= ' name="' . esc_attr( $args['name'] ) . '" ';
133
+            }
134
+
135
+            // id
136
+            if ( ! empty( $args['id'] ) ) {
137
+                $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
138
+            }
139
+
140
+            // placeholder
141
+            if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
142
+                $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
143
+            }
144
+
145
+            // title
146
+            if ( ! empty( $args['title'] ) ) {
147
+                $output .= ' title="' . esc_attr( $args['title'] ) . '" ';
148
+            }
149
+
150
+            // value
151
+            if ( ! empty( $args['value'] ) ) {
152
+                $output .= AUI_Component_Helper::value( $args['value'] );
153
+            }
154
+
155
+            // checked, for radio and checkboxes
156
+            if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
157
+                $output .= ' checked ';
158
+            }
159
+
160
+            // validation text
161
+            if ( ! empty( $args['validation_text'] ) ) {
162
+                $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
163
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
164
+            }
165
+
166
+            // validation_pattern
167
+            if ( ! empty( $args['validation_pattern'] ) ) {
168
+                $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
169
+            }
170
+
171
+            // step (for numbers)
172
+            if ( ! empty( $args['step'] ) ) {
173
+                $output .= ' step="' . $args['step'] . '" ';
174
+            }
175
+
176
+            // required
177
+            if ( ! empty( $args['required'] ) ) {
178
+                $output .= ' required ';
179
+            }
180
+
181
+            // class
182
+            $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
183
+            $output .= ' class="form-control ' . $class . '" ';
184
+
185
+            // data-attributes
186
+            $output .= AUI_Component_Helper::data_attributes( $args );
187
+
188
+            // extra attributes
189
+            if ( ! empty( $args['extra_attributes'] ) ) {
190
+                $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
191
+            }
192
+
193
+            // close
194
+            $output .= ' >';
195
+
196
+            // help text
197
+            if ( ! empty( $args['help_text'] ) ) {
198
+                $help_text = AUI_Component_Helper::help_text( $args['help_text'] );
199
+            }
200
+
201
+            // label
202
+            if ( ! empty( $args['label'] ) ) {
203
+                $label_base_class = '';
204
+                if ( $type == 'file' ) {
205
+                    $label_base_class = ' custom-file-label';
206
+                } elseif ( $type == 'checkbox' ) {
207
+                    if ( ! empty( $args['label_force_left'] ) ) {
208
+                        $label_args['title'] = wp_kses_post( $args['help_text'] );
209
+                        $help_text = '';
210
+                        //$label_args['class'] .= ' d-inline ';
211
+                        $args['wrap_class'] .= ' align-items-center ';
212
+                    }else{
213
+
214
+                    }
215
+
216
+                    $label_base_class = ' custom-control-label';
217
+                }
218
+                $label_args['class'] .= $label_base_class;
219
+                $temp_label_args = $label_args;
220
+                if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
221
+                $label = self::label( $temp_label_args, $type );
222
+            }
223
+
224
+
225
+
226
+
227
+            // set help text in the correct position
228
+            if ( $label_after ) {
229
+                $output .= $label . $help_text;
230
+            }
231
+
232
+            // some input types need a separate wrap
233
+            if ( $type == 'file' ) {
234
+                $output = self::wrap( array(
235
+                    'content' => $output,
236
+                    'class'   => 'form-group custom-file'
237
+                ) );
238
+            } elseif ( $type == 'checkbox' ) {
239
+
240
+                $label_args['title'] = $args['label'];
241
+                $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
242
+                $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
243
+                $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
244
+                $wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox';
245
+                if ( ! empty( $args['label_force_left'] ) ) {
246
+                    $wrap_class .= ' d-flex align-content-center';
247
+                    $label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) );
248
+                }
249
+                $output     = self::wrap( array(
250
+                    'content' => $output,
251
+                    'class'   => 'custom-control ' . $wrap_class
252
+                ) );
253
+
254
+                if ( $args['label_type'] == 'horizontal' ) {
255
+                    $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
256
+                    $output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
257
+                }
258
+            } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
259
+
260
+
261
+                // allow password field to toggle view
262
+                $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
263 263
 onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\');
264 264
 var $eli = jQuery(this).parent().parent().find(\'input\');
265 265
 if($el.hasClass(\'fa-eye\'))
266 266
 {$eli.attr(\'type\',\'text\');}
267 267
 else{$eli.attr(\'type\',\'password\');}"
268 268
 ><i class="far fa-fw fa-eye-slash"></i></span>';
269
-			}
270
-
271
-			// input group wraps
272
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
273
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
274
-				if ( $args['input_group_left'] ) {
275
-					$output = self::wrap( array(
276
-						'content'                 => $output,
277
-						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
278
-						'input_group_left'        => $args['input_group_left'],
279
-						'input_group_left_inside' => $args['input_group_left_inside']
280
-					) );
281
-				}
282
-				if ( $args['input_group_right'] ) {
283
-					$output = self::wrap( array(
284
-						'content'                  => $output,
285
-						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
286
-						'input_group_right'        => $args['input_group_right'],
287
-						'input_group_right_inside' => $args['input_group_right_inside']
288
-					) );
289
-				}
290
-
291
-			}
292
-
293
-			if ( ! $label_after ) {
294
-				$output .= $help_text;
295
-			}
296
-
297
-
298
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
299
-				$output = self::wrap( array(
300
-					'content' => $output,
301
-					'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
302
-				) );
303
-			}
304
-
305
-			if ( ! $label_after ) {
306
-				$output = $label . $output;
307
-			}
308
-
309
-			// wrap
310
-			if ( ! $args['no_wrap'] ) {
311
-				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
312
-				$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
313
-				$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
-				$output           = self::wrap( array(
315
-					'content'         => $output,
316
-					'class'           => $wrap_class,
317
-					'element_require' => $args['element_require'],
318
-					'argument_id'     => $args['id'],
319
-					'wrap_attributes' => $args['wrap_attributes'],
320
-				) );
321
-			}
322
-		}
323
-
324
-		return $output;
325
-	}
326
-
327
-	public static function label( $args = array(), $type = '' ) {
328
-		//<label for="exampleInputEmail1">Email address</label>
329
-		$defaults = array(
330
-			'title'      => 'div',
331
-			'for'        => '',
332
-			'class'      => '',
333
-			'label_type' => '', // empty = hidden, top, horizontal
334
-			'label_col'  => '',
335
-		);
336
-
337
-		/**
338
-		 * Parse incoming $args into an array and merge it with $defaults
339
-		 */
340
-		$args   = wp_parse_args( $args, $defaults );
341
-		$output = '';
342
-
343
-		if ( $args['title'] ) {
344
-
345
-			// maybe hide labels //@todo set a global option for visibility class
346
-			if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
347
-				$class = $args['class'];
348
-			} else {
349
-				$class = 'sr-only ' . $args['class'];
350
-			}
351
-
352
-			// maybe horizontal
353
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
354
-				$class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label';
355
-			}
356
-
357
-			// open
358
-			$output .= '<label ';
359
-
360
-			// for
361
-			if ( ! empty( $args['for'] ) ) {
362
-				$output .= ' for="' . esc_attr( $args['for'] ) . '" ';
363
-			}
364
-
365
-			// class
366
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
367
-			$output .= ' class="' . $class . '" ';
368
-
369
-			// close
370
-			$output .= '>';
371
-
372
-
373
-			// title, don't escape fully as can contain html
374
-			if ( ! empty( $args['title'] ) ) {
375
-				$output .= wp_kses_post( $args['title'] );
376
-			}
377
-
378
-			// close wrap
379
-			$output .= '</label>';
380
-
381
-
382
-		}
383
-
384
-
385
-		return $output;
386
-	}
387
-
388
-	/**
389
-	 * Wrap some content in a HTML wrapper.
390
-	 *
391
-	 * @param array $args
392
-	 *
393
-	 * @return string
394
-	 */
395
-	public static function wrap( $args = array() ) {
396
-		$defaults = array(
397
-			'type'                     => 'div',
398
-			'class'                    => 'form-group',
399
-			'content'                  => '',
400
-			'input_group_left'         => '',
401
-			'input_group_right'        => '',
402
-			'input_group_left_inside'  => false,
403
-			'input_group_right_inside' => false,
404
-			'element_require'          => '',
405
-			'argument_id'              => '',
406
-			'wrap_attributes'          => array()
407
-		);
408
-
409
-		/**
410
-		 * Parse incoming $args into an array and merge it with $defaults
411
-		 */
412
-		$args   = wp_parse_args( $args, $defaults );
413
-		$output = '';
414
-		if ( $args['type'] ) {
415
-
416
-			// open
417
-			$output .= '<' . sanitize_html_class( $args['type'] );
418
-
419
-			// element require
420
-			if ( ! empty( $args['element_require'] ) ) {
421
-				$output .= AUI_Component_Helper::element_require( $args['element_require'] );
422
-				$args['class'] .= " aui-conditional-field";
423
-			}
424
-
425
-			// argument_id
426
-			if ( ! empty( $args['argument_id'] ) ) {
427
-				$output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
428
-			}
429
-
430
-			// class
431
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
432
-			$output .= ' class="' . $class . '" ';
433
-
434
-			// Attributes
435
-			if ( ! empty( $args['wrap_attributes'] ) ) {
436
-				$output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
437
-			}
438
-
439
-			// close wrap
440
-			$output .= ' >';
441
-
442
-
443
-			// Input group left
444
-			if ( ! empty( $args['input_group_left'] ) ) {
445
-				$position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
446
-				$input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
447
-				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
448
-			}
449
-
450
-			// content
451
-			$output .= $args['content'];
452
-
453
-			// Input group right
454
-			if ( ! empty( $args['input_group_right'] ) ) {
455
-				$position_class    = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
456
-				$input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
457
-				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
458
-			}
459
-
460
-
461
-			// close wrap
462
-			$output .= '</' . sanitize_html_class( $args['type'] ) . '>';
463
-
464
-
465
-		} else {
466
-			$output = $args['content'];
467
-		}
468
-
469
-		return $output;
470
-	}
471
-
472
-	/**
473
-	 * Build the component.
474
-	 *
475
-	 * @param array $args
476
-	 *
477
-	 * @return string The rendered component.
478
-	 */
479
-	public static function textarea( $args = array() ) {
480
-		$defaults = array(
481
-			'name'               => '',
482
-			'class'              => '',
483
-			'wrap_class'         => '',
484
-			'id'                 => '',
485
-			'placeholder'        => '',
486
-			'title'              => '',
487
-			'value'              => '',
488
-			'required'           => false,
489
-			'label'              => '',
490
-			'label_after'        => false,
491
-			'label_class'        => '',
492
-			'label_type'         => '',
493
-			'label_col'          => '',
494
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
495
-			'input_group_right'        => '',
496
-			'input_group_left'         => '',
497
-			'input_group_right_inside' => false,
498
-			'help_text'          => '',
499
-			'validation_text'    => '',
500
-			'validation_pattern' => '',
501
-			'no_wrap'            => false,
502
-			'rows'               => '',
503
-			'wysiwyg'            => false,
504
-			'allow_tags'         => false,
505
-			// Allow HTML tags
506
-			'element_require'    => '',
507
-			// [%element_id%] == "1"
508
-			'extra_attributes'   => array(),
509
-			// an array of extra attributes
510
-			'wrap_attributes'    => array(),
511
-		);
512
-
513
-		/**
514
-		 * Parse incoming $args into an array and merge it with $defaults
515
-		 */
516
-		$args   = wp_parse_args( $args, $defaults );
517
-		$output = '';
518
-
519
-		// hidden label option needs to be empty
520
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
521
-
522
-		// floating labels don't work with wysiwyg so set it as top
523
-		if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
524
-			$args['label_type'] = 'top';
525
-		}
526
-
527
-		$label_after = $args['label_after'];
528
-
529
-		// floating labels need label after
530
-		if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
531
-			$label_after         = true;
532
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
533
-		}
534
-
535
-		// label
536
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
537
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
538
-			$label_args = array(
539
-				'title'      => $args['label'],
540
-				'for'        => $args['id'],
541
-				'class'      => $args['label_class'] . " ",
542
-				'label_type' => $args['label_type'],
543
-				'label_col'  => $args['label_col']
544
-			);
545
-			$output .= self::label( $label_args );
546
-		}
547
-
548
-		// maybe horizontal label
549
-		if ( $args['label_type'] == 'horizontal' ) {
550
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
551
-			$output .= '<div class="' . $input_col . '">';
552
-		}
553
-
554
-		if ( ! empty( $args['wysiwyg'] ) ) {
555
-			ob_start();
556
-			$content   = $args['value'];
557
-			$editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
558
-			$settings  = array(
559
-				'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
560
-				'quicktags'     => false,
561
-				'media_buttons' => false,
562
-				'editor_class'  => 'form-control',
563
-				'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
564
-				'teeny'         => true,
565
-			);
566
-
567
-			// maybe set settings if array
568
-			if ( is_array( $args['wysiwyg'] ) ) {
569
-				$settings = wp_parse_args( $args['wysiwyg'], $settings );
570
-			}
571
-
572
-			wp_editor( $content, $editor_id, $settings );
573
-			$output .= ob_get_clean();
574
-		} else {
575
-
576
-			// open
577
-			$output .= '<textarea ';
578
-
579
-			// name
580
-			if ( ! empty( $args['name'] ) ) {
581
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
582
-			}
583
-
584
-			// id
585
-			if ( ! empty( $args['id'] ) ) {
586
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
587
-			}
588
-
589
-			// placeholder
590
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
591
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
592
-			}
593
-
594
-			// title
595
-			if ( ! empty( $args['title'] ) ) {
596
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
597
-			}
598
-
599
-			// validation text
600
-			if ( ! empty( $args['validation_text'] ) ) {
601
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
602
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
603
-			}
604
-
605
-			// validation_pattern
606
-			if ( ! empty( $args['validation_pattern'] ) ) {
607
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
608
-			}
609
-
610
-			// required
611
-			if ( ! empty( $args['required'] ) ) {
612
-				$output .= ' required ';
613
-			}
614
-
615
-			// rows
616
-			if ( ! empty( $args['rows'] ) ) {
617
-				$output .= ' rows="' . absint( $args['rows'] ) . '" ';
618
-			}
619
-
620
-
621
-			// class
622
-			$class = ! empty( $args['class'] ) ? $args['class'] : '';
623
-			$output .= ' class="form-control ' . $class . '" ';
624
-
625
-			// extra attributes
626
-			if ( ! empty( $args['extra_attributes'] ) ) {
627
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
628
-			}
629
-
630
-			// close tag
631
-			$output .= ' >';
632
-
633
-			// value
634
-			if ( ! empty( $args['value'] ) ) {
635
-				if ( ! empty( $args['allow_tags'] ) ) {
636
-					$output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
637
-				} else {
638
-					$output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] );
639
-				}
640
-			}
641
-
642
-			// closing tag
643
-			$output .= '</textarea>';
644
-
645
-
646
-			// input group wraps
647
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
648
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
649
-				if ( $args['input_group_left'] ) {
650
-					$output = self::wrap( array(
651
-						'content'                 => $output,
652
-						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
653
-						'input_group_left'        => $args['input_group_left'],
654
-						'input_group_left_inside' => $args['input_group_left_inside']
655
-					) );
656
-				}
657
-				if ( $args['input_group_right'] ) {
658
-					$output = self::wrap( array(
659
-						'content'                  => $output,
660
-						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
661
-						'input_group_right'        => $args['input_group_right'],
662
-						'input_group_right_inside' => $args['input_group_right_inside']
663
-					) );
664
-				}
665
-
666
-			}
667
-
668
-
669
-		}
670
-
671
-		if ( ! empty( $args['label'] ) && $label_after ) {
672
-			$label_args = array(
673
-				'title'      => $args['label'],
674
-				'for'        => $args['id'],
675
-				'class'      => $args['label_class'] . " ",
676
-				'label_type' => $args['label_type'],
677
-				'label_col'  => $args['label_col']
678
-			);
679
-			$output .= self::label( $label_args );
680
-		}
681
-
682
-		// help text
683
-		if ( ! empty( $args['help_text'] ) ) {
684
-			$output .= AUI_Component_Helper::help_text( $args['help_text'] );
685
-		}
686
-
687
-		// maybe horizontal label
688
-		if ( $args['label_type'] == 'horizontal' ) {
689
-			$output .= '</div>';
690
-		}
691
-
692
-
693
-		// wrap
694
-		if ( ! $args['no_wrap'] ) {
695
-			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
696
-			$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
697
-			$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
698
-			$output           = self::wrap( array(
699
-				'content'         => $output,
700
-				'class'           => $wrap_class,
701
-				'element_require' => $args['element_require'],
702
-				'argument_id'     => $args['id'],
703
-				'wrap_attributes' => $args['wrap_attributes'],
704
-			) );
705
-		}
706
-
707
-
708
-		return $output;
709
-	}
710
-
711
-	/**
712
-	 * Build the component.
713
-	 *
714
-	 * @param array $args
715
-	 *
716
-	 * @return string The rendered component.
717
-	 */
718
-	public static function select( $args = array() ) {
719
-		$defaults = array(
720
-			'class'            => '',
721
-			'wrap_class'       => '',
722
-			'id'               => '',
723
-			'title'            => '',
724
-			'value'            => '',
725
-			// can be an array or a string
726
-			'required'         => false,
727
-			'label'            => '',
728
-			'label_after'      => false,
729
-			'label_type'       => '',
730
-			'label_col'        => '',
731
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
732
-			'label_class'      => '',
733
-			'help_text'        => '',
734
-			'placeholder'      => '',
735
-			'options'          => array(),
736
-			// array or string
737
-			'icon'             => '',
738
-			'multiple'         => false,
739
-			'select2'          => false,
740
-			'no_wrap'          => false,
741
-			'input_group_right' => '',
742
-			'input_group_left' => '',
743
-			'input_group_right_inside' => false, // forces the input group inside the input
744
-			'input_group_left_inside' => false, // forces the input group inside the input
745
-			'element_require'  => '',
746
-			// [%element_id%] == "1"
747
-			'extra_attributes' => array(),
748
-			// an array of extra attributes
749
-			'wrap_attributes'  => array(),
750
-		);
751
-
752
-		/**
753
-		 * Parse incoming $args into an array and merge it with $defaults
754
-		 */
755
-		$args   = wp_parse_args( $args, $defaults );
756
-		$output = '';
757
-
758
-		// for now lets hide floating labels
759
-		if ( $args['label_type'] == 'floating' ) {
760
-			$args['label_type'] = 'hidden';
761
-		}
762
-
763
-		// hidden label option needs to be empty
764
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
765
-
766
-
767
-		$label_after = $args['label_after'];
768
-
769
-		// floating labels need label after
770
-		if ( $args['label_type'] == 'floating' ) {
771
-			$label_after         = true;
772
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
773
-		}
774
-
775
-		// Maybe setup select2
776
-		$is_select2 = false;
777
-		if ( ! empty( $args['select2'] ) ) {
778
-			$args['class'] .= ' aui-select2';
779
-			$is_select2 = true;
780
-		} elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
781
-			$is_select2 = true;
782
-		}
783
-
784
-		// select2 tags
785
-		if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
786
-			$args['data-tags']             = 'true';
787
-			$args['data-token-separators'] = "[',']";
788
-			$args['multiple']              = true;
789
-		}
790
-
791
-		// select2 placeholder
792
-		if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
793
-			$args['data-placeholder'] = esc_attr( $args['placeholder'] );
794
-			$args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
795
-		}
796
-
797
-
798
-
799
-		// maybe horizontal label
269
+            }
270
+
271
+            // input group wraps
272
+            if ( $args['input_group_left'] || $args['input_group_right'] ) {
273
+                $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
274
+                if ( $args['input_group_left'] ) {
275
+                    $output = self::wrap( array(
276
+                        'content'                 => $output,
277
+                        'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
278
+                        'input_group_left'        => $args['input_group_left'],
279
+                        'input_group_left_inside' => $args['input_group_left_inside']
280
+                    ) );
281
+                }
282
+                if ( $args['input_group_right'] ) {
283
+                    $output = self::wrap( array(
284
+                        'content'                  => $output,
285
+                        'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
286
+                        'input_group_right'        => $args['input_group_right'],
287
+                        'input_group_right_inside' => $args['input_group_right_inside']
288
+                    ) );
289
+                }
290
+
291
+            }
292
+
293
+            if ( ! $label_after ) {
294
+                $output .= $help_text;
295
+            }
296
+
297
+
298
+            if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
299
+                $output = self::wrap( array(
300
+                    'content' => $output,
301
+                    'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
302
+                ) );
303
+            }
304
+
305
+            if ( ! $label_after ) {
306
+                $output = $label . $output;
307
+            }
308
+
309
+            // wrap
310
+            if ( ! $args['no_wrap'] ) {
311
+                $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
312
+                $wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
313
+                $wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
+                $output           = self::wrap( array(
315
+                    'content'         => $output,
316
+                    'class'           => $wrap_class,
317
+                    'element_require' => $args['element_require'],
318
+                    'argument_id'     => $args['id'],
319
+                    'wrap_attributes' => $args['wrap_attributes'],
320
+                ) );
321
+            }
322
+        }
323
+
324
+        return $output;
325
+    }
326
+
327
+    public static function label( $args = array(), $type = '' ) {
328
+        //<label for="exampleInputEmail1">Email address</label>
329
+        $defaults = array(
330
+            'title'      => 'div',
331
+            'for'        => '',
332
+            'class'      => '',
333
+            'label_type' => '', // empty = hidden, top, horizontal
334
+            'label_col'  => '',
335
+        );
336
+
337
+        /**
338
+         * Parse incoming $args into an array and merge it with $defaults
339
+         */
340
+        $args   = wp_parse_args( $args, $defaults );
341
+        $output = '';
342
+
343
+        if ( $args['title'] ) {
344
+
345
+            // maybe hide labels //@todo set a global option for visibility class
346
+            if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
347
+                $class = $args['class'];
348
+            } else {
349
+                $class = 'sr-only ' . $args['class'];
350
+            }
351
+
352
+            // maybe horizontal
353
+            if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
354
+                $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label';
355
+            }
356
+
357
+            // open
358
+            $output .= '<label ';
359
+
360
+            // for
361
+            if ( ! empty( $args['for'] ) ) {
362
+                $output .= ' for="' . esc_attr( $args['for'] ) . '" ';
363
+            }
364
+
365
+            // class
366
+            $class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
367
+            $output .= ' class="' . $class . '" ';
368
+
369
+            // close
370
+            $output .= '>';
371
+
372
+
373
+            // title, don't escape fully as can contain html
374
+            if ( ! empty( $args['title'] ) ) {
375
+                $output .= wp_kses_post( $args['title'] );
376
+            }
377
+
378
+            // close wrap
379
+            $output .= '</label>';
380
+
381
+
382
+        }
383
+
384
+
385
+        return $output;
386
+    }
387
+
388
+    /**
389
+     * Wrap some content in a HTML wrapper.
390
+     *
391
+     * @param array $args
392
+     *
393
+     * @return string
394
+     */
395
+    public static function wrap( $args = array() ) {
396
+        $defaults = array(
397
+            'type'                     => 'div',
398
+            'class'                    => 'form-group',
399
+            'content'                  => '',
400
+            'input_group_left'         => '',
401
+            'input_group_right'        => '',
402
+            'input_group_left_inside'  => false,
403
+            'input_group_right_inside' => false,
404
+            'element_require'          => '',
405
+            'argument_id'              => '',
406
+            'wrap_attributes'          => array()
407
+        );
408
+
409
+        /**
410
+         * Parse incoming $args into an array and merge it with $defaults
411
+         */
412
+        $args   = wp_parse_args( $args, $defaults );
413
+        $output = '';
414
+        if ( $args['type'] ) {
415
+
416
+            // open
417
+            $output .= '<' . sanitize_html_class( $args['type'] );
418
+
419
+            // element require
420
+            if ( ! empty( $args['element_require'] ) ) {
421
+                $output .= AUI_Component_Helper::element_require( $args['element_require'] );
422
+                $args['class'] .= " aui-conditional-field";
423
+            }
424
+
425
+            // argument_id
426
+            if ( ! empty( $args['argument_id'] ) ) {
427
+                $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
428
+            }
429
+
430
+            // class
431
+            $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
432
+            $output .= ' class="' . $class . '" ';
433
+
434
+            // Attributes
435
+            if ( ! empty( $args['wrap_attributes'] ) ) {
436
+                $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
437
+            }
438
+
439
+            // close wrap
440
+            $output .= ' >';
441
+
442
+
443
+            // Input group left
444
+            if ( ! empty( $args['input_group_left'] ) ) {
445
+                $position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
446
+                $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
447
+                $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
448
+            }
449
+
450
+            // content
451
+            $output .= $args['content'];
452
+
453
+            // Input group right
454
+            if ( ! empty( $args['input_group_right'] ) ) {
455
+                $position_class    = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
456
+                $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
457
+                $output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
458
+            }
459
+
460
+
461
+            // close wrap
462
+            $output .= '</' . sanitize_html_class( $args['type'] ) . '>';
463
+
464
+
465
+        } else {
466
+            $output = $args['content'];
467
+        }
468
+
469
+        return $output;
470
+    }
471
+
472
+    /**
473
+     * Build the component.
474
+     *
475
+     * @param array $args
476
+     *
477
+     * @return string The rendered component.
478
+     */
479
+    public static function textarea( $args = array() ) {
480
+        $defaults = array(
481
+            'name'               => '',
482
+            'class'              => '',
483
+            'wrap_class'         => '',
484
+            'id'                 => '',
485
+            'placeholder'        => '',
486
+            'title'              => '',
487
+            'value'              => '',
488
+            'required'           => false,
489
+            'label'              => '',
490
+            'label_after'        => false,
491
+            'label_class'        => '',
492
+            'label_type'         => '',
493
+            'label_col'          => '',
494
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
495
+            'input_group_right'        => '',
496
+            'input_group_left'         => '',
497
+            'input_group_right_inside' => false,
498
+            'help_text'          => '',
499
+            'validation_text'    => '',
500
+            'validation_pattern' => '',
501
+            'no_wrap'            => false,
502
+            'rows'               => '',
503
+            'wysiwyg'            => false,
504
+            'allow_tags'         => false,
505
+            // Allow HTML tags
506
+            'element_require'    => '',
507
+            // [%element_id%] == "1"
508
+            'extra_attributes'   => array(),
509
+            // an array of extra attributes
510
+            'wrap_attributes'    => array(),
511
+        );
512
+
513
+        /**
514
+         * Parse incoming $args into an array and merge it with $defaults
515
+         */
516
+        $args   = wp_parse_args( $args, $defaults );
517
+        $output = '';
518
+
519
+        // hidden label option needs to be empty
520
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
521
+
522
+        // floating labels don't work with wysiwyg so set it as top
523
+        if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
524
+            $args['label_type'] = 'top';
525
+        }
526
+
527
+        $label_after = $args['label_after'];
528
+
529
+        // floating labels need label after
530
+        if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
531
+            $label_after         = true;
532
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
533
+        }
534
+
535
+        // label
536
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
537
+        } elseif ( ! empty( $args['label'] ) && ! $label_after ) {
538
+            $label_args = array(
539
+                'title'      => $args['label'],
540
+                'for'        => $args['id'],
541
+                'class'      => $args['label_class'] . " ",
542
+                'label_type' => $args['label_type'],
543
+                'label_col'  => $args['label_col']
544
+            );
545
+            $output .= self::label( $label_args );
546
+        }
547
+
548
+        // maybe horizontal label
549
+        if ( $args['label_type'] == 'horizontal' ) {
550
+            $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
551
+            $output .= '<div class="' . $input_col . '">';
552
+        }
553
+
554
+        if ( ! empty( $args['wysiwyg'] ) ) {
555
+            ob_start();
556
+            $content   = $args['value'];
557
+            $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
558
+            $settings  = array(
559
+                'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
560
+                'quicktags'     => false,
561
+                'media_buttons' => false,
562
+                'editor_class'  => 'form-control',
563
+                'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
564
+                'teeny'         => true,
565
+            );
566
+
567
+            // maybe set settings if array
568
+            if ( is_array( $args['wysiwyg'] ) ) {
569
+                $settings = wp_parse_args( $args['wysiwyg'], $settings );
570
+            }
571
+
572
+            wp_editor( $content, $editor_id, $settings );
573
+            $output .= ob_get_clean();
574
+        } else {
575
+
576
+            // open
577
+            $output .= '<textarea ';
578
+
579
+            // name
580
+            if ( ! empty( $args['name'] ) ) {
581
+                $output .= ' name="' . esc_attr( $args['name'] ) . '" ';
582
+            }
583
+
584
+            // id
585
+            if ( ! empty( $args['id'] ) ) {
586
+                $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
587
+            }
588
+
589
+            // placeholder
590
+            if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
591
+                $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
592
+            }
593
+
594
+            // title
595
+            if ( ! empty( $args['title'] ) ) {
596
+                $output .= ' title="' . esc_attr( $args['title'] ) . '" ';
597
+            }
598
+
599
+            // validation text
600
+            if ( ! empty( $args['validation_text'] ) ) {
601
+                $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
602
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
603
+            }
604
+
605
+            // validation_pattern
606
+            if ( ! empty( $args['validation_pattern'] ) ) {
607
+                $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
608
+            }
609
+
610
+            // required
611
+            if ( ! empty( $args['required'] ) ) {
612
+                $output .= ' required ';
613
+            }
614
+
615
+            // rows
616
+            if ( ! empty( $args['rows'] ) ) {
617
+                $output .= ' rows="' . absint( $args['rows'] ) . '" ';
618
+            }
619
+
620
+
621
+            // class
622
+            $class = ! empty( $args['class'] ) ? $args['class'] : '';
623
+            $output .= ' class="form-control ' . $class . '" ';
624
+
625
+            // extra attributes
626
+            if ( ! empty( $args['extra_attributes'] ) ) {
627
+                $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
628
+            }
629
+
630
+            // close tag
631
+            $output .= ' >';
632
+
633
+            // value
634
+            if ( ! empty( $args['value'] ) ) {
635
+                if ( ! empty( $args['allow_tags'] ) ) {
636
+                    $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
637
+                } else {
638
+                    $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] );
639
+                }
640
+            }
641
+
642
+            // closing tag
643
+            $output .= '</textarea>';
644
+
645
+
646
+            // input group wraps
647
+            if ( $args['input_group_left'] || $args['input_group_right'] ) {
648
+                $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
649
+                if ( $args['input_group_left'] ) {
650
+                    $output = self::wrap( array(
651
+                        'content'                 => $output,
652
+                        'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
653
+                        'input_group_left'        => $args['input_group_left'],
654
+                        'input_group_left_inside' => $args['input_group_left_inside']
655
+                    ) );
656
+                }
657
+                if ( $args['input_group_right'] ) {
658
+                    $output = self::wrap( array(
659
+                        'content'                  => $output,
660
+                        'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
661
+                        'input_group_right'        => $args['input_group_right'],
662
+                        'input_group_right_inside' => $args['input_group_right_inside']
663
+                    ) );
664
+                }
665
+
666
+            }
667
+
668
+
669
+        }
670
+
671
+        if ( ! empty( $args['label'] ) && $label_after ) {
672
+            $label_args = array(
673
+                'title'      => $args['label'],
674
+                'for'        => $args['id'],
675
+                'class'      => $args['label_class'] . " ",
676
+                'label_type' => $args['label_type'],
677
+                'label_col'  => $args['label_col']
678
+            );
679
+            $output .= self::label( $label_args );
680
+        }
681
+
682
+        // help text
683
+        if ( ! empty( $args['help_text'] ) ) {
684
+            $output .= AUI_Component_Helper::help_text( $args['help_text'] );
685
+        }
686
+
687
+        // maybe horizontal label
688
+        if ( $args['label_type'] == 'horizontal' ) {
689
+            $output .= '</div>';
690
+        }
691
+
692
+
693
+        // wrap
694
+        if ( ! $args['no_wrap'] ) {
695
+            $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
696
+            $wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
697
+            $wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
698
+            $output           = self::wrap( array(
699
+                'content'         => $output,
700
+                'class'           => $wrap_class,
701
+                'element_require' => $args['element_require'],
702
+                'argument_id'     => $args['id'],
703
+                'wrap_attributes' => $args['wrap_attributes'],
704
+            ) );
705
+        }
706
+
707
+
708
+        return $output;
709
+    }
710
+
711
+    /**
712
+     * Build the component.
713
+     *
714
+     * @param array $args
715
+     *
716
+     * @return string The rendered component.
717
+     */
718
+    public static function select( $args = array() ) {
719
+        $defaults = array(
720
+            'class'            => '',
721
+            'wrap_class'       => '',
722
+            'id'               => '',
723
+            'title'            => '',
724
+            'value'            => '',
725
+            // can be an array or a string
726
+            'required'         => false,
727
+            'label'            => '',
728
+            'label_after'      => false,
729
+            'label_type'       => '',
730
+            'label_col'        => '',
731
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
732
+            'label_class'      => '',
733
+            'help_text'        => '',
734
+            'placeholder'      => '',
735
+            'options'          => array(),
736
+            // array or string
737
+            'icon'             => '',
738
+            'multiple'         => false,
739
+            'select2'          => false,
740
+            'no_wrap'          => false,
741
+            'input_group_right' => '',
742
+            'input_group_left' => '',
743
+            'input_group_right_inside' => false, // forces the input group inside the input
744
+            'input_group_left_inside' => false, // forces the input group inside the input
745
+            'element_require'  => '',
746
+            // [%element_id%] == "1"
747
+            'extra_attributes' => array(),
748
+            // an array of extra attributes
749
+            'wrap_attributes'  => array(),
750
+        );
751
+
752
+        /**
753
+         * Parse incoming $args into an array and merge it with $defaults
754
+         */
755
+        $args   = wp_parse_args( $args, $defaults );
756
+        $output = '';
757
+
758
+        // for now lets hide floating labels
759
+        if ( $args['label_type'] == 'floating' ) {
760
+            $args['label_type'] = 'hidden';
761
+        }
762
+
763
+        // hidden label option needs to be empty
764
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
765
+
766
+
767
+        $label_after = $args['label_after'];
768
+
769
+        // floating labels need label after
770
+        if ( $args['label_type'] == 'floating' ) {
771
+            $label_after         = true;
772
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
773
+        }
774
+
775
+        // Maybe setup select2
776
+        $is_select2 = false;
777
+        if ( ! empty( $args['select2'] ) ) {
778
+            $args['class'] .= ' aui-select2';
779
+            $is_select2 = true;
780
+        } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
781
+            $is_select2 = true;
782
+        }
783
+
784
+        // select2 tags
785
+        if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
786
+            $args['data-tags']             = 'true';
787
+            $args['data-token-separators'] = "[',']";
788
+            $args['multiple']              = true;
789
+        }
790
+
791
+        // select2 placeholder
792
+        if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
793
+            $args['data-placeholder'] = esc_attr( $args['placeholder'] );
794
+            $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
795
+        }
796
+
797
+
798
+
799
+        // maybe horizontal label
800 800
 //		if ( $args['label_type'] == 'horizontal' ) {
801 801
 //			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
802 802
 //			$output .= '<div class="' . $input_col . '">';
803 803
 //		}
804 804
 
805
-		// Set hidden input to save empty value for multiselect.
806
-		if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
807
-			$output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>';
808
-		}
809
-
810
-		// open/type
811
-		$output .= '<select ';
812
-
813
-		// style
814
-		if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
815
-			$output .= " style='width:100%;' ";
816
-		}
817
-
818
-		// element require
819
-		if ( ! empty( $args['element_require'] ) ) {
820
-			$output .= AUI_Component_Helper::element_require( $args['element_require'] );
821
-			$args['class'] .= " aui-conditional-field";
822
-		}
823
-
824
-		// class
825
-		$class = ! empty( $args['class'] ) ? $args['class'] : '';
826
-		$output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class );
827
-
828
-		// name
829
-		if ( ! empty( $args['name'] ) ) {
830
-			$output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
831
-		}
832
-
833
-		// id
834
-		if ( ! empty( $args['id'] ) ) {
835
-			$output .= AUI_Component_Helper::id( $args['id'] );
836
-		}
837
-
838
-		// title
839
-		if ( ! empty( $args['title'] ) ) {
840
-			$output .= AUI_Component_Helper::title( $args['title'] );
841
-		}
842
-
843
-		// data-attributes
844
-		$output .= AUI_Component_Helper::data_attributes( $args );
845
-
846
-		// aria-attributes
847
-		$output .= AUI_Component_Helper::aria_attributes( $args );
848
-
849
-		// extra attributes
850
-		if ( ! empty( $args['extra_attributes'] ) ) {
851
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
852
-		}
853
-
854
-		// required
855
-		if ( ! empty( $args['required'] ) ) {
856
-			$output .= ' required ';
857
-		}
858
-
859
-		// multiple
860
-		if ( ! empty( $args['multiple'] ) ) {
861
-			$output .= ' multiple ';
862
-		}
863
-
864
-		// close opening tag
865
-		$output .= ' >';
866
-
867
-		// placeholder
868
-		if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
869
-			$output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
870
-		} elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
871
-			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
872
-		}
873
-
874
-		// Options
875
-		if ( ! empty( $args['options'] ) ) {
876
-
877
-			if ( ! is_array( $args['options'] ) ) {
878
-				$output .= $args['options']; // not the preferred way but an option
879
-			} else {
880
-				foreach ( $args['options'] as $val => $name ) {
881
-					$selected = '';
882
-					if ( is_array( $name ) ) {
883
-						if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
884
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
885
-
886
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
887
-						} else {
888
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
889
-							$option_value = isset( $name['value'] ) ? $name['value'] : '';
890
-							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
891
-							if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
892
-								$selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
893
-							} elseif ( ! empty( $args['value'] ) ) {
894
-								$selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
895
-							} elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) {
896
-								$selected = selected( $option_value, $args['value'], false );
897
-							}
898
-
899
-							$output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
900
-						}
901
-					} else {
902
-						if ( ! empty( $args['value'] ) ) {
903
-							if ( is_array( $args['value'] ) ) {
904
-								$selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
905
-							} elseif ( ! empty( $args['value'] ) ) {
906
-								$selected = selected( $args['value'], $val, false );
907
-							}
908
-						} elseif ( $args['value'] === $val ) {
909
-							$selected = selected( $args['value'], $val, false );
910
-						}
911
-						$output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
912
-					}
913
-				}
914
-			}
915
-
916
-		}
917
-
918
-		// closing tag
919
-		$output .= '</select>';
920
-
921
-		$label = '';
922
-		$help_text = '';
923
-		// label
924
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
925
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
926
-			$label_args = array(
927
-				'title'      => $args['label'],
928
-				'for'        => $args['id'],
929
-				'class'      => $args['label_class'] . " ",
930
-				'label_type' => $args['label_type'],
931
-				'label_col'  => $args['label_col']
932
-			);
933
-			$label = self::label( $label_args );
934
-		}
935
-
936
-		// help text
937
-		if ( ! empty( $args['help_text'] ) ) {
938
-			$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
939
-		}
940
-
941
-		// input group wraps
942
-		if ( $args['input_group_left'] || $args['input_group_right'] ) {
943
-			$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
944
-			if ( $args['input_group_left'] ) {
945
-				$output = self::wrap( array(
946
-					'content'                 => $output,
947
-					'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
948
-					'input_group_left'        => $args['input_group_left'],
949
-					'input_group_left_inside' => $args['input_group_left_inside']
950
-				) );
951
-			}
952
-			if ( $args['input_group_right'] ) {
953
-				$output = self::wrap( array(
954
-					'content'                  => $output,
955
-					'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
956
-					'input_group_right'        => $args['input_group_right'],
957
-					'input_group_right_inside' => $args['input_group_right_inside']
958
-				) );
959
-			}
960
-
961
-		}
962
-
963
-		if ( ! $label_after ) {
964
-			$output .= $help_text;
965
-		}
966
-
967
-
968
-		if ( $args['label_type'] == 'horizontal' ) {
969
-			$output = self::wrap( array(
970
-				'content' => $output,
971
-				'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
972
-			) );
973
-		}
974
-
975
-		if ( ! $label_after ) {
976
-			$output = $label . $output;
977
-		}
978
-
979
-		// maybe horizontal label
805
+        // Set hidden input to save empty value for multiselect.
806
+        if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
807
+            $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>';
808
+        }
809
+
810
+        // open/type
811
+        $output .= '<select ';
812
+
813
+        // style
814
+        if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
815
+            $output .= " style='width:100%;' ";
816
+        }
817
+
818
+        // element require
819
+        if ( ! empty( $args['element_require'] ) ) {
820
+            $output .= AUI_Component_Helper::element_require( $args['element_require'] );
821
+            $args['class'] .= " aui-conditional-field";
822
+        }
823
+
824
+        // class
825
+        $class = ! empty( $args['class'] ) ? $args['class'] : '';
826
+        $output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class );
827
+
828
+        // name
829
+        if ( ! empty( $args['name'] ) ) {
830
+            $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
831
+        }
832
+
833
+        // id
834
+        if ( ! empty( $args['id'] ) ) {
835
+            $output .= AUI_Component_Helper::id( $args['id'] );
836
+        }
837
+
838
+        // title
839
+        if ( ! empty( $args['title'] ) ) {
840
+            $output .= AUI_Component_Helper::title( $args['title'] );
841
+        }
842
+
843
+        // data-attributes
844
+        $output .= AUI_Component_Helper::data_attributes( $args );
845
+
846
+        // aria-attributes
847
+        $output .= AUI_Component_Helper::aria_attributes( $args );
848
+
849
+        // extra attributes
850
+        if ( ! empty( $args['extra_attributes'] ) ) {
851
+            $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
852
+        }
853
+
854
+        // required
855
+        if ( ! empty( $args['required'] ) ) {
856
+            $output .= ' required ';
857
+        }
858
+
859
+        // multiple
860
+        if ( ! empty( $args['multiple'] ) ) {
861
+            $output .= ' multiple ';
862
+        }
863
+
864
+        // close opening tag
865
+        $output .= ' >';
866
+
867
+        // placeholder
868
+        if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
869
+            $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
870
+        } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
871
+            $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
872
+        }
873
+
874
+        // Options
875
+        if ( ! empty( $args['options'] ) ) {
876
+
877
+            if ( ! is_array( $args['options'] ) ) {
878
+                $output .= $args['options']; // not the preferred way but an option
879
+            } else {
880
+                foreach ( $args['options'] as $val => $name ) {
881
+                    $selected = '';
882
+                    if ( is_array( $name ) ) {
883
+                        if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
884
+                            $option_label = isset( $name['label'] ) ? $name['label'] : '';
885
+
886
+                            $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
887
+                        } else {
888
+                            $option_label = isset( $name['label'] ) ? $name['label'] : '';
889
+                            $option_value = isset( $name['value'] ) ? $name['value'] : '';
890
+                            $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
891
+                            if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
892
+                                $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
893
+                            } elseif ( ! empty( $args['value'] ) ) {
894
+                                $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
895
+                            } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) {
896
+                                $selected = selected( $option_value, $args['value'], false );
897
+                            }
898
+
899
+                            $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
900
+                        }
901
+                    } else {
902
+                        if ( ! empty( $args['value'] ) ) {
903
+                            if ( is_array( $args['value'] ) ) {
904
+                                $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
905
+                            } elseif ( ! empty( $args['value'] ) ) {
906
+                                $selected = selected( $args['value'], $val, false );
907
+                            }
908
+                        } elseif ( $args['value'] === $val ) {
909
+                            $selected = selected( $args['value'], $val, false );
910
+                        }
911
+                        $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
912
+                    }
913
+                }
914
+            }
915
+
916
+        }
917
+
918
+        // closing tag
919
+        $output .= '</select>';
920
+
921
+        $label = '';
922
+        $help_text = '';
923
+        // label
924
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
925
+        } elseif ( ! empty( $args['label'] ) && ! $label_after ) {
926
+            $label_args = array(
927
+                'title'      => $args['label'],
928
+                'for'        => $args['id'],
929
+                'class'      => $args['label_class'] . " ",
930
+                'label_type' => $args['label_type'],
931
+                'label_col'  => $args['label_col']
932
+            );
933
+            $label = self::label( $label_args );
934
+        }
935
+
936
+        // help text
937
+        if ( ! empty( $args['help_text'] ) ) {
938
+            $help_text = AUI_Component_Helper::help_text( $args['help_text'] );
939
+        }
940
+
941
+        // input group wraps
942
+        if ( $args['input_group_left'] || $args['input_group_right'] ) {
943
+            $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
944
+            if ( $args['input_group_left'] ) {
945
+                $output = self::wrap( array(
946
+                    'content'                 => $output,
947
+                    'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
948
+                    'input_group_left'        => $args['input_group_left'],
949
+                    'input_group_left_inside' => $args['input_group_left_inside']
950
+                ) );
951
+            }
952
+            if ( $args['input_group_right'] ) {
953
+                $output = self::wrap( array(
954
+                    'content'                  => $output,
955
+                    'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
956
+                    'input_group_right'        => $args['input_group_right'],
957
+                    'input_group_right_inside' => $args['input_group_right_inside']
958
+                ) );
959
+            }
960
+
961
+        }
962
+
963
+        if ( ! $label_after ) {
964
+            $output .= $help_text;
965
+        }
966
+
967
+
968
+        if ( $args['label_type'] == 'horizontal' ) {
969
+            $output = self::wrap( array(
970
+                'content' => $output,
971
+                'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
972
+            ) );
973
+        }
974
+
975
+        if ( ! $label_after ) {
976
+            $output = $label . $output;
977
+        }
978
+
979
+        // maybe horizontal label
980 980
 //		if ( $args['label_type'] == 'horizontal' ) {
981 981
 //			$output .= '</div>';
982 982
 //		}
983 983
 
984 984
 
985
-		// wrap
986
-		if ( ! $args['no_wrap'] ) {
987
-			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
988
-			$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
989
-			$output     = self::wrap( array(
990
-				'content'         => $output,
991
-				'class'           => $wrap_class,
992
-				'element_require' => $args['element_require'],
993
-				'argument_id'     => $args['id'],
994
-				'wrap_attributes' => $args['wrap_attributes'],
995
-			) );
996
-		}
997
-
998
-
999
-		return $output;
1000
-	}
1001
-
1002
-	/**
1003
-	 * Build the component.
1004
-	 *
1005
-	 * @param array $args
1006
-	 *
1007
-	 * @return string The rendered component.
1008
-	 */
1009
-	public static function radio( $args = array() ) {
1010
-		$defaults = array(
1011
-			'class'            => '',
1012
-			'wrap_class'       => '',
1013
-			'id'               => '',
1014
-			'title'            => '',
1015
-			'horizontal'       => false,
1016
-			// sets the lable horizontal
1017
-			'value'            => '',
1018
-			'label'            => '',
1019
-			'label_class'      => '',
1020
-			'label_type'       => '',
1021
-			'label_col'        => '',
1022
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
1023
-			'help_text'        => '',
1024
-			'inline'           => true,
1025
-			'required'         => false,
1026
-			'options'          => array(),
1027
-			'icon'             => '',
1028
-			'no_wrap'          => false,
1029
-			'element_require'  => '',
1030
-			// [%element_id%] == "1"
1031
-			'extra_attributes' => array(),
1032
-			// an array of extra attributes
1033
-			'wrap_attributes'  => array()
1034
-		);
1035
-
1036
-		/**
1037
-		 * Parse incoming $args into an array and merge it with $defaults
1038
-		 */
1039
-		$args = wp_parse_args( $args, $defaults );
1040
-
1041
-		// for now lets use horizontal for floating
1042
-		if ( $args['label_type'] == 'floating' ) {
1043
-			$args['label_type'] = 'horizontal';
1044
-		}
1045
-
1046
-		$label_args = array(
1047
-			'title'      => $args['label'],
1048
-			'class'      => $args['label_class'] . " pt-0 ",
1049
-			'label_type' => $args['label_type'],
1050
-			'label_col'  => $args['label_col']
1051
-		);
1052
-
1053
-		$output = '';
1054
-
1055
-
1056
-		// label before
1057
-		if ( ! empty( $args['label'] ) ) {
1058
-			$output .= self::label( $label_args, 'radio' );
1059
-		}
1060
-
1061
-		// maybe horizontal label
1062
-		if ( $args['label_type'] == 'horizontal' ) {
1063
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1064
-			$output .= '<div class="' . $input_col . '">';
1065
-		}
1066
-
1067
-		if ( ! empty( $args['options'] ) ) {
1068
-			$count = 0;
1069
-			foreach ( $args['options'] as $value => $label ) {
1070
-				$option_args            = $args;
1071
-				$option_args['value']   = $value;
1072
-				$option_args['label']   = $label;
1073
-				$option_args['checked'] = $value == $args['value'] ? true : false;
1074
-				$output .= self::radio_option( $option_args, $count );
1075
-				$count ++;
1076
-			}
1077
-		}
1078
-
1079
-		// help text
1080
-		$help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1081
-		$output .= $help_text;
1082
-
1083
-		// maybe horizontal label
1084
-		if ( $args['label_type'] == 'horizontal' ) {
1085
-			$output .= '</div>';
1086
-		}
1087
-
1088
-		// wrap
1089
-		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
1090
-		$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1091
-		$output     = self::wrap( array(
1092
-			'content'         => $output,
1093
-			'class'           => $wrap_class,
1094
-			'element_require' => $args['element_require'],
1095
-			'argument_id'     => $args['id'],
1096
-			'wrap_attributes' => $args['wrap_attributes'],
1097
-		) );
1098
-
1099
-
1100
-		return $output;
1101
-	}
1102
-
1103
-	/**
1104
-	 * Build the component.
1105
-	 *
1106
-	 * @param array $args
1107
-	 *
1108
-	 * @return string The rendered component.
1109
-	 */
1110
-	public static function radio_option( $args = array(), $count = '' ) {
1111
-		$defaults = array(
1112
-			'class'            => '',
1113
-			'id'               => '',
1114
-			'title'            => '',
1115
-			'value'            => '',
1116
-			'required'         => false,
1117
-			'inline'           => true,
1118
-			'label'            => '',
1119
-			'options'          => array(),
1120
-			'icon'             => '',
1121
-			'no_wrap'          => false,
1122
-			'extra_attributes' => array() // an array of extra attributes
1123
-		);
1124
-
1125
-		/**
1126
-		 * Parse incoming $args into an array and merge it with $defaults
1127
-		 */
1128
-		$args = wp_parse_args( $args, $defaults );
1129
-
1130
-		$output = '';
1131
-
1132
-		// open/type
1133
-		$output .= '<input type="radio"';
1134
-
1135
-		// class
1136
-		$output .= ' class="form-check-input" ';
1137
-
1138
-		// name
1139
-		if ( ! empty( $args['name'] ) ) {
1140
-			$output .= AUI_Component_Helper::name( $args['name'] );
1141
-		}
1142
-
1143
-		// id
1144
-		if ( ! empty( $args['id'] ) ) {
1145
-			$output .= AUI_Component_Helper::id( $args['id'] . $count );
1146
-		}
1147
-
1148
-		// title
1149
-		if ( ! empty( $args['title'] ) ) {
1150
-			$output .= AUI_Component_Helper::title( $args['title'] );
1151
-		}
1152
-
1153
-		// value
1154
-		if ( isset( $args['value'] ) ) {
1155
-			$output .= AUI_Component_Helper::value( $args['value'] );
1156
-		}
1157
-
1158
-		// checked, for radio and checkboxes
1159
-		if ( $args['checked'] ) {
1160
-			$output .= ' checked ';
1161
-		}
1162
-
1163
-		// data-attributes
1164
-		$output .= AUI_Component_Helper::data_attributes( $args );
1165
-
1166
-		// aria-attributes
1167
-		$output .= AUI_Component_Helper::aria_attributes( $args );
1168
-
1169
-		// extra attributes
1170
-		if ( ! empty( $args['extra_attributes'] ) ) {
1171
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1172
-		}
1173
-
1174
-		// required
1175
-		if ( ! empty( $args['required'] ) ) {
1176
-			$output .= ' required ';
1177
-		}
1178
-
1179
-		// close opening tag
1180
-		$output .= ' >';
1181
-
1182
-		// label
1183
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1184
-		} elseif ( ! empty( $args['label'] ) ) {
1185
-			$output .= self::label( array(
1186
-				'title' => $args['label'],
1187
-				'for'   => $args['id'] . $count,
1188
-				'class' => 'form-check-label'
1189
-			), 'radio' );
1190
-		}
1191
-
1192
-		// wrap
1193
-		if ( ! $args['no_wrap'] ) {
1194
-			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1195
-
1196
-			// Unique wrap class
1197
-			$uniq_class = 'fwrap';
1198
-			if ( ! empty( $args['name'] ) ) {
1199
-				$uniq_class .= '-' . $args['name'];
1200
-			} else if ( ! empty( $args['id'] ) ) {
1201
-				$uniq_class .= '-' . $args['id'];
1202
-			}
1203
-
1204
-			if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1205
-				$uniq_class .= '-' . $args['value'];
1206
-			} else {
1207
-				$uniq_class .= '-' . $count;
1208
-			}
1209
-			$wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1210
-
1211
-			$output = self::wrap( array(
1212
-				'content' => $output,
1213
-				'class'   => $wrap_class
1214
-			) );
1215
-		}
1216
-
1217
-		return $output;
1218
-	}
985
+        // wrap
986
+        if ( ! $args['no_wrap'] ) {
987
+            $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
988
+            $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
989
+            $output     = self::wrap( array(
990
+                'content'         => $output,
991
+                'class'           => $wrap_class,
992
+                'element_require' => $args['element_require'],
993
+                'argument_id'     => $args['id'],
994
+                'wrap_attributes' => $args['wrap_attributes'],
995
+            ) );
996
+        }
997
+
998
+
999
+        return $output;
1000
+    }
1001
+
1002
+    /**
1003
+     * Build the component.
1004
+     *
1005
+     * @param array $args
1006
+     *
1007
+     * @return string The rendered component.
1008
+     */
1009
+    public static function radio( $args = array() ) {
1010
+        $defaults = array(
1011
+            'class'            => '',
1012
+            'wrap_class'       => '',
1013
+            'id'               => '',
1014
+            'title'            => '',
1015
+            'horizontal'       => false,
1016
+            // sets the lable horizontal
1017
+            'value'            => '',
1018
+            'label'            => '',
1019
+            'label_class'      => '',
1020
+            'label_type'       => '',
1021
+            'label_col'        => '',
1022
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
1023
+            'help_text'        => '',
1024
+            'inline'           => true,
1025
+            'required'         => false,
1026
+            'options'          => array(),
1027
+            'icon'             => '',
1028
+            'no_wrap'          => false,
1029
+            'element_require'  => '',
1030
+            // [%element_id%] == "1"
1031
+            'extra_attributes' => array(),
1032
+            // an array of extra attributes
1033
+            'wrap_attributes'  => array()
1034
+        );
1035
+
1036
+        /**
1037
+         * Parse incoming $args into an array and merge it with $defaults
1038
+         */
1039
+        $args = wp_parse_args( $args, $defaults );
1040
+
1041
+        // for now lets use horizontal for floating
1042
+        if ( $args['label_type'] == 'floating' ) {
1043
+            $args['label_type'] = 'horizontal';
1044
+        }
1045
+
1046
+        $label_args = array(
1047
+            'title'      => $args['label'],
1048
+            'class'      => $args['label_class'] . " pt-0 ",
1049
+            'label_type' => $args['label_type'],
1050
+            'label_col'  => $args['label_col']
1051
+        );
1052
+
1053
+        $output = '';
1054
+
1055
+
1056
+        // label before
1057
+        if ( ! empty( $args['label'] ) ) {
1058
+            $output .= self::label( $label_args, 'radio' );
1059
+        }
1060
+
1061
+        // maybe horizontal label
1062
+        if ( $args['label_type'] == 'horizontal' ) {
1063
+            $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1064
+            $output .= '<div class="' . $input_col . '">';
1065
+        }
1066
+
1067
+        if ( ! empty( $args['options'] ) ) {
1068
+            $count = 0;
1069
+            foreach ( $args['options'] as $value => $label ) {
1070
+                $option_args            = $args;
1071
+                $option_args['value']   = $value;
1072
+                $option_args['label']   = $label;
1073
+                $option_args['checked'] = $value == $args['value'] ? true : false;
1074
+                $output .= self::radio_option( $option_args, $count );
1075
+                $count ++;
1076
+            }
1077
+        }
1078
+
1079
+        // help text
1080
+        $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1081
+        $output .= $help_text;
1082
+
1083
+        // maybe horizontal label
1084
+        if ( $args['label_type'] == 'horizontal' ) {
1085
+            $output .= '</div>';
1086
+        }
1087
+
1088
+        // wrap
1089
+        $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
1090
+        $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1091
+        $output     = self::wrap( array(
1092
+            'content'         => $output,
1093
+            'class'           => $wrap_class,
1094
+            'element_require' => $args['element_require'],
1095
+            'argument_id'     => $args['id'],
1096
+            'wrap_attributes' => $args['wrap_attributes'],
1097
+        ) );
1098
+
1099
+
1100
+        return $output;
1101
+    }
1102
+
1103
+    /**
1104
+     * Build the component.
1105
+     *
1106
+     * @param array $args
1107
+     *
1108
+     * @return string The rendered component.
1109
+     */
1110
+    public static function radio_option( $args = array(), $count = '' ) {
1111
+        $defaults = array(
1112
+            'class'            => '',
1113
+            'id'               => '',
1114
+            'title'            => '',
1115
+            'value'            => '',
1116
+            'required'         => false,
1117
+            'inline'           => true,
1118
+            'label'            => '',
1119
+            'options'          => array(),
1120
+            'icon'             => '',
1121
+            'no_wrap'          => false,
1122
+            'extra_attributes' => array() // an array of extra attributes
1123
+        );
1124
+
1125
+        /**
1126
+         * Parse incoming $args into an array and merge it with $defaults
1127
+         */
1128
+        $args = wp_parse_args( $args, $defaults );
1129
+
1130
+        $output = '';
1131
+
1132
+        // open/type
1133
+        $output .= '<input type="radio"';
1134
+
1135
+        // class
1136
+        $output .= ' class="form-check-input" ';
1137
+
1138
+        // name
1139
+        if ( ! empty( $args['name'] ) ) {
1140
+            $output .= AUI_Component_Helper::name( $args['name'] );
1141
+        }
1142
+
1143
+        // id
1144
+        if ( ! empty( $args['id'] ) ) {
1145
+            $output .= AUI_Component_Helper::id( $args['id'] . $count );
1146
+        }
1147
+
1148
+        // title
1149
+        if ( ! empty( $args['title'] ) ) {
1150
+            $output .= AUI_Component_Helper::title( $args['title'] );
1151
+        }
1152
+
1153
+        // value
1154
+        if ( isset( $args['value'] ) ) {
1155
+            $output .= AUI_Component_Helper::value( $args['value'] );
1156
+        }
1157
+
1158
+        // checked, for radio and checkboxes
1159
+        if ( $args['checked'] ) {
1160
+            $output .= ' checked ';
1161
+        }
1162
+
1163
+        // data-attributes
1164
+        $output .= AUI_Component_Helper::data_attributes( $args );
1165
+
1166
+        // aria-attributes
1167
+        $output .= AUI_Component_Helper::aria_attributes( $args );
1168
+
1169
+        // extra attributes
1170
+        if ( ! empty( $args['extra_attributes'] ) ) {
1171
+            $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1172
+        }
1173
+
1174
+        // required
1175
+        if ( ! empty( $args['required'] ) ) {
1176
+            $output .= ' required ';
1177
+        }
1178
+
1179
+        // close opening tag
1180
+        $output .= ' >';
1181
+
1182
+        // label
1183
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1184
+        } elseif ( ! empty( $args['label'] ) ) {
1185
+            $output .= self::label( array(
1186
+                'title' => $args['label'],
1187
+                'for'   => $args['id'] . $count,
1188
+                'class' => 'form-check-label'
1189
+            ), 'radio' );
1190
+        }
1191
+
1192
+        // wrap
1193
+        if ( ! $args['no_wrap'] ) {
1194
+            $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1195
+
1196
+            // Unique wrap class
1197
+            $uniq_class = 'fwrap';
1198
+            if ( ! empty( $args['name'] ) ) {
1199
+                $uniq_class .= '-' . $args['name'];
1200
+            } else if ( ! empty( $args['id'] ) ) {
1201
+                $uniq_class .= '-' . $args['id'];
1202
+            }
1203
+
1204
+            if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1205
+                $uniq_class .= '-' . $args['value'];
1206
+            } else {
1207
+                $uniq_class .= '-' . $count;
1208
+            }
1209
+            $wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1210
+
1211
+            $output = self::wrap( array(
1212
+                'content' => $output,
1213
+                'class'   => $wrap_class
1214
+            ) );
1215
+        }
1216
+
1217
+        return $output;
1218
+    }
1219 1219
 
1220 1220
 }
1221 1221
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +284 added lines, -284 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
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function input( $args = array() ) {
21
+	public static function input($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'                     => 'text',
24 24
 			'name'                     => '',
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 		/**
64 64
 		 * Parse incoming $args into an array and merge it with $defaults
65 65
 		 */
66
-		$args   = wp_parse_args( $args, $defaults );
66
+		$args   = wp_parse_args($args, $defaults);
67 67
 		$output = '';
68
-		if ( ! empty( $args['type'] ) ) {
68
+		if (!empty($args['type'])) {
69 69
 			// hidden label option needs to be empty
70 70
 			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
71 71
 
72
-			$type = sanitize_html_class( $args['type'] );
72
+			$type = sanitize_html_class($args['type']);
73 73
 
74 74
 			$help_text   = '';
75 75
 			$label       = '';
@@ -83,19 +83,19 @@  discard block
 block discarded – undo
83 83
 			);
84 84
 
85 85
 			// floating labels need label after
86
-			if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
86
+			if ($args['label_type'] == 'floating' && $type != 'checkbox') {
87 87
 				$label_after         = true;
88 88
 				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
89 89
 			}
90 90
 
91 91
 			// Some special sauce for files
92
-			if ( $type == 'file' ) {
92
+			if ($type == 'file') {
93 93
 				$label_after = true; // if type file we need the label after
94 94
 				$args['class'] .= ' custom-file-input ';
95
-			} elseif ( $type == 'checkbox' ) {
95
+			} elseif ($type == 'checkbox') {
96 96
 				$label_after = true; // if type file we need the label after
97 97
 				$args['class'] .= ' custom-control-input ';
98
-			} elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
98
+			} elseif ($type == 'datepicker' || $type == 'timepicker') {
99 99
 				$type = 'text';
100 100
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
101 101
 				$args['class'] .= ' bg-initial ';
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 				// enqueue the script
105 105
 				$aui_settings = AyeCode_UI_Settings::instance();
106 106
 				$aui_settings->enqueue_flatpickr();
107
-			} elseif ( $type == 'iconpicker' ) {
107
+			} elseif ($type == 'iconpicker') {
108 108
 				$type = 'text';
109 109
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
110 110
 //				$args['class'] .= ' bg-initial ';
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 				$aui_settings->enqueue_iconpicker();
120 120
 			}
121 121
 
122
-			if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) {
123
-				$output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
122
+			if ($type == 'checkbox' && !empty($args['name']) && strpos($args['name'], '[') === false) {
123
+				$output .= '<input type="hidden" name="' . esc_attr($args['name']) . '" value="0" />';
124 124
 			}
125 125
 
126 126
 
@@ -128,88 +128,88 @@  discard block
 block discarded – undo
128 128
 			$output .= '<input type="' . $type . '" ';
129 129
 
130 130
 			// name
131
-			if ( ! empty( $args['name'] ) ) {
132
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
131
+			if (!empty($args['name'])) {
132
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
133 133
 			}
134 134
 
135 135
 			// id
136
-			if ( ! empty( $args['id'] ) ) {
137
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
136
+			if (!empty($args['id'])) {
137
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
138 138
 			}
139 139
 
140 140
 			// placeholder
141
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
142
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
141
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
142
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
143 143
 			}
144 144
 
145 145
 			// title
146
-			if ( ! empty( $args['title'] ) ) {
147
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
146
+			if (!empty($args['title'])) {
147
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
148 148
 			}
149 149
 
150 150
 			// value
151
-			if ( ! empty( $args['value'] ) ) {
152
-				$output .= AUI_Component_Helper::value( $args['value'] );
151
+			if (!empty($args['value'])) {
152
+				$output .= AUI_Component_Helper::value($args['value']);
153 153
 			}
154 154
 
155 155
 			// checked, for radio and checkboxes
156
-			if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
156
+			if (($type == 'checkbox' || $type == 'radio') && $args['checked']) {
157 157
 				$output .= ' checked ';
158 158
 			}
159 159
 
160 160
 			// validation text
161
-			if ( ! empty( $args['validation_text'] ) ) {
162
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
161
+			if (!empty($args['validation_text'])) {
162
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
163 163
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
164 164
 			}
165 165
 
166 166
 			// validation_pattern
167
-			if ( ! empty( $args['validation_pattern'] ) ) {
168
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
167
+			if (!empty($args['validation_pattern'])) {
168
+				$output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" ';
169 169
 			}
170 170
 
171 171
 			// step (for numbers)
172
-			if ( ! empty( $args['step'] ) ) {
172
+			if (!empty($args['step'])) {
173 173
 				$output .= ' step="' . $args['step'] . '" ';
174 174
 			}
175 175
 
176 176
 			// required
177
-			if ( ! empty( $args['required'] ) ) {
177
+			if (!empty($args['required'])) {
178 178
 				$output .= ' required ';
179 179
 			}
180 180
 
181 181
 			// class
182
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
182
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
183 183
 			$output .= ' class="form-control ' . $class . '" ';
184 184
 
185 185
 			// data-attributes
186
-			$output .= AUI_Component_Helper::data_attributes( $args );
186
+			$output .= AUI_Component_Helper::data_attributes($args);
187 187
 
188 188
 			// extra attributes
189
-			if ( ! empty( $args['extra_attributes'] ) ) {
190
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
189
+			if (!empty($args['extra_attributes'])) {
190
+				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
191 191
 			}
192 192
 
193 193
 			// close
194 194
 			$output .= ' >';
195 195
 
196 196
 			// help text
197
-			if ( ! empty( $args['help_text'] ) ) {
198
-				$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
197
+			if (!empty($args['help_text'])) {
198
+				$help_text = AUI_Component_Helper::help_text($args['help_text']);
199 199
 			}
200 200
 
201 201
 			// label
202
-			if ( ! empty( $args['label'] ) ) {
202
+			if (!empty($args['label'])) {
203 203
 				$label_base_class = '';
204
-				if ( $type == 'file' ) {
204
+				if ($type == 'file') {
205 205
 					$label_base_class = ' custom-file-label';
206
-				} elseif ( $type == 'checkbox' ) {
207
-					if ( ! empty( $args['label_force_left'] ) ) {
208
-						$label_args['title'] = wp_kses_post( $args['help_text'] );
206
+				} elseif ($type == 'checkbox') {
207
+					if (!empty($args['label_force_left'])) {
208
+						$label_args['title'] = wp_kses_post($args['help_text']);
209 209
 						$help_text = '';
210 210
 						//$label_args['class'] .= ' d-inline ';
211 211
 						$args['wrap_class'] .= ' align-items-center ';
212
-					}else{
212
+					} else {
213 213
 
214 214
 					}
215 215
 
@@ -217,45 +217,45 @@  discard block
 block discarded – undo
217 217
 				}
218 218
 				$label_args['class'] .= $label_base_class;
219 219
 				$temp_label_args = $label_args;
220
-				if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
221
-				$label = self::label( $temp_label_args, $type );
220
+				if (!empty($args['label_force_left'])) {$temp_label_args['class'] = $label_base_class . " text-muted"; }
221
+				$label = self::label($temp_label_args, $type);
222 222
 			}
223 223
 
224 224
 
225 225
 
226 226
 
227 227
 			// set help text in the correct position
228
-			if ( $label_after ) {
228
+			if ($label_after) {
229 229
 				$output .= $label . $help_text;
230 230
 			}
231 231
 
232 232
 			// some input types need a separate wrap
233
-			if ( $type == 'file' ) {
234
-				$output = self::wrap( array(
233
+			if ($type == 'file') {
234
+				$output = self::wrap(array(
235 235
 					'content' => $output,
236 236
 					'class'   => 'form-group custom-file'
237
-				) );
238
-			} elseif ( $type == 'checkbox' ) {
237
+				));
238
+			} elseif ($type == 'checkbox') {
239 239
 
240 240
 				$label_args['title'] = $args['label'];
241
-				$label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
242
-				$label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
243
-				$switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
244
-				$wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox';
245
-				if ( ! empty( $args['label_force_left'] ) ) {
241
+				$label_col = AUI_Component_Helper::get_column_class($args['label_col'], 'label');
242
+				$label = !empty($args['label_force_left']) ? self::label($label_args, 'cb') : '<div class="' . $label_col . ' col-form-label"></div>';
243
+				$switch_size_class = $args['switch'] && !is_bool($args['switch']) ? ' custom-switch-' . esc_attr($args['switch']) : '';
244
+				$wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox';
245
+				if (!empty($args['label_force_left'])) {
246 246
 					$wrap_class .= ' d-flex align-content-center';
247
-					$label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) );
247
+					$label = str_replace("custom-control-label", "", self::label($label_args, 'cb'));
248 248
 				}
249
-				$output     = self::wrap( array(
249
+				$output = self::wrap(array(
250 250
 					'content' => $output,
251 251
 					'class'   => 'custom-control ' . $wrap_class
252
-				) );
252
+				));
253 253
 
254
-				if ( $args['label_type'] == 'horizontal' ) {
255
-					$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
254
+				if ($args['label_type'] == 'horizontal') {
255
+					$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
256 256
 					$output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
257 257
 				}
258
-			} elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
258
+			} elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) {
259 259
 
260 260
 
261 261
 				// allow password field to toggle view
@@ -269,62 +269,62 @@  discard block
 block discarded – undo
269 269
 			}
270 270
 
271 271
 			// input group wraps
272
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
273
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
274
-				if ( $args['input_group_left'] ) {
275
-					$output = self::wrap( array(
272
+			if ($args['input_group_left'] || $args['input_group_right']) {
273
+				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
274
+				if ($args['input_group_left']) {
275
+					$output = self::wrap(array(
276 276
 						'content'                 => $output,
277 277
 						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
278 278
 						'input_group_left'        => $args['input_group_left'],
279 279
 						'input_group_left_inside' => $args['input_group_left_inside']
280
-					) );
280
+					));
281 281
 				}
282
-				if ( $args['input_group_right'] ) {
283
-					$output = self::wrap( array(
282
+				if ($args['input_group_right']) {
283
+					$output = self::wrap(array(
284 284
 						'content'                  => $output,
285 285
 						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
286 286
 						'input_group_right'        => $args['input_group_right'],
287 287
 						'input_group_right_inside' => $args['input_group_right_inside']
288
-					) );
288
+					));
289 289
 				}
290 290
 
291 291
 			}
292 292
 
293
-			if ( ! $label_after ) {
293
+			if (!$label_after) {
294 294
 				$output .= $help_text;
295 295
 			}
296 296
 
297 297
 
298
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
299
-				$output = self::wrap( array(
298
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
299
+				$output = self::wrap(array(
300 300
 					'content' => $output,
301
-					'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
302
-				) );
301
+					'class'   => AUI_Component_Helper::get_column_class($args['label_col'], 'input')
302
+				));
303 303
 			}
304 304
 
305
-			if ( ! $label_after ) {
305
+			if (!$label_after) {
306 306
 				$output = $label . $output;
307 307
 			}
308 308
 
309 309
 			// wrap
310
-			if ( ! $args['no_wrap'] ) {
310
+			if (!$args['no_wrap']) {
311 311
 				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
312 312
 				$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
313
-				$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
-				$output           = self::wrap( array(
313
+				$wrap_class       = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
+				$output           = self::wrap(array(
315 315
 					'content'         => $output,
316 316
 					'class'           => $wrap_class,
317 317
 					'element_require' => $args['element_require'],
318 318
 					'argument_id'     => $args['id'],
319 319
 					'wrap_attributes' => $args['wrap_attributes'],
320
-				) );
320
+				));
321 321
 			}
322 322
 		}
323 323
 
324 324
 		return $output;
325 325
 	}
326 326
 
327
-	public static function label( $args = array(), $type = '' ) {
327
+	public static function label($args = array(), $type = '') {
328 328
 		//<label for="exampleInputEmail1">Email address</label>
329 329
 		$defaults = array(
330 330
 			'title'      => 'div',
@@ -337,33 +337,33 @@  discard block
 block discarded – undo
337 337
 		/**
338 338
 		 * Parse incoming $args into an array and merge it with $defaults
339 339
 		 */
340
-		$args   = wp_parse_args( $args, $defaults );
340
+		$args   = wp_parse_args($args, $defaults);
341 341
 		$output = '';
342 342
 
343
-		if ( $args['title'] ) {
343
+		if ($args['title']) {
344 344
 
345 345
 			// maybe hide labels //@todo set a global option for visibility class
346
-			if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
346
+			if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) {
347 347
 				$class = $args['class'];
348 348
 			} else {
349 349
 				$class = 'sr-only ' . $args['class'];
350 350
 			}
351 351
 
352 352
 			// maybe horizontal
353
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
354
-				$class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label';
353
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
354
+				$class .= ' ' . AUI_Component_Helper::get_column_class($args['label_col'], 'label') . ' col-form-label';
355 355
 			}
356 356
 
357 357
 			// open
358 358
 			$output .= '<label ';
359 359
 
360 360
 			// for
361
-			if ( ! empty( $args['for'] ) ) {
362
-				$output .= ' for="' . esc_attr( $args['for'] ) . '" ';
361
+			if (!empty($args['for'])) {
362
+				$output .= ' for="' . esc_attr($args['for']) . '" ';
363 363
 			}
364 364
 
365 365
 			// class
366
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
366
+			$class = $class ? AUI_Component_Helper::esc_classes($class) : '';
367 367
 			$output .= ' class="' . $class . '" ';
368 368
 
369 369
 			// close
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 
372 372
 
373 373
 			// title, don't escape fully as can contain html
374
-			if ( ! empty( $args['title'] ) ) {
375
-				$output .= wp_kses_post( $args['title'] );
374
+			if (!empty($args['title'])) {
375
+				$output .= wp_kses_post($args['title']);
376 376
 			}
377 377
 
378 378
 			// close wrap
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	 *
393 393
 	 * @return string
394 394
 	 */
395
-	public static function wrap( $args = array() ) {
395
+	public static function wrap($args = array()) {
396 396
 		$defaults = array(
397 397
 			'type'                     => 'div',
398 398
 			'class'                    => 'form-group',
@@ -409,31 +409,31 @@  discard block
 block discarded – undo
409 409
 		/**
410 410
 		 * Parse incoming $args into an array and merge it with $defaults
411 411
 		 */
412
-		$args   = wp_parse_args( $args, $defaults );
412
+		$args   = wp_parse_args($args, $defaults);
413 413
 		$output = '';
414
-		if ( $args['type'] ) {
414
+		if ($args['type']) {
415 415
 
416 416
 			// open
417
-			$output .= '<' . sanitize_html_class( $args['type'] );
417
+			$output .= '<' . sanitize_html_class($args['type']);
418 418
 
419 419
 			// element require
420
-			if ( ! empty( $args['element_require'] ) ) {
421
-				$output .= AUI_Component_Helper::element_require( $args['element_require'] );
420
+			if (!empty($args['element_require'])) {
421
+				$output .= AUI_Component_Helper::element_require($args['element_require']);
422 422
 				$args['class'] .= " aui-conditional-field";
423 423
 			}
424 424
 
425 425
 			// argument_id
426
-			if ( ! empty( $args['argument_id'] ) ) {
427
-				$output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
426
+			if (!empty($args['argument_id'])) {
427
+				$output .= ' data-argument="' . esc_attr($args['argument_id']) . '"';
428 428
 			}
429 429
 
430 430
 			// class
431
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
431
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
432 432
 			$output .= ' class="' . $class . '" ';
433 433
 
434 434
 			// Attributes
435
-			if ( ! empty( $args['wrap_attributes'] ) ) {
436
-				$output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
435
+			if (!empty($args['wrap_attributes'])) {
436
+				$output .= AUI_Component_Helper::extra_attributes($args['wrap_attributes']);
437 437
 			}
438 438
 
439 439
 			// close wrap
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
 
442 442
 
443 443
 			// Input group left
444
-			if ( ! empty( $args['input_group_left'] ) ) {
445
-				$position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
446
-				$input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
444
+			if (!empty($args['input_group_left'])) {
445
+				$position_class   = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
446
+				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
447 447
 				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
448 448
 			}
449 449
 
@@ -451,15 +451,15 @@  discard block
 block discarded – undo
451 451
 			$output .= $args['content'];
452 452
 
453 453
 			// Input group right
454
-			if ( ! empty( $args['input_group_right'] ) ) {
455
-				$position_class    = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
456
-				$input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
454
+			if (!empty($args['input_group_right'])) {
455
+				$position_class    = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
456
+				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
457 457
 				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
458 458
 			}
459 459
 
460 460
 
461 461
 			// close wrap
462
-			$output .= '</' . sanitize_html_class( $args['type'] ) . '>';
462
+			$output .= '</' . sanitize_html_class($args['type']) . '>';
463 463
 
464 464
 
465 465
 		} else {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 *
477 477
 	 * @return string The rendered component.
478 478
 	 */
479
-	public static function textarea( $args = array() ) {
479
+	public static function textarea($args = array()) {
480 480
 		$defaults = array(
481 481
 			'name'               => '',
482 482
 			'class'              => '',
@@ -513,28 +513,28 @@  discard block
 block discarded – undo
513 513
 		/**
514 514
 		 * Parse incoming $args into an array and merge it with $defaults
515 515
 		 */
516
-		$args   = wp_parse_args( $args, $defaults );
516
+		$args   = wp_parse_args($args, $defaults);
517 517
 		$output = '';
518 518
 
519 519
 		// hidden label option needs to be empty
520 520
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
521 521
 
522 522
 		// floating labels don't work with wysiwyg so set it as top
523
-		if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
523
+		if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) {
524 524
 			$args['label_type'] = 'top';
525 525
 		}
526 526
 
527 527
 		$label_after = $args['label_after'];
528 528
 
529 529
 		// floating labels need label after
530
-		if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
530
+		if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) {
531 531
 			$label_after         = true;
532 532
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
533 533
 		}
534 534
 
535 535
 		// label
536
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
537
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
536
+		if (!empty($args['label']) && is_array($args['label'])) {
537
+		} elseif (!empty($args['label']) && !$label_after) {
538 538
 			$label_args = array(
539 539
 				'title'      => $args['label'],
540 540
 				'for'        => $args['id'],
@@ -542,34 +542,34 @@  discard block
 block discarded – undo
542 542
 				'label_type' => $args['label_type'],
543 543
 				'label_col'  => $args['label_col']
544 544
 			);
545
-			$output .= self::label( $label_args );
545
+			$output .= self::label($label_args);
546 546
 		}
547 547
 
548 548
 		// maybe horizontal label
549
-		if ( $args['label_type'] == 'horizontal' ) {
550
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
549
+		if ($args['label_type'] == 'horizontal') {
550
+			$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
551 551
 			$output .= '<div class="' . $input_col . '">';
552 552
 		}
553 553
 
554
-		if ( ! empty( $args['wysiwyg'] ) ) {
554
+		if (!empty($args['wysiwyg'])) {
555 555
 			ob_start();
556 556
 			$content   = $args['value'];
557
-			$editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
557
+			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
558 558
 			$settings  = array(
559
-				'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
559
+				'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
560 560
 				'quicktags'     => false,
561 561
 				'media_buttons' => false,
562 562
 				'editor_class'  => 'form-control',
563
-				'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
563
+				'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
564 564
 				'teeny'         => true,
565 565
 			);
566 566
 
567 567
 			// maybe set settings if array
568
-			if ( is_array( $args['wysiwyg'] ) ) {
569
-				$settings = wp_parse_args( $args['wysiwyg'], $settings );
568
+			if (is_array($args['wysiwyg'])) {
569
+				$settings = wp_parse_args($args['wysiwyg'], $settings);
570 570
 			}
571 571
 
572
-			wp_editor( $content, $editor_id, $settings );
572
+			wp_editor($content, $editor_id, $settings);
573 573
 			$output .= ob_get_clean();
574 574
 		} else {
575 575
 
@@ -577,65 +577,65 @@  discard block
 block discarded – undo
577 577
 			$output .= '<textarea ';
578 578
 
579 579
 			// name
580
-			if ( ! empty( $args['name'] ) ) {
581
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
580
+			if (!empty($args['name'])) {
581
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
582 582
 			}
583 583
 
584 584
 			// id
585
-			if ( ! empty( $args['id'] ) ) {
586
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
585
+			if (!empty($args['id'])) {
586
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
587 587
 			}
588 588
 
589 589
 			// placeholder
590
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
591
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
590
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
591
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
592 592
 			}
593 593
 
594 594
 			// title
595
-			if ( ! empty( $args['title'] ) ) {
596
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
595
+			if (!empty($args['title'])) {
596
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
597 597
 			}
598 598
 
599 599
 			// validation text
600
-			if ( ! empty( $args['validation_text'] ) ) {
601
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
600
+			if (!empty($args['validation_text'])) {
601
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
602 602
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
603 603
 			}
604 604
 
605 605
 			// validation_pattern
606
-			if ( ! empty( $args['validation_pattern'] ) ) {
607
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
606
+			if (!empty($args['validation_pattern'])) {
607
+				$output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" ';
608 608
 			}
609 609
 
610 610
 			// required
611
-			if ( ! empty( $args['required'] ) ) {
611
+			if (!empty($args['required'])) {
612 612
 				$output .= ' required ';
613 613
 			}
614 614
 
615 615
 			// rows
616
-			if ( ! empty( $args['rows'] ) ) {
617
-				$output .= ' rows="' . absint( $args['rows'] ) . '" ';
616
+			if (!empty($args['rows'])) {
617
+				$output .= ' rows="' . absint($args['rows']) . '" ';
618 618
 			}
619 619
 
620 620
 
621 621
 			// class
622
-			$class = ! empty( $args['class'] ) ? $args['class'] : '';
622
+			$class = !empty($args['class']) ? $args['class'] : '';
623 623
 			$output .= ' class="form-control ' . $class . '" ';
624 624
 
625 625
 			// extra attributes
626
-			if ( ! empty( $args['extra_attributes'] ) ) {
627
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
626
+			if (!empty($args['extra_attributes'])) {
627
+				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
628 628
 			}
629 629
 
630 630
 			// close tag
631 631
 			$output .= ' >';
632 632
 
633 633
 			// value
634
-			if ( ! empty( $args['value'] ) ) {
635
-				if ( ! empty( $args['allow_tags'] ) ) {
636
-					$output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
634
+			if (!empty($args['value'])) {
635
+				if (!empty($args['allow_tags'])) {
636
+					$output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML.
637 637
 				} else {
638
-					$output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] );
638
+					$output .= AUI_Component_Helper::sanitize_textarea_field($args['value']);
639 639
 				}
640 640
 			}
641 641
 
@@ -644,23 +644,23 @@  discard block
 block discarded – undo
644 644
 
645 645
 
646 646
 			// input group wraps
647
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
648
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
649
-				if ( $args['input_group_left'] ) {
650
-					$output = self::wrap( array(
647
+			if ($args['input_group_left'] || $args['input_group_right']) {
648
+				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
649
+				if ($args['input_group_left']) {
650
+					$output = self::wrap(array(
651 651
 						'content'                 => $output,
652 652
 						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
653 653
 						'input_group_left'        => $args['input_group_left'],
654 654
 						'input_group_left_inside' => $args['input_group_left_inside']
655
-					) );
655
+					));
656 656
 				}
657
-				if ( $args['input_group_right'] ) {
658
-					$output = self::wrap( array(
657
+				if ($args['input_group_right']) {
658
+					$output = self::wrap(array(
659 659
 						'content'                  => $output,
660 660
 						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
661 661
 						'input_group_right'        => $args['input_group_right'],
662 662
 						'input_group_right_inside' => $args['input_group_right_inside']
663
-					) );
663
+					));
664 664
 				}
665 665
 
666 666
 			}
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 
669 669
 		}
670 670
 
671
-		if ( ! empty( $args['label'] ) && $label_after ) {
671
+		if (!empty($args['label']) && $label_after) {
672 672
 			$label_args = array(
673 673
 				'title'      => $args['label'],
674 674
 				'for'        => $args['id'],
@@ -676,32 +676,32 @@  discard block
 block discarded – undo
676 676
 				'label_type' => $args['label_type'],
677 677
 				'label_col'  => $args['label_col']
678 678
 			);
679
-			$output .= self::label( $label_args );
679
+			$output .= self::label($label_args);
680 680
 		}
681 681
 
682 682
 		// help text
683
-		if ( ! empty( $args['help_text'] ) ) {
684
-			$output .= AUI_Component_Helper::help_text( $args['help_text'] );
683
+		if (!empty($args['help_text'])) {
684
+			$output .= AUI_Component_Helper::help_text($args['help_text']);
685 685
 		}
686 686
 
687 687
 		// maybe horizontal label
688
-		if ( $args['label_type'] == 'horizontal' ) {
688
+		if ($args['label_type'] == 'horizontal') {
689 689
 			$output .= '</div>';
690 690
 		}
691 691
 
692 692
 
693 693
 		// wrap
694
-		if ( ! $args['no_wrap'] ) {
694
+		if (!$args['no_wrap']) {
695 695
 			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
696 696
 			$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
697
-			$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
698
-			$output           = self::wrap( array(
697
+			$wrap_class       = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
698
+			$output           = self::wrap(array(
699 699
 				'content'         => $output,
700 700
 				'class'           => $wrap_class,
701 701
 				'element_require' => $args['element_require'],
702 702
 				'argument_id'     => $args['id'],
703 703
 				'wrap_attributes' => $args['wrap_attributes'],
704
-			) );
704
+			));
705 705
 		}
706 706
 
707 707
 
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 	 *
716 716
 	 * @return string The rendered component.
717 717
 	 */
718
-	public static function select( $args = array() ) {
718
+	public static function select($args = array()) {
719 719
 		$defaults = array(
720 720
 			'class'            => '',
721 721
 			'wrap_class'       => '',
@@ -752,11 +752,11 @@  discard block
 block discarded – undo
752 752
 		/**
753 753
 		 * Parse incoming $args into an array and merge it with $defaults
754 754
 		 */
755
-		$args   = wp_parse_args( $args, $defaults );
755
+		$args   = wp_parse_args($args, $defaults);
756 756
 		$output = '';
757 757
 
758 758
 		// for now lets hide floating labels
759
-		if ( $args['label_type'] == 'floating' ) {
759
+		if ($args['label_type'] == 'floating') {
760 760
 			$args['label_type'] = 'hidden';
761 761
 		}
762 762
 
@@ -767,31 +767,31 @@  discard block
 block discarded – undo
767 767
 		$label_after = $args['label_after'];
768 768
 
769 769
 		// floating labels need label after
770
-		if ( $args['label_type'] == 'floating' ) {
770
+		if ($args['label_type'] == 'floating') {
771 771
 			$label_after         = true;
772 772
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
773 773
 		}
774 774
 
775 775
 		// Maybe setup select2
776 776
 		$is_select2 = false;
777
-		if ( ! empty( $args['select2'] ) ) {
777
+		if (!empty($args['select2'])) {
778 778
 			$args['class'] .= ' aui-select2';
779 779
 			$is_select2 = true;
780
-		} elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
780
+		} elseif (strpos($args['class'], 'aui-select2') !== false) {
781 781
 			$is_select2 = true;
782 782
 		}
783 783
 
784 784
 		// select2 tags
785
-		if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
785
+		if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason
786 786
 			$args['data-tags']             = 'true';
787 787
 			$args['data-token-separators'] = "[',']";
788 788
 			$args['multiple']              = true;
789 789
 		}
790 790
 
791 791
 		// select2 placeholder
792
-		if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
793
-			$args['data-placeholder'] = esc_attr( $args['placeholder'] );
794
-			$args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
792
+		if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) {
793
+			$args['data-placeholder'] = esc_attr($args['placeholder']);
794
+			$args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
795 795
 		}
796 796
 
797 797
 
@@ -803,61 +803,61 @@  discard block
 block discarded – undo
803 803
 //		}
804 804
 
805 805
 		// Set hidden input to save empty value for multiselect.
806
-		if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
807
-			$output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>';
806
+		if (!empty($args['multiple']) && !empty($args['name'])) {
807
+			$output .= '<input type="hidden" ' . AUI_Component_Helper::name($args['name']) . ' value=""/>';
808 808
 		}
809 809
 
810 810
 		// open/type
811 811
 		$output .= '<select ';
812 812
 
813 813
 		// style
814
-		if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
814
+		if ($is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
815 815
 			$output .= " style='width:100%;' ";
816 816
 		}
817 817
 
818 818
 		// element require
819
-		if ( ! empty( $args['element_require'] ) ) {
820
-			$output .= AUI_Component_Helper::element_require( $args['element_require'] );
819
+		if (!empty($args['element_require'])) {
820
+			$output .= AUI_Component_Helper::element_require($args['element_require']);
821 821
 			$args['class'] .= " aui-conditional-field";
822 822
 		}
823 823
 
824 824
 		// class
825
-		$class = ! empty( $args['class'] ) ? $args['class'] : '';
826
-		$output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class );
825
+		$class = !empty($args['class']) ? $args['class'] : '';
826
+		$output .= AUI_Component_Helper::class_attr('custom-select ' . $class);
827 827
 
828 828
 		// name
829
-		if ( ! empty( $args['name'] ) ) {
830
-			$output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
829
+		if (!empty($args['name'])) {
830
+			$output .= AUI_Component_Helper::name($args['name'], $args['multiple']);
831 831
 		}
832 832
 
833 833
 		// id
834
-		if ( ! empty( $args['id'] ) ) {
835
-			$output .= AUI_Component_Helper::id( $args['id'] );
834
+		if (!empty($args['id'])) {
835
+			$output .= AUI_Component_Helper::id($args['id']);
836 836
 		}
837 837
 
838 838
 		// title
839
-		if ( ! empty( $args['title'] ) ) {
840
-			$output .= AUI_Component_Helper::title( $args['title'] );
839
+		if (!empty($args['title'])) {
840
+			$output .= AUI_Component_Helper::title($args['title']);
841 841
 		}
842 842
 
843 843
 		// data-attributes
844
-		$output .= AUI_Component_Helper::data_attributes( $args );
844
+		$output .= AUI_Component_Helper::data_attributes($args);
845 845
 
846 846
 		// aria-attributes
847
-		$output .= AUI_Component_Helper::aria_attributes( $args );
847
+		$output .= AUI_Component_Helper::aria_attributes($args);
848 848
 
849 849
 		// extra attributes
850
-		if ( ! empty( $args['extra_attributes'] ) ) {
851
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
850
+		if (!empty($args['extra_attributes'])) {
851
+			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
852 852
 		}
853 853
 
854 854
 		// required
855
-		if ( ! empty( $args['required'] ) ) {
855
+		if (!empty($args['required'])) {
856 856
 			$output .= ' required ';
857 857
 		}
858 858
 
859 859
 		// multiple
860
-		if ( ! empty( $args['multiple'] ) ) {
860
+		if (!empty($args['multiple'])) {
861 861
 			$output .= ' multiple ';
862 862
 		}
863 863
 
@@ -865,50 +865,50 @@  discard block
 block discarded – undo
865 865
 		$output .= ' >';
866 866
 
867 867
 		// placeholder
868
-		if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
869
-			$output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
870
-		} elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
868
+		if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) {
869
+			$output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>';
870
+		} elseif ($is_select2 && !empty($args['placeholder'])) {
871 871
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
872 872
 		}
873 873
 
874 874
 		// Options
875
-		if ( ! empty( $args['options'] ) ) {
875
+		if (!empty($args['options'])) {
876 876
 
877
-			if ( ! is_array( $args['options'] ) ) {
877
+			if (!is_array($args['options'])) {
878 878
 				$output .= $args['options']; // not the preferred way but an option
879 879
 			} else {
880
-				foreach ( $args['options'] as $val => $name ) {
880
+				foreach ($args['options'] as $val => $name) {
881 881
 					$selected = '';
882
-					if ( is_array( $name ) ) {
883
-						if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
884
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
882
+					if (is_array($name)) {
883
+						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
884
+							$option_label = isset($name['label']) ? $name['label'] : '';
885 885
 
886
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
886
+							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
887 887
 						} else {
888
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
889
-							$option_value = isset( $name['value'] ) ? $name['value'] : '';
890
-							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
891
-							if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
892
-								$selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
893
-							} elseif ( ! empty( $args['value'] ) ) {
894
-								$selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
895
-							} elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) {
896
-								$selected = selected( $option_value, $args['value'], false );
888
+							$option_label = isset($name['label']) ? $name['label'] : '';
889
+							$option_value = isset($name['value']) ? $name['value'] : '';
890
+							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes($name['extra_attributes']) : '';
891
+							if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) {
892
+								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
893
+							} elseif (!empty($args['value'])) {
894
+								$selected = selected($option_value, stripslashes_deep($args['value']), false);
895
+							} elseif (empty($args['value']) && $args['value'] === $option_value) {
896
+								$selected = selected($option_value, $args['value'], false);
897 897
 							}
898 898
 
899
-							$output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
899
+							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . ' ' . $extra_attributes . '>' . $option_label . '</option>';
900 900
 						}
901 901
 					} else {
902
-						if ( ! empty( $args['value'] ) ) {
903
-							if ( is_array( $args['value'] ) ) {
904
-								$selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
905
-							} elseif ( ! empty( $args['value'] ) ) {
906
-								$selected = selected( $args['value'], $val, false );
902
+						if (!empty($args['value'])) {
903
+							if (is_array($args['value'])) {
904
+								$selected = in_array($val, $args['value']) ? 'selected="selected"' : '';
905
+							} elseif (!empty($args['value'])) {
906
+								$selected = selected($args['value'], $val, false);
907 907
 							}
908
-						} elseif ( $args['value'] === $val ) {
909
-							$selected = selected( $args['value'], $val, false );
908
+						} elseif ($args['value'] === $val) {
909
+							$selected = selected($args['value'], $val, false);
910 910
 						}
911
-						$output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
911
+						$output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>';
912 912
 					}
913 913
 				}
914 914
 			}
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
 		$label = '';
922 922
 		$help_text = '';
923 923
 		// label
924
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
925
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
924
+		if (!empty($args['label']) && is_array($args['label'])) {
925
+		} elseif (!empty($args['label']) && !$label_after) {
926 926
 			$label_args = array(
927 927
 				'title'      => $args['label'],
928 928
 				'for'        => $args['id'],
@@ -930,49 +930,49 @@  discard block
 block discarded – undo
930 930
 				'label_type' => $args['label_type'],
931 931
 				'label_col'  => $args['label_col']
932 932
 			);
933
-			$label = self::label( $label_args );
933
+			$label = self::label($label_args);
934 934
 		}
935 935
 
936 936
 		// help text
937
-		if ( ! empty( $args['help_text'] ) ) {
938
-			$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
937
+		if (!empty($args['help_text'])) {
938
+			$help_text = AUI_Component_Helper::help_text($args['help_text']);
939 939
 		}
940 940
 
941 941
 		// input group wraps
942
-		if ( $args['input_group_left'] || $args['input_group_right'] ) {
943
-			$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
944
-			if ( $args['input_group_left'] ) {
945
-				$output = self::wrap( array(
942
+		if ($args['input_group_left'] || $args['input_group_right']) {
943
+			$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
944
+			if ($args['input_group_left']) {
945
+				$output = self::wrap(array(
946 946
 					'content'                 => $output,
947 947
 					'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
948 948
 					'input_group_left'        => $args['input_group_left'],
949 949
 					'input_group_left_inside' => $args['input_group_left_inside']
950
-				) );
950
+				));
951 951
 			}
952
-			if ( $args['input_group_right'] ) {
953
-				$output = self::wrap( array(
952
+			if ($args['input_group_right']) {
953
+				$output = self::wrap(array(
954 954
 					'content'                  => $output,
955 955
 					'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
956 956
 					'input_group_right'        => $args['input_group_right'],
957 957
 					'input_group_right_inside' => $args['input_group_right_inside']
958
-				) );
958
+				));
959 959
 			}
960 960
 
961 961
 		}
962 962
 
963
-		if ( ! $label_after ) {
963
+		if (!$label_after) {
964 964
 			$output .= $help_text;
965 965
 		}
966 966
 
967 967
 
968
-		if ( $args['label_type'] == 'horizontal' ) {
969
-			$output = self::wrap( array(
968
+		if ($args['label_type'] == 'horizontal') {
969
+			$output = self::wrap(array(
970 970
 				'content' => $output,
971
-				'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
972
-			) );
971
+				'class'   => AUI_Component_Helper::get_column_class($args['label_col'], 'input')
972
+			));
973 973
 		}
974 974
 
975
-		if ( ! $label_after ) {
975
+		if (!$label_after) {
976 976
 			$output = $label . $output;
977 977
 		}
978 978
 
@@ -983,16 +983,16 @@  discard block
 block discarded – undo
983 983
 
984 984
 
985 985
 		// wrap
986
-		if ( ! $args['no_wrap'] ) {
986
+		if (!$args['no_wrap']) {
987 987
 			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
988
-			$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
989
-			$output     = self::wrap( array(
988
+			$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
989
+			$output     = self::wrap(array(
990 990
 				'content'         => $output,
991 991
 				'class'           => $wrap_class,
992 992
 				'element_require' => $args['element_require'],
993 993
 				'argument_id'     => $args['id'],
994 994
 				'wrap_attributes' => $args['wrap_attributes'],
995
-			) );
995
+			));
996 996
 		}
997 997
 
998 998
 
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 	 *
1007 1007
 	 * @return string The rendered component.
1008 1008
 	 */
1009
-	public static function radio( $args = array() ) {
1009
+	public static function radio($args = array()) {
1010 1010
 		$defaults = array(
1011 1011
 			'class'            => '',
1012 1012
 			'wrap_class'       => '',
@@ -1036,10 +1036,10 @@  discard block
 block discarded – undo
1036 1036
 		/**
1037 1037
 		 * Parse incoming $args into an array and merge it with $defaults
1038 1038
 		 */
1039
-		$args = wp_parse_args( $args, $defaults );
1039
+		$args = wp_parse_args($args, $defaults);
1040 1040
 
1041 1041
 		// for now lets use horizontal for floating
1042
-		if ( $args['label_type'] == 'floating' ) {
1042
+		if ($args['label_type'] == 'floating') {
1043 1043
 			$args['label_type'] = 'horizontal';
1044 1044
 		}
1045 1045
 
@@ -1054,47 +1054,47 @@  discard block
 block discarded – undo
1054 1054
 
1055 1055
 
1056 1056
 		// label before
1057
-		if ( ! empty( $args['label'] ) ) {
1058
-			$output .= self::label( $label_args, 'radio' );
1057
+		if (!empty($args['label'])) {
1058
+			$output .= self::label($label_args, 'radio');
1059 1059
 		}
1060 1060
 
1061 1061
 		// maybe horizontal label
1062
-		if ( $args['label_type'] == 'horizontal' ) {
1063
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1062
+		if ($args['label_type'] == 'horizontal') {
1063
+			$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
1064 1064
 			$output .= '<div class="' . $input_col . '">';
1065 1065
 		}
1066 1066
 
1067
-		if ( ! empty( $args['options'] ) ) {
1067
+		if (!empty($args['options'])) {
1068 1068
 			$count = 0;
1069
-			foreach ( $args['options'] as $value => $label ) {
1069
+			foreach ($args['options'] as $value => $label) {
1070 1070
 				$option_args            = $args;
1071 1071
 				$option_args['value']   = $value;
1072 1072
 				$option_args['label']   = $label;
1073 1073
 				$option_args['checked'] = $value == $args['value'] ? true : false;
1074
-				$output .= self::radio_option( $option_args, $count );
1075
-				$count ++;
1074
+				$output .= self::radio_option($option_args, $count);
1075
+				$count++;
1076 1076
 			}
1077 1077
 		}
1078 1078
 
1079 1079
 		// help text
1080
-		$help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1080
+		$help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : '';
1081 1081
 		$output .= $help_text;
1082 1082
 
1083 1083
 		// maybe horizontal label
1084
-		if ( $args['label_type'] == 'horizontal' ) {
1084
+		if ($args['label_type'] == 'horizontal') {
1085 1085
 			$output .= '</div>';
1086 1086
 		}
1087 1087
 
1088 1088
 		// wrap
1089 1089
 		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
1090
-		$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1091
-		$output     = self::wrap( array(
1090
+		$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1091
+		$output     = self::wrap(array(
1092 1092
 			'content'         => $output,
1093 1093
 			'class'           => $wrap_class,
1094 1094
 			'element_require' => $args['element_require'],
1095 1095
 			'argument_id'     => $args['id'],
1096 1096
 			'wrap_attributes' => $args['wrap_attributes'],
1097
-		) );
1097
+		));
1098 1098
 
1099 1099
 
1100 1100
 		return $output;
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 	 *
1108 1108
 	 * @return string The rendered component.
1109 1109
 	 */
1110
-	public static function radio_option( $args = array(), $count = '' ) {
1110
+	public static function radio_option($args = array(), $count = '') {
1111 1111
 		$defaults = array(
1112 1112
 			'class'            => '',
1113 1113
 			'id'               => '',
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 		/**
1126 1126
 		 * Parse incoming $args into an array and merge it with $defaults
1127 1127
 		 */
1128
-		$args = wp_parse_args( $args, $defaults );
1128
+		$args = wp_parse_args($args, $defaults);
1129 1129
 
1130 1130
 		$output = '';
1131 1131
 
@@ -1136,43 +1136,43 @@  discard block
 block discarded – undo
1136 1136
 		$output .= ' class="form-check-input" ';
1137 1137
 
1138 1138
 		// name
1139
-		if ( ! empty( $args['name'] ) ) {
1140
-			$output .= AUI_Component_Helper::name( $args['name'] );
1139
+		if (!empty($args['name'])) {
1140
+			$output .= AUI_Component_Helper::name($args['name']);
1141 1141
 		}
1142 1142
 
1143 1143
 		// id
1144
-		if ( ! empty( $args['id'] ) ) {
1145
-			$output .= AUI_Component_Helper::id( $args['id'] . $count );
1144
+		if (!empty($args['id'])) {
1145
+			$output .= AUI_Component_Helper::id($args['id'] . $count);
1146 1146
 		}
1147 1147
 
1148 1148
 		// title
1149
-		if ( ! empty( $args['title'] ) ) {
1150
-			$output .= AUI_Component_Helper::title( $args['title'] );
1149
+		if (!empty($args['title'])) {
1150
+			$output .= AUI_Component_Helper::title($args['title']);
1151 1151
 		}
1152 1152
 
1153 1153
 		// value
1154
-		if ( isset( $args['value'] ) ) {
1155
-			$output .= AUI_Component_Helper::value( $args['value'] );
1154
+		if (isset($args['value'])) {
1155
+			$output .= AUI_Component_Helper::value($args['value']);
1156 1156
 		}
1157 1157
 
1158 1158
 		// checked, for radio and checkboxes
1159
-		if ( $args['checked'] ) {
1159
+		if ($args['checked']) {
1160 1160
 			$output .= ' checked ';
1161 1161
 		}
1162 1162
 
1163 1163
 		// data-attributes
1164
-		$output .= AUI_Component_Helper::data_attributes( $args );
1164
+		$output .= AUI_Component_Helper::data_attributes($args);
1165 1165
 
1166 1166
 		// aria-attributes
1167
-		$output .= AUI_Component_Helper::aria_attributes( $args );
1167
+		$output .= AUI_Component_Helper::aria_attributes($args);
1168 1168
 
1169 1169
 		// extra attributes
1170
-		if ( ! empty( $args['extra_attributes'] ) ) {
1171
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1170
+		if (!empty($args['extra_attributes'])) {
1171
+			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
1172 1172
 		}
1173 1173
 
1174 1174
 		// required
1175
-		if ( ! empty( $args['required'] ) ) {
1175
+		if (!empty($args['required'])) {
1176 1176
 			$output .= ' required ';
1177 1177
 		}
1178 1178
 
@@ -1180,38 +1180,38 @@  discard block
 block discarded – undo
1180 1180
 		$output .= ' >';
1181 1181
 
1182 1182
 		// label
1183
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1184
-		} elseif ( ! empty( $args['label'] ) ) {
1185
-			$output .= self::label( array(
1183
+		if (!empty($args['label']) && is_array($args['label'])) {
1184
+		} elseif (!empty($args['label'])) {
1185
+			$output .= self::label(array(
1186 1186
 				'title' => $args['label'],
1187 1187
 				'for'   => $args['id'] . $count,
1188 1188
 				'class' => 'form-check-label'
1189
-			), 'radio' );
1189
+			), 'radio');
1190 1190
 		}
1191 1191
 
1192 1192
 		// wrap
1193
-		if ( ! $args['no_wrap'] ) {
1193
+		if (!$args['no_wrap']) {
1194 1194
 			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1195 1195
 
1196 1196
 			// Unique wrap class
1197 1197
 			$uniq_class = 'fwrap';
1198
-			if ( ! empty( $args['name'] ) ) {
1198
+			if (!empty($args['name'])) {
1199 1199
 				$uniq_class .= '-' . $args['name'];
1200
-			} else if ( ! empty( $args['id'] ) ) {
1200
+			} else if (!empty($args['id'])) {
1201 1201
 				$uniq_class .= '-' . $args['id'];
1202 1202
 			}
1203 1203
 
1204
-			if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1204
+			if (isset($args['value']) || $args['value'] !== "") {
1205 1205
 				$uniq_class .= '-' . $args['value'];
1206 1206
 			} else {
1207 1207
 				$uniq_class .= '-' . $count;
1208 1208
 			}
1209
-			$wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1209
+			$wrap_class .= ' ' . sanitize_html_class($uniq_class);
1210 1210
 
1211
-			$output = self::wrap( array(
1211
+			$output = self::wrap(array(
1212 1212
 				'content' => $output,
1213 1213
 				'class'   => $wrap_class
1214
-			) );
1214
+			));
1215 1215
 		}
1216 1216
 
1217 1217
 		return $output;
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-details.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Item_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the item.
@@ -270,35 +270,35 @@  discard block
 block discarded – undo
270 270
     }
271 271
 
272 272
     /**
273
-	 * Save meta box data.
274
-	 *
275
-	 * @param int $post_id
276
-	 */
277
-	public static function save( $post_id ) {
273
+     * Save meta box data.
274
+     *
275
+     * @param int $post_id
276
+     */
277
+    public static function save( $post_id ) {
278 278
 
279 279
         // Prepare the item.
280 280
         $item = new WPInv_Item( $post_id );
281 281
 
282 282
         // Load new data.
283 283
         $item->set_props(
284
-			array(
285
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
-				'is_dynamic_pricing'   => ! empty( $_POST['wpinv_name_your_price'] ),
284
+            array(
285
+                'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
+                'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
+                'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
+                'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
+                'is_dynamic_pricing'   => ! empty( $_POST['wpinv_name_your_price'] ),
290 290
                 'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
291
-				'is_recurring'         => ! empty( $_POST['wpinv_is_recurring'] ),
292
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
298
-			)
291
+                'is_recurring'         => ! empty( $_POST['wpinv_is_recurring'] ),
292
+                'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
+                'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
+                'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
+                'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
+                'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
+                'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
298
+            )
299 299
         );
300 300
 
301
-		$item->save();
302
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
303
-	}
301
+        $item->save();
302
+        do_action( 'getpaid_item_metabox_save', $post_id, $item );
303
+    }
304 304
 }
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,27 +21,27 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32 32
         // Set the currency position.
33 33
         $position = wpinv_currency_position();
34 34
 
35
-        if ( $position == 'left_space' ) {
35
+        if ($position == 'left_space') {
36 36
             $position = 'left';
37 37
         }
38 38
 
39
-        if ( $position == 'right_space' ) {
39
+        if ($position == 'right_space') {
40 40
             $position = 'right';
41 41
         }
42 42
 
43 43
         ?>
44
-        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" />
44
+        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" />
45 45
         <style>
46 46
             #poststuff .input-group-text,
47 47
             #poststuff .form-control {
@@ -55,21 +55,21 @@  discard block
 block discarded – undo
55 55
         </style>
56 56
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
57 57
 
58
-            <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?>
58
+            <?php do_action('wpinv_item_details_metabox_before_price', $item); ?>
59 59
             <div class="form-group row">
60
-                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label>
60
+                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label>
61 61
                 <div class="col-sm-8">
62 62
                     <div class="row">
63 63
                         <div class="col-sm-4 getpaid-price-input">
64 64
                             <div class="input-group input-group-sm">
65
-                                <?php if( 'left' == $position ) : ?>
65
+                                <?php if ('left' == $position) : ?>
66 66
                                 <div class="input-group-prepend">
67 67
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
68 68
                                 </div>
69 69
                                 <?php endif; ?>
70
-                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
70
+                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
71 71
 
72
-                                <?php if( 'left' != $position ) : ?>
72
+                                <?php if ('left' != $position) : ?>
73 73
                                 <div class="input-group-append">
74 74
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
75 75
                                 </div>
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
                         </div>
80 80
                         <div class="col-sm-4 wpinv_show_if_recurring">
81 81
                             <?php
82
-                                _e( 'every' );
82
+                                _e('every');
83 83
                                 echo "&nbsp;";
84 84
                             ?>
85
-                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
85
+                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
86 86
                         </div>
87 87
                         <div class="col-sm-4 wpinv_show_if_recurring">
88 88
                             <?php
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
                                     array(
91 91
                                         'id'               => 'wpinv_recurring_period',
92 92
                                         'name'             => 'wpinv_recurring_period',
93
-                                        'label'            => __( 'Period', 'invoicing' ),
94
-                                        'placeholder'      => __( 'Select Period', 'invoicing' ),
95
-                                        'value'            => $item->get_recurring_period( 'edit' ),
93
+                                        'label'            => __('Period', 'invoicing'),
94
+                                        'placeholder'      => __('Select Period', 'invoicing'),
95
+                                        'value'            => $item->get_recurring_period('edit'),
96 96
                                         'select2'          => true,
97 97
                                         'data-allow-clear' => 'false',
98 98
                                         'options'     => array(
99
-                                            'D'  => __( 'day(s)', 'invoicing' ),
100
-                                            'W'  => __( 'week(s)', 'invoicing' ),
101
-                                            'M'  => __( 'month(s)', 'invoicing' ),
102
-                                            'Y'  => __( 'year(s)', 'invoicing' ),
99
+                                            'D'  => __('day(s)', 'invoicing'),
100
+                                            'W'  => __('week(s)', 'invoicing'),
101
+                                            'M'  => __('month(s)', 'invoicing'),
102
+                                            'Y'  => __('year(s)', 'invoicing'),
103 103
                                         )
104 104
                                     )
105 105
                                 );
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
                             <?php
112 112
 
113 113
                                 // Dynamic pricing.
114
-                                if( $item->supports_dynamic_pricing() ) {
114
+                                if ($item->supports_dynamic_pricing()) {
115 115
 
116
-                                    do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
116
+                                    do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item);
117 117
 
118 118
                                     // NYP toggle.
119 119
                                     echo aui()->input(
@@ -121,31 +121,31 @@  discard block
 block discarded – undo
121 121
                                             'id'          => 'wpinv_name_your_price',
122 122
                                             'name'        => 'wpinv_name_your_price',
123 123
                                             'type'        => 'checkbox',
124
-                                            'label'       => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
124
+                                            'label'       => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')),
125 125
                                             'value'       => '1',
126 126
                                             'checked'     => $item->user_can_set_their_price(),
127 127
                                             'no_wrap'     => true,
128 128
                                         )
129 129
                                     );
130 130
 
131
-                                    do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
131
+                                    do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item);
132 132
 
133 133
                                 }
134 134
 
135 135
                                 // Subscriptions.
136
-                                do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item );
136
+                                do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item);
137 137
                                 echo aui()->input(
138 138
                                     array(
139 139
                                         'id'          => 'wpinv_is_recurring',
140 140
                                         'name'        => 'wpinv_is_recurring',
141 141
                                         'type'        => 'checkbox',
142
-                                        'label'       => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ),
142
+                                        'label'       => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')),
143 143
                                         'value'       => '1',
144 144
                                         'checked'     => $item->is_recurring(),
145 145
                                         'no_wrap'     => true,
146 146
                                     )
147 147
                                 );
148
-                                do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item );
148
+                                do_action('wpinv_item_details_metabox_subscription_checkbox', $item);
149 149
 
150 150
                             ?>
151 151
                             <div class="wpinv_show_if_recurring">
@@ -155,30 +155,30 @@  discard block
 block discarded – undo
155 155
                     </div>
156 156
                 </div>
157 157
                 <div class="col-sm-1 pt-2 pl-0">
158
-                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span>
158
+                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span>
159 159
                 </div>
160 160
             </div>
161
-            <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?>
161
+            <?php do_action('wpinv_item_details_metabox_after_price', $item); ?>
162 162
 
163
-            <?php if( $item->supports_dynamic_pricing() ) : ?>
164
-                <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?>
163
+            <?php if ($item->supports_dynamic_pricing()) : ?>
164
+                <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?>
165 165
                 <div class="wpinv_show_if_dynamic wpinv_minimum_price">
166 166
 
167 167
                     <div class="form-group row">
168 168
                         <label for="wpinv_minimum_price" class="col-sm-3 col-form-label">
169
-                            <?php _e( 'Minimum Price', 'invoicing' );?>
169
+                            <?php _e('Minimum Price', 'invoicing'); ?>
170 170
                         </label>
171 171
                         <div class="col-sm-8">
172 172
                             <div class="input-group input-group-sm">
173
-                                <?php if( 'left' == $position ) : ?>
173
+                                <?php if ('left' == $position) : ?>
174 174
                                     <div class="input-group-prepend">
175 175
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
176 176
                                     </div>
177 177
                                 <?php endif; ?>
178 178
 
179
-                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
179
+                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
180 180
 
181
-                                <?php if( 'left' != $position ) : ?>
181
+                                <?php if ('left' != $position) : ?>
182 182
                                     <div class="input-group-append">
183 183
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
184 184
                                     </div>
@@ -187,45 +187,45 @@  discard block
 block discarded – undo
187 187
                         </div>
188 188
 
189 189
                         <div class="col-sm-1 pt-2 pl-0">
190
-                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span>
190
+                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span>
191 191
                         </div>
192 192
                     </div>
193 193
 
194 194
                 </div>
195
-                <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?>
195
+                <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?>
196 196
             <?php endif; ?>
197 197
 
198
-            <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?>
198
+            <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?>
199 199
             <div class="wpinv_show_if_recurring wpinv_maximum_renewals">
200 200
 
201 201
                 <div class="form-group row">
202 202
                     <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label">
203
-                        <?php _e( 'Maximum Renewals', 'invoicing' );?>
203
+                        <?php _e('Maximum Renewals', 'invoicing'); ?>
204 204
                     </label>
205 205
                     <div class="col-sm-8">
206
-                        <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
206
+                        <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
207 207
                     </div>
208 208
                     <div class="col-sm-1 pt-2 pl-0">
209
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span>
209
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span>
210 210
                     </div>
211 211
                 </div>
212 212
 
213 213
             </div>
214
-            <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?>
214
+            <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?>
215 215
 
216
-            <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?>
216
+            <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?>
217 217
             <div class="wpinv_show_if_recurring wpinv_free_trial">
218 218
 
219 219
                 <div class="form-group row">
220
-                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined( 'GETPAID_PAID_TRIALS_VERSION' ) ? _e( 'Free/Paid Trial', 'invoicing' ) : _e( 'Free Trial', 'invoicing' )?></label>
220
+                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined('GETPAID_PAID_TRIALS_VERSION') ? _e('Free/Paid Trial', 'invoicing') : _e('Free Trial', 'invoicing')?></label>
221 221
 
222 222
                     <div class="col-sm-8">
223 223
                         <div class="row">
224 224
                             <div class="col-sm-6">
225
-                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?>
225
+                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?>
226 226
 
227 227
                                 <div>
228
-                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" >
228
+                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" >
229 229
                                 </div>
230 230
                             </div>
231 231
                             <div class="col-sm-6">
@@ -234,17 +234,17 @@  discard block
 block discarded – undo
234 234
                                         array(
235 235
                                             'id'               => 'wpinv_trial_period',
236 236
                                             'name'             => 'wpinv_trial_period',
237
-                                            'label'            => __( 'Trial Period', 'invoicing' ),
238
-                                            'placeholder'      => __( 'Trial Period', 'invoicing' ),
239
-                                            'value'            => $item->get_trial_period( 'edit' ),
237
+                                            'label'            => __('Trial Period', 'invoicing'),
238
+                                            'placeholder'      => __('Trial Period', 'invoicing'),
239
+                                            'value'            => $item->get_trial_period('edit'),
240 240
                                             'select2'          => true,
241 241
                                             'data-allow-clear' => 'false',
242 242
                                             'no_wrap'          => true,
243 243
                                             'options'          => array(
244
-                                                'D'  => __( 'day(s)', 'invoicing' ),
245
-                                                'W'  => __( 'week(s)', 'invoicing' ),
246
-                                                'M'  => __( 'month(s)', 'invoicing' ),
247
-                                                'Y'  => __( 'year(s)', 'invoicing' ),
244
+                                                'D'  => __('day(s)', 'invoicing'),
245
+                                                'W'  => __('week(s)', 'invoicing'),
246
+                                                'M'  => __('month(s)', 'invoicing'),
247
+                                                'Y'  => __('year(s)', 'invoicing'),
248 248
                                             )
249 249
                                         )
250 250
                                     );
@@ -255,15 +255,15 @@  discard block
 block discarded – undo
255 255
                     </div>
256 256
 
257 257
                     <div class="col-sm-1 pt-2 pl-0">
258
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span>
258
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span>
259 259
                     </div>
260 260
 
261 261
                 </div>
262 262
 
263 263
             </div>
264
-            <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?>
264
+            <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?>
265 265
 
266
-            <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?>
266
+            <?php do_action('wpinv_item_details_metabox_item_details', $item); ?>
267 267
         </div>
268 268
         <?php
269 269
 
@@ -274,31 +274,31 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @param int $post_id
276 276
 	 */
277
-	public static function save( $post_id ) {
277
+	public static function save($post_id) {
278 278
 
279 279
         // Prepare the item.
280
-        $item = new WPInv_Item( $post_id );
280
+        $item = new WPInv_Item($post_id);
281 281
 
282 282
         // Load new data.
283 283
         $item->set_props(
284 284
 			array(
285
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
-				'is_dynamic_pricing'   => ! empty( $_POST['wpinv_name_your_price'] ),
290
-                'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
291
-				'is_recurring'         => ! empty( $_POST['wpinv_is_recurring'] ),
292
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
285
+				'price'                => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null,
286
+				'vat_rule'             => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null,
287
+				'vat_class'            => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null,
288
+				'type'                 => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null,
289
+				'is_dynamic_pricing'   => !empty($_POST['wpinv_name_your_price']),
290
+                'minimum_price'        => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null,
291
+				'is_recurring'         => !empty($_POST['wpinv_is_recurring']),
292
+				'recurring_period'     => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null,
293
+				'recurring_interval'   => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
+				'recurring_limit'      => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
+				'is_free_trial'        => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null,
296
+				'trial_period'         => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null,
297
+				'trial_interval'       => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null,
298 298
 			)
299 299
         );
300 300
 
301 301
 		$item->save();
302
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
302
+		do_action('getpaid_item_metabox_save', $post_id, $item);
303 303
 	}
304 304
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-discount-details.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Discount_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the discount.
@@ -396,35 +396,35 @@  discard block
 block discarded – undo
396 396
     }
397 397
 
398 398
     /**
399
-	 * Save meta box data.
400
-	 *
401
-	 * @param int $post_id
402
-	 */
403
-	public static function save( $post_id ) {
399
+     * Save meta box data.
400
+     *
401
+     * @param int $post_id
402
+     */
403
+    public static function save( $post_id ) {
404 404
 
405 405
         // Prepare the discount.
406 406
         $discount = new WPInv_Discount( $post_id );
407 407
 
408 408
         // Load new data.
409 409
         $discount->set_props(
410
-			array(
411
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null,
412
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null,
413
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
414
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
415
-				'is_single_use'        => ! empty( $_POST['wpinv_discount_single_use'] ),
410
+            array(
411
+                'code'                 => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null,
412
+                'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null,
413
+                'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
414
+                'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
415
+                'is_single_use'        => ! empty( $_POST['wpinv_discount_single_use'] ),
416 416
                 'type'                 => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null,
417
-				'is_recurring'         => ! empty( $_POST['wpinv_discount_recurring'] ),
418
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(),
419
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(),
417
+                'is_recurring'         => ! empty( $_POST['wpinv_discount_recurring'] ),
418
+                'items'                => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(),
419
+                'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(),
420 420
                 'required_items'       => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(),
421
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null,
422
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null,
423
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null,
424
-			)
421
+                'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null,
422
+                'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null,
423
+                'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null,
424
+            )
425 425
         );
426 426
 
427
-		$discount->save();
428
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
429
-	}
427
+        $discount->save();
428
+        do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
429
+    }
430 430
 }
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,24 +21,24 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the discount.
27
-        $discount = new WPInv_Discount( $post );
27
+        $discount = new WPInv_Discount($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32
-        do_action( 'wpinv_discount_form_top', $discount );
32
+        do_action('wpinv_discount_form_top', $discount);
33 33
 
34 34
         // Set the currency position.
35 35
         $position = wpinv_currency_position();
36 36
 
37
-        if ( $position == 'left_space' ) {
37
+        if ($position == 'left_space') {
38 38
             $position = 'left';
39 39
         }
40 40
 
41
-        if ( $position == 'right_space' ) {
41
+        if ($position == 'right_space') {
42 42
             $position = 'right';
43 43
         }
44 44
 
@@ -52,66 +52,66 @@  discard block
 block discarded – undo
52 52
         </style>
53 53
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
54 54
 
55
-            <?php do_action( 'wpinv_discount_form_first', $discount ); ?>
55
+            <?php do_action('wpinv_discount_form_first', $discount); ?>
56 56
 
57
-            <?php do_action( 'wpinv_discount_form_before_code', $discount ); ?>
57
+            <?php do_action('wpinv_discount_form_before_code', $discount); ?>
58 58
             <div class="form-group row">
59 59
                 <label for="wpinv_discount_code" class="col-sm-3 col-form-label">
60
-                    <?php _e( 'Discount Code', 'invoicing' );?>
60
+                    <?php _e('Discount Code', 'invoicing'); ?>
61 61
                 </label>
62 62
                 <div class="col-sm-8">
63 63
                     <div class="row">
64 64
                         <div class="col-sm-12 form-group">
65
-                            <input type="text" value="<?php echo esc_attr( $discount->get_code( 'edit' ) ); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
65
+                            <input type="text" value="<?php echo esc_attr($discount->get_code('edit')); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
66 66
                         </div>
67 67
                         <div class="col-sm-12">
68 68
                             <?php
69
-                                do_action( 'wpinv_discount_form_before_single_use', $discount );
69
+                                do_action('wpinv_discount_form_before_single_use', $discount);
70 70
 
71 71
                                 echo aui()->input(
72 72
                                     array(
73 73
                                         'id'          => 'wpinv_discount_single_use',
74 74
                                         'name'        => 'wpinv_discount_single_use',
75 75
                                         'type'        => 'checkbox',
76
-                                        'label'       => __( 'Each customer can only use this discount once', 'invoicing' ),
76
+                                        'label'       => __('Each customer can only use this discount once', 'invoicing'),
77 77
                                         'value'       => '1',
78 78
                                         'checked'     => $discount->is_single_use(),
79 79
                                     )
80 80
                                 );
81 81
 
82
-                                do_action( 'wpinv_discount_form_single_use', $discount );
82
+                                do_action('wpinv_discount_form_single_use', $discount);
83 83
                             ?>
84 84
                         </div>
85 85
                         <div class="col-sm-12">
86 86
                             <?php
87
-                                do_action( 'wpinv_discount_form_before_recurring', $discount );
87
+                                do_action('wpinv_discount_form_before_recurring', $discount);
88 88
 
89 89
                                 echo aui()->input(
90 90
                                     array(
91 91
                                         'id'          => 'wpinv_discount_recurring',
92 92
                                         'name'        => 'wpinv_discount_recurring',
93 93
                                         'type'        => 'checkbox',
94
-                                        'label'       => __( 'Apply this discount to all recurring payments for subscriptions', 'invoicing' ),
94
+                                        'label'       => __('Apply this discount to all recurring payments for subscriptions', 'invoicing'),
95 95
                                         'value'       => '1',
96 96
                                         'checked'     => $discount->is_recurring(),
97 97
                                     )
98 98
                                 );
99 99
 
100
-                                do_action( 'wpinv_discount_form_recurring', $discount );
100
+                                do_action('wpinv_discount_form_recurring', $discount);
101 101
                             ?>
102 102
                         </div>
103 103
                     </div>
104 104
                 </div>
105 105
                 <div class="col-sm-1 pt-2 pl-0">
106
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter a discount code such as 10OFF.', 'invoicing' ); ?>"></span>
106
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter a discount code such as 10OFF.', 'invoicing'); ?>"></span>
107 107
                 </div>
108 108
             </div>
109
-            <?php do_action( 'wpinv_discount_form_code', $discount ); ?>
109
+            <?php do_action('wpinv_discount_form_code', $discount); ?>
110 110
 
111
-            <?php do_action( 'wpinv_discount_form_before_type', $discount ); ?>
111
+            <?php do_action('wpinv_discount_form_before_type', $discount); ?>
112 112
             <div class="form-group row">
113 113
                 <label for="wpinv_discount_type" class="col-sm-3 col-form-label">
114
-                    <?php _e( 'Discount Type', 'invoicing' );?>
114
+                    <?php _e('Discount Type', 'invoicing'); ?>
115 115
                 </label>
116 116
                 <div class="col-sm-8">
117 117
                     <?php
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
                             array(
120 120
                                 'id'               => 'wpinv_discount_type',
121 121
                                 'name'             => 'wpinv_discount_type',
122
-                                'label'            => __( 'Discount Type', 'invoicing' ),
123
-                                'placeholder'      => __( 'Select Discount Type', 'invoicing' ),
124
-                                'value'            => $discount->get_type( 'edit' ),
122
+                                'label'            => __('Discount Type', 'invoicing'),
123
+                                'placeholder'      => __('Select Discount Type', 'invoicing'),
124
+                                'value'            => $discount->get_type('edit'),
125 125
                                 'select2'          => true,
126 126
                                 'data-allow-clear' => 'false',
127 127
                                 'options'          => wpinv_get_discount_types()
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
                     ?>
131 131
                 </div>
132 132
                 <div class="col-sm-1 pt-2 pl-0">
133
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Discount type.', 'invoicing' ); ?>"></span>
133
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Discount type.', 'invoicing'); ?>"></span>
134 134
                 </div>
135 135
             </div>
136
-            <?php do_action( 'wpinv_discount_form_type', $discount ); ?>
136
+            <?php do_action('wpinv_discount_form_type', $discount); ?>
137 137
 
138
-            <?php do_action( 'wpinv_discount_form_before_amount', $discount ); ?>
139
-            <div class="form-group row <?php echo esc_attr( $discount->get_type( 'edit' ) ); ?>" id="wpinv_discount_amount_wrap">
138
+            <?php do_action('wpinv_discount_form_before_amount', $discount); ?>
139
+            <div class="form-group row <?php echo esc_attr($discount->get_type('edit')); ?>" id="wpinv_discount_amount_wrap">
140 140
                 <label for="wpinv_discount_amount" class="col-sm-3 col-form-label">
141
-                    <?php _e( 'Discount Amount', 'invoicing' );?>
141
+                    <?php _e('Discount Amount', 'invoicing'); ?>
142 142
                 </label>
143 143
                 <div class="col-sm-8">
144 144
                     <div class="input-group input-group-sm">
145
-                        <?php if( 'left' == $position ) : ?>
145
+                        <?php if ('left' == $position) : ?>
146 146
                             <div class="input-group-prepend left wpinv-if-flat">
147 147
                                 <span class="input-group-text">
148 148
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
                             </div>
151 151
                         <?php endif; ?>
152 152
 
153
-                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr( $discount->get_amount( 'edit' ) ); ?>" placeholder="0" class="form-control">
153
+                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr($discount->get_amount('edit')); ?>" placeholder="0" class="form-control">
154 154
 
155
-                        <?php if( 'right' == $position ) : ?>
155
+                        <?php if ('right' == $position) : ?>
156 156
                             <div class="input-group-prepend left wpinv-if-flat">
157 157
                                 <span class="input-group-text">
158 158
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
                     </div>
166 166
                 </div>
167 167
                 <div class="col-sm-1 pt-2 pl-0">
168
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?>"></span>
168
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the discount value. Ex: 10', 'invoicing'); ?>"></span>
169 169
                 </div>
170 170
             </div>
171
-            <?php do_action( 'wpinv_discount_form_amount', $discount ); ?>
171
+            <?php do_action('wpinv_discount_form_amount', $discount); ?>
172 172
 
173
-            <?php do_action( 'wpinv_discount_form_before_items', $discount ); ?>
173
+            <?php do_action('wpinv_discount_form_before_items', $discount); ?>
174 174
             <div class="form-group row">
175 175
                 <label for="wpinv_discount_items" class="col-sm-3 col-form-label">
176
-                    <?php _e( 'Items', 'invoicing' );?>
176
+                    <?php _e('Items', 'invoicing'); ?>
177 177
                 </label>
178 178
                 <div class="col-sm-8">
179 179
                     <?php
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
                             array(
182 182
                                 'id'               => 'wpinv_discount_items',
183 183
                                 'name'             => 'wpinv_discount_items[]',
184
-                                'label'            => __( 'Items', 'invoicing' ),
185
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
186
-                                'value'            => $discount->get_items( 'edit' ),
184
+                                'label'            => __('Items', 'invoicing'),
185
+                                'placeholder'      => __('Select Items', 'invoicing'),
186
+                                'value'            => $discount->get_items('edit'),
187 187
                                 'select2'          => true,
188 188
                                 'multiple'         => true,
189 189
                                 'data-allow-clear' => 'false',
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
                     ?>
194 194
                 </div>
195 195
                 <div class="col-sm-1 pt-2 pl-0">
196
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing' ); ?>"></span>
196
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing'); ?>"></span>
197 197
                 </div>
198 198
             </div>
199
-            <?php do_action( 'wpinv_discount_form_items', $discount ); ?>
199
+            <?php do_action('wpinv_discount_form_items', $discount); ?>
200 200
 
201
-            <?php do_action( 'wpinv_discount_form_before_excluded_items', $discount ); ?>
201
+            <?php do_action('wpinv_discount_form_before_excluded_items', $discount); ?>
202 202
             <div class="form-group row">
203 203
                 <label for="wpinv_discount_excluded_items" class="col-sm-3 col-form-label">
204
-                    <?php _e( 'Excluded Items', 'invoicing' );?>
204
+                    <?php _e('Excluded Items', 'invoicing'); ?>
205 205
                 </label>
206 206
                 <div class="col-sm-8">
207 207
                     <?php
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
                             array(
210 210
                                 'id'               => 'wpinv_discount_excluded_items',
211 211
                                 'name'             => 'wpinv_discount_excluded_items[]',
212
-                                'label'            => __( 'Excluded Items', 'invoicing' ),
213
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
214
-                                'value'            => $discount->get_excluded_items( 'edit' ),
212
+                                'label'            => __('Excluded Items', 'invoicing'),
213
+                                'placeholder'      => __('Select Items', 'invoicing'),
214
+                                'value'            => $discount->get_excluded_items('edit'),
215 215
                                 'select2'          => true,
216 216
                                 'multiple'         => true,
217 217
                                 'data-allow-clear' => 'false',
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
                     ?>
222 222
                 </div>
223 223
                 <div class="col-sm-1 pt-2 pl-0">
224
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are not allowed to use this discount.', 'invoicing' ); ?>"></span>
224
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are not allowed to use this discount.', 'invoicing'); ?>"></span>
225 225
                 </div>
226 226
             </div>
227
-            <?php do_action( 'wpinv_discount_form_excluded_items', $discount ); ?>
227
+            <?php do_action('wpinv_discount_form_excluded_items', $discount); ?>
228 228
 
229
-            <?php do_action( 'wpinv_discount_form_before_required_items', $discount ); ?>
229
+            <?php do_action('wpinv_discount_form_before_required_items', $discount); ?>
230 230
             <div class="form-group row">
231 231
                 <label for="wpinv_discount_required_items" class="col-sm-3 col-form-label">
232
-                    <?php _e( 'Required Items', 'invoicing' );?>
232
+                    <?php _e('Required Items', 'invoicing'); ?>
233 233
                 </label>
234 234
                 <div class="col-sm-8">
235 235
                     <?php
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
                             array(
238 238
                                 'id'               => 'wpinv_discount_required_items',
239 239
                                 'name'             => 'wpinv_discount_required_items[]',
240
-                                'label'            => __( 'Required Items', 'invoicing' ),
241
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
242
-                                'value'            => $discount->get_required_items( 'edit' ),
240
+                                'label'            => __('Required Items', 'invoicing'),
241
+                                'placeholder'      => __('Select Items', 'invoicing'),
242
+                                'value'            => $discount->get_required_items('edit'),
243 243
                                 'select2'          => true,
244 244
                                 'multiple'         => true,
245 245
                                 'data-allow-clear' => 'false',
@@ -249,15 +249,15 @@  discard block
 block discarded – undo
249 249
                     ?>
250 250
                 </div>
251 251
                 <div class="col-sm-1 pt-2 pl-0">
252
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are required to be in the cart before using this discount.', 'invoicing' ); ?>"></span>
252
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are required to be in the cart before using this discount.', 'invoicing'); ?>"></span>
253 253
                 </div>
254 254
             </div>
255
-            <?php do_action( 'wpinv_discount_form_required_items', $discount ); ?>
255
+            <?php do_action('wpinv_discount_form_required_items', $discount); ?>
256 256
 
257
-            <?php do_action( 'wpinv_discount_form_before_start', $discount ); ?>
257
+            <?php do_action('wpinv_discount_form_before_start', $discount); ?>
258 258
             <div class="form-group row">
259 259
                 <label for="wpinv_discount_start" class="col-sm-3 col-form-label">
260
-                    <?php _e( 'Start Date', 'invoicing' );?>
260
+                    <?php _e('Start Date', 'invoicing'); ?>
261 261
                 </label>
262 262
                 <div class="col-sm-8">
263 263
                     <?php
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
                                 'type'        => 'datepicker',
267 267
                                 'id'          => 'wpinv_discount_start',
268 268
                                 'name'        => 'wpinv_discount_start',
269
-                                'label'       => __( 'Start Date', 'invoicing' ),
269
+                                'label'       => __('Start Date', 'invoicing'),
270 270
                                 'placeholder' => 'YYYY-MM-DD 00:00',
271 271
                                 'class'       => 'form-control-sm',
272
-                                'value'       => $discount->get_start_date( 'edit' ),
272
+                                'value'       => $discount->get_start_date('edit'),
273 273
                                 'extra_attributes' => array(
274 274
                                     'data-enable-time' => 'true',
275 275
                                     'data-time_24hr'   => 'true',
@@ -280,15 +280,15 @@  discard block
 block discarded – undo
280 280
                     ?>
281 281
                 </div>
282 282
                 <div class="col-sm-1 pt-2 pl-0">
283
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?>"></span>
283
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?>"></span>
284 284
                 </div>
285 285
             </div>
286
-            <?php do_action( 'wpinv_discount_form_start', $discount ); ?>
286
+            <?php do_action('wpinv_discount_form_start', $discount); ?>
287 287
 
288
-            <?php do_action( 'wpinv_discount_form_before_expiration', $discount ); ?>
288
+            <?php do_action('wpinv_discount_form_before_expiration', $discount); ?>
289 289
             <div class="form-group row">
290 290
                 <label for="wpinv_discount_expiration" class="col-sm-3 col-form-label">
291
-                    <?php _e( 'Expiration Date', 'invoicing' );?>
291
+                    <?php _e('Expiration Date', 'invoicing'); ?>
292 292
                 </label>
293 293
                 <div class="col-sm-8">
294 294
                     <?php
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
                                 'type'        => 'datepicker',
298 298
                                 'id'          => 'wpinv_discount_expiration',
299 299
                                 'name'        => 'wpinv_discount_expiration',
300
-                                'label'       => __( 'Expiration Date', 'invoicing' ),
300
+                                'label'       => __('Expiration Date', 'invoicing'),
301 301
                                 'placeholder' => 'YYYY-MM-DD 00:00',
302 302
                                 'class'       => 'form-control-sm',
303
-                                'value'       => $discount->get_end_date( 'edit' ),
303
+                                'value'       => $discount->get_end_date('edit'),
304 304
                                 'extra_attributes' => array(
305 305
                                     'data-enable-time' => 'true',
306 306
                                     'data-time_24hr'   => 'true',
@@ -313,27 +313,27 @@  discard block
 block discarded – undo
313 313
                     ?>
314 314
                 </div>
315 315
                 <div class="col-sm-1 pt-2 pl-0">
316
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the date after which the discount will expire.', 'invoicing' ); ?>"></span>
316
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the date after which the discount will expire.', 'invoicing'); ?>"></span>
317 317
                 </div>
318 318
             </div>
319
-            <?php do_action( 'wpinv_discount_form_expiration', $discount ); ?>
319
+            <?php do_action('wpinv_discount_form_expiration', $discount); ?>
320 320
 
321
-            <?php do_action( 'wpinv_discount_form_before_min_total', $discount ); ?>
321
+            <?php do_action('wpinv_discount_form_before_min_total', $discount); ?>
322 322
             <div class="form-group row">
323 323
                 <label for="wpinv_discount_min_total" class="col-sm-3 col-form-label">
324
-                    <?php _e( 'Minimum Amount', 'invoicing' );?>
324
+                    <?php _e('Minimum Amount', 'invoicing'); ?>
325 325
                 </label>
326 326
                 <div class="col-sm-8">
327 327
                     <div class="input-group input-group-sm">
328
-                        <?php if( 'left' == $position ) : ?>
328
+                        <?php if ('left' == $position) : ?>
329 329
                             <div class="input-group-prepend">
330 330
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
331 331
                             </div>
332 332
                         <?php endif; ?>
333 333
 
334
-                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr( $discount->get_minimum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No minimum', 'invoicing' ); ?>" class="form-control">
334
+                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr($discount->get_minimum_total('edit')); ?>" placeholder="<?php esc_attr_e('No minimum', 'invoicing'); ?>" class="form-control">
335 335
 
336
-                        <?php if( 'left' != $position ) : ?>
336
+                        <?php if ('left' != $position) : ?>
337 337
                             <div class="input-group-append">
338 338
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
339 339
                             </div>
@@ -341,27 +341,27 @@  discard block
 block discarded – undo
341 341
                     </div>
342 342
                 </div>
343 343
                 <div class="col-sm-1 pt-2 pl-0">
344
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing' ); ?>"></span>
344
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing'); ?>"></span>
345 345
                 </div>
346 346
             </div>
347
-            <?php do_action( 'wpinv_discount_form_min_total', $discount ); ?>
347
+            <?php do_action('wpinv_discount_form_min_total', $discount); ?>
348 348
 
349
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
349
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
350 350
             <div class="form-group row">
351 351
                 <label for="wpinv_discount_max_total" class="col-sm-3 col-form-label">
352
-                    <?php _e( 'Maximum Amount', 'invoicing' );?>
352
+                    <?php _e('Maximum Amount', 'invoicing'); ?>
353 353
                 </label>
354 354
                 <div class="col-sm-8">
355 355
                     <div class="input-group input-group-sm">
356
-                        <?php if( 'left' == $position ) : ?>
356
+                        <?php if ('left' == $position) : ?>
357 357
                             <div class="input-group-prepend">
358 358
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
359 359
                             </div>
360 360
                         <?php endif; ?>
361 361
 
362
-                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr( $discount->get_maximum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No maximum', 'invoicing' ); ?>" class="form-control">
362
+                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr($discount->get_maximum_total('edit')); ?>" placeholder="<?php esc_attr_e('No maximum', 'invoicing'); ?>" class="form-control">
363 363
 
364
-                        <?php if( 'left' != $position ) : ?>
364
+                        <?php if ('left' != $position) : ?>
365 365
                             <div class="input-group-append">
366 366
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
367 367
                             </div>
@@ -369,30 +369,30 @@  discard block
 block discarded – undo
369 369
                     </div>
370 370
                 </div>
371 371
                 <div class="col-sm-1 pt-2 pl-0">
372
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing' ); ?>"></span>
372
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing'); ?>"></span>
373 373
                 </div>
374 374
             </div>
375
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
375
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
376 376
 
377
-            <?php do_action( 'wpinv_discount_form_before_max_uses', $discount ); ?>
377
+            <?php do_action('wpinv_discount_form_before_max_uses', $discount); ?>
378 378
             <div class="form-group row">
379 379
                 <label for="wpinv_discount_max_uses" class="col-sm-3 col-form-label">
380
-                    <?php _e( 'Maximum Uses', 'invoicing' );?>
380
+                    <?php _e('Maximum Uses', 'invoicing'); ?>
381 381
                 </label>
382 382
                 <div class="col-sm-8">
383
-                    <input type="text" value="<?php echo esc_attr( $discount->get_max_uses( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'invoicing' ); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
383
+                    <input type="text" value="<?php echo esc_attr($discount->get_max_uses('edit')); ?>" placeholder="<?php esc_attr_e('Unlimited', 'invoicing'); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
384 384
                 </div>
385 385
                 <div class="col-sm-1 pt-2 pl-0">
386
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum number of times that this discount code can be used.', 'invoicing' ); ?>"></span>
386
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum number of times that this discount code can be used.', 'invoicing'); ?>"></span>
387 387
                 </div>
388 388
             </div>
389
-            <?php do_action( 'wpinv_discount_form_max_uses', $discount ); ?>
389
+            <?php do_action('wpinv_discount_form_max_uses', $discount); ?>
390 390
 
391
-            <?php do_action( 'wpinv_discount_form_last', $discount ); ?>
391
+            <?php do_action('wpinv_discount_form_last', $discount); ?>
392 392
 
393 393
         </div>
394 394
         <?php
395
-        do_action( 'wpinv_discount_form_bottom', $post );
395
+        do_action('wpinv_discount_form_bottom', $post);
396 396
     }
397 397
 
398 398
     /**
@@ -400,31 +400,31 @@  discard block
 block discarded – undo
400 400
 	 *
401 401
 	 * @param int $post_id
402 402
 	 */
403
-	public static function save( $post_id ) {
403
+	public static function save($post_id) {
404 404
 
405 405
         // Prepare the discount.
406
-        $discount = new WPInv_Discount( $post_id );
406
+        $discount = new WPInv_Discount($post_id);
407 407
 
408 408
         // Load new data.
409 409
         $discount->set_props(
410 410
 			array(
411
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null,
412
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null,
413
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
414
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
415
-				'is_single_use'        => ! empty( $_POST['wpinv_discount_single_use'] ),
416
-                'type'                 => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null,
417
-				'is_recurring'         => ! empty( $_POST['wpinv_discount_recurring'] ),
418
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(),
419
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(),
420
-                'required_items'       => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(),
421
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null,
422
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null,
423
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null,
411
+				'code'                 => isset($_POST['wpinv_discount_code']) ? wpinv_clean($_POST['wpinv_discount_code']) : null,
412
+				'amount'               => isset($_POST['wpinv_discount_amount']) ? floatval($_POST['wpinv_discount_amount']) : null,
413
+				'start'                => isset($_POST['wpinv_discount_start']) ? wpinv_clean($_POST['wpinv_discount_start']) : null,
414
+				'expiration'           => isset($_POST['wpinv_discount_expiration']) ? wpinv_clean($_POST['wpinv_discount_expiration']) : null,
415
+				'is_single_use'        => !empty($_POST['wpinv_discount_single_use']),
416
+                'type'                 => isset($_POST['wpinv_discount_type']) ? wpinv_clean($_POST['wpinv_discount_type']) : null,
417
+				'is_recurring'         => !empty($_POST['wpinv_discount_recurring']),
418
+				'items'                => isset($_POST['wpinv_discount_items']) ? wpinv_clean($_POST['wpinv_discount_items']) : array(),
419
+				'excluded_items'       => isset($_POST['wpinv_discount_excluded_items']) ? wpinv_clean($_POST['wpinv_discount_excluded_items']) : array(),
420
+                'required_items'       => isset($_POST['wpinv_discount_required_items']) ? wpinv_clean($_POST['wpinv_discount_required_items']) : array(),
421
+				'max_uses'             => isset($_POST['wpinv_discount_max_uses']) ? intval($_POST['wpinv_discount_max_uses']) : null,
422
+				'min_total'            => isset($_POST['wpinv_discount_min_total']) ? floatval($_POST['wpinv_discount_min_total']) : null,
423
+				'max_total'            => isset($_POST['wpinv_discount_max_total']) ? floatval($_POST['wpinv_discount_max_total']) : null,
424 424
 			)
425 425
         );
426 426
 
427 427
 		$discount->save();
428
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
428
+		do_action('getpaid_discount_metabox_save', $post_id, $discount);
429 429
 	}
430 430
 }
Please login to merge, or discard this patch.