Passed
Push — master ( 1e7191...abab7b )
by Brian
05:39
created
includes/admin/class-getpaid-metaboxes.php 2 patches
Indentation   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -12,276 +12,276 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Metaboxes {
14 14
 
15
-	/**
16
-	 * Only save metaboxes once.
17
-	 *
18
-	 * @var boolean
19
-	 */
20
-	private static $saved_meta_boxes = false;
21
-
22 15
     /**
23
-	 * Hook in methods.
24
-	 */
25
-	public static function init() {
26
-
27
-		// Register metaboxes.
28
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 );
29
-
30
-		// Remove metaboxes.
31
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
32
-
33
-		// Rename metaboxes.
34
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
35
-
36
-		// Save metaboxes.
37
-		add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
38
-	}
39
-
40
-	/**
41
-	 * Register core metaboxes.
42
-	 */
43
-	public static function add_meta_boxes( $post_type, $post ) {
44
-
45
-		// For invoices...
46
-		self::add_invoice_meta_boxes( $post_type, $post );
47
-
48
-		// For payment forms.
49
-		self::add_payment_form_meta_boxes( $post_type, $post );
50
-
51
-		// For invoice items.
52
-		self::add_item_meta_boxes( $post_type );
53
-
54
-		// For invoice discounts.
55
-		if ( $post_type == 'wpi_discount' ) {
56
-			add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
57
-		}
58
-
59
-	}
16
+     * Only save metaboxes once.
17
+     *
18
+     * @var boolean
19
+     */
20
+    private static $saved_meta_boxes = false;
60 21
 
61
-	/**
62
-	 * Register core metaboxes.
63
-	 */
64
-	protected static function add_payment_form_meta_boxes( $post_type, $post ) {
22
+    /**
23
+     * Hook in methods.
24
+     */
25
+    public static function init() {
65 26
 
66
-		// For payment forms.
67
-		if ( $post_type == 'wpi_payment_form' ) {
27
+        // Register metaboxes.
28
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 );
68 29
 
69
-			// Design payment form.
70
-			add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
30
+        // Remove metaboxes.
31
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
71 32
 
72
-			// Payment form information.
73
-			if ( $post->ID != wpinv_get_default_payment_form() ) {
74
-				add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
75
-			}
33
+        // Rename metaboxes.
34
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
76 35
 
77
-		}
36
+        // Save metaboxes.
37
+        add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
38
+    }
78 39
 
79
-	}
40
+    /**
41
+     * Register core metaboxes.
42
+     */
43
+    public static function add_meta_boxes( $post_type, $post ) {
80 44
 
81
-	/**
82
-	 * Register core metaboxes.
83
-	 */
84
-	protected static function add_item_meta_boxes( $post_type ) {
45
+        // For invoices...
46
+        self::add_invoice_meta_boxes( $post_type, $post );
85 47
 
86
-		if ( $post_type == 'wpi_item' ) {
48
+        // For payment forms.
49
+        self::add_payment_form_meta_boxes( $post_type, $post );
87 50
 
88
-			// Item details.
89
-			add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
51
+        // For invoice items.
52
+        self::add_item_meta_boxes( $post_type );
90 53
 
91
-			// If taxes are enabled, register the tax metabox.
92
-			if ( wpinv_use_taxes() ) {
93
-				add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
94
-			}
54
+        // For invoice discounts.
55
+        if ( $post_type == 'wpi_discount' ) {
56
+            add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
57
+        }
95 58
 
96
-			// Item info.
97
-			add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
59
+    }
98 60
 
99
-		}
61
+    /**
62
+     * Register core metaboxes.
63
+     */
64
+    protected static function add_payment_form_meta_boxes( $post_type, $post ) {
100 65
 
101
-	}
66
+        // For payment forms.
67
+        if ( $post_type == 'wpi_payment_form' ) {
102 68
 
103
-	/**
104
-	 * Register invoice metaboxes.
105
-	 */
106
-	protected static function add_invoice_meta_boxes( $post_type, $post ) {
69
+            // Design payment form.
70
+            add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
107 71
 
108
-		// For invoices...
109
-		if ( getpaid_is_invoice_post_type( $post_type ) ) {
110
-			$invoice = new WPInv_Invoice( $post );
72
+            // Payment form information.
73
+            if ( $post->ID != wpinv_get_default_payment_form() ) {
74
+                add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
75
+            }
111 76
 
112
-			// Resend invoice.
113
-			if ( ! $invoice->is_draft() ) {
77
+        }
114 78
 
115
-				add_meta_box(
116
-					'wpinv-mb-resend-invoice',
117
-					sprintf(
118
-						__( 'Resend %s', 'invoicing' ),
119
-						ucfirst( $invoice->get_invoice_quote_type() )
120
-					),
121
-					'GetPaid_Meta_Box_Resend_Invoice::output',
122
-					$post_type,
123
-					'side',
124
-					'low'
125
-				);
79
+    }
126 80
 
127
-			}
81
+    /**
82
+     * Register core metaboxes.
83
+     */
84
+    protected static function add_item_meta_boxes( $post_type ) {
128 85
 
129
-			// Subscriptions.
130
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
131
-			if ( ! empty( $subscriptions ) ) {
86
+        if ( $post_type == 'wpi_item' ) {
132 87
 
133
-				if ( is_array( $subscriptions ) ) {
134
-					add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' );
135
-				} else {
136
-					add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' );
137
-				}
88
+            // Item details.
89
+            add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
138 90
 
139
-				if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) {
140
-					add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' );
141
-				}
91
+            // If taxes are enabled, register the tax metabox.
92
+            if ( wpinv_use_taxes() ) {
93
+                add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
94
+            }
142 95
 
143
-			}
96
+            // Item info.
97
+            add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
144 98
 
145
-			// Invoice details.
146
-			add_meta_box(
147
-				'wpinv-details',
148
-				sprintf(
149
-					__( '%s Details', 'invoicing' ),
150
-					ucfirst( $invoice->get_invoice_quote_type() )
151
-				),
152
-				'GetPaid_Meta_Box_Invoice_Details::output',
153
-				$post_type,
154
-				'side'
155
-			);
99
+        }
156 100
 
157
-			// Payment details.
158
-			add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' );
101
+    }
159 102
 
160
-			// Billing details.
161
-			add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' );
103
+    /**
104
+     * Register invoice metaboxes.
105
+     */
106
+    protected static function add_invoice_meta_boxes( $post_type, $post ) {
107
+
108
+        // For invoices...
109
+        if ( getpaid_is_invoice_post_type( $post_type ) ) {
110
+            $invoice = new WPInv_Invoice( $post );
111
+
112
+            // Resend invoice.
113
+            if ( ! $invoice->is_draft() ) {
114
+
115
+                add_meta_box(
116
+                    'wpinv-mb-resend-invoice',
117
+                    sprintf(
118
+                        __( 'Resend %s', 'invoicing' ),
119
+                        ucfirst( $invoice->get_invoice_quote_type() )
120
+                    ),
121
+                    'GetPaid_Meta_Box_Resend_Invoice::output',
122
+                    $post_type,
123
+                    'side',
124
+                    'low'
125
+                );
126
+
127
+            }
128
+
129
+            // Subscriptions.
130
+            $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
131
+            if ( ! empty( $subscriptions ) ) {
132
+
133
+                if ( is_array( $subscriptions ) ) {
134
+                    add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' );
135
+                } else {
136
+                    add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' );
137
+                }
138
+
139
+                if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) {
140
+                    add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' );
141
+                }
142
+
143
+            }
144
+
145
+            // Invoice details.
146
+            add_meta_box(
147
+                'wpinv-details',
148
+                sprintf(
149
+                    __( '%s Details', 'invoicing' ),
150
+                    ucfirst( $invoice->get_invoice_quote_type() )
151
+                ),
152
+                'GetPaid_Meta_Box_Invoice_Details::output',
153
+                $post_type,
154
+                'side'
155
+            );
156
+
157
+            // Payment details.
158
+            add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' );
159
+
160
+            // Billing details.
161
+            add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' );
162 162
 			
163
-			// Invoice items.
164
-			add_meta_box(
165
-				'wpinv-items',
166
-				sprintf(
167
-					__( '%s Items', 'invoicing' ),
168
-					ucfirst( $invoice->get_invoice_quote_type() )
169
-				),
170
-				'GetPaid_Meta_Box_Invoice_Items::output',
171
-				$post_type,
172
-				'normal',
173
-				'high'
174
-			);
163
+            // Invoice items.
164
+            add_meta_box(
165
+                'wpinv-items',
166
+                sprintf(
167
+                    __( '%s Items', 'invoicing' ),
168
+                    ucfirst( $invoice->get_invoice_quote_type() )
169
+                ),
170
+                'GetPaid_Meta_Box_Invoice_Items::output',
171
+                $post_type,
172
+                'normal',
173
+                'high'
174
+            );
175 175
 			
176
-			// Invoice notes.
177
-			add_meta_box(
178
-				'wpinv-notes',
179
-				sprintf(
180
-					__( '%s Notes', 'invoicing' ),
181
-					ucfirst( $invoice->get_invoice_quote_type() )
182
-				),
183
-				'WPInv_Meta_Box_Notes::output',
184
-				$post_type,
185
-				'side',
186
-				'low'
187
-			);
188
-
189
-			// Shipping Address.
190
-			if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) {
191
-				add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' );
192
-			}
193
-
194
-			// Payment form information.
195
-			if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) {
196
-				add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' );
197
-			}
198
-
199
-		}
200
-
201
-	}
202
-
203
-	/**
204
-	 * Remove some metaboxes.
205
-	 */
206
-	public static function remove_meta_boxes() {
207
-		remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
208
-	}
209
-
210
-	/**
211
-	 * Rename other metaboxes.
212
-	 */
213
-	public static function rename_meta_boxes() {
176
+            // Invoice notes.
177
+            add_meta_box(
178
+                'wpinv-notes',
179
+                sprintf(
180
+                    __( '%s Notes', 'invoicing' ),
181
+                    ucfirst( $invoice->get_invoice_quote_type() )
182
+                ),
183
+                'WPInv_Meta_Box_Notes::output',
184
+                $post_type,
185
+                'side',
186
+                'low'
187
+            );
188
+
189
+            // Shipping Address.
190
+            if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) {
191
+                add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' );
192
+            }
193
+
194
+            // Payment form information.
195
+            if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) {
196
+                add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' );
197
+            }
198
+
199
+        }
200
+
201
+    }
202
+
203
+    /**
204
+     * Remove some metaboxes.
205
+     */
206
+    public static function remove_meta_boxes() {
207
+        remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
208
+    }
209
+
210
+    /**
211
+     * Rename other metaboxes.
212
+     */
213
+    public static function rename_meta_boxes() {
214 214
 		
215
-	}
216
-
217
-	/**
218
-	 * Check if we're saving, then trigger an action based on the post type.
219
-	 *
220
-	 * @param  int    $post_id Post ID.
221
-	 * @param  object $post Post object.
222
-	 */
223
-	public static function save_meta_boxes( $post_id, $post ) {
224
-		$post_id = absint( $post_id );
225
-		$data    = wp_kses_post_deep( wp_unslash( $_POST ) );
226
-
227
-		// Do not save for ajax requests.
228
-		if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
229
-			return;
230
-		}
231
-
232
-		// $post_id and $post are required
233
-		if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
234
-			return;
235
-		}
236
-
237
-		// Dont' save meta boxes for revisions or autosaves.
238
-		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
239
-			return;
240
-		}
241
-
242
-		// Check the nonce.
243
-		if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
244
-			return;
245
-		}
246
-
247
-		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
248
-		if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
249
-			return;
250
-		}
251
-
252
-		// Check user has permission to edit.
253
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
254
-			return;
255
-		}
256
-
257
-		if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
258
-
259
-			// We need this save event to run once to avoid potential endless loops.
260
-			self::$saved_meta_boxes = true;
261
-
262
-			return GetPaid_Meta_Box_Invoice_Address::save( $post_id );
263
-
264
-		}
265
-
266
-		// Ensure this is our post type.
267
-		$post_types_map = array(
268
-			'wpi_item'         => 'GetPaid_Meta_Box_Item_Details',
269
-			'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form',
270
-			'wpi_discount'     => 'GetPaid_Meta_Box_Discount_Details',
271
-		);
272
-
273
-		// Is this our post type?
274
-		if ( ! isset( $post_types_map[ $post->post_type ] ) ) {
275
-			return;
276
-		}
277
-
278
-		// We need this save event to run once to avoid potential endless loops.
279
-		self::$saved_meta_boxes = true;
215
+    }
216
+
217
+    /**
218
+     * Check if we're saving, then trigger an action based on the post type.
219
+     *
220
+     * @param  int    $post_id Post ID.
221
+     * @param  object $post Post object.
222
+     */
223
+    public static function save_meta_boxes( $post_id, $post ) {
224
+        $post_id = absint( $post_id );
225
+        $data    = wp_kses_post_deep( wp_unslash( $_POST ) );
226
+
227
+        // Do not save for ajax requests.
228
+        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
229
+            return;
230
+        }
231
+
232
+        // $post_id and $post are required
233
+        if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
234
+            return;
235
+        }
236
+
237
+        // Dont' save meta boxes for revisions or autosaves.
238
+        if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
239
+            return;
240
+        }
241
+
242
+        // Check the nonce.
243
+        if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
244
+            return;
245
+        }
246
+
247
+        // Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
248
+        if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
249
+            return;
250
+        }
251
+
252
+        // Check user has permission to edit.
253
+        if ( ! current_user_can( 'edit_post', $post_id ) ) {
254
+            return;
255
+        }
256
+
257
+        if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
258
+
259
+            // We need this save event to run once to avoid potential endless loops.
260
+            self::$saved_meta_boxes = true;
261
+
262
+            return GetPaid_Meta_Box_Invoice_Address::save( $post_id );
263
+
264
+        }
265
+
266
+        // Ensure this is our post type.
267
+        $post_types_map = array(
268
+            'wpi_item'         => 'GetPaid_Meta_Box_Item_Details',
269
+            'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form',
270
+            'wpi_discount'     => 'GetPaid_Meta_Box_Discount_Details',
271
+        );
272
+
273
+        // Is this our post type?
274
+        if ( ! isset( $post_types_map[ $post->post_type ] ) ) {
275
+            return;
276
+        }
277
+
278
+        // We need this save event to run once to avoid potential endless loops.
279
+        self::$saved_meta_boxes = true;
280 280
 		
281
-		// Save the post.
282
-		$class = $post_types_map[ $post->post_type ];
283
-		$class::save( $post_id, $_POST, $post );
281
+        // Save the post.
282
+        $class = $post_types_map[ $post->post_type ];
283
+        $class::save( $post_id, $_POST, $post );
284 284
 
285
-	}
285
+    }
286 286
 
287 287
 }
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 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
  * Metaboxes Admin Class
@@ -25,35 +25,35 @@  discard block
 block discarded – undo
25 25
 	public static function init() {
26 26
 
27 27
 		// Register metaboxes.
28
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 );
28
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2);
29 29
 
30 30
 		// Remove metaboxes.
31
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
31
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30);
32 32
 
33 33
 		// Rename metaboxes.
34
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
34
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45);
35 35
 
36 36
 		// Save metaboxes.
37
-		add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
37
+		add_action('save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2);
38 38
 	}
39 39
 
40 40
 	/**
41 41
 	 * Register core metaboxes.
42 42
 	 */
43
-	public static function add_meta_boxes( $post_type, $post ) {
43
+	public static function add_meta_boxes($post_type, $post) {
44 44
 
45 45
 		// For invoices...
46
-		self::add_invoice_meta_boxes( $post_type, $post );
46
+		self::add_invoice_meta_boxes($post_type, $post);
47 47
 
48 48
 		// For payment forms.
49
-		self::add_payment_form_meta_boxes( $post_type, $post );
49
+		self::add_payment_form_meta_boxes($post_type, $post);
50 50
 
51 51
 		// For invoice items.
52
-		self::add_item_meta_boxes( $post_type );
52
+		self::add_item_meta_boxes($post_type);
53 53
 
54 54
 		// For invoice discounts.
55
-		if ( $post_type == 'wpi_discount' ) {
56
-			add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
55
+		if ($post_type == 'wpi_discount') {
56
+			add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high');
57 57
 		}
58 58
 
59 59
 	}
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
 	/**
62 62
 	 * Register core metaboxes.
63 63
 	 */
64
-	protected static function add_payment_form_meta_boxes( $post_type, $post ) {
64
+	protected static function add_payment_form_meta_boxes($post_type, $post) {
65 65
 
66 66
 		// For payment forms.
67
-		if ( $post_type == 'wpi_payment_form' ) {
67
+		if ($post_type == 'wpi_payment_form') {
68 68
 
69 69
 			// Design payment form.
70
-			add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
70
+			add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal');
71 71
 
72 72
 			// Payment form information.
73
-			if ( $post->ID != wpinv_get_default_payment_form() ) {
74
-				add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
73
+			if ($post->ID != wpinv_get_default_payment_form()) {
74
+				add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side');
75 75
 			}
76 76
 
77 77
 		}
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 	/**
82 82
 	 * Register core metaboxes.
83 83
 	 */
84
-	protected static function add_item_meta_boxes( $post_type ) {
84
+	protected static function add_item_meta_boxes($post_type) {
85 85
 
86
-		if ( $post_type == 'wpi_item' ) {
86
+		if ($post_type == 'wpi_item') {
87 87
 
88 88
 			// Item details.
89
-			add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
89
+			add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high');
90 90
 
91 91
 			// If taxes are enabled, register the tax metabox.
92
-			if ( wpinv_use_taxes() ) {
93
-				add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
92
+			if (wpinv_use_taxes()) {
93
+				add_meta_box('wpinv_item_vat', __('Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high');
94 94
 			}
95 95
 
96 96
 			// Item info.
97
-			add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
97
+			add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core');
98 98
 
99 99
 		}
100 100
 
@@ -103,20 +103,20 @@  discard block
 block discarded – undo
103 103
 	/**
104 104
 	 * Register invoice metaboxes.
105 105
 	 */
106
-	protected static function add_invoice_meta_boxes( $post_type, $post ) {
106
+	protected static function add_invoice_meta_boxes($post_type, $post) {
107 107
 
108 108
 		// For invoices...
109
-		if ( getpaid_is_invoice_post_type( $post_type ) ) {
110
-			$invoice = new WPInv_Invoice( $post );
109
+		if (getpaid_is_invoice_post_type($post_type)) {
110
+			$invoice = new WPInv_Invoice($post);
111 111
 
112 112
 			// Resend invoice.
113
-			if ( ! $invoice->is_draft() ) {
113
+			if (!$invoice->is_draft()) {
114 114
 
115 115
 				add_meta_box(
116 116
 					'wpinv-mb-resend-invoice',
117 117
 					sprintf(
118
-						__( 'Resend %s', 'invoicing' ),
119
-						ucfirst( $invoice->get_invoice_quote_type() )
118
+						__('Resend %s', 'invoicing'),
119
+						ucfirst($invoice->get_invoice_quote_type())
120 120
 					),
121 121
 					'GetPaid_Meta_Box_Resend_Invoice::output',
122 122
 					$post_type,
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
 			}
128 128
 
129 129
 			// Subscriptions.
130
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
131
-			if ( ! empty( $subscriptions ) ) {
130
+			$subscriptions = getpaid_get_invoice_subscriptions($invoice);
131
+			if (!empty($subscriptions)) {
132 132
 
133
-				if ( is_array( $subscriptions ) ) {
134
-					add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' );
133
+				if (is_array($subscriptions)) {
134
+					add_meta_box('wpinv-mb-subscriptions', __('Related Subscriptions', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced');
135 135
 				} else {
136
-					add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' );
136
+					add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced');
137 137
 				}
138 138
 
139
-				if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) {
140
-					add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' );
139
+				if (getpaid_count_subscription_invoices($invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id()) > 1) {
140
+					add_meta_box('wpinv-mb-subscription-invoices', __('Related Payments', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced');
141 141
 				}
142 142
 
143 143
 			}
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 			add_meta_box(
147 147
 				'wpinv-details',
148 148
 				sprintf(
149
-					__( '%s Details', 'invoicing' ),
150
-					ucfirst( $invoice->get_invoice_quote_type() )
149
+					__('%s Details', 'invoicing'),
150
+					ucfirst($invoice->get_invoice_quote_type())
151 151
 				),
152 152
 				'GetPaid_Meta_Box_Invoice_Details::output',
153 153
 				$post_type,
@@ -155,17 +155,17 @@  discard block
 block discarded – undo
155 155
 			);
156 156
 
157 157
 			// Payment details.
158
-			add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' );
158
+			add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default');
159 159
 
160 160
 			// Billing details.
161
-			add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' );
161
+			add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high');
162 162
 			
163 163
 			// Invoice items.
164 164
 			add_meta_box(
165 165
 				'wpinv-items',
166 166
 				sprintf(
167
-					__( '%s Items', 'invoicing' ),
168
-					ucfirst( $invoice->get_invoice_quote_type() )
167
+					__('%s Items', 'invoicing'),
168
+					ucfirst($invoice->get_invoice_quote_type())
169 169
 				),
170 170
 				'GetPaid_Meta_Box_Invoice_Items::output',
171 171
 				$post_type,
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 			add_meta_box(
178 178
 				'wpinv-notes',
179 179
 				sprintf(
180
-					__( '%s Notes', 'invoicing' ),
181
-					ucfirst( $invoice->get_invoice_quote_type() )
180
+					__('%s Notes', 'invoicing'),
181
+					ucfirst($invoice->get_invoice_quote_type())
182 182
 				),
183 183
 				'WPInv_Meta_Box_Notes::output',
184 184
 				$post_type,
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 			);
188 188
 
189 189
 			// Shipping Address.
190
-			if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) {
191
-				add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' );
190
+			if (get_post_meta($invoice->get_id(), 'shipping_address', true)) {
191
+				add_meta_box('wpinv-invoice-shipping-details', __('Shipping Address', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high');
192 192
 			}
193 193
 
194 194
 			// Payment form information.
195
-			if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) {
196
-				add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' );
195
+			if (get_post_meta($invoice->get_id(), 'payment_form_data', true)) {
196
+				add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high');
197 197
 			}
198 198
 
199 199
 		}
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * Remove some metaboxes.
205 205
 	 */
206 206
 	public static function remove_meta_boxes() {
207
-		remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
207
+		remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
208 208
 	}
209 209
 
210 210
 	/**
@@ -220,46 +220,46 @@  discard block
 block discarded – undo
220 220
 	 * @param  int    $post_id Post ID.
221 221
 	 * @param  object $post Post object.
222 222
 	 */
223
-	public static function save_meta_boxes( $post_id, $post ) {
224
-		$post_id = absint( $post_id );
225
-		$data    = wp_kses_post_deep( wp_unslash( $_POST ) );
223
+	public static function save_meta_boxes($post_id, $post) {
224
+		$post_id = absint($post_id);
225
+		$data    = wp_kses_post_deep(wp_unslash($_POST));
226 226
 
227 227
 		// Do not save for ajax requests.
228
-		if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
228
+		if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
229 229
 			return;
230 230
 		}
231 231
 
232 232
 		// $post_id and $post are required
233
-		if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
233
+		if (empty($post_id) || empty($post) || self::$saved_meta_boxes) {
234 234
 			return;
235 235
 		}
236 236
 
237 237
 		// Dont' save meta boxes for revisions or autosaves.
238
-		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
238
+		if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
239 239
 			return;
240 240
 		}
241 241
 
242 242
 		// Check the nonce.
243
-		if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
243
+		if (empty($data['getpaid_meta_nonce']) || !wp_verify_nonce($data['getpaid_meta_nonce'], 'getpaid_meta_nonce')) {
244 244
 			return;
245 245
 		}
246 246
 
247 247
 		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
248
-		if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
248
+		if (empty($data['post_ID']) || absint($data['post_ID']) !== $post_id) {
249 249
 			return;
250 250
 		}
251 251
 
252 252
 		// Check user has permission to edit.
253
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
253
+		if (!current_user_can('edit_post', $post_id)) {
254 254
 			return;
255 255
 		}
256 256
 
257
-		if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
257
+		if (getpaid_is_invoice_post_type($post->post_type)) {
258 258
 
259 259
 			// We need this save event to run once to avoid potential endless loops.
260 260
 			self::$saved_meta_boxes = true;
261 261
 
262
-			return GetPaid_Meta_Box_Invoice_Address::save( $post_id );
262
+			return GetPaid_Meta_Box_Invoice_Address::save($post_id);
263 263
 
264 264
 		}
265 265
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 		);
272 272
 
273 273
 		// Is this our post type?
274
-		if ( ! isset( $post_types_map[ $post->post_type ] ) ) {
274
+		if (!isset($post_types_map[$post->post_type])) {
275 275
 			return;
276 276
 		}
277 277
 
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 		self::$saved_meta_boxes = true;
280 280
 		
281 281
 		// Save the post.
282
-		$class = $post_types_map[ $post->post_type ];
283
-		$class::save( $post_id, $_POST, $post );
282
+		$class = $post_types_map[$post->post_type];
283
+		$class::save($post_id, $_POST, $post);
284 284
 
285 285
 	}
286 286
 
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Spacing   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Are we supporting item quantities?
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wpinv_get_ip() {
22 22
 
23
-    if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
24
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) );
23
+    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
24
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP']));
25 25
     }
26 26
 
27
-    if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
27
+    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
28 28
         // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
29 29
         // Make sure we always only send through the first IP in the list which should always be the client IP.
30
-        return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) );
30
+        return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR']))))));
31 31
     }
32 32
 
33
-    if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
34
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
33
+    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
34
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP']));
35 35
     }
36 36
 
37
-    if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
38
-        return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
37
+    if (isset($_SERVER['REMOTE_ADDR'])) {
38
+        return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
39 39
     }
40 40
 
41 41
     return '';
42 42
 }
43 43
 
44 44
 function wpinv_get_user_agent() {
45
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
46
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
45
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
46
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
47 47
     } else {
48 48
         $user_agent = '';
49 49
     }
50 50
 
51
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
51
+    return apply_filters('wpinv_get_user_agent', $user_agent);
52 52
 }
53 53
 
54 54
 /**
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
  * @param string $amount The amount to sanitize.
58 58
  * @return float
59 59
  */
60
-function getpaid_standardize_amount( $amount ) {
60
+function getpaid_standardize_amount($amount) {
61 61
 
62
-    $amount = str_replace( wpinv_thousands_separator(), '', $amount );
63
-    $amount = str_replace( wpinv_decimal_separator(), '.', $amount );
64
-    if ( is_numeric( $amount ) ) {
65
-        return floatval( $amount );
62
+    $amount = str_replace(wpinv_thousands_separator(), '', $amount);
63
+    $amount = str_replace(wpinv_decimal_separator(), '.', $amount);
64
+    if (is_numeric($amount)) {
65
+        return floatval($amount);
66 66
     }
67 67
 
68 68
     // Cast the remaining to a float.
69
-    return wpinv_round_amount( preg_replace( '/[^0-9\.\-]/', '', $amount ) );
69
+    return wpinv_round_amount(preg_replace('/[^0-9\.\-]/', '', $amount));
70 70
 
71 71
 }
72 72
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
  *
76 76
  * @param string $amount The amount to sanitize.
77 77
  */
78
-function getpaid_unstandardize_amount( $amount ) {
79
-    return str_replace( '.', wpinv_decimal_separator(), $amount );
78
+function getpaid_unstandardize_amount($amount) {
79
+    return str_replace('.', wpinv_decimal_separator(), $amount);
80 80
 }
81 81
 
82 82
 /**
@@ -84,23 +84,23 @@  discard block
 block discarded – undo
84 84
  * 
85 85
  * @param string $amount The amount to sanitize.
86 86
  */
87
-function wpinv_sanitize_amount( $amount ) {
87
+function wpinv_sanitize_amount($amount) {
88 88
 
89
-    if ( is_numeric( $amount ) ) {
90
-        return floatval( $amount );
89
+    if (is_numeric($amount)) {
90
+        return floatval($amount);
91 91
     }
92 92
 
93 93
     // Separate the decimals and thousands.
94
-    $amount    = explode( wpinv_decimal_separator(), $amount );
94
+    $amount    = explode(wpinv_decimal_separator(), $amount);
95 95
 
96 96
     // Remove thousands.
97
-    $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] );
97
+    $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]);
98 98
 
99 99
     // Convert back to string.
100
-    $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
100
+    $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
101 101
 
102 102
     // Cast the remaining to a float.
103
-    return (float) preg_replace( '/[^0-9\.\-]/', '', $amount );
103
+    return (float) preg_replace('/[^0-9\.\-]/', '', $amount);
104 104
 
105 105
 }
106 106
 
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
  * @param float $amount
111 111
  * @param float|string|int|null $decimals
112 112
  */
113
-function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) {
113
+function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) {
114 114
 
115
-    if ( $decimals === null ) {
115
+    if ($decimals === null) {
116 116
         $decimals = wpinv_decimals();
117 117
     }
118 118
 
119
-    if ( $use_sprintf ) {
120
-        $amount = sprintf( "%.{$decimals}f", (float) $amount );
119
+    if ($use_sprintf) {
120
+        $amount = sprintf("%.{$decimals}f", (float) $amount);
121 121
     } else {
122
-        $amount = round( (float) $amount, absint( $decimals ) );
122
+        $amount = round((float) $amount, absint($decimals));
123 123
     }
124 124
 
125
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
125
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
126 126
 }
127 127
 
128 128
 /**
@@ -134,32 +134,32 @@  discard block
 block discarded – undo
134 134
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
135 135
  * @return array
136 136
  */
137
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
137
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
138 138
 
139 139
 	$invoice_statuses = array(
140
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
141
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
142
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
143
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
144
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
145
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
146
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
147
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
140
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
141
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
142
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
143
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
144
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
145
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
146
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
147
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
148 148
     );
149 149
 
150
-    if ( $draft ) {
151
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
150
+    if ($draft) {
151
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
152 152
     }
153 153
 
154
-    if ( $trashed ) {
155
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
154
+    if ($trashed) {
155
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
156 156
     }
157 157
 
158
-    if ( $invoice instanceof WPInv_Invoice ) {
158
+    if ($invoice instanceof WPInv_Invoice) {
159 159
         $invoice = $invoice->get_post_type();
160 160
     }
161 161
 
162
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
162
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
163 163
 }
164 164
 
165 165
 /**
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
  * @param string $status The raw status
169 169
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
170 170
  */
171
-function wpinv_status_nicename( $status, $invoice = false ) {
172
-    $statuses = wpinv_get_invoice_statuses( true, true, $invoice );
173
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : $status;
171
+function wpinv_status_nicename($status, $invoice = false) {
172
+    $statuses = wpinv_get_invoice_statuses(true, true, $invoice);
173
+    $status   = isset($statuses[$status]) ? $statuses[$status] : $status;
174 174
 
175
-    return sanitize_text_field( $status );
175
+    return sanitize_text_field($status);
176 176
 }
177 177
 
178 178
 /**
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
  * 
181 181
  * @param string $current
182 182
  */
183
-function wpinv_get_currency( $current = '' ) {
183
+function wpinv_get_currency($current = '') {
184 184
 
185
-    if ( empty( $current ) ) {
186
-        $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
185
+    if (empty($current)) {
186
+        $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
187 187
     }
188 188
 
189
-    return trim( strtoupper( $current ) );
189
+    return trim(strtoupper($current));
190 190
 }
191 191
 
192 192
 /**
@@ -194,25 +194,25 @@  discard block
 block discarded – undo
194 194
  * 
195 195
  * @param string|null $currency The currency code. Defaults to the default currency.
196 196
  */
197
-function wpinv_currency_symbol( $currency = null ) {
197
+function wpinv_currency_symbol($currency = null) {
198 198
 
199 199
     // Prepare the currency.
200
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
200
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
201 201
 
202 202
     // Fetch all symbols.
203 203
     $symbols = wpinv_get_currency_symbols();
204 204
 
205 205
     // Fetch this currencies symbol.
206
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
206
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
207 207
 
208 208
     // Filter the symbol.
209
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
209
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
210 210
 }
211 211
 
212 212
 function wpinv_currency_position() {
213
-    $position = wpinv_get_option( 'currency_position', 'left' );
213
+    $position = wpinv_get_option('currency_position', 'left');
214 214
     
215
-    return apply_filters( 'wpinv_currency_position', $position );
215
+    return apply_filters('wpinv_currency_position', $position);
216 216
 }
217 217
 
218 218
 /**
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
  * 
221 221
  * @param $string|null $current
222 222
  */
223
-function wpinv_thousands_separator( $current = null ) {
223
+function wpinv_thousands_separator($current = null) {
224 224
 
225
-    if ( null == $current ) {
226
-        $current = wpinv_get_option( 'thousands_separator', ',' );
225
+    if (null == $current) {
226
+        $current = wpinv_get_option('thousands_separator', ',');
227 227
     }
228 228
 
229
-    return trim( $current );
229
+    return trim($current);
230 230
 }
231 231
 
232 232
 /**
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
  * 
235 235
  * @param $string|null $current
236 236
  */
237
-function wpinv_decimal_separator( $current = null ) {
237
+function wpinv_decimal_separator($current = null) {
238 238
 
239
-    if ( null == $current ) {
240
-        $current = wpinv_get_option( 'decimal_separator', '.' );
239
+    if (null == $current) {
240
+        $current = wpinv_get_option('decimal_separator', '.');
241 241
     }
242 242
     
243
-    return trim( $current );
243
+    return trim($current);
244 244
 }
245 245
 
246 246
 /**
@@ -248,27 +248,27 @@  discard block
 block discarded – undo
248 248
  * 
249 249
  * @param $string|null $current
250 250
  */
251
-function wpinv_decimals( $current = null ) {
251
+function wpinv_decimals($current = null) {
252 252
 
253
-    if ( null == $current ) {
254
-        $current = wpinv_get_option( 'decimals', 2 );
253
+    if (null == $current) {
254
+        $current = wpinv_get_option('decimals', 2);
255 255
     }
256 256
     
257
-    return absint( $current );
257
+    return absint($current);
258 258
 }
259 259
 
260 260
 /**
261 261
  * Retrieves a list of all supported currencies.
262 262
  */
263 263
 function wpinv_get_currencies() {
264
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
264
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
265 265
 }
266 266
 
267 267
 /**
268 268
  * Retrieves a list of all currency symbols.
269 269
  */
270 270
 function wpinv_get_currency_symbols() {
271
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
271
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
272 272
 }
273 273
 
274 274
 /**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	$currency_pos = wpinv_currency_position();
281 281
 	$format       = '%1$s%2$s';
282 282
 
283
-	switch ( $currency_pos ) {
283
+	switch ($currency_pos) {
284 284
 		case 'left':
285 285
 			$format = '%1$s%2$s';
286 286
 			break;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 			break;
296 296
 	}
297 297
 
298
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
298
+	return apply_filters('getpaid_price_format', $format, $currency_pos);
299 299
 }
300 300
 
301 301
 /**
@@ -305,25 +305,25 @@  discard block
 block discarded – undo
305 305
  * @param  string $currency Currency.
306 306
  * @return string
307 307
  */
308
-function wpinv_price( $amount = 0, $currency = '' ) {
308
+function wpinv_price($amount = 0, $currency = '') {
309 309
 
310 310
     // Backwards compatibility.
311
-    $amount             = wpinv_sanitize_amount( $amount );
311
+    $amount             = wpinv_sanitize_amount($amount);
312 312
 
313 313
     // Prepare variables.
314
-    $currency           = wpinv_get_currency( $currency );
314
+    $currency           = wpinv_get_currency($currency);
315 315
     $amount             = (float) $amount;
316 316
     $unformatted_amount = $amount;
317 317
     $negative           = $amount < 0;
318
-    $amount             = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) );
319
-    $amount             = wpinv_format_amount( $amount );
318
+    $amount             = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount));
319
+    $amount             = wpinv_format_amount($amount);
320 320
 
321 321
     // Format the amount.
322 322
     $format             = getpaid_get_price_format();
323
-    $formatted_amount   = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount );
323
+    $formatted_amount   = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount);
324 324
 
325 325
     // Filter the formatting.
326
-    return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount );
326
+    return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount);
327 327
 }
328 328
 
329 329
 /**
@@ -334,25 +334,25 @@  discard block
 block discarded – undo
334 334
  * @param  bool     $calculate Whether or not to apply separators.
335 335
  * @return string
336 336
  */
337
-function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) {
337
+function wpinv_format_amount($amount, $decimals = null, $calculate = false) {
338 338
     $thousands_sep = wpinv_thousands_separator();
339 339
     $decimal_sep   = wpinv_decimal_separator();
340
-    $decimals      = wpinv_decimals( $decimals );
341
-    $amount        = wpinv_sanitize_amount( $amount );
340
+    $decimals      = wpinv_decimals($decimals);
341
+    $amount        = wpinv_sanitize_amount($amount);
342 342
 
343
-    if ( $calculate ) {
343
+    if ($calculate) {
344 344
         return $amount;
345 345
     }
346 346
 
347 347
     // Fomart the amount.
348
-    return number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
348
+    return number_format($amount, $decimals, $decimal_sep, $thousands_sep);
349 349
 }
350 350
 
351
-function wpinv_sanitize_key( $key ) {
351
+function wpinv_sanitize_key($key) {
352 352
     $raw_key = $key;
353
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
353
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
354 354
 
355
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
355
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
356 356
 }
357 357
 
358 358
 /**
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
  * 
361 361
  * @param $str the file whose extension should be retrieved.
362 362
  */
363
-function wpinv_get_file_extension( $str ) {
364
-    $filetype = wp_check_filetype( $str );
363
+function wpinv_get_file_extension($str) {
364
+    $filetype = wp_check_filetype($str);
365 365
     return $filetype['ext'];
366 366
 }
367 367
 
@@ -370,16 +370,16 @@  discard block
 block discarded – undo
370 370
  * 
371 371
  * @param string $string
372 372
  */
373
-function wpinv_string_is_image_url( $string ) {
374
-    $extension = strtolower( wpinv_get_file_extension( $string ) );
375
-    return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true );
373
+function wpinv_string_is_image_url($string) {
374
+    $extension = strtolower(wpinv_get_file_extension($string));
375
+    return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true);
376 376
 }
377 377
 
378 378
 /**
379 379
  * Returns the current URL.
380 380
  */
381 381
 function wpinv_get_current_page_url() {
382
-    return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
382
+    return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
383 383
 }
384 384
 
385 385
 /**
@@ -389,46 +389,46 @@  discard block
 block discarded – undo
389 389
  * @param string $name  Constant name.
390 390
  * @param mixed  $value Value.
391 391
  */
392
-function getpaid_maybe_define_constant( $name, $value ) {
393
-	if ( ! defined( $name ) ) {
394
-		define( $name, $value );
392
+function getpaid_maybe_define_constant($name, $value) {
393
+	if (!defined($name)) {
394
+		define($name, $value);
395 395
 	}
396 396
 }
397 397
 
398 398
 function wpinv_get_php_arg_separator_output() {
399
-	return ini_get( 'arg_separator.output' );
399
+	return ini_get('arg_separator.output');
400 400
 }
401 401
 
402
-function wpinv_rgb_from_hex( $color ) {
403
-    $color = str_replace( '#', '', $color );
402
+function wpinv_rgb_from_hex($color) {
403
+    $color = str_replace('#', '', $color);
404 404
 
405 405
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
406
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
407
-    if ( empty( $color ) ) {
406
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
407
+    if (empty($color)) {
408 408
         return NULL;
409 409
     }
410 410
 
411
-    $color = str_split( $color );
411
+    $color = str_split($color);
412 412
 
413 413
     $rgb      = array();
414
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
415
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
416
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
414
+    $rgb['R'] = hexdec($color[0] . $color[1]);
415
+    $rgb['G'] = hexdec($color[2] . $color[3]);
416
+    $rgb['B'] = hexdec($color[4] . $color[5]);
417 417
 
418 418
     return $rgb;
419 419
 }
420 420
 
421
-function wpinv_hex_darker( $color, $factor = 30 ) {
422
-    $base  = wpinv_rgb_from_hex( $color );
421
+function wpinv_hex_darker($color, $factor = 30) {
422
+    $base  = wpinv_rgb_from_hex($color);
423 423
     $color = '#';
424 424
 
425
-    foreach ( $base as $k => $v ) {
425
+    foreach ($base as $k => $v) {
426 426
         $amount      = $v / 100;
427
-        $amount      = round( $amount * $factor );
427
+        $amount      = round($amount * $factor);
428 428
         $new_decimal = $v - $amount;
429 429
 
430
-        $new_hex_component = dechex( $new_decimal );
431
-        if ( strlen( $new_hex_component ) < 2 ) {
430
+        $new_hex_component = dechex($new_decimal);
431
+        if (strlen($new_hex_component) < 2) {
432 432
             $new_hex_component = "0" . $new_hex_component;
433 433
         }
434 434
         $color .= $new_hex_component;
@@ -437,18 +437,18 @@  discard block
 block discarded – undo
437 437
     return $color;
438 438
 }
439 439
 
440
-function wpinv_hex_lighter( $color, $factor = 30 ) {
441
-    $base  = wpinv_rgb_from_hex( $color );
440
+function wpinv_hex_lighter($color, $factor = 30) {
441
+    $base  = wpinv_rgb_from_hex($color);
442 442
     $color = '#';
443 443
 
444
-    foreach ( $base as $k => $v ) {
444
+    foreach ($base as $k => $v) {
445 445
         $amount      = 255 - $v;
446 446
         $amount      = $amount / 100;
447
-        $amount      = round( $amount * $factor );
447
+        $amount      = round($amount * $factor);
448 448
         $new_decimal = $v + $amount;
449 449
 
450
-        $new_hex_component = dechex( $new_decimal );
451
-        if ( strlen( $new_hex_component ) < 2 ) {
450
+        $new_hex_component = dechex($new_decimal);
451
+        if (strlen($new_hex_component) < 2) {
452 452
             $new_hex_component = "0" . $new_hex_component;
453 453
         }
454 454
         $color .= $new_hex_component;
@@ -457,22 +457,22 @@  discard block
 block discarded – undo
457 457
     return $color;
458 458
 }
459 459
 
460
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
461
-    $hex = str_replace( '#', '', $color );
460
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
461
+    $hex = str_replace('#', '', $color);
462 462
 
463
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
464
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
465
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
463
+    $c_r = hexdec(substr($hex, 0, 2));
464
+    $c_g = hexdec(substr($hex, 2, 2));
465
+    $c_b = hexdec(substr($hex, 4, 2));
466 466
 
467
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
467
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
468 468
 
469 469
     return $brightness > 155 ? $dark : $light;
470 470
 }
471 471
 
472
-function wpinv_format_hex( $hex ) {
473
-    $hex = trim( str_replace( '#', '', $hex ) );
472
+function wpinv_format_hex($hex) {
473
+    $hex = trim(str_replace('#', '', $hex));
474 474
 
475
-    if ( strlen( $hex ) == 3 ) {
475
+    if (strlen($hex) == 3) {
476 476
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
477 477
     }
478 478
 
@@ -492,12 +492,12 @@  discard block
 block discarded – undo
492 492
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
493 493
  * @return string
494 494
  */
495
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
496
-    if ( function_exists( 'mb_strimwidth' ) ) {
497
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
495
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
496
+    if (function_exists('mb_strimwidth')) {
497
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
498 498
     }
499 499
     
500
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
500
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
501 501
 }
502 502
 
503 503
 /**
@@ -509,28 +509,28 @@  discard block
 block discarded – undo
509 509
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
510 510
  * @return int Returns the number of characters in string.
511 511
  */
512
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
513
-    if ( function_exists( 'mb_strlen' ) ) {
514
-        return mb_strlen( $str, $encoding );
512
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
513
+    if (function_exists('mb_strlen')) {
514
+        return mb_strlen($str, $encoding);
515 515
     }
516 516
         
517
-    return strlen( $str );
517
+    return strlen($str);
518 518
 }
519 519
 
520
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
521
-    if ( function_exists( 'mb_strtolower' ) ) {
522
-        return mb_strtolower( $str, $encoding );
520
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
521
+    if (function_exists('mb_strtolower')) {
522
+        return mb_strtolower($str, $encoding);
523 523
     }
524 524
     
525
-    return strtolower( $str );
525
+    return strtolower($str);
526 526
 }
527 527
 
528
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
529
-    if ( function_exists( 'mb_strtoupper' ) ) {
530
-        return mb_strtoupper( $str, $encoding );
528
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
529
+    if (function_exists('mb_strtoupper')) {
530
+        return mb_strtoupper($str, $encoding);
531 531
     }
532 532
     
533
-    return strtoupper( $str );
533
+    return strtoupper($str);
534 534
 }
535 535
 
536 536
 /**
@@ -544,12 +544,12 @@  discard block
 block discarded – undo
544 544
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
545 545
  * @return int Returns the position of the first occurrence of search in the string.
546 546
  */
547
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
548
-    if ( function_exists( 'mb_strpos' ) ) {
549
-        return mb_strpos( $str, $find, $offset, $encoding );
547
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
548
+    if (function_exists('mb_strpos')) {
549
+        return mb_strpos($str, $find, $offset, $encoding);
550 550
     }
551 551
         
552
-    return strpos( $str, $find, $offset );
552
+    return strpos($str, $find, $offset);
553 553
 }
554 554
 
555 555
 /**
@@ -563,12 +563,12 @@  discard block
 block discarded – undo
563 563
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
564 564
  * @return int Returns the position of the last occurrence of search.
565 565
  */
566
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
567
-    if ( function_exists( 'mb_strrpos' ) ) {
568
-        return mb_strrpos( $str, $find, $offset, $encoding );
566
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
567
+    if (function_exists('mb_strrpos')) {
568
+        return mb_strrpos($str, $find, $offset, $encoding);
569 569
     }
570 570
         
571
-    return strrpos( $str, $find, $offset );
571
+    return strrpos($str, $find, $offset);
572 572
 }
573 573
 
574 574
 /**
@@ -583,16 +583,16 @@  discard block
 block discarded – undo
583 583
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
584 584
  * @return string
585 585
  */
586
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
587
-    if ( function_exists( 'mb_substr' ) ) {
588
-        if ( $length === null ) {
589
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
586
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
587
+    if (function_exists('mb_substr')) {
588
+        if ($length === null) {
589
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
590 590
         } else {
591
-            return mb_substr( $str, $start, $length, $encoding );
591
+            return mb_substr($str, $start, $length, $encoding);
592 592
         }
593 593
     }
594 594
         
595
-    return substr( $str, $start, $length );
595
+    return substr($str, $start, $length);
596 596
 }
597 597
 
598 598
 /**
@@ -604,48 +604,48 @@  discard block
 block discarded – undo
604 604
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
605 605
  * @return string The width of string.
606 606
  */
607
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
608
-    if ( function_exists( 'mb_strwidth' ) ) {
609
-        return mb_strwidth( $str, $encoding );
607
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
608
+    if (function_exists('mb_strwidth')) {
609
+        return mb_strwidth($str, $encoding);
610 610
     }
611 611
     
612
-    return wpinv_utf8_strlen( $str, $encoding );
612
+    return wpinv_utf8_strlen($str, $encoding);
613 613
 }
614 614
 
615
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
616
-    if ( function_exists( 'mb_strlen' ) ) {
617
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
615
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
616
+    if (function_exists('mb_strlen')) {
617
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
618 618
         $str_end = "";
619 619
         
620
-        if ( $lower_str_end ) {
621
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
620
+        if ($lower_str_end) {
621
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
622 622
         } else {
623
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
623
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
624 624
         }
625 625
 
626 626
         return $first_letter . $str_end;
627 627
     }
628 628
     
629
-    return ucfirst( $str );
629
+    return ucfirst($str);
630 630
 }
631 631
 
632
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
633
-    if ( function_exists( 'mb_convert_case' ) ) {
634
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
632
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
633
+    if (function_exists('mb_convert_case')) {
634
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
635 635
     }
636 636
     
637
-    return ucwords( $str );
637
+    return ucwords($str);
638 638
 }
639 639
 
640
-function wpinv_period_in_days( $period, $unit ) {
641
-    $period = absint( $period );
640
+function wpinv_period_in_days($period, $unit) {
641
+    $period = absint($period);
642 642
     
643
-    if ( $period > 0 ) {
644
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
643
+    if ($period > 0) {
644
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
645 645
             $period = $period * 7;
646
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
646
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
647 647
             $period = $period * 30;
648
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
648
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
649 649
             $period = $period * 365;
650 650
         }
651 651
     }
@@ -653,14 +653,14 @@  discard block
 block discarded – undo
653 653
     return $period;
654 654
 }
655 655
 
656
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
657
-    if ( function_exists( 'cal_days_in_month' ) ) {
658
-        return cal_days_in_month( $calendar, $month, $year );
656
+function wpinv_cal_days_in_month($calendar, $month, $year) {
657
+    if (function_exists('cal_days_in_month')) {
658
+        return cal_days_in_month($calendar, $month, $year);
659 659
     }
660 660
 
661 661
     // Fallback in case the calendar extension is not loaded in PHP
662 662
     // Only supports Gregorian calendar
663
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
663
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
664 664
 }
665 665
 
666 666
 /**
@@ -671,15 +671,15 @@  discard block
 block discarded – undo
671 671
  *
672 672
  * @return string
673 673
  */
674
-function wpi_help_tip( $tip, $allow_html = false, $is_vue = false ) {
674
+function wpi_help_tip($tip, $allow_html = false, $is_vue = false) {
675 675
 
676
-    if ( $allow_html ) {
677
-        $tip = wpi_sanitize_tooltip( $tip );
676
+    if ($allow_html) {
677
+        $tip = wpi_sanitize_tooltip($tip);
678 678
     } else {
679
-        $tip = esc_attr( $tip );
679
+        $tip = esc_attr($tip);
680 680
     }
681 681
 
682
-    if ( $is_vue ) {
682
+    if ($is_vue) {
683 683
         return '<span class="dashicons dashicons-editor-help" title="' . $tip . '"></span>';
684 684
     }
685 685
 
@@ -694,8 +694,8 @@  discard block
 block discarded – undo
694 694
  * @param string $var
695 695
  * @return string
696 696
  */
697
-function wpi_sanitize_tooltip( $var ) {
698
-    return wp_kses( html_entity_decode( $var ), array(
697
+function wpi_sanitize_tooltip($var) {
698
+    return wp_kses(html_entity_decode($var), array(
699 699
         'br'     => array(),
700 700
         'em'     => array(),
701 701
         'strong' => array(),
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
         'li'     => array(),
707 707
         'ol'     => array(),
708 708
         'p'      => array(),
709
-    ) );
709
+    ));
710 710
 }
711 711
 
712 712
 /**
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
  */
717 717
 function wpinv_get_screen_ids() {
718 718
 
719
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
719
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
720 720
 
721 721
     $screen_ids = array(
722 722
         'toplevel_page_' . $screen_id,
@@ -735,10 +735,10 @@  discard block
 block discarded – undo
735 735
         'getpaid_page_wpinv-reports',
736 736
         'getpaid_page_wpi-addons',
737 737
         'getpaid_page_wpinv-customers',
738
-        'gp-setup',// setup wizard
738
+        'gp-setup', // setup wizard
739 739
     );
740 740
 
741
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
741
+    return apply_filters('wpinv_screen_ids', $screen_ids);
742 742
 }
743 743
 
744 744
 /**
@@ -749,14 +749,14 @@  discard block
 block discarded – undo
749 749
  * @param array|string $list List of values.
750 750
  * @return array Sanitized array of values.
751 751
  */
752
-function wpinv_parse_list( $list ) {
752
+function wpinv_parse_list($list) {
753 753
 
754
-    if ( empty( $list ) ) {
754
+    if (empty($list)) {
755 755
         $list = array();
756 756
     }
757 757
 
758
-	if ( ! is_array( $list ) ) {
759
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
758
+	if (!is_array($list)) {
759
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
760 760
 	}
761 761
 
762 762
 	return $list;
@@ -770,16 +770,16 @@  discard block
 block discarded – undo
770 770
  * @param string $key Type of data to fetch.
771 771
  * @return mixed Fetched data.
772 772
  */
773
-function wpinv_get_data( $key ) {
773
+function wpinv_get_data($key) {
774 774
 
775 775
     // Try fetching it from the cache.
776
-    $data = wp_cache_get( "wpinv-data-$key", 'wpinv' );
777
-    if( $data ) {
776
+    $data = wp_cache_get("wpinv-data-$key", 'wpinv');
777
+    if ($data) {
778 778
         return $data;
779 779
     }
780 780
 
781
-    $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
782
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
781
+    $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
782
+	wp_cache_set("wpinv-data-$key", $data, 'wpinv');
783 783
 
784 784
 	return $data;
785 785
 }
@@ -793,10 +793,10 @@  discard block
 block discarded – undo
793 793
  * @param bool $first_empty Whether or not the first item in the list should be empty
794 794
  * @return mixed Fetched data.
795 795
  */
796
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
796
+function wpinv_maybe_add_empty_option($options, $first_empty) {
797 797
 
798
-    if ( ! empty( $options ) && $first_empty ) {
799
-        return array_merge( array( '' => '' ), $options );
798
+    if (!empty($options) && $first_empty) {
799
+        return array_merge(array('' => ''), $options);
800 800
     }
801 801
     return $options;
802 802
 
@@ -808,21 +808,21 @@  discard block
 block discarded – undo
808 808
  * @param mixed $var Data to sanitize.
809 809
  * @return string|array
810 810
  */
811
-function wpinv_clean( $var ) {
811
+function wpinv_clean($var) {
812 812
 
813
-	if ( is_array( $var ) ) {
814
-		return array_map( 'wpinv_clean', $var );
813
+	if (is_array($var)) {
814
+		return array_map('wpinv_clean', $var);
815 815
     }
816 816
 
817
-    if ( is_object( $var ) ) {
818
-		$object_vars = get_object_vars( $var );
819
-		foreach ( $object_vars as $property_name => $property_value ) {
820
-			$var->$property_name = wpinv_clean( $property_value );
817
+    if (is_object($var)) {
818
+		$object_vars = get_object_vars($var);
819
+		foreach ($object_vars as $property_name => $property_value) {
820
+			$var->$property_name = wpinv_clean($property_value);
821 821
         }
822 822
         return $var;
823 823
 	}
824 824
 
825
-    return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var;
825
+    return is_string($var) ? sanitize_text_field(stripslashes($var)) : $var;
826 826
 }
827 827
 
828 828
 /**
@@ -831,43 +831,43 @@  discard block
 block discarded – undo
831 831
  * @param string $str Data to convert.
832 832
  * @return string|array
833 833
  */
834
-function getpaid_convert_price_string_to_options( $str ) {
834
+function getpaid_convert_price_string_to_options($str) {
835 835
 
836
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
837
-    $options     = array();
836
+	$raw_options = array_map('trim', explode(',', $str));
837
+    $options = array();
838 838
 
839
-    foreach ( $raw_options as $option ) {
839
+    foreach ($raw_options as $option) {
840 840
 
841
-        if ( '' == $option ) {
841
+        if ('' == $option) {
842 842
             continue;
843 843
         }
844 844
 
845
-        $option = array_map( 'trim', explode( '|', $option ) );
845
+        $option = array_map('trim', explode('|', $option));
846 846
 
847 847
         $price = null;
848 848
         $label = null;
849 849
 
850
-        if ( isset( $option[0] ) && '' !=  $option[0] ) {
851
-            $label  = $option[0];
850
+        if (isset($option[0]) && '' != $option[0]) {
851
+            $label = $option[0];
852 852
         }
853 853
 
854
-        if ( isset( $option[1] ) && '' !=  $option[1] ) {
854
+        if (isset($option[1]) && '' != $option[1]) {
855 855
             $price = $option[1];
856 856
         }
857 857
 
858
-        if ( ! isset( $price ) ) {
858
+        if (!isset($price)) {
859 859
             $price = $label;
860 860
         }
861 861
 
862
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
862
+        if (!isset($price) || !is_numeric($price)) {
863 863
             continue;
864 864
         }
865 865
 
866
-        if ( ! isset( $label ) ) {
866
+        if (!isset($label)) {
867 867
             $label = $price;
868 868
         }
869 869
 
870
-        $options[ "$label|$price" ] = $label;
870
+        $options["$label|$price"] = $label;
871 871
     }
872 872
 
873 873
     return $options;
@@ -876,27 +876,27 @@  discard block
 block discarded – undo
876 876
 /**
877 877
  * Returns the help tip.
878 878
  */
879
-function getpaid_get_help_tip( $tip, $additional_classes = '' ) {
880
-    $additional_classes = sanitize_html_class( $additional_classes );
881
-    $tip                = esc_attr__( $tip );
879
+function getpaid_get_help_tip($tip, $additional_classes = '') {
880
+    $additional_classes = sanitize_html_class($additional_classes);
881
+    $tip                = esc_attr__($tip);
882 882
     return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>";
883 883
 }
884 884
 
885 885
 /**
886 886
  * Formats a date
887 887
  */
888
-function getpaid_format_date( $date, $with_time = false ) {
888
+function getpaid_format_date($date, $with_time = false) {
889 889
 
890
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
890
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
891 891
         return '';
892 892
     }
893 893
 
894 894
     $format = getpaid_date_format();
895 895
 
896
-    if ( $with_time ) {
896
+    if ($with_time) {
897 897
         $format .= ' ' . getpaid_time_format();
898 898
     }
899
-    return date_i18n( $format, strtotime( $date ) );
899
+    return date_i18n($format, strtotime($date));
900 900
 
901 901
 }
902 902
 
@@ -905,9 +905,9 @@  discard block
 block discarded – undo
905 905
  *
906 906
  * @return string
907 907
  */
908
-function getpaid_format_date_value( $date, $default = "&mdash;", $with_time = false ) {
909
-    $date = getpaid_format_date( $date, $with_time );
910
-    return empty( $date ) ? $default : $date;
908
+function getpaid_format_date_value($date, $default = "&mdash;", $with_time = false) {
909
+    $date = getpaid_format_date($date, $with_time);
910
+    return empty($date) ? $default : $date;
911 911
 }
912 912
 
913 913
 /**
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
  * @return string
917 917
  */
918 918
 function getpaid_date_format() {
919
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
919
+	return apply_filters('getpaid_date_format', get_option('date_format'));
920 920
 }
921 921
 
922 922
 /**
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
  * @return string
926 926
  */
927 927
 function getpaid_time_format() {
928
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
928
+	return apply_filters('getpaid_time_format', get_option('time_format'));
929 929
 }
930 930
 
931 931
 /**
@@ -935,16 +935,16 @@  discard block
 block discarded – undo
935 935
  * @param  integer $limit Limit size in characters.
936 936
  * @return string
937 937
  */
938
-function getpaid_limit_length( $string, $limit ) {
938
+function getpaid_limit_length($string, $limit) {
939 939
     $str_limit = $limit - 3;
940 940
 
941
-	if ( function_exists( 'mb_strimwidth' ) ) {
942
-		if ( mb_strlen( $string ) > $limit ) {
943
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
941
+	if (function_exists('mb_strimwidth')) {
942
+		if (mb_strlen($string) > $limit) {
943
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
944 944
 		}
945 945
 	} else {
946
-		if ( strlen( $string ) > $limit ) {
947
-			$string = substr( $string, 0, $str_limit ) . '...';
946
+		if (strlen($string) > $limit) {
947
+			$string = substr($string, 0, $str_limit) . '...';
948 948
 		}
949 949
 	}
950 950
     return $string;
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
  * @since 1.0.19
959 959
  */
960 960
 function getpaid_api() {
961
-    return getpaid()->get( 'api' );
961
+    return getpaid()->get('api');
962 962
 }
963 963
 
964 964
 /**
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
  * @since 1.0.19
969 969
  */
970 970
 function getpaid_post_types() {
971
-    return getpaid()->get( 'post_types' );
971
+    return getpaid()->get('post_types');
972 972
 }
973 973
 
974 974
 /**
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
  * @since 1.0.19
979 979
  */
980 980
 function getpaid_session() {
981
-    return getpaid()->get( 'session' );
981
+    return getpaid()->get('session');
982 982
 }
983 983
 
984 984
 /**
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
  * @since 1.0.19
989 989
  */
990 990
 function getpaid_notes() {
991
-    return getpaid()->get( 'notes' );
991
+    return getpaid()->get('notes');
992 992
 }
993 993
 
994 994
 /**
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
  * @return GetPaid_Admin
998 998
  */
999 999
 function getpaid_admin() {
1000
-    return getpaid()->get( 'admin' );
1000
+    return getpaid()->get('admin');
1001 1001
 }
1002 1002
 
1003 1003
 /**
@@ -1007,8 +1007,8 @@  discard block
 block discarded – undo
1007 1007
  * @param string $base the base url
1008 1008
  * @return string
1009 1009
  */
1010
-function getpaid_get_authenticated_action_url( $action, $base = false ) {
1011
-    return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' );
1010
+function getpaid_get_authenticated_action_url($action, $base = false) {
1011
+    return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce');
1012 1012
 }
1013 1013
 
1014 1014
 /**
@@ -1016,11 +1016,11 @@  discard block
 block discarded – undo
1016 1016
  *
1017 1017
  * @return string
1018 1018
  */
1019
-function getpaid_get_post_type_label( $post_type, $plural = true ) {
1019
+function getpaid_get_post_type_label($post_type, $plural = true) {
1020 1020
 
1021
-    $post_type = get_post_type_object( $post_type );
1021
+    $post_type = get_post_type_object($post_type);
1022 1022
 
1023
-    if ( ! is_object( $post_type ) ) {
1023
+    if (!is_object($post_type)) {
1024 1024
         return null;
1025 1025
     }
1026 1026
 
@@ -1033,18 +1033,18 @@  discard block
 block discarded – undo
1033 1033
  *
1034 1034
  * @return mixed|null
1035 1035
  */
1036
-function getpaid_get_array_field( $array, $key, $secondary_key = null ) {
1036
+function getpaid_get_array_field($array, $key, $secondary_key = null) {
1037 1037
 
1038
-    if ( ! is_array( $array ) ) {
1038
+    if (!is_array($array)) {
1039 1039
         return null;
1040 1040
     }
1041 1041
 
1042
-    if ( ! empty( $secondary_key ) ) {
1043
-        $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array();
1044
-        return getpaid_get_array_field( $array, $key );
1042
+    if (!empty($secondary_key)) {
1043
+        $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array();
1044
+        return getpaid_get_array_field($array, $key);
1045 1045
     }
1046 1046
 
1047
-    return isset( $array[ $key ] ) ? $array[ $key ] : null;
1047
+    return isset($array[$key]) ? $array[$key] : null;
1048 1048
 
1049 1049
 }
1050 1050
 
@@ -1053,12 +1053,12 @@  discard block
 block discarded – undo
1053 1053
  *
1054 1054
  * @return array
1055 1055
  */
1056
-function getpaid_array_merge_if_empty( $args, $defaults ) {
1056
+function getpaid_array_merge_if_empty($args, $defaults) {
1057 1057
 
1058
-    foreach ( $defaults as $key => $value ) {
1058
+    foreach ($defaults as $key => $value) {
1059 1059
 
1060
-        if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) {
1061
-            $args[ $key ] = $value;
1060
+        if (array_key_exists($key, $args) && empty($args[$key])) {
1061
+            $args[$key] = $value;
1062 1062
         }
1063 1063
 
1064 1064
     }
@@ -1076,12 +1076,12 @@  discard block
 block discarded – undo
1076 1076
 
1077 1077
     $types = get_allowed_mime_types();
1078 1078
 
1079
-    if ( isset( $types['htm|html'] ) ) {
1080
-		unset( $types['htm|html'] );
1079
+    if (isset($types['htm|html'])) {
1080
+		unset($types['htm|html']);
1081 1081
 	}
1082 1082
 
1083
-    if ( isset( $types['js'] ) ) {
1084
-		unset( $types['js'] );
1083
+    if (isset($types['js'])) {
1084
+		unset($types['js']);
1085 1085
 	}
1086 1086
 
1087 1087
     return $types;
Please login to merge, or discard this patch.
templates/payment-forms/elements/date.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,33 +7,33 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$label       = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
14
-if ( ! empty( $required ) ) {
12
+$label       = empty($label) ? '' : wp_kses_post($label);
13
+$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14
+if (!empty($required)) {
15 15
     $label .= "<span class='text-danger'> *</span>";
16 16
 }
17 17
 
18 18
 $options = array(
19
-    'data-default-date' => empty( 'default_date' ) ? false : $default_date,
20
-    'data-min-date'     => empty( 'min_date' ) ? false : $min_date,
21
-    'data-max-date'     => empty( 'max_date' ) ? false : $max_date,
22
-    'data-alt-format'   => get_option( 'date_format', 'F j, Y' ),
19
+    'data-default-date' => empty('default_date') ? false : $default_date,
20
+    'data-min-date'     => empty('min_date') ? false : $min_date,
21
+    'data-max-date'     => empty('max_date') ? false : $max_date,
22
+    'data-alt-format'   => get_option('date_format', 'F j, Y'),
23 23
     'data-date-format'  => 'Y-m-d'
24 24
 );
25 25
 
26 26
 echo aui()->input(
27 27
     array(
28
-        'name'             => esc_attr( $id ),
29
-        'id'               => esc_attr( $id ) . uniqid( '_' ),
30
-        'placeholder'      => empty( $placeholder ) ? '' : esc_attr( $placeholder ),
31
-        'required'         => ! empty( $required ),
28
+        'name'             => esc_attr($id),
29
+        'id'               => esc_attr($id) . uniqid('_'),
30
+        'placeholder'      => empty($placeholder) ? '' : esc_attr($placeholder),
31
+        'required'         => !empty($required),
32 32
         'label'            => $label,
33 33
         'label_type'       => 'vertical',
34
-        'help_text'        => empty( $description ) ? '' : wp_kses_post( $description ),
34
+        'help_text'        => empty($description) ? '' : wp_kses_post($description),
35 35
         'type'             => 'datepicker',
36 36
         'class'            => $label_class,
37
-        'extra_attributes' => array_filter( apply_filters( 'getpaid_date_field_attributes', $options ) ),
37
+        'extra_attributes' => array_filter(apply_filters('getpaid_date_field_attributes', $options)),
38 38
     )
39 39
 );
Please login to merge, or discard this patch.
templates/payment-forms-admin/edit/date.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -7,73 +7,73 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14 14
 <div class='form-group'>
15 15
     <label class="d-block">
16
-        <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span>
16
+        <span><?php esc_html_e('Field Label', 'invoicing'); ?></span>
17 17
         <input v-model='active_form_element.label' class='form-control' type="text"/>
18 18
     </label>
19 19
 </div>
20 20
 
21 21
 <div class='form-group'>
22 22
     <label class="d-block">
23
-        <span><?php esc_html_e( 'Default Date', 'invoicing' ); ?></span>
24
-        <?php echo wpi_help_tip( sprintf( __( 'You can enter the shortcut "today" or enter a date matching the format Y-m-d, e.g %s', 'invoicing' ), current_time( 'Y-m-d' ) ), false, true ); ?>
25
-        <input v-model='active_form_element.default_date' placeholder="<?php esc_attr_e( 'None', 'invoicing' ); ?>" class='form-control' type="text"/>
23
+        <span><?php esc_html_e('Default Date', 'invoicing'); ?></span>
24
+        <?php echo wpi_help_tip(sprintf(__('You can enter the shortcut "today" or enter a date matching the format Y-m-d, e.g %s', 'invoicing'), current_time('Y-m-d')), false, true); ?>
25
+        <input v-model='active_form_element.default_date' placeholder="<?php esc_attr_e('None', 'invoicing'); ?>" class='form-control' type="text"/>
26 26
     </label>
27 27
 </div>
28 28
 
29 29
 <div class='form-group'>
30 30
     <label class="d-block">
31
-        <span><?php esc_html_e( 'Minimum Date', 'invoicing' ); ?></span>
32
-        <?php echo wpi_help_tip( sprintf( __( 'You can enter the shortcut "today" or enter a date matching the format Y-m-d, e.g %s', 'invoicing' ), current_time( 'Y-m-d' ) ), false, true ); ?>
33
-        <input v-model='active_form_element.min_date' placeholder="<?php esc_attr_e( 'None', 'invoicing' ); ?>" class='form-control' type="text"/>
34
-        <small class="form-text text-muted"><?php _e( 'Specify the minimum/earliest date (inclusively) allowed for selection.', 'invoicing' ); ?></small>
31
+        <span><?php esc_html_e('Minimum Date', 'invoicing'); ?></span>
32
+        <?php echo wpi_help_tip(sprintf(__('You can enter the shortcut "today" or enter a date matching the format Y-m-d, e.g %s', 'invoicing'), current_time('Y-m-d')), false, true); ?>
33
+        <input v-model='active_form_element.min_date' placeholder="<?php esc_attr_e('None', 'invoicing'); ?>" class='form-control' type="text"/>
34
+        <small class="form-text text-muted"><?php _e('Specify the minimum/earliest date (inclusively) allowed for selection.', 'invoicing'); ?></small>
35 35
     </label>
36 36
 </div>
37 37
 
38 38
 <div class='form-group'>
39 39
     <label class="d-block">
40
-        <span><?php esc_html_e( 'Maximum Date', 'invoicing' ); ?></span>
41
-        <?php echo wpi_help_tip( sprintf( __( 'You can enter the shortcut "today" or enter a date matching the format Y-m-d, e.g %s', 'invoicing' ), current_time( 'Y-m-d' ) ), false, true ); ?>
42
-        <input v-model='active_form_element.max_date' placeholder="<?php esc_attr_e( 'None', 'invoicing' ); ?>" class='form-control' type="text"/>
43
-        <small class="form-text text-muted"><?php _e( 'Specify the maximum/latest date (inclusively) allowed for selection.', 'invoicing' ); ?></small>
40
+        <span><?php esc_html_e('Maximum Date', 'invoicing'); ?></span>
41
+        <?php echo wpi_help_tip(sprintf(__('You can enter the shortcut "today" or enter a date matching the format Y-m-d, e.g %s', 'invoicing'), current_time('Y-m-d')), false, true); ?>
42
+        <input v-model='active_form_element.max_date' placeholder="<?php esc_attr_e('None', 'invoicing'); ?>" class='form-control' type="text"/>
43
+        <small class="form-text text-muted"><?php _e('Specify the maximum/latest date (inclusively) allowed for selection.', 'invoicing'); ?></small>
44 44
     </label>
45 45
 </div>
46 46
 
47 47
 <div class='form-group'>
48 48
     <label class="d-block">
49
-        <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span>
50
-        <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea>
51
-        <small class="form-text text-muted"><?php _e( 'HTML is allowed', 'invoicing' ); ?></small>
49
+        <span><?php esc_html_e('Help Text', 'invoicing'); ?></span>
50
+        <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea>
51
+        <small class="form-text text-muted"><?php _e('HTML is allowed', 'invoicing'); ?></small>
52 52
     </label>
53 53
 </div>
54 54
 
55 55
 <div class='form-group form-check'>
56 56
     <input :id="active_form_element.id + '_edit'" v-model='active_form_element.required' type='checkbox' class='form-check-input' />
57
-    <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Is this field required?', 'invoicing' ); ?></label>
57
+    <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e('Is this field required?', 'invoicing'); ?></label>
58 58
 </div>
59 59
 
60 60
 <div class='form-group form-check'>
61 61
     <input :id="active_form_element.id + '_edit'" v-model='active_form_element.required' type='checkbox' class='form-check-input' />
62
-    <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Is this field required?', 'invoicing' ); ?></label>
62
+    <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e('Is this field required?', 'invoicing'); ?></label>
63 63
 </div>
64 64
 
65 65
 <div class='form-group form-check'>
66 66
     <input :id="active_form_element.id + '_add_meta'" v-model='active_form_element.add_meta' type='checkbox' class='form-check-input' />
67
-    <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e( 'Show this field in receipts and emails?', 'invoicing' ); ?></label>
67
+    <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e('Show this field in receipts and emails?', 'invoicing'); ?></label>
68 68
 </div>
69 69
 
70 70
 <hr class='featurette-divider mt-4'>
71 71
 
72 72
 <div class='form-group'>
73 73
     <label class="d-block">
74
-        <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span>
74
+        <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span>
75 75
         <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" />
76
-        <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span>
76
+        <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span>
77 77
     </label>
78 78
 </div>
79 79
 
Please login to merge, or discard this patch.